mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-01 13:24:10 +01:00
Contacts: Modifications for using categories.
This commit is contained in:
parent
37ce038d46
commit
7b00319bae
@ -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())));
|
||||
|
||||
?>
|
@ -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));
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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');
|
||||
|
119
js/contacts.js
119
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
|
||||
|
@ -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'> </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 );
|
||||
|
@ -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,
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user