(js) Restore user's last Calendar view

Also reviewed the handling of Angular modules dependencies.
This commit is contained in:
Francis Lachapelle
2015-07-29 11:47:01 -04:00
parent 762f305914
commit 7e10cff395
16 changed files with 101 additions and 65 deletions
@@ -6,7 +6,7 @@
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:label="OGo:label"
const:userDefaultsKeys="SOGoContactsCategories"
const:jsFiles="Contacts.app.js, Contacts.js, Common.js"
const:jsFiles="Common.js, Preferences.services.js, Contacts.js, Contacts.services.js"
className="UIxPageFrame"
title="name">
<script type="text/javascript">
+1 -1
View File
@@ -9,7 +9,7 @@
title="title"
const:userDefaultsKeys="SOGoMailMessageCheck,SOGoRefreshViewCheck,SOGoMailSortByThreads,SOGoMailListViewColumnsOrder,SOGoMailDisplayRemoteInlineImages,SOGoMailComposeMessageType,SOGoMailReplyPlacement,SOGoMailLabelsColors"
const:userSettingsKeys="Mail"
const:jsFiles="Mailer.app.js, Common.js, Contacts.js, Mailer.js, Preferences.js, vendor/ckeditor/ckeditor.js, vendor/ckeditor/ck.js, vendor/angular-file-upload.js">
const:jsFiles="Common.js, Contacts.services.js, Mailer.services.js, Preferences.services.js, Mailer.js, Mailer.services.js, vendor/ckeditor/ckeditor.js, vendor/ckeditor/ck.js, vendor/angular-file-upload.js">
<script type="text/javascript">
var mailAccounts =<var:string value="mailAccounts" const:escapeHTML="NO" />;
var userNames =<var:string value="userNames" const:escapeHTML="NO" />;
@@ -9,7 +9,7 @@
xmlns:label="OGo:label"
className="UIxPageFrame"
title="title"
const:jsFiles="Preferences.app.js, Common.js, Mailer.js, Contacts.js, Preferences.js">
const:jsFiles="Common.js, Preferences.js, Preferences.services.js, Mailer.services.js, Contacts.services.js">
<main class="view md-layout-fill" ui-view="preferences" layout="row"
ng-controller="navController"><!-- preferences --> </main>
+1 -1
View File
@@ -10,7 +10,7 @@
title="title"
const:userDefaultsKeys="SOGoRefreshViewCheck, SOGoCalendarCategoriesColors, SOGoDefaultCalendar, SOGoTimeFormat"
const:userSettingsKeys="Calendar, ShowCompletedTasks"
const:jsFiles="Scheduler.app.js, Scheduler.js, Common.js, Contacts.js, Mailer.js, Preferences.js">
const:jsFiles="Common.js, Preferences.services.js, Contacts.services.js, Mailer.services.js, Scheduler.js, Scheduler.services.js">
<script type="text/javascript">
var firstDayOfWeek = <var:string value="firstDayOfWeek"/>;
var dayStartHour = <var:string value="dayStartHour"/>;
+8 -4
View File
@@ -1,10 +1,14 @@
module.exports = function(grunt) {
var js_files = {
'js/Common.js': ['js/Common/Common.app.js', 'js/Common/*.filter.js', 'js/Common/*Controller.js', 'js/Common/*.service.js', 'js/Common/*.directive.js'],
'js/Scheduler.js': ['js/Scheduler/*.js'],
'js/Contacts.js': ['js/Contacts/*.js'],
'js/Mailer.js': ['js/Mailer/*.js'],
'js/Preferences.js': ['js/Preferences/*service.js', 'js/Preferences/*Controller.js']
'js/Scheduler.services.js': ['js/Scheduler/*.service.js'],
'js/Scheduler.js': ['js/Scheduler.app.js', 'js/Scheduler/*Controller.js', 'js/Scheduler/*.directive.js'],
'js/Contacts.services.js': ['js/Contacts/*.service.js'],
'js/Contacts.js': ['js/Contacts.app.js', 'js/Contacts/*Controller.js', 'js/Contacts/*.directive.js'],
'js/Mailer.services.js': ['js/Mailer/*.service.js'],
'js/Mailer.js': ['js/Mailer.app.js', 'js/Mailer/*Controller.js', 'js/Mailer/*.directive.js'],
'js/Preferences.services.js': ['js/Preferences/*.service.js'],
'js/Preferences.js': ['js/Preferences.app.js', 'js/Preferences/*Controller.js']
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@@ -4,6 +4,17 @@
'use strict';
angular.module('SOGo.Common', ['ngMaterial'])
.constant('sgSettings', {
baseURL: ApplicationBaseURL,
activeUser: {
login: UserLogin,
identification: UserIdentification,
language: UserLanguage,
folderURL: UserFolderURL,
isSuperUser: IsSuperUser
}
})
// md break-points values are hard-coded in angular-material/src/core/util/constant.js
// $mdMedia has a built-in support for those values but can also evaluate others
// For some reasons, angular-material's break-points don't match the specs
+1 -3
View File
@@ -4,9 +4,7 @@
(function() {
'use strict';
angular.module('SOGo.Common', []);
angular.module('SOGo.ContactsUI', ['ngSanitize', 'ui.router', 'SOGo.Common'])
angular.module('SOGo.ContactsUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.PreferencesUI'])
.constant('sgSettings', {
baseURL: ApplicationBaseURL,
@@ -47,7 +47,16 @@
return AddressBook; // return constructor
}];
/* Factory registration in Angular module */
/**
* @module SOGo.ContactsUI
* @desc Factory registration of AddressBook in Angular module.
*/
try {
angular.module('SOGo.ContactsUI');
}
catch(e) {
angular.module('SOGo.ContactsUI', ['SOGo.Common']);
}
angular.module('SOGo.ContactsUI')
.factory('AddressBook', AddressBook.$factory);
@@ -53,6 +53,12 @@
* @module SOGo.ContactsUI
* @desc Factory registration of Card in Angular module.
*/
try {
angular.module('SOGo.ContactsUI');
}
catch(e) {
angular.module('SOGo.ContactsUI', ['SOGo.Common']);
}
angular.module('SOGo.ContactsUI')
.factory('Card', Card.$factory);
@@ -403,15 +409,15 @@
* @param {string} email
* @param {Card} card
*/
Card.prototype.$updateMember = function(index, email, card) {
var ref = {
email: email,
emails: [{value: email}],
reference: card.c_name,
c_cn: card.$fullname()
};
this.refs[index] = new Card(ref);
};
// Card.prototype.$updateMember = function(index, email, card) {
// var ref = {
// email: email,
// emails: [{value: email}],
// reference: card.c_name,
// c_cn: card.$fullname()
// };
// this.refs[index] = new Card(ref);
// };
/**
* @function $unwrap
+2 -17
View File
@@ -4,22 +4,7 @@
(function() {
'use strict';
angular.module('SOGo.ContactsUI', []);
angular.module('SOGo.PreferencesUI', []);
angular.module('SOGo.MailerUI', ['ngSanitize', 'ui.router', 'ck', 'angularFileUpload', 'SOGo.Common', 'SOGo.ContactsUI', 'ngAnimate', 'SOGo.PreferencesUI'])
.constant('sgSettings', {
baseURL: ApplicationBaseURL,
activeUser: {
login: UserLogin,
identification: UserIdentification,
language: UserLanguage,
folderURL: UserFolderURL,
isSuperUser: IsSuperUser
}
})
.config(configure)
.run(runBlock);
@@ -229,8 +214,8 @@
runBlock.$inject = ['$rootScope'];
function runBlock($rootScope) {
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
console.error(event, current, previous, rejection)
})
console.error(event, current, previous, rejection);
});
}
})();
@@ -44,7 +44,16 @@
return Account; // return constructor
}];
/* Factory registration in Angular module */
/**
* @module SOGo.MailerUI
* @desc Factory registration of Account in Angular module.
*/
try {
angular.module('SOGo.MailerUI');
}
catch(e) {
angular.module('SOGo.MailerUI', ['SOGo.Common']);
}
angular.module('SOGo.MailerUI')
.factory('Account', Account.$factory);
@@ -57,15 +57,19 @@
/**
* @module SOGo.MailerUI
* @desc Factory registration of Card in Angular module.
* @desc Factory registration of Mailbox in Angular module.
*/
try {
angular.module('SOGo.MailerUI');
}
catch(e) {
angular.module('SOGo.MailerUI', ['SOGo.Common']);
}
angular.module('SOGo.MailerUI')
/* Factory constants */
.constant('sgMailbox_PRELOAD', {
LOOKAHEAD: 50,
SIZE: 100
})
/* Factory registration in Angular module */
.factory('Mailbox', Mailbox.$factory);
/**
+16 -21
View File
@@ -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]);
}
});
}
}
})();
@@ -40,7 +40,16 @@
return Calendar; // return constructor
}];
/* Factory registration in Angular module */
/**
* @module SOGo.SchedulerUI
* @desc Factory registration of Calendar in Angular module.
*/
try {
angular.module('SOGo.SchedulerUI');
}
catch(e) {
angular.module('SOGo.SchedulerUI', ['SOGo.Common']);
}
angular.module('SOGo.SchedulerUI')
.factory('Calendar', Calendar.$factory);
@@ -122,6 +122,6 @@
}
angular
.module('SOGo.SchedulerUI')
.module('SOGo.SchedulerUI')
.controller('CalendarListController', CalendarListController);
})();
@@ -63,6 +63,12 @@
* @module SOGo.SchedulerUI
* @desc Factory registration of Component in Angular module.
*/
try {
angular.module('SOGo.SchedulerUI');
}
catch(e) {
angular.module('SOGo.SchedulerUI', ['SOGo.Common']);
}
angular.module('SOGo.SchedulerUI')
.factory('Component', Component.$factory);