summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-09-11 12:44:12 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-09-11 12:44:12 (GMT)
commit109044c87ba861cd068e9ec70f355716bf10e0d9 (patch)
tree3420f966ad41a5f2755d021f77802acc1f5066c4
parent359d8dc1107d363708d47070381af1507c2c9859 (diff)
downloadroundcubemail-plugins-kolab-109044c87ba861cd068e9ec70f355716bf10e0d9.tar.gz
Add command to remove a Kolab address book from the list (-> unsubscribe); fix contextmenu for abooks and contact groups
-rw-r--r--plugins/kolab_addressbook/kolab_addressbook.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/plugins/kolab_addressbook/kolab_addressbook.js b/plugins/kolab_addressbook/kolab_addressbook.js
index b9edb42..c837030 100644
--- a/plugins/kolab_addressbook/kolab_addressbook.js
+++ b/plugins/kolab_addressbook/kolab_addressbook.js
@@ -107,6 +107,11 @@ if (window.rcmail) {
rcmail.http_post('plugin.book-subscribe', { _source:node.id, _permanent:source.subscribed?1:0 });
}
})
+ .addEventListener('remove', function(node) {
+ if (rcmail.env.address_sources[node.id]) {
+ rcmail.book_remove(node.id);
+ }
+ })
.addEventListener('insert-item', function(data) {
// register new address source
rcmail.env.address_sources[data.id] = rcmail.env.contactfolders[data.id] = data.data;
@@ -131,11 +136,12 @@ if (window.rcmail) {
// (De-)activates address book management commands
rcube_webmail.prototype.set_book_actions = function()
{
- var source = this.env.source,
+ var source = !this.env.group ? this.env.source : null,
sources = this.env.address_sources;
this.enable_command('book-create', true);
this.enable_command('book-edit', 'book-delete', source && sources[source] && sources[source].kolab && sources[source].editable);
+ this.enable_command('book-remove', source && sources[source] && sources[source].kolab && sources[source].removable);
this.enable_command('book-showurl', source && sources[source] && sources[source].carddavurl);
};
@@ -149,6 +155,15 @@ rcube_webmail.prototype.book_edit = function()
this.book_show_contentframe('edit');
};
+rcube_webmail.prototype.book_remove = function(id)
+{
+ if (!id) id = this.env.source;
+ if (id != '' && rcmail.env.address_sources[id]) {
+ rcmail.book_delete_done(id, true);
+ rcmail.http_post('plugin.book-subscribe', { _source:id, _permanent:0, _recursive:1 });
+ }
+};
+
rcube_webmail.prototype.book_delete = function()
{
if (this.env.source != '' && confirm(this.get_label('kolab_addressbook.bookdeleteconfirm'))) {
@@ -343,7 +358,7 @@ function kolab_addressbook_contextmenu()
menu_source: ['#directorylist-footer', '#groupoptionsmenu']
}, {
'activate': function(p) {
- var source = rcmail.env.source,
+ var source = !rcmail.env.group ? rcmail.env.source : null,
sources = rcmail.env.address_sources;
if (p.command == 'book-create') {
@@ -354,10 +369,18 @@ function kolab_addressbook_contextmenu()
return !!(source && sources[source] && sources[source].kolab && sources[source].editable);
}
+ if (p.command == 'book-remove') {
+ return !!(source && sources[source] && sources[source].kolab && sources[source].removable);
+ }
+
if (p.command == 'book-showurl') {
return !!(source && sources[source] && sources[source].carddavurl);
}
+ if (p.command == 'group-rename' || p.command == 'group-delete') {
+ return !!(rcmail.env.group && sources[rcmail.env.source] && sources[rcmail.env.source].editable);
+ }
+
return false;
},
'beforeactivate': function(p) {
@@ -367,11 +390,16 @@ function kolab_addressbook_contextmenu()
rcmail.env.kolab_old_source = rcmail.env.source;
rcmail.env.kolab_old_group = rcmail.env.group;
- var onclick = $(p.source).attr('onclick');
+ var elem = $(p.source), onclick = elem.attr('onclick');
if (onclick && onclick.match(rcmail.context_menu_command_pattern)) {
rcmail.env.source = RegExp.$2;
rcmail.env.group = null;
}
+ else if (elem.parent().hasClass('contactgroup')) {
+ var grp = String(elem.attr('rel')).split(':');
+ rcmail.env.source = grp[0];
+ rcmail.env.group = grp[1];
+ }
},
'aftercommand': function(p) {
rcmail.env.source = rcmail.env.kolab_old_source;
@@ -380,7 +408,7 @@ function kolab_addressbook_contextmenu()
}
);
- $('#directorylist div > a').off('contextmenu').on('contextmenu', function(e) {
+ $('#directorylist').off('contextmenu').on('contextmenu', 'div > a, li.contactgroup > a', function(e) {
$(this).blur();
rcm_show_menu(e, this, $(this).attr('rel'), menu);
});