Merge branch 'vcategories' of gitorious.org:owncloud/owncloud into vcategories

Conflicts:
	apps/contacts/lib/vcard.php
	apps/contacts/templates/part.contact.php
This commit is contained in:
Thomas Tanghus 2012-03-08 02:55:48 +01:00
commit a33a62bf60
8 changed files with 74 additions and 13 deletions

View File

@ -128,14 +128,8 @@ switch($element) {
$checksum = md5($vcard->children[$line]->serialize()); $checksum = md5($vcard->children[$line]->serialize());
debug('New checksum: '.$checksum); debug('New checksum: '.$checksum);
<<<<<<< HEAD
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));
=======
if(!OC_Contacts_VCard::edit($id,$vcard)) { if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error updating contact property.')))); bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));
OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
>>>>>>> d8cfe77ba5348d29a9e2b046e2c7efc1dd4758cb
exit(); exit();
} }

View File

@ -49,6 +49,7 @@ OC_Util::addScript('contacts','contacts');
OC_Util::addScript('contacts','jquery.combobox'); OC_Util::addScript('contacts','jquery.combobox');
OC_Util::addScript('contacts','jquery.inview'); OC_Util::addScript('contacts','jquery.inview');
OC_Util::addScript('contacts','jquery.Jcrop'); OC_Util::addScript('contacts','jquery.Jcrop');
OC_Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addStyle('','jquery.multiselect'); OC_Util::addStyle('','jquery.multiselect');
//OC_Util::addStyle('contacts','styles'); //OC_Util::addStyle('contacts','styles');
OC_Util::addStyle('contacts','jquery.combobox'); OC_Util::addStyle('contacts','jquery.combobox');
@ -59,6 +60,7 @@ $tmpl = new OC_Template( "contacts", "index", "user" );
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
$tmpl->assign('property_types',$property_types); $tmpl->assign('property_types',$property_types);
$tmpl->assign('categories',OC_Contacts_App::getCategories());
$tmpl->assign('phone_types',$phone_types); $tmpl->assign('phone_types',$phone_types);
$tmpl->assign('categories',$categories); $tmpl->assign('categories',$categories);
$tmpl->assign('addressbooks', $addressbooks); $tmpl->assign('addressbooks', $addressbooks);

View File

@ -252,12 +252,12 @@ Contacts={
$('#bday').datepicker({ $('#bday').datepicker({
dateFormat : 'dd-mm-yy' dateFormat : 'dd-mm-yy'
}); });
$('#categories_value').find('select').multiselect({ /*$('#categories_value').find('select').multiselect({
noneSelectedText: t('contacts', 'Select categories'), noneSelectedText: t('contacts', 'Select categories'),
header: false, header: false,
selectedList: 6, selectedList: 6,
classes: 'categories' classes: 'categories'
}); });*/
// Style phone types // Style phone types
$('#phonelist').find('select.contacts_property').multiselect({ $('#phonelist').find('select.contacts_property').multiselect({
noneSelectedText: t('contacts', 'Select type'), noneSelectedText: t('contacts', 'Select type'),
@ -299,6 +299,7 @@ Contacts={
click: function() { $(this).dialog('close'); } click: function() { $(this).dialog('close'); }
} }
] ); ] );
$('#categories').multiple_autocomplete({source: categories});
Contacts.UI.loadListHandlers(); Contacts.UI.loadListHandlers();
}, },
Card:{ Card:{
@ -439,7 +440,7 @@ Contacts={
$('#rightcontent').data('id',this.id); $('#rightcontent').data('id',this.id);
console.log('loaded: ' + this.data.FN[0]['value']); console.log('loaded: ' + this.data.FN[0]['value']);
this.populateNameFields(); this.populateNameFields();
this.loadCategories(); //this.loadCategories();
this.loadPhoto(); this.loadPhoto();
this.loadMails(); this.loadMails();
this.loadPhones(); this.loadPhones();
@ -457,7 +458,7 @@ Contacts={
} }
}, },
loadSingleProperties:function() { loadSingleProperties:function() {
var props = ['BDAY', 'NICKNAME', 'ORG']; var props = ['BDAY', 'NICKNAME', 'ORG', 'CATEGORIES'];
// Clear all elements // Clear all elements
$('#ident .propertycontainer').each(function(){ $('#ident .propertycontainer').each(function(){
if(props.indexOf($(this).data('element')) > -1) { if(props.indexOf($(this).data('element')) > -1) {
@ -493,6 +494,12 @@ Contacts={
$('#contact_identity').find('#org_label').show(); $('#contact_identity').find('#org_label').show();
$('#contact_identity').find('#org_value').show(); $('#contact_identity').find('#org_value').show();
break; break;
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;
} }
} else { } else {
$('#contacts_propertymenu a[data-type="'+props[prop]+'"]').parent().show(); $('#contacts_propertymenu a[data-type="'+props[prop]+'"]').parent().show();
@ -740,6 +747,7 @@ Contacts={
case 'NICKNAME': case 'NICKNAME':
case 'ORG': case 'ORG':
case 'BDAY': case 'BDAY':
case 'CATEGORIES':
$('dl dt[data-element="'+type+'"],dd[data-element="'+type+'"]').show(); $('dl dt[data-element="'+type+'"],dd[data-element="'+type+'"]').show();
$('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide();
break; break;

View File

@ -0,0 +1,47 @@
/**
* Inspired by http://jqueryui.com/demos/autocomplete/#multiple
*/
(function( $ ) {
$.widget('ui.multiple_autocomplete', {
_create: function() {
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
//console.log('_create: ' + this.options['id']);
var self = this;
this.element.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
self.options.source, extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
},
});
})( jQuery );

View File

@ -155,6 +155,10 @@ class OC_Contacts_App {
} }
} }
public static function getCategories() {
return self::$categories->categories();
}
public static function setLastModifiedHeader($contact) { public static function setLastModifiedHeader($contact) {
$rev = $contact->getAsString('REV'); $rev = $contact->getAsString('REV');
if ($rev) { if ($rev) {

View File

@ -306,6 +306,8 @@ class OC_Contacts_VCard{
return false; return false;
} }
OC_Contacts_App::$categories->loadFromVObject($card);
$fn = $card->getAsString('FN'); $fn = $card->getAsString('FN');
if (empty($fn)) { if (empty($fn)) {
$fn = null; $fn = null;

View File

@ -1,5 +1,6 @@
<script type='text/javascript'> <script type='text/javascript'>
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks'; var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
var categories = <?php echo json_encode($_['categories']); ?>;
</script> </script>
<div id="controls"> <div id="controls">
<form> <form>

View File

@ -14,6 +14,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<li><a data-type="EMAIL"><?php echo $l->t('Email'); ?></a></li> <li><a data-type="EMAIL"><?php echo $l->t('Email'); ?></a></li>
<li><a data-type="ADR"><?php echo $l->t('Address'); ?></a></li> <li><a data-type="ADR"><?php echo $l->t('Address'); ?></a></li>
<li><a data-type="NOTE"><?php echo $l->t('Note'); ?></a></li> <li><a data-type="NOTE"><?php echo $l->t('Note'); ?></a></li>
<li><a data-type="CATEGORIES"><?php echo $l->t('Categories'); ?></a></li>
</ul> </ul>
</div> </div>
<img onclick="Contacts.UI.Card.export();" class="svg action" id="contacts_downloadcard" src="<?php echo image_path('', 'actions/download.svg'); ?>" title="<?php echo $l->t('Download contact');?>" /> <img onclick="Contacts.UI.Card.export();" class="svg action" id="contacts_downloadcard" src="<?php echo image_path('', 'actions/download.svg'); ?>" title="<?php echo $l->t('Download contact');?>" />
@ -54,13 +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> <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> <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> <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"> <dd class="propertycontainer" id="categories_value" data-element="CATEGORIES">
<select class="contacts_property" multiple="multiple" id="categories" name="value[]"> <select class="contacts_property" multiple="multiple" id="categories" name="value[]">
<?php echo html_select_options($_['categories'], array(), array('combine'=>true)) ?> <?php echo html_select_options($_['categories'], array(), array('combine'=>true)) ?>
</select> </select>
<a class="action edit" onclick="$(this).tipsy('hide');Categories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a> <a class="action edit" onclick="$(this).tipsy('hide');Categories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
</dd> </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>
</dl> </dl>
</fieldset> </fieldset>
<fieldset id="note" class="formfloat propertycontainer" style="display:none;" data-element="NOTE"> <fieldset id="note" class="formfloat propertycontainer" style="display:none;" data-element="NOTE">