summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-03-12 14:12:27 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-03-12 14:13:03 +0100
commitd36d317bb21774e0629d760294080510a7501206 (patch)
tree77676348072a543c2121019b93ee45097c73e428 /apps/contacts
parent03eb5197b62664ee89060e2d644531c9e7fe8250 (diff)
downloadnextcloud-server-d36d317bb21774e0629d760294080510a7501206.tar.gz
nextcloud-server-d36d317bb21774e0629d760294080510a7501206.zip
Contacts: Modifications for using categories.
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/ajax/categories/add.php39
-rw-r--r--apps/contacts/ajax/saveproperty.php8
-rw-r--r--apps/contacts/css/contacts.css7
-rw-r--r--apps/contacts/index.php3
-rw-r--r--apps/contacts/js/contacts.js119
-rw-r--r--apps/contacts/js/jquery.multi-autocomplete.js24
-rw-r--r--apps/contacts/lib/vcard.php4
-rw-r--r--apps/contacts/templates/index.php2
-rw-r--r--apps/contacts/templates/part.contact.php10
9 files changed, 48 insertions, 168 deletions
diff --git a/apps/contacts/ajax/categories/add.php b/apps/contacts/ajax/categories/add.php
deleted file mode 100644
index 9b6c262978b..00000000000
--- a/apps/contacts/ajax/categories/add.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-require_once('../../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-OC_JSON::checkAppEnabled('contacts');
-
-function bailOut($msg) {
- OC_JSON::error(array('data' => array('message' => $msg)));
- OC_Log::write('contacts','ajax/categories/add.php: '.$msg, OC_Log::DEBUG);
- exit();
-}
-function debug($msg) {
- OC_Log::write('contacts','ajax/categories/add.php: '.$msg, OC_Log::DEBUG);
-}
-
-$category = isset($_GET['category'])?strip_tags($_GET['category']):null;
-
-if(is_null($category)) {
- bailOut(OC_Contacts_App::$l10n->t('No category to add?'));
-}
-
-debug(print_r($category, true));
-
-$categories = new OC_VCategories('contacts');
-if($categories->hasCategory($category)) {
- bailOut(OC_Contacts_App::$l10n->t('This category already exists: '.$category));
-} else {
- $categories->add($category, true);
-}
-
-OC_JSON::success(array('data' => array('categories'=>$categories->categories())));
-
-?>
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 0769791ea36..95a7ac20193 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -63,11 +63,11 @@ if(!$checksum) {
if(is_array($value)){
$value = array_map('strip_tags', $value);
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
- if($name == 'CATEGORIES') {
- $value = OC_Contacts_VCard::escapeDelimiters($value, ',');
- } else {
+ //if($name == 'CATEGORIES') {
+ // $value = OC_Contacts_VCard::escapeDelimiters($value, ',');
+ //} else {
$value = OC_Contacts_VCard::escapeDelimiters($value, ';');
- }
+ //}
} else {
$value = trim(strip_tags($value));
}
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index a6f7d9316f8..7c36a511d6e 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -188,10 +188,3 @@ input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
.typelist { float: left; max-width: 10em; } /* for multiselect */
.addresslist { clear: both; }
-#categoryform .scrollarea { position: absolute; left: 10px; top: 10px; right: 10px; bottom: 50px; overflow: auto; border:1px solid #ddd; background: #f8f8f8; }
-#categoryform .bottombuttons { position: absolute; bottom: 10px;}
-#categoryform .bottombuttons * { float: left;}
-/*#categorylist { border:1px solid #ddd;}*/
-#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
-#categorylist li:hover, li:active { background:#eee; }
-#category_addinput { width: 10em; }
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 48b2b8b4f01..04f6c65a145 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -45,13 +45,14 @@ $freeSpace=max($freeSpace,0);
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
OC_Util::addScript('','jquery.multiselect');
+OC_Util::addScript('','oc-vcategories');
OC_Util::addScript('contacts','contacts');
OC_Util::addScript('contacts','jquery.combobox');
OC_Util::addScript('contacts','jquery.inview');
OC_Util::addScript('contacts','jquery.Jcrop');
OC_Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addStyle('','jquery.multiselect');
-//OC_Util::addStyle('contacts','styles');
+OC_Util::addStyle('','oc-vcategories');
OC_Util::addStyle('contacts','jquery.combobox');
OC_Util::addStyle('contacts','jquery.Jcrop');
OC_Util::addStyle('contacts','contacts');
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index ccedf1d3032..1d19eb47f68 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -10,105 +10,6 @@ String.prototype.strip_tags = function(){
return stripped;
};
-Categories={
- edit:function(){
- console.log('Categories.edit');
- $('body').append('<div id="category_dialog"></div>');
- $('#category_dialog').load(OC.filePath('contacts', 'ajax', 'categories/edit.php'), function(response, status, xhr){
- try {
- var response = jQuery.parseJSON(response);
- console.log('status: ' + status + ', response: ' + response + ', response.status:' + response.status);
- if(response.status == 'error'){
- OC.dialogs.alert(response.data.message, 'Error');
- } else {
- OC.dialogs.alert(response, 'Error');
- }
- } catch(e) {
- $('#edit_categories_dialog').dialog({
- modal: true,
- height: 350, minHeight:200, width: 250, minWidth: 200,
- buttons: {
- 'Delete':function() {
- Categories.delete();
- },
- 'Rescan':function() {
- Categories.rescan();
- }
- },
- close : function(event, ui) {
- //alert('close');
- $(this).dialog('destroy').remove();
- $('#category_dialog').remove();
- },
- open : function(event, ui) {
- $('#category_addinput').live('input',function(){
- if($(this).val().length > 0) {
- $('#category_addbutton').removeAttr('disabled');
- }
- });
- $('#categoryform').submit(function() {
- Categories.add($('#category_addinput').val());
- $('#category_addinput').val('');
- $('#category_addbutton').attr('disabled', 'disabled');
- return false;
- });
- $('#category_addbutton').live('click',function(e){
- e.preventDefault();
- if($('#category_addinput').val().length > 0) {
- Categories.add($('#category_addinput').val());
- $('#category_addinput').val('');
- }
- });
- }
- });
- }
- });
- },
- delete:function(){
- var categories = $('#categorylist').find('input[type="checkbox"]').serialize();
- console.log('Categories.delete: ' + categories);
- $.post(OC.filePath('contacts', 'ajax', 'categories/delete.php'),categories,function(jsondata){
- if(jsondata.status == 'success'){
- Categories._update(jsondata.data.categories);
- } else {
- OC.dialogs.alert(jsondata.data.message, 'Error');
- }
- });
- },
- add:function(category){
- console.log('Categories.add ' + category);
- $.getJSON(OC.filePath('contacts', 'ajax', 'categories/add.php'),{'category':category},function(jsondata){
- if(jsondata.status == 'success'){
- Categories._update(jsondata.data.categories);
- } else {
- OC.dialogs.alert(jsondata.data.message, 'Error');
- }
- });
- return false;
- },
- rescan:function(){
- console.log('Categories.rescan');
- $.getJSON(OC.filePath('contacts', 'ajax', 'categories/rescan.php'),{},function(jsondata){
- if(jsondata.status == 'success'){
- Categories._update(jsondata.data.categories);
- } else {
- OC.dialogs.alert(jsondata.data.message, 'Error');
- }
- });
- },
- _update:function(categories){
- var categorylist = $('#categorylist');
- categorylist.find('li').remove();
- for(var category in categories) {
- var item = '<li><input type="checkbox" name="categories" value="' + categories[category] + '" />' + categories[category] + '</li>';
- $(item).appendTo(categorylist);
- }
- if(Categories.changed != undefined) {
- Categories.changed(categories);
- }
- }
-}
-
Contacts={
UI:{
notImplemented:function() {
@@ -146,7 +47,6 @@ Contacts={
console.log('uri: ' + uri);
var newWindow = window.open(uri,'_blank');
newWindow.focus();
- //Contacts.UI.notImplemented();
},
mailTo:function(obj) {
var adr = Contacts.UI.propertyContainerFor($(obj)).find('input[type="email"]').val().trim();
@@ -252,12 +152,12 @@ Contacts={
$('#bday').datepicker({
dateFormat : 'dd-mm-yy'
});
- $('#categories_value').find('select').multiselect({
+ /*$('#categories_value').find('select').multiselect({
noneSelectedText: t('contacts', 'Select categories'),
header: false,
selectedList: 6,
classes: 'categories'
- });
+ });*/
// Style phone types
$('#phonelist').find('select.contacts_property').multiselect({
noneSelectedText: t('contacts', 'Select type'),
@@ -299,7 +199,7 @@ Contacts={
click: function() { $(this).dialog('close'); }
}
] );
- //$('#categories').multiple_autocomplete({source: categories});
+ $('#categories').multiple_autocomplete({source: categories});
Contacts.UI.loadListHandlers();
},
Card:{
@@ -440,7 +340,7 @@ Contacts={
$('#rightcontent').data('id',this.id);
console.log('loaded: ' + this.data.FN[0]['value']);
this.populateNameFields();
- this.loadCategories();
+ //this.loadCategories();
this.loadPhoto();
this.loadMails();
this.loadPhones();
@@ -458,7 +358,7 @@ Contacts={
}
},
loadSingleProperties:function() {
- var props = ['BDAY', 'NICKNAME', 'ORG']; //, 'CATEGORIES'];
+ var props = ['BDAY', 'NICKNAME', 'ORG', 'CATEGORIES'];
// Clear all elements
$('#ident .propertycontainer').each(function(){
if(props.indexOf($(this).data('element')) > -1) {
@@ -494,12 +394,12 @@ Contacts={
$('#contact_identity').find('#org_label').show();
$('#contact_identity').find('#org_value').show();
break;
- /*case 'CATEGORIES':
+ case 'CATEGORIES':
$('#contact_identity').find('#categories').val(value);
$('#contact_identity').find('#categories_value').data('checksum', checksum);
$('#contact_identity').find('#categories_label').show();
$('#contact_identity').find('#categories_value').show();
- break;*/
+ break;
}
} else {
$('#contacts_propertymenu a[data-type="'+props[prop]+'"]').parent().show();
@@ -825,7 +725,7 @@ Contacts={
}*/
});
} else {
- alert(jsondata.data.message);
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
@@ -1295,7 +1195,8 @@ Contacts={
$(document).ready(function(){
Contacts.UI.loadHandlers();
- Categories.changed = Contacts.UI.Card.categoriesChanged;
+ OCCategories.changed = Contacts.UI.Card.categoriesChanged;
+ OCCategories.app = 'contacts';
/**
* Show the Addressbook chooser
diff --git a/apps/contacts/js/jquery.multi-autocomplete.js b/apps/contacts/js/jquery.multi-autocomplete.js
index 4be8d901c96..7cc9df1930d 100644
--- a/apps/contacts/js/jquery.multi-autocomplete.js
+++ b/apps/contacts/js/jquery.multi-autocomplete.js
@@ -13,6 +13,9 @@
}
//console.log('_create: ' + this.options['id']);
var self = this;
+ this.element.bind('blur', function( event ) {
+ self.element.trigger('change'); // Changes wasn't saved when only using the dropdown.
+ });
this.element.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
@@ -42,6 +45,27 @@
return false;
}
});
+ this.button = $( "<button type='button'>&nbsp;</button>" )
+ .attr( "tabIndex", -1 )
+ .attr( "title", "Show All Items" )
+ .insertAfter( this.element )
+ .addClass('svg')
+ .addClass('action')
+ .addClass('combo-button')
+ .click(function() {
+ // close if already visible
+ if ( self.element.autocomplete( "widget" ).is( ":visible" ) ) {
+ self.element.autocomplete( "close" );
+ return;
+ }
+
+ // work around a bug (likely same cause as #5265)
+ $( this ).blur();
+
+ // pass empty string as value to search for, displaying all results
+ self.element.autocomplete( "search", "" );
+ self.element.focus();
+ });
},
});
})( jQuery );
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index a7e1817d7c8..3736f18c647 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -442,9 +442,9 @@ class OC_Contacts_VCard{
//$value = htmlspecialchars($value);
if($property->name == 'ADR' || $property->name == 'N'){
$value = self::unescapeDelimiters($value);
- } elseif($property->name == 'CATEGORIES') {
+ }/* elseif($property->name == 'CATEGORIES') {
$value = self::unescapeDelimiters($value, ',');
- }
+ }*/
$temp = array(
'name' => $property->name,
'value' => $value,
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index efd797e25cb..af159ce9c60 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -1,6 +1,6 @@
<script type='text/javascript'>
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
- var categories = <?php echo json_encode($_['categories']); ?>;
+ var categories = <?php sort($_['categories']); echo json_encode($_['categories']); ?>;
</script>
<div id="controls">
<form>
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index 67838238e2b..87ee40e99f5 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -55,15 +55,15 @@ $id = isset($_['id']) ? $_['id'] : '';
<dd style="display:none;" class="propertycontainer" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt style="display:none;" id="bday_label" data-element="BDAY"><label for="bday"><?php echo $l->t('Birthday'); ?></label></dt>
<dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
- <dt id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
+ <!-- dt id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
<dd class="propertycontainer" id="categories_value" data-element="CATEGORIES">
<select class="contacts_property" multiple="multiple" id="categories" name="value[]">
<?php echo html_select_options($_['categories'], array(), array('combine'=>true)) ?>
</select>
- <a class="action edit" onclick="$(this).tipsy('hide');Categories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
- </dd>
- <!-- dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
- <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');Categories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd -->
+ <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
+ </dd -->
+ <dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
+ <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
</dl>
</fieldset>
<fieldset id="note" class="formfloat propertycontainer" style="display:none;" data-element="NOTE">