Skip to content

Commit

Permalink
(js) Fix ordering of calendars
Browse files Browse the repository at this point in the history
Fixes #3931
  • Loading branch information
cgx committed Dec 8, 2016
1 parent 4b2b369 commit d0e0d53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -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)
------------------
Expand Down
14 changes: 8 additions & 6 deletions UI/WebServerResources/js/Scheduler/Calendar.service.js
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit d0e0d53

Please sign in to comment.