Fixed groups updating after addressbook rename
Fixed new addressbook selection on IE7 (#353)
This commit is contained in:
parent
4d22d4d71e
commit
7577e5411d
1 changed files with 30 additions and 27 deletions
|
@ -103,7 +103,7 @@ rcube_webmail.prototype.book_delete_done = function(id)
|
||||||
// action executed after book create/update
|
// action executed after book create/update
|
||||||
rcube_webmail.prototype.book_update = function(data, old)
|
rcube_webmail.prototype.book_update = function(data, old)
|
||||||
{
|
{
|
||||||
var n, i, id, len, row, refrow, olddata, name = '', realname = '', sources, level,
|
var n, i, id, len, link, row, refrow, olddata, name = '', realname = '', sources, level,
|
||||||
folders = [], class_name = 'addressbook',
|
folders = [], class_name = 'addressbook',
|
||||||
list = this.gui_objects.folderlist,
|
list = this.gui_objects.folderlist,
|
||||||
groups = this.env.contactgroups;
|
groups = this.env.contactgroups;
|
||||||
|
@ -116,31 +116,11 @@ rcube_webmail.prototype.book_update = function(data, old)
|
||||||
olddata = this.env.address_sources[old];
|
olddata = this.env.address_sources[old];
|
||||||
delete this.env.address_sources[old];
|
delete this.env.address_sources[old];
|
||||||
delete this.env.contactfolders[old];
|
delete this.env.contactfolders[old];
|
||||||
|
|
||||||
// update source ID in groups
|
|
||||||
for (n in groups)
|
|
||||||
if (groups[n].source == old)
|
|
||||||
this.env.contactgroups[n].source = data.id;
|
|
||||||
|
|
||||||
refrow = $('#rcmli'+old);
|
refrow = $('#rcmli'+old);
|
||||||
}
|
}
|
||||||
// create
|
|
||||||
else if (!old) {
|
|
||||||
refrow = $('li', list).get(0);
|
|
||||||
|
|
||||||
// this shouldn't happen
|
|
||||||
if (!refrow)
|
|
||||||
this.redirect(this.get_task_url('addressbook'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refrow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sources = this.env.address_sources;
|
sources = this.env.address_sources;
|
||||||
|
|
||||||
// clone a table row if there are existing rows
|
|
||||||
row = $(refrow).clone();
|
|
||||||
|
|
||||||
// set row attributes
|
// set row attributes
|
||||||
if (data.readonly)
|
if (data.readonly)
|
||||||
class_name += ' readonly';
|
class_name += ' readonly';
|
||||||
|
@ -152,9 +132,10 @@ rcube_webmail.prototype.book_update = function(data, old)
|
||||||
this.env.source = data.id;
|
this.env.source = data.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
row.attr({id: 'rcmli'+data.id, 'class': class_name});
|
link = $('<a>').attr({'href': '#', 'rel': data.id}).html(data.name)
|
||||||
$('a', row).html(data.name).attr({onclick: '', rel: data.id, href: '#'})
|
.click(function() { return rcmail.command('list', data.id, this); });
|
||||||
.click({id: data.id}, function(e) { return rcmail.command('list', e.data.id, this); });
|
row = $('<li>').attr({id: 'rcmli'+data.id, 'class': class_name})
|
||||||
|
.append(link);
|
||||||
|
|
||||||
// sort kolab folders, to put the new one in order
|
// sort kolab folders, to put the new one in order
|
||||||
for (n in sources)
|
for (n in sources)
|
||||||
|
@ -187,6 +168,27 @@ rcube_webmail.prototype.book_update = function(data, old)
|
||||||
if (olddata) {
|
if (olddata) {
|
||||||
// remove old row (just after the new row has been inserted)
|
// remove old row (just after the new row has been inserted)
|
||||||
refrow.remove();
|
refrow.remove();
|
||||||
|
|
||||||
|
// update groups
|
||||||
|
for (n in groups) {
|
||||||
|
if (groups[n].source == old) {
|
||||||
|
// update existing row
|
||||||
|
refrow = $('#rcmli'+n);
|
||||||
|
refrow.remove().attr({id: 'rcmliG'+data.id+groups[n].id});
|
||||||
|
$('a', refrow).removeAttr('onclick').unbind()
|
||||||
|
.click({source: data.id, id: groups[n].id}, function(e) {
|
||||||
|
return rcmail.command('listgroup', {'source': e.data.source, 'id': e.data.id}, this);
|
||||||
|
});
|
||||||
|
refrow.insertAfter(row);
|
||||||
|
row = refrow;
|
||||||
|
|
||||||
|
// update group data
|
||||||
|
groups[n].source = data.id;
|
||||||
|
this.env.contactgroups['G'+data.id+groups[n].id] = groups[n];
|
||||||
|
delete this.env.contactgroups[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
old += '-';
|
old += '-';
|
||||||
level = olddata.realname.split(this.env.delimiter).length - data.realname.split(this.env.delimiter).length;
|
level = olddata.realname.split(this.env.delimiter).length - data.realname.split(this.env.delimiter).length;
|
||||||
// update (realname and ID of) subfolders
|
// update (realname and ID of) subfolders
|
||||||
|
@ -210,7 +212,7 @@ rcube_webmail.prototype.book_update = function(data, old)
|
||||||
// update existing row
|
// update existing row
|
||||||
refrow = $('#rcmli'+n);
|
refrow = $('#rcmli'+n);
|
||||||
refrow.remove().attr({id: 'rcmli'+id});
|
refrow.remove().attr({id: 'rcmli'+id});
|
||||||
$('a', refrow).html(name).attr({onclick: '', rel: id, href: '#'})
|
$('a', refrow).html(name).removeAttr('onclick').unbind().attr({rel: id, href: '#'})
|
||||||
.click({id: id}, function(e) { return rcmail.command('list', e.data.id, this); });
|
.click({id: id}, function(e) { return rcmail.command('list', e.data.id, this); });
|
||||||
|
|
||||||
// move the row to the new place
|
// move the row to the new place
|
||||||
|
@ -231,9 +233,10 @@ rcube_webmail.prototype.book_update = function(data, old)
|
||||||
// update existing row
|
// update existing row
|
||||||
refrow = $('#rcmli'+i);
|
refrow = $('#rcmli'+i);
|
||||||
refrow.remove().attr({id: 'rcmliG'+id+groups[i].id});
|
refrow.remove().attr({id: 'rcmliG'+id+groups[i].id});
|
||||||
$('a', refrow).attr('onclick', '')
|
$('a', refrow).removeAttr('onclick').unbind()
|
||||||
.click({source: id, id: groups[i].id}, function(e) {
|
.click({source: id, id: groups[i].id}, function(e) {
|
||||||
return rcmail.command('listgroup', {'source': e.data.source, 'id': e.data.id}, this); });
|
return rcmail.command('listgroup', {'source': e.data.source, 'id': e.data.id}, this);
|
||||||
|
});
|
||||||
refrow.insertAfter(row);
|
refrow.insertAfter(row);
|
||||||
row = refrow;
|
row = refrow;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue