(js) Fix ordering of calendars

Fixes #3931
pull/233/head
Francis Lachapelle 2016-12-08 10:17:03 -05:00
parent 4b2b3693c5
commit d0e0d5300a
2 changed files with 9 additions and 6 deletions

1
NEWS
View File

@ -11,6 +11,7 @@ Bug fixes
- [web] fixed confusion between owner and active user in ACLs management of Administration module
- [web] fixed JavaScript exception after renaming an address book
- [web] fixed Sieve folder encoding support (#3904)
- [web] fixed ordering of calendars when renaming or adding a calendar (#3931)
3.2.4 (2016-12-01)
------------------

View File

@ -84,7 +84,7 @@
*/
Calendar.$add = function(calendar) {
// Insert new calendar at proper index
var list, sibling, i;
var list, sibling;
if (calendar.isWebCalendar)
list = this.$webcalendars;
@ -93,13 +93,15 @@
else
list = this.$calendars;
sibling = _.find(list, function(o) {
sibling = _.findIndex(list, function(o, i) {
console.debug(i + ': "' + o.id + '".localeCompare("' + calendar.name + '") = ' + o.name.localeCompare(calendar.name));
return (calendar.id == 'personal' ||
(o.id != 'personal' &&
o.name.localeCompare(calendar.name) === 1));
(o.id != 'personal' && o.name.localeCompare(calendar.name) > 0));
});
i = sibling ? _.indexOf(_.map(list, 'id'), sibling.id) : 1;
list.splice(i, 0, calendar);
if (sibling < 0)
list.push(calendar);
else
list.splice(sibling, 0, calendar);
this.$Preferences.ready().then(function() {
if (Calendar.$Preferences.settings.Calendar.FoldersOrder)