1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-11-29 11:24:11 +01:00

Contacts: Use addnew plugin for groups.

This commit is contained in:
Thomas Tanghus 2013-05-02 22:01:37 +02:00
parent c560af4375
commit 2bd98c3cb7
3 changed files with 34 additions and 12 deletions

View File

@ -112,6 +112,13 @@
}
#grouplist { z-index: 100; }
#grouplist .oc-addnew-init { padding: 0 16px; }
#grouplist .add-contact:before {
content: '+';
font-weight: bold;
font-size: 180%;
padding-right: 5px;
}
#grouplist li .action:not(.starred):not(.checked):not(.favorite):not([class^="add-"]) { display: none; padding: 0; }
#grouplist li:not([data-type="shared"]):not(.editing):hover .action.numcontacts,
#grouplist li:not([data-type="shared"]):not(.editing) .active.action.numcontacts { display: inline-block; }
@ -119,6 +126,7 @@
#grouplist li.active[data-type="category"]:not(.editing):hover .action.delete { display: inline-block; }
#grouplist li:not(.editing) .action.delete { width: 20px; height: 20px; }
#grouplist .group span.numcontacts { width: 30px; text-align: right; margin-right: 10px !important; }
#grouplist li.special { height: 40px; }
/* First run */

View File

@ -35,13 +35,31 @@ OC.Contacts = OC.Contacts || {};
}
});
} else if($(event.target).is('.add-group')) {
self.editGroup();
//self.editGroup();
} else if($(event.target).is('.add-contact')) {
$.noop(); // handled elsewhere in app.js
} else {
self.selectGroup({element:$(this)});
}
});
var $addInput = this.$groupList.find('.add-group');
$addInput.addnew({
ok: function(event, name) {
console.log('add-address-book ok', name);
$addInput.addClass('loading');
self.addGroup({name:name}, function(response) {
console.log('response', response);
if(response.error) {
$(document).trigger('status.contact.error', {
message: response.message
});
} else {
$addInput.addnew('close');
}
$addInput.removeClass('loading');
});
}
});
this.$groupListItemTemplate = listItemTmpl;
this.categories = [];
@ -430,7 +448,7 @@ OC.Contacts = OC.Contacts || {};
* FIXME: This works fine for adding, but will need refactoring
* if used for renaming.
*/
GroupList.prototype.editGroup = function(id) {
/*GroupList.prototype.editGroup = function(id) {
var self = this;
if(this.$editelem) {
console.log('Already editing, returning');
@ -510,7 +528,7 @@ OC.Contacts = OC.Contacts || {};
} else {
throw { name: 'WrongParameterType', message: 'GroupList.editGroup only accept integers.'};
}
};
};*/
/**
* Add a new group.
@ -544,7 +562,7 @@ OC.Contacts = OC.Contacts || {};
});
if(exists) {
if(typeof cb === 'function') {
cb({status:'error', message:t('contacts', 'A group named {group} already exists', {group: escapeHTML(name)})});
cb({error:true, message:t('contacts', 'A group named {group} already exists', {group: escapeHTML(name)})});
}
return;
}

View File

@ -1,17 +1,13 @@
<div id="app">
<div id="app-navigation" class="loading">
<ul id="grouplist">
<li>
<li class="special">
<a role="button" class="add-contact">
<i class="icon-plus"></i>
<?php p($l->t('New Contact')); ?>
</a>
</li>
<li>
<a role="button" class="add-group">
<i class="icon-plus"></i>
<?php p($l->t('New Group')); ?>
</a>
<li class="special">
<input class="add-group" type="text" tabindex="0" autofocus placeholder="<?php p($l->t('Group name')); ?>" title="<?php p($l->t('New Group')); ?>" />
</li>
</ul>
<div id="app-settings">
@ -23,7 +19,7 @@
<h2 data-id="addressbooks" tabindex="0" role="button"><?php p($l->t('Address books')); ?></h2>
<ul class="addressbooklist">
</ul>
<input type="text" id="add-address-book" placeholder="<?php p($l->t('Display name')); ?>" title="<?php p($l->t('Add Address Book')); ?>" />
<input type="text" tabindex="0" autofocus id="add-address-book" placeholder="<?php p($l->t('Display name')); ?>" title="<?php p($l->t('Add Address Book')); ?>" />
</div>
<div id="import">
<h2 data-id="import" tabindex="0" role="button"><?php p($l->t('Import')); ?></h2>