mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-08 16:33:22 +00:00
(js) Restore user's last Calendar view
Also reviewed the handling of Angular modules dependencies.
This commit is contained in:
@@ -4,22 +4,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.ContactsUI', []);
|
||||
angular.module('SOGo.MailerUI', []);
|
||||
angular.module('SOGo.PreferencesUI', []);
|
||||
|
||||
angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.ContactsUI', 'SOGo.MailerUI', 'SOGo.PreferencesUI'])
|
||||
|
||||
.constant('sgSettings', {
|
||||
baseURL: ApplicationBaseURL,
|
||||
activeUser: {
|
||||
login: UserLogin,
|
||||
identification: UserIdentification,
|
||||
language: UserLanguage,
|
||||
folderURL: UserFolderURL,
|
||||
isSuperUser: IsSuperUser
|
||||
}
|
||||
})
|
||||
angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.ContactsUI', 'SOGo.MailerUI'])
|
||||
.config(configure)
|
||||
.run(runBlock);
|
||||
|
||||
@@ -67,19 +52,20 @@
|
||||
// If no date is specified, show today
|
||||
var now = new Date();
|
||||
return '/calendar/day/' + now.getDayString();
|
||||
})
|
||||
});
|
||||
$urlRouterProvider.when('/calendar/week', function() {
|
||||
// If no date is specified, show today's week
|
||||
var now = new Date();
|
||||
return '/calendar/week/' + now.getDayString();
|
||||
})
|
||||
});
|
||||
$urlRouterProvider.when('/calendar/month', function() {
|
||||
// If no date is specified, show today's month
|
||||
var now = new Date();
|
||||
return '/calendar/month/' + now.getDayString();
|
||||
});
|
||||
|
||||
// if none of the above states are matched, use this as the fallback
|
||||
// If none of the above states are matched, use this as the fallback.
|
||||
// runBlock will also act as a fallback by looking at user's settings
|
||||
$urlRouterProvider.otherwise('/calendar');
|
||||
}
|
||||
|
||||
@@ -102,11 +88,20 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
runBlock.$inject = ['$rootScope'];
|
||||
function runBlock($rootScope) {
|
||||
runBlock.$inject = ['$rootScope', '$location', 'Preferences'];
|
||||
function runBlock($rootScope, $location, Preferences) {
|
||||
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
|
||||
console.error(event, current, previous, rejection);
|
||||
});
|
||||
if ($location.url().length === 0) {
|
||||
// Restore user's last view
|
||||
Preferences.ready().then(function() {
|
||||
var view = /(.+)view/.exec(Preferences.settings.Calendar.View);
|
||||
if (view) {
|
||||
$location.replace().url('/calendar/' + view[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user