Expose user's settings and defaults inline
This improves performance by removing two AJAX calls and a lot of JavaScript promises.
This commit is contained in:
parent
1fa056bb25
commit
89bfa0c536
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ Enhancements
|
||||||
- [web] improve display of tasks status
|
- [web] improve display of tasks status
|
||||||
- [web] added custom fields support from Thunderbird's address book
|
- [web] added custom fields support from Thunderbird's address book
|
||||||
- [web] added Latvian (lv) translation - thanks to Juris Balandis
|
- [web] added Latvian (lv) translation - thanks to Juris Balandis
|
||||||
|
- [web] expose user's defaults and settings inline
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
- [web] respect SOGoLanguage and SOGoSupportedLanguages (#4169)
|
- [web] respect SOGoLanguage and SOGoSupportedLanguages (#4169)
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
};
|
};
|
||||||
jsonDefaults = {
|
jsonDefaults = {
|
||||||
protectedBy = "View";
|
protectedBy = "View";
|
||||||
actionClass = "UIxJSONPreferences";
|
pageName = "UIxJSONPreferences";
|
||||||
actionName = "jsonDefaults";
|
actionName = "jsonDefaults";
|
||||||
};
|
};
|
||||||
jsonSettings = {
|
jsonSettings = {
|
||||||
protectedBy = "View";
|
protectedBy = "View";
|
||||||
actionClass = "UIxJSONPreferences";
|
pageName = "UIxJSONPreferences";
|
||||||
actionName = "jsonSettings";
|
actionName = "jsonSettings";
|
||||||
};
|
};
|
||||||
save = {
|
save = {
|
||||||
|
|
12
UI/Templates/PreferencesUI/UIxJSONPreferences.wox
Normal file
12
UI/Templates/PreferencesUI/UIxJSONPreferences.wox
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version='1.0' standalone='yes'?>
|
||||||
|
<container
|
||||||
|
xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:var="http://www.skyrix.com/od/binding"
|
||||||
|
xmlns:const="http://www.skyrix.com/od/constant">
|
||||||
|
<script id="UserDefaults" type="text/json">
|
||||||
|
<var:string value="jsonDefaults" const:escapeHTML="NO"/>
|
||||||
|
</script>
|
||||||
|
<script id="UserSettings" type="text/json">
|
||||||
|
<var:string value="jsonSettings" const:escapeHTML="NO"/>
|
||||||
|
</script>
|
||||||
|
</container>
|
|
@ -58,16 +58,6 @@
|
||||||
<iframe width="100%" height="100%" src="/SOGo/loading"><!-- space --></iframe>
|
<iframe width="100%" height="100%" src="/SOGo/loading"><!-- space --></iframe>
|
||||||
</div>
|
</div>
|
||||||
</var:if>
|
</var:if>
|
||||||
<script type="text/javascript">
|
|
||||||
<var:if condition="shortUserNameForDisplay" const:value="anonymous" const:negate="YES">
|
|
||||||
<var:if condition="hasUserSettingsKeys">
|
|
||||||
var UserSettings =<var:string value="userSettings" const:escapeHTML="NO" />;
|
|
||||||
</var:if>
|
|
||||||
<var:if condition="hasUserDefaultsKeys">
|
|
||||||
var UserDefaults = <var:string value="userDefaults" const:escapeHTML="NO" />;
|
|
||||||
</var:if>
|
|
||||||
</var:if>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- MAIN CONTENT ROW -->
|
<!-- MAIN CONTENT ROW -->
|
||||||
<var:component-content />
|
<var:component-content />
|
||||||
|
@ -131,10 +121,15 @@
|
||||||
|
|
||||||
// This is the equivalent of an AJAX call to /SOGo/so/_UserLogin_/date
|
// This is the equivalent of an AJAX call to /SOGo/so/_UserLogin_/date
|
||||||
var currentDay = <var:string value="currentDayDescription" const:escapeHTML="NO"/>;
|
var currentDay = <var:string value="currentDayDescription" const:escapeHTML="NO"/>;
|
||||||
|
|
||||||
<var:string value="commonLocalizableStrings" const:escapeHTML="NO" />
|
<var:string value="commonLocalizableStrings" const:escapeHTML="NO" />
|
||||||
<var:string value="productLocalizableStrings" const:escapeHTML="NO" />
|
<var:string value="productLocalizableStrings" const:escapeHTML="NO" />
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<var:if condition="shortUserNameForDisplay" const:value="anonymous" const:negate="YES">
|
||||||
|
<var:component className="UIxJSONPreferences"/>
|
||||||
|
</var:if>
|
||||||
|
|
||||||
<!-- JAVASCRIPT IMPORTS -->
|
<!-- JAVASCRIPT IMPORTS -->
|
||||||
<script type="text/javascript" rsrc:src="js/vendor/lodash.min.js"><!-- space --></script>
|
<script type="text/javascript" rsrc:src="js/vendor/lodash.min.js"><!-- space --></script>
|
||||||
<script type="text/javascript" rsrc:src="js/vendor/angular.min.js"><!-- space --></script>
|
<script type="text/javascript" rsrc:src="js/vendor/angular.min.js"><!-- space --></script>
|
||||||
|
|
|
@ -77,8 +77,6 @@
|
||||||
$element.off('click', toggleZoomFcn);
|
$element.off('click', toggleZoomFcn);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait on user's defaults
|
|
||||||
Preferences.ready().then(function() {
|
|
||||||
$scope.$watch(function() { return vm.email; }, function(email, old) {
|
$scope.$watch(function() { return vm.email; }, function(email, old) {
|
||||||
if (email && vm.urlEmail != email) {
|
if (email && vm.urlEmail != email) {
|
||||||
// Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)
|
// Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)
|
||||||
|
@ -89,7 +87,6 @@
|
||||||
else if (!email)
|
else if (!email)
|
||||||
showGenericAvatar();
|
showGenericAvatar();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// If sg-src is defined, watch the expression for the URL of a local image
|
// If sg-src is defined, watch the expression for the URL of a local image
|
||||||
if ('sg-src' in $element[0].attributes) {
|
if ('sg-src' in $element[0].attributes) {
|
||||||
|
|
|
@ -49,12 +49,11 @@
|
||||||
$refreshTimeout: null
|
$refreshTimeout: null
|
||||||
});
|
});
|
||||||
// Initialize sort parameters from user's settings
|
// Initialize sort parameters from user's settings
|
||||||
Preferences.ready().then(function() {
|
|
||||||
if (Preferences.settings.Contact.SortingState) {
|
if (Preferences.settings.Contact.SortingState) {
|
||||||
AddressBook.$query.sort = Preferences.settings.Contact.SortingState[0];
|
AddressBook.$query.sort = Preferences.settings.Contact.SortingState[0];
|
||||||
AddressBook.$query.asc = parseInt(Preferences.settings.Contact.SortingState[1]);
|
AddressBook.$query.asc = parseInt(Preferences.settings.Contact.SortingState[1]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return AddressBook; // return constructor
|
return AddressBook; // return constructor
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -437,19 +436,15 @@
|
||||||
* @desc Starts the refresh timeout for the current selected address book
|
* @desc Starts the refresh timeout for the current selected address book
|
||||||
*/
|
*/
|
||||||
AddressBook.prototype.$startRefreshTimeout = function() {
|
AddressBook.prototype.$startRefreshTimeout = function() {
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
if (AddressBook.$refreshTimeout)
|
if (AddressBook.$refreshTimeout)
|
||||||
AddressBook.$timeout.cancel(AddressBook.$refreshTimeout);
|
AddressBook.$timeout.cancel(AddressBook.$refreshTimeout);
|
||||||
|
|
||||||
AddressBook.$Preferences.ready().then(function() {
|
|
||||||
// Restart the refresh timer, if needed
|
// Restart the refresh timer, if needed
|
||||||
var refreshViewCheck = AddressBook.$Preferences.defaults.SOGoRefreshViewCheck;
|
var refreshViewCheck = AddressBook.$Preferences.defaults.SOGoRefreshViewCheck;
|
||||||
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
||||||
var f = angular.bind(_this, AddressBook.prototype.$reload);
|
var f = angular.bind(this, AddressBook.prototype.$reload);
|
||||||
AddressBook.$refreshTimeout = AddressBook.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
AddressBook.$refreshTimeout = AddressBook.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -487,7 +482,6 @@
|
||||||
if (!this.isRemote) query.partial = 1;
|
if (!this.isRemote) query.partial = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AddressBook.$Preferences.ready().then(function() {
|
|
||||||
if (options) {
|
if (options) {
|
||||||
angular.extend(query, options);
|
angular.extend(query, options);
|
||||||
if (dry) {
|
if (dry) {
|
||||||
|
@ -572,7 +566,6 @@
|
||||||
return _this.$unwrap(futureData);
|
return _this.$unwrap(futureData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,13 +46,11 @@
|
||||||
$Preferences: Preferences
|
$Preferences: Preferences
|
||||||
});
|
});
|
||||||
// Initialize categories from user's defaults
|
// Initialize categories from user's defaults
|
||||||
Preferences.ready().then(function() {
|
|
||||||
if (Preferences.defaults.SOGoContactsCategories) {
|
if (Preferences.defaults.SOGoContactsCategories) {
|
||||||
Card.$categories = Preferences.defaults.SOGoContactsCategories;
|
Card.$categories = Preferences.defaults.SOGoContactsCategories;
|
||||||
}
|
}
|
||||||
if (Preferences.defaults.SOGoAlternateAvatar)
|
if (Preferences.defaults.SOGoAlternateAvatar)
|
||||||
Card.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar;
|
Card.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar;
|
||||||
});
|
|
||||||
|
|
||||||
return Card; // return constructor
|
return Card; // return constructor
|
||||||
}];
|
}];
|
||||||
|
@ -149,9 +147,7 @@
|
||||||
if (!this.$$image)
|
if (!this.$$image)
|
||||||
this.$$image = this.image;
|
this.$$image = this.image;
|
||||||
if (!this.$$image)
|
if (!this.$$image)
|
||||||
Card.$Preferences.avatar(this.$$email, 32, {no_404: true}).then(function(url) {
|
this.$$image = Card.$Preferences.avatar(this.$$email, 32, {no_404: true});
|
||||||
_this.$$image = url;
|
|
||||||
});
|
|
||||||
if (this.hasphoto)
|
if (this.hasphoto)
|
||||||
this.photoURL = Card.$$resource.path(this.pid, this.id, 'photo');
|
this.photoURL = Card.$$resource.path(this.pid, this.id, 'photo');
|
||||||
if (this.isgroup)
|
if (this.isgroup)
|
||||||
|
@ -177,11 +173,9 @@
|
||||||
});
|
});
|
||||||
// Instanciate date object of birthday
|
// Instanciate date object of birthday
|
||||||
if (this.birthday) {
|
if (this.birthday) {
|
||||||
Card.$Preferences.ready().then(function() {
|
|
||||||
var dlp = Card.$Preferences.$mdDateLocaleProvider;
|
var dlp = Card.$Preferences.$mdDateLocaleProvider;
|
||||||
_this.birthday = _this.birthday.parseDate(dlp, '%Y-%m-%d');
|
this.birthday = this.birthday.parseDate(dlp, '%Y-%m-%d');
|
||||||
_this.$birthday = dlp.formatDate(_this.birthday);
|
this.$birthday = dlp.formatDate(this.birthday);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$loaded = angular.isDefined(this.c_name)? Card.STATUS.LOADED : Card.STATUS.NOT_LOADED;
|
this.$loaded = angular.isDefined(this.c_name)? Card.STATUS.LOADED : Card.STATUS.NOT_LOADED;
|
||||||
|
|
|
@ -136,7 +136,6 @@
|
||||||
_this.$expanded = false;
|
_this.$expanded = false;
|
||||||
|
|
||||||
// Set expanded folders from user's settings
|
// Set expanded folders from user's settings
|
||||||
Account.$Preferences.ready().then(function() {
|
|
||||||
var expandedFolders,
|
var expandedFolders,
|
||||||
_visit = function(mailboxes) {
|
_visit = function(mailboxes) {
|
||||||
_.forEach(mailboxes, function(o) {
|
_.forEach(mailboxes, function(o) {
|
||||||
|
@ -160,7 +159,6 @@
|
||||||
if (Account.$accounts)
|
if (Account.$accounts)
|
||||||
_this.$expanded |= (Account.$accounts.length == 1); // Always expand single account
|
_this.$expanded |= (Account.$accounts.length == 1); // Always expand single account
|
||||||
_this.$flattenMailboxes({reload: true});
|
_this.$flattenMailboxes({reload: true});
|
||||||
});
|
|
||||||
|
|
||||||
return _this.$mailboxes;
|
return _this.$mailboxes;
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,12 +48,10 @@
|
||||||
PRELOAD: PRELOAD
|
PRELOAD: PRELOAD
|
||||||
});
|
});
|
||||||
// Initialize sort parameters from user's settings
|
// Initialize sort parameters from user's settings
|
||||||
Preferences.ready().then(function() {
|
|
||||||
if (Preferences.settings.Mail.SortingState) {
|
if (Preferences.settings.Mail.SortingState) {
|
||||||
Mailbox.$query.sort = Preferences.settings.Mail.SortingState[0];
|
Mailbox.$query.sort = Preferences.settings.Mail.SortingState[0];
|
||||||
Mailbox.$query.asc = parseInt(Preferences.settings.Mail.SortingState[1]);
|
Mailbox.$query.asc = parseInt(Preferences.settings.Mail.SortingState[1]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return Mailbox; // return constructor
|
return Mailbox; // return constructor
|
||||||
}];
|
}];
|
||||||
|
@ -343,8 +341,6 @@
|
||||||
_this.$isLoading = true;
|
_this.$isLoading = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return Mailbox.$Preferences.ready().then(function() {
|
|
||||||
|
|
||||||
if (Mailbox.$refreshTimeout)
|
if (Mailbox.$refreshTimeout)
|
||||||
Mailbox.$timeout.cancel(Mailbox.$refreshTimeout);
|
Mailbox.$timeout.cancel(Mailbox.$refreshTimeout);
|
||||||
|
|
||||||
|
@ -375,14 +371,13 @@
|
||||||
if (!Mailbox.$virtualMode) {
|
if (!Mailbox.$virtualMode) {
|
||||||
var refreshViewCheck = Mailbox.$Preferences.defaults.SOGoRefreshViewCheck;
|
var refreshViewCheck = Mailbox.$Preferences.defaults.SOGoRefreshViewCheck;
|
||||||
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
||||||
var f = angular.bind(_this, Mailbox.prototype.$filter, null, filters);
|
var f = angular.bind(this, Mailbox.prototype.$filter, null, filters);
|
||||||
Mailbox.$refreshTimeout = Mailbox.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
Mailbox.$refreshTimeout = Mailbox.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var futureMailboxData = Mailbox.$$resource.post(_this.id, 'view', options);
|
var futureMailboxData = Mailbox.$$resource.post(this.id, 'view', options);
|
||||||
return _this.$unwrap(futureMailboxData);
|
return this.$unwrap(futureMailboxData);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,9 +32,7 @@
|
||||||
params: []
|
params: []
|
||||||
};
|
};
|
||||||
|
|
||||||
Preferences.ready().then(function() {
|
this.showSubscribedOnly = Preferences.defaults.SOGoMailShowSubscribedFoldersOnly;
|
||||||
vm.showSubscribedOnly = Preferences.defaults.SOGoMailShowSubscribedFoldersOnly;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.refreshUnseenCount();
|
this.refreshUnseenCount();
|
||||||
|
|
||||||
|
@ -258,7 +256,7 @@
|
||||||
}; // delegate
|
}; // delegate
|
||||||
|
|
||||||
this.refreshUnseenCount = function() {
|
this.refreshUnseenCount = function() {
|
||||||
var unseenCountFolders = $window.unseenCountFolders;
|
var unseenCountFolders = $window.unseenCountFolders, refreshViewCheck;
|
||||||
|
|
||||||
_.forEach(vm.accounts, function(account) {
|
_.forEach(vm.accounts, function(account) {
|
||||||
|
|
||||||
|
@ -282,11 +280,9 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Preferences.ready().then(function() {
|
refreshViewCheck = Preferences.defaults.SOGoRefreshViewCheck;
|
||||||
var refreshViewCheck = Preferences.defaults.SOGoRefreshViewCheck;
|
|
||||||
if (refreshViewCheck && refreshViewCheck != 'manually')
|
if (refreshViewCheck && refreshViewCheck != 'manually')
|
||||||
$timeout(vm.refreshUnseenCount, refreshViewCheck.timeInterval()*1000);
|
$timeout(vm.refreshUnseenCount, refreshViewCheck.timeInterval()*1000);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isDroppableFolder = function(srcFolder, dstFolder) {
|
this.isDroppableFolder = function(srcFolder, dstFolder) {
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),
|
$$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),
|
||||||
$avatar: angular.bind(Preferences, Preferences.avatar)
|
$avatar: angular.bind(Preferences, Preferences.avatar)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize tags form user's defaults
|
// Initialize tags form user's defaults
|
||||||
Preferences.ready().then(function() {
|
|
||||||
if (Preferences.defaults.SOGoMailLabelsColors) {
|
if (Preferences.defaults.SOGoMailLabelsColors) {
|
||||||
Message.$tags = Preferences.defaults.SOGoMailLabelsColors;
|
Message.$tags = Preferences.defaults.SOGoMailLabelsColors;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@
|
||||||
Preferences.defaults.SOGoMailDisplayRemoteInlineImages == 'always') {
|
Preferences.defaults.SOGoMailDisplayRemoteInlineImages == 'always') {
|
||||||
Message.$displayRemoteInlineImages = true;
|
Message.$displayRemoteInlineImages = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return Message; // return constructor
|
return Message; // return constructor
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -65,6 +65,13 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Read user's defaults
|
||||||
|
if (Preferences.defaults.SOGoMailAutoSave)
|
||||||
|
// Enable auto-save of draft
|
||||||
|
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
||||||
|
// Set the locale of CKEditor
|
||||||
|
vm.localeCode = Preferences.defaults.LocaleCode;
|
||||||
|
|
||||||
// Destroy file uploader when the controller is being deactivated
|
// Destroy file uploader when the controller is being deactivated
|
||||||
$scope.$on('$destroy', function() { vm.uploader.destroy(); });
|
$scope.$on('$destroy', function() { vm.uploader.destroy(); });
|
||||||
|
|
||||||
|
@ -297,14 +304,6 @@
|
||||||
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read user's defaults
|
|
||||||
Preferences.ready().then(function() {
|
|
||||||
if (Preferences.defaults.SOGoMailAutoSave)
|
|
||||||
// Enable auto-save of draft
|
|
||||||
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
|
||||||
// Set the locale of CKEditor
|
|
||||||
vm.localeCode = Preferences.defaults.LocaleCode;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessageToastController.$inject = ['$scope', '$mdToast'];
|
SendMessageToastController.$inject = ['$scope', '$mdToast'];
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
controller: 'PreferencesController',
|
controller: 'PreferencesController',
|
||||||
controllerAs: 'app'
|
controllerAs: 'app'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
statePreferences: statePreferences
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('preferences.general', {
|
.state('preferences.general', {
|
||||||
|
@ -64,13 +61,6 @@
|
||||||
$urlRouterProvider.otherwise('/general');
|
$urlRouterProvider.otherwise('/general');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngInject
|
|
||||||
*/
|
|
||||||
statePreferences.$inject = ['Preferences'];
|
|
||||||
function statePreferences(Preferences) {
|
|
||||||
return Preferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
|
|
|
@ -8,13 +8,19 @@
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Preferences() {
|
function Preferences() {
|
||||||
var _this = this;
|
var _this = this, defaultsElement, settingsElement, data;
|
||||||
|
|
||||||
this.defaults = {};
|
this.defaults = {};
|
||||||
this.settings = {};
|
this.settings = {};
|
||||||
|
|
||||||
this.defaultsPromise = Preferences.$$resource.fetch("jsonDefaults").then(function(response) {
|
defaultsElement = Preferences.$document[0].getElementById('UserDefaults');
|
||||||
var data = response || {};
|
if (defaultsElement) {
|
||||||
|
try {
|
||||||
|
data = angular.fromJson(defaultsElement.textContent || defaultsElement.innerHTML);
|
||||||
|
} catch (e) {
|
||||||
|
Preferences.$log.error("Can't parse user's defaults: " + e.message);
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
|
||||||
// We swap $key -> _$key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
|
// We swap $key -> _$key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
|
||||||
var labels = _.fromPairs(_.map(data.SOGoMailLabelsColors, function(value, key) {
|
var labels = _.fromPairs(_.map(data.SOGoMailLabelsColors, function(value, key) {
|
||||||
|
@ -117,22 +123,28 @@
|
||||||
_this.$mdDateLocaleProvider.msgCalendar = l('Calender');
|
_this.$mdDateLocaleProvider.msgCalendar = l('Calender');
|
||||||
_this.$mdDateLocaleProvider.msgOpenCalendar = l('Open Calendar');
|
_this.$mdDateLocaleProvider.msgOpenCalendar = l('Open Calendar');
|
||||||
_this.$mdDateLocaleProvider.parseDate = function(dateString) {
|
_this.$mdDateLocaleProvider.parseDate = function(dateString) {
|
||||||
return dateString? dateString.parseDate(_this.$mdDateLocaleProvider, data.SOGoShortDateFormat) : new Date(NaN);
|
return dateString? dateString.parseDate(_this.$mdDateLocaleProvider, _this.defaults.SOGoShortDateFormat) : new Date(NaN);
|
||||||
};
|
};
|
||||||
_this.$mdDateLocaleProvider.formatDate = function(date) {
|
_this.$mdDateLocaleProvider.formatDate = function(date) {
|
||||||
return date? date.format(_this.$mdDateLocaleProvider, date.$dateFormat || data.SOGoShortDateFormat) : '';
|
return date? date.format(_this.$mdDateLocaleProvider, date.$dateFormat || _this.defaults.SOGoShortDateFormat) : '';
|
||||||
};
|
};
|
||||||
_this.$mdDateLocaleProvider.parseTime = function(timeString) {
|
_this.$mdDateLocaleProvider.parseTime = function(timeString) {
|
||||||
return timeString? timeString.parseDate(_this.$mdDateLocaleProvider, data.SOGoTimeFormat) : new Date(NaN);
|
return timeString? timeString.parseDate(_this.$mdDateLocaleProvider, _this.defaults.SOGoTimeFormat) : new Date(NaN);
|
||||||
};
|
};
|
||||||
_this.$mdDateLocaleProvider.formatTime = function(date) {
|
_this.$mdDateLocaleProvider.formatTime = function(date) {
|
||||||
return date? date.format(_this.$mdDateLocaleProvider, data.SOGoTimeFormat) : '';
|
return date? date.format(_this.$mdDateLocaleProvider, _this.defaults.SOGoTimeFormat) : '';
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return _this.defaults;
|
settingsElement = Preferences.$document[0].getElementById('UserSettings');
|
||||||
});
|
if (settingsElement) {
|
||||||
|
try {
|
||||||
|
data = angular.fromJson(settingsElement.textContent || settingsElement.innerHTML);
|
||||||
|
} catch (e) {
|
||||||
|
Preferences.$log.error("Can't parse user's settings: " + e.message);
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
|
||||||
this.settingsPromise = Preferences.$$resource.fetch("jsonSettings").then(function(data) {
|
|
||||||
// We convert our PreventInvitationsWhitelist hash into a array of user
|
// We convert our PreventInvitationsWhitelist hash into a array of user
|
||||||
if (data.Calendar) {
|
if (data.Calendar) {
|
||||||
if (data.Calendar.PreventInvitationsWhitelist) {
|
if (data.Calendar.PreventInvitationsWhitelist) {
|
||||||
|
@ -140,9 +152,7 @@
|
||||||
var match = /^(.+)\s<(\S+)>$/.exec(value),
|
var match = /^(.+)\s<(\S+)>$/.exec(value),
|
||||||
user = new Preferences.$User({uid: key, cn: match[1], c_email: match[2]});
|
user = new Preferences.$User({uid: key, cn: match[1], c_email: match[2]});
|
||||||
if (!user.$$image)
|
if (!user.$$image)
|
||||||
_this.avatar(user.c_email, 32, {no_404: true}).then(function(url) {
|
user.$$image = _this.avatar(user.c_email, 32, {no_404: true});
|
||||||
user.$$image = url;
|
|
||||||
});
|
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -151,9 +161,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.extend(_this.settings, data);
|
angular.extend(_this.settings, data);
|
||||||
|
}
|
||||||
return _this.settings;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,8 +169,9 @@
|
||||||
* @desc The factory we'll use to register with Angular
|
* @desc The factory we'll use to register with Angular
|
||||||
* @returns the Preferences constructor
|
* @returns the Preferences constructor
|
||||||
*/
|
*/
|
||||||
Preferences.$factory = ['$q', '$timeout', '$log', '$mdDateLocale', 'sgSettings', 'Gravatar', 'Resource', 'User', function($q, $timeout, $log, $mdDateLocaleProvider, Settings, Gravatar, Resource, User) {
|
Preferences.$factory = ['$document', '$q', '$timeout', '$log', '$mdDateLocale', 'sgSettings', 'Gravatar', 'Resource', 'User', function($document, $q, $timeout, $log, $mdDateLocaleProvider, Settings, Gravatar, Resource, User) {
|
||||||
angular.extend(Preferences, {
|
angular.extend(Preferences, {
|
||||||
|
$document: $document,
|
||||||
$q: $q,
|
$q: $q,
|
||||||
$timeout: $timeout,
|
$timeout: $timeout,
|
||||||
$log: $log,
|
$log: $log,
|
||||||
|
@ -195,7 +204,8 @@
|
||||||
* @return a combined promise
|
* @return a combined promise
|
||||||
*/
|
*/
|
||||||
Preferences.prototype.ready = function() {
|
Preferences.prototype.ready = function() {
|
||||||
return Preferences.$q.all([this.defaultsPromise, this.settingsPromise]);
|
Preferences.$log.warn('Preferences.ready is deprecated -- access settings/defaults directly.');
|
||||||
|
return Preferences.$q.when(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,7 +216,6 @@
|
||||||
*/
|
*/
|
||||||
Preferences.prototype.avatar = function(email, size, options) {
|
Preferences.prototype.avatar = function(email, size, options) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return this.ready().then(function() {
|
|
||||||
var alternate_avatar = _this.defaults.SOGoAlternateAvatar, url;
|
var alternate_avatar = _this.defaults.SOGoAlternateAvatar, url;
|
||||||
if (_this.defaults.SOGoGravatarEnabled)
|
if (_this.defaults.SOGoGravatarEnabled)
|
||||||
url = Preferences.$gravatar(email, size, alternate_avatar, options);
|
url = Preferences.$gravatar(email, size, alternate_avatar, options);
|
||||||
|
@ -215,7 +224,6 @@
|
||||||
if (options && options.dstObject && options.dstAttr)
|
if (options && options.dstObject && options.dstAttr)
|
||||||
options.dstObject[options.dstAttr] = url;
|
options.dstObject[options.dstAttr] = url;
|
||||||
return url;
|
return url;
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -285,12 +293,16 @@
|
||||||
if (preferences.defaults.Vacation) {
|
if (preferences.defaults.Vacation) {
|
||||||
if (preferences.defaults.Vacation.startDateEnabled)
|
if (preferences.defaults.Vacation.startDateEnabled)
|
||||||
preferences.defaults.Vacation.startDate = preferences.defaults.Vacation.startDate.getTime()/1000;
|
preferences.defaults.Vacation.startDate = preferences.defaults.Vacation.startDate.getTime()/1000;
|
||||||
else
|
else {
|
||||||
|
delete preferences.defaults.Vacation.startDateEnabled;
|
||||||
preferences.defaults.Vacation.startDate = 0;
|
preferences.defaults.Vacation.startDate = 0;
|
||||||
|
}
|
||||||
if (preferences.defaults.Vacation.endDateEnabled)
|
if (preferences.defaults.Vacation.endDateEnabled)
|
||||||
preferences.defaults.Vacation.endDate = preferences.defaults.Vacation.endDate.getTime()/1000;
|
preferences.defaults.Vacation.endDate = preferences.defaults.Vacation.endDate.getTime()/1000;
|
||||||
else
|
else {
|
||||||
|
delete preferences.defaults.Vacation.endDateEnabled;
|
||||||
preferences.defaults.Vacation.endDate = 0;
|
preferences.defaults.Vacation.endDate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (preferences.defaults.Vacation.autoReplyEmailAddresses)
|
if (preferences.defaults.Vacation.autoReplyEmailAddresses)
|
||||||
preferences.defaults.Vacation.autoReplyEmailAddresses = _.filter(preferences.defaults.Vacation.autoReplyEmailAddresses.split(","), function(v) { return v.length; });
|
preferences.defaults.Vacation.autoReplyEmailAddresses = _.filter(preferences.defaults.Vacation.autoReplyEmailAddresses.split(","), function(v) { return v.length; });
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
PreferencesController.$inject = ['$q', '$window', '$state', '$mdMedia', '$mdSidenav', '$mdDialog', '$mdToast', 'sgSettings', 'sgFocus', 'Dialog', 'User', 'Account', 'statePreferences', 'Authentication'];
|
PreferencesController.$inject = ['$q', '$window', '$state', '$mdMedia', '$mdSidenav', '$mdDialog', '$mdToast', 'sgSettings', 'sgFocus', 'Dialog', 'User', 'Account', 'Preferences', 'Authentication'];
|
||||||
function PreferencesController($q, $window, $state, $mdMedia, $mdSidenav, $mdDialog, $mdToast, sgSettings, focus, Dialog, User, Account, statePreferences, Authentication) {
|
function PreferencesController($q, $window, $state, $mdMedia, $mdSidenav, $mdDialog, $mdToast, sgSettings, focus, Dialog, User, Account, Preferences, Authentication) {
|
||||||
var vm = this, account, mailboxes = [], today = new Date(), tomorrow = today.beginOfDay().addDays(1);
|
var vm = this, account, mailboxes = [], today = new Date(), tomorrow = today.beginOfDay().addDays(1);
|
||||||
|
|
||||||
vm.preferences = statePreferences;
|
vm.preferences = Preferences;
|
||||||
vm.passwords = { newPassword: null, newPasswordConfirmation: null };
|
vm.passwords = { newPassword: null, newPasswordConfirmation: null };
|
||||||
|
|
||||||
vm.go = go;
|
vm.go = go;
|
||||||
|
@ -60,11 +60,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set alternate avatar in User service
|
// Set alternate avatar in User service
|
||||||
statePreferences.ready().then(function() {
|
if (Preferences.defaults.SOGoAlternateAvatar)
|
||||||
if (statePreferences.defaults.SOGoAlternateAvatar)
|
User.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar;
|
||||||
User.$alternateAvatar = statePreferences.defaults.SOGoAlternateAvatar;
|
|
||||||
updateVacationDates();
|
updateVacationDates();
|
||||||
});
|
|
||||||
|
|
||||||
function go(module, form) {
|
function go(module, form) {
|
||||||
if (form.$valid) {
|
if (form.$valid) {
|
||||||
|
|
|
@ -102,11 +102,9 @@
|
||||||
else
|
else
|
||||||
list.splice(sibling, 0, calendar);
|
list.splice(sibling, 0, calendar);
|
||||||
|
|
||||||
this.$Preferences.ready().then(function() {
|
|
||||||
if (Calendar.$Preferences.settings.Calendar.FoldersOrder)
|
if (Calendar.$Preferences.settings.Calendar.FoldersOrder)
|
||||||
// Save list order
|
// Save list order
|
||||||
Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));
|
Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));
|
||||||
});
|
|
||||||
// Refresh list of calendars to fetch links associated to new calendar
|
// Refresh list of calendars to fetch links associated to new calendar
|
||||||
Calendar.$reloadAll();
|
Calendar.$reloadAll();
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,11 +23,10 @@
|
||||||
vm.changeView = changeView;
|
vm.changeView = changeView;
|
||||||
|
|
||||||
|
|
||||||
|
this.$onInit = function() {
|
||||||
_registerHotkeys(hotkeys);
|
_registerHotkeys(hotkeys);
|
||||||
|
|
||||||
Preferences.ready().then(function() {
|
|
||||||
_formatDate(vm.selectedDate);
|
_formatDate(vm.selectedDate);
|
||||||
});
|
|
||||||
|
|
||||||
// Refresh current view when the list of calendars is modified
|
// Refresh current view when the list of calendars is modified
|
||||||
deregisterCalendarsList = $rootScope.$on('calendars:list', updateView);
|
deregisterCalendarsList = $rootScope.$on('calendars:list', updateView);
|
||||||
|
@ -40,6 +39,7 @@
|
||||||
sgHotkeys.deregisterHotkey(key);
|
sgHotkeys.deregisterHotkey(key);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function _registerHotkeys(keys) {
|
function _registerHotkeys(keys) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
CalendarListController.$inject = ['$rootScope', '$scope', '$timeout', '$state', '$mdDialog', 'sgHotkeys', 'sgFocus', 'Dialog', 'Preferences', 'CalendarSettings', 'Calendar', 'Component', 'Alarm'];
|
CalendarListController.$inject = ['$rootScope', '$scope', '$timeout', '$state', '$mdDialog', 'sgHotkeys', 'sgFocus', 'Dialog', 'Preferences', 'CalendarSettings', 'Calendar', 'Component', 'Alarm'];
|
||||||
function CalendarListController($rootScope, $scope, $timeout, $state, $mdDialog, sgHotkeys, focus, Dialog, Preferences, CalendarSettings, Calendar, Component, Alarm) {
|
function CalendarListController($rootScope, $scope, $timeout, $state, $mdDialog, sgHotkeys, focus, Dialog, Preferences, CalendarSettings, Calendar, Component, Alarm) {
|
||||||
var vm = this, hotkeys = [];
|
var vm = this, hotkeys = [], type;
|
||||||
|
|
||||||
vm.component = Component;
|
vm.component = Component;
|
||||||
vm.componentType = 'events';
|
vm.componentType = 'events';
|
||||||
|
@ -32,17 +32,16 @@
|
||||||
vm.mode = { search: false, multiple: 0 };
|
vm.mode = { search: false, multiple: 0 };
|
||||||
|
|
||||||
|
|
||||||
|
this.$onInit = function() {
|
||||||
_registerHotkeys(hotkeys);
|
_registerHotkeys(hotkeys);
|
||||||
|
|
||||||
// Select list based on user's settings
|
// Select list based on user's settings
|
||||||
Preferences.ready().then(function() {
|
type = 'events';
|
||||||
var type = 'events';
|
|
||||||
if (Preferences.settings.Calendar.SelectedList == 'tasksListView') {
|
if (Preferences.settings.Calendar.SelectedList == 'tasksListView') {
|
||||||
vm.selectedList = 1;
|
vm.selectedList = 1;
|
||||||
type = 'tasks';
|
type = 'tasks';
|
||||||
}
|
}
|
||||||
selectComponentType(type, { reload: true }); // fetch events/tasks lists
|
selectComponentType(type, { reload: true }); // fetch events/tasks lists
|
||||||
});
|
|
||||||
|
|
||||||
// Refresh current list when the list of calendars is modified
|
// Refresh current list when the list of calendars is modified
|
||||||
$rootScope.$on('calendars:list', function() {
|
$rootScope.$on('calendars:list', function() {
|
||||||
|
@ -58,6 +57,7 @@
|
||||||
sgHotkeys.deregisterHotkey(key);
|
sgHotkeys.deregisterHotkey(key);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function _registerHotkeys(keys) {
|
function _registerHotkeys(keys) {
|
||||||
|
|
|
@ -38,14 +38,13 @@
|
||||||
accept: _sortableAccept
|
accept: _sortableAccept
|
||||||
};
|
};
|
||||||
|
|
||||||
Preferences.ready().then(function() {
|
this.$onInit = function() {
|
||||||
vm.categories = _.map(Preferences.defaults.SOGoCalendarCategories, function(name) {
|
vm.categories = _.map(Preferences.defaults.SOGoCalendarCategories, function(name) {
|
||||||
return { id: name.asCSSIdentifier(),
|
return { id: name.asCSSIdentifier(),
|
||||||
name: name,
|
name: name,
|
||||||
color: Preferences.defaults.SOGoCalendarCategoriesColors[name]
|
color: Preferences.defaults.SOGoCalendarCategoriesColors[name]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Dispatch the event named 'calendars:list' when a calendar is activated or deactivated or
|
// Dispatch the event named 'calendars:list' when a calendar is activated or deactivated or
|
||||||
// when the color of a calendar is changed
|
// when the color of a calendar is changed
|
||||||
|
@ -79,6 +78,7 @@
|
||||||
},
|
},
|
||||||
true // compare for object equality
|
true // compare for object equality
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only allow to sort items within the same list.
|
* Only allow to sort items within the same list.
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
$refreshTimeout: null,
|
$refreshTimeout: null,
|
||||||
$ghost: {}
|
$ghost: {}
|
||||||
});
|
});
|
||||||
Preferences.ready().then(function() {
|
|
||||||
// Initialize filter parameters from user's settings
|
// Initialize filter parameters from user's settings
|
||||||
if (Preferences.settings.Calendar.EventsFilterState)
|
if (Preferences.settings.Calendar.EventsFilterState)
|
||||||
Component.$queryEvents.filterpopup = Preferences.settings.Calendar.EventsFilterState;
|
Component.$queryEvents.filterpopup = Preferences.settings.Calendar.EventsFilterState;
|
||||||
|
@ -73,7 +72,6 @@
|
||||||
if (Preferences.defaults.SOGoTimeFormat) {
|
if (Preferences.defaults.SOGoTimeFormat) {
|
||||||
Component.timeFormat = Preferences.defaults.SOGoTimeFormat;
|
Component.timeFormat = Preferences.defaults.SOGoTimeFormat;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return Component; // return constructor
|
return Component; // return constructor
|
||||||
}];
|
}];
|
||||||
|
@ -124,19 +122,15 @@
|
||||||
* current view.
|
* current view.
|
||||||
*/
|
*/
|
||||||
Component.$startRefreshTimeout = function(type) {
|
Component.$startRefreshTimeout = function(type) {
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
if (Component.$refreshTimeout)
|
if (Component.$refreshTimeout)
|
||||||
Component.$timeout.cancel(Component.$refreshTimeout);
|
Component.$timeout.cancel(Component.$refreshTimeout);
|
||||||
|
|
||||||
Component.$Preferences.ready().then(function() {
|
|
||||||
// Restart the refresh timer, if needed
|
// Restart the refresh timer, if needed
|
||||||
var refreshViewCheck = Component.$Preferences.defaults.SOGoRefreshViewCheck;
|
var refreshViewCheck = Component.$Preferences.defaults.SOGoRefreshViewCheck;
|
||||||
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
if (refreshViewCheck && refreshViewCheck != 'manually') {
|
||||||
var f = angular.bind(Component.$rootScope, Component.$rootScope.$emit, 'calendars:list');
|
var f = angular.bind(Component.$rootScope, Component.$rootScope.$emit, 'calendars:list');
|
||||||
Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,16 +160,14 @@
|
||||||
queryKey = '$query' + type.capitalize(),
|
queryKey = '$query' + type.capitalize(),
|
||||||
params = {
|
params = {
|
||||||
day: '' + year + (month < 10?'0':'') + month + (day < 10?'0':'') + day,
|
day: '' + year + (month < 10?'0':'') + month + (day < 10?'0':'') + day,
|
||||||
};
|
},
|
||||||
|
futureComponentData,
|
||||||
Component.$startRefreshTimeout(type);
|
|
||||||
|
|
||||||
return this.$Preferences.ready().then(function() {
|
|
||||||
var futureComponentData,
|
|
||||||
dirty = false,
|
dirty = false,
|
||||||
otherType;
|
otherType;
|
||||||
|
|
||||||
angular.extend(_this.$query, params);
|
Component.$startRefreshTimeout(type);
|
||||||
|
|
||||||
|
angular.extend(this.$query, params);
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
_.forEach(_.keys(options), function(key) {
|
_.forEach(_.keys(options), function(key) {
|
||||||
|
@ -192,8 +184,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform query with both common and type-specific parameters
|
// Perform query with both common and type-specific parameters
|
||||||
futureComponentData = _this.$$resource.fetch(null, type + 'list',
|
futureComponentData = this.$$resource.fetch(null, type + 'list',
|
||||||
angular.extend(_this[queryKey], _this.$query));
|
angular.extend(this[queryKey], this.$query));
|
||||||
|
|
||||||
// Invalidate cached results of other type if $query has changed
|
// Invalidate cached results of other type if $query has changed
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
|
@ -202,8 +194,7 @@
|
||||||
Component.$log.debug('force reload of ' + otherType);
|
Component.$log.debug('force reload of ' + otherType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this.$unwrapCollection(type, futureComponentData);
|
return this.$unwrapCollection(type, futureComponentData);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -256,12 +247,9 @@
|
||||||
* @returns a promise of a collection of objects describing the events blocks
|
* @returns a promise of a collection of objects describing the events blocks
|
||||||
*/
|
*/
|
||||||
Component.$eventsBlocksForView = function(view, date) {
|
Component.$eventsBlocksForView = function(view, date) {
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
return Component.$Preferences.ready().then(function(data) {
|
|
||||||
var firstDayOfWeek, viewAction, startDate, endDate, params;
|
var firstDayOfWeek, viewAction, startDate, endDate, params;
|
||||||
firstDayOfWeek = Component.$Preferences.defaults.SOGoFirstDayOfWeek;
|
|
||||||
|
|
||||||
|
firstDayOfWeek = Component.$Preferences.defaults.SOGoFirstDayOfWeek;
|
||||||
if (view == 'day') {
|
if (view == 'day') {
|
||||||
viewAction = 'dayView';
|
viewAction = 'dayView';
|
||||||
startDate = endDate = date;
|
startDate = endDate = date;
|
||||||
|
@ -288,8 +276,7 @@
|
||||||
endDate.addDays(-1);
|
endDate.addDays(-1);
|
||||||
endDate = endDate.endOfWeek(firstDayOfWeek);
|
endDate = endDate.endOfWeek(firstDayOfWeek);
|
||||||
}
|
}
|
||||||
return _this.$eventsBlocks(viewAction, startDate, endDate);
|
return this.$eventsBlocks(viewAction, startDate, endDate);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,12 +520,10 @@
|
||||||
|
|
||||||
if (this.c_category) {
|
if (this.c_category) {
|
||||||
// c_category is only defined in list mode (when calling $filter)
|
// c_category is only defined in list mode (when calling $filter)
|
||||||
Component.$Preferences.ready().then(function() {
|
|
||||||
// Filter out categories for which there's no associated color
|
// Filter out categories for which there's no associated color
|
||||||
_this.categories = _.invokeMap(_.filter(_this.c_category, function(name) {
|
this.categories = _.invokeMap(_.filter(this.c_category, function(name) {
|
||||||
return Component.$Preferences.defaults.SOGoCalendarCategoriesColors[name];
|
return Component.$Preferences.defaults.SOGoCalendarCategoriesColors[name];
|
||||||
}), 'asCSSIdentifier');
|
}), 'asCSSIdentifier');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse recurrence rule definition and initialize default values
|
// Parse recurrence rule definition and initialize default values
|
||||||
|
@ -591,24 +576,22 @@
|
||||||
|
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
// Set default values
|
// Set default values
|
||||||
Component.$Preferences.ready().then(function() {
|
var type = (this.type == 'appointment')? 'Events' : 'Tasks';
|
||||||
var type = (_this.type == 'appointment')? 'Events' : 'Tasks';
|
|
||||||
|
|
||||||
// Set default classification
|
// Set default classification
|
||||||
_this.classification = Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();
|
this.classification = Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();
|
||||||
|
|
||||||
// Set default alarm
|
// Set default alarm
|
||||||
var units = { M: 'MINUTES', H: 'HOURS', D: 'DAYS', W: 'WEEKS' };
|
var units = { M: 'MINUTES', H: 'HOURS', D: 'DAYS', W: 'WEEKS' };
|
||||||
var match = /-PT?([0-9]+)([MHDW])/.exec(Component.$Preferences.defaults.SOGoCalendarDefaultReminder);
|
var match = /-PT?([0-9]+)([MHDW])/.exec(Component.$Preferences.defaults.SOGoCalendarDefaultReminder);
|
||||||
if (match) {
|
if (match) {
|
||||||
_this.$hasAlarm = true;
|
this.$hasAlarm = true;
|
||||||
_this.alarm.quantity = parseInt(match[1]);
|
this.alarm.quantity = parseInt(match[1]);
|
||||||
_this.alarm.unit = units[match[2]];
|
this.alarm.unit = units[match[2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set notitifications
|
// Set notitifications
|
||||||
_this.sendAppointmentNotifications = Component.$Preferences.defaults.SOGoAppointmentSendEMailNotifications;
|
this.sendAppointmentNotifications = Component.$Preferences.defaults.SOGoAppointmentSendEMailNotifications;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else if (angular.isUndefined(data.$hasAlarm)) {
|
else if (angular.isUndefined(data.$hasAlarm)) {
|
||||||
this.$hasAlarm = angular.isDefined(data.alarm);
|
this.$hasAlarm = angular.isDefined(data.alarm);
|
||||||
|
|
|
@ -116,7 +116,6 @@
|
||||||
});
|
});
|
||||||
if ($location.url().length === 0) {
|
if ($location.url().length === 0) {
|
||||||
// Restore user's last view
|
// Restore user's last view
|
||||||
Preferences.ready().then(function() {
|
|
||||||
var url = '/calendar/',
|
var url = '/calendar/',
|
||||||
view = /(.+)view/.exec(Preferences.settings.Calendar.View);
|
view = /(.+)view/.exec(Preferences.settings.Calendar.View);
|
||||||
if (view)
|
if (view)
|
||||||
|
@ -135,7 +134,6 @@
|
||||||
}
|
}
|
||||||
url += '/' + now.getDayString();
|
url += '/' + now.getDayString();
|
||||||
$location.replace().url(url);
|
$location.replace().url(url);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,8 @@
|
||||||
function initView() {
|
function initView() {
|
||||||
view = new sgScrollView(element, type);
|
view = new sgScrollView(element, type);
|
||||||
|
|
||||||
if (type != 'monthly')
|
if (type != 'monthly') {
|
||||||
// Scroll to the day start hour defined in the user's defaults
|
// Scroll to the day start hour defined in the user's defaults
|
||||||
Preferences.ready().then(function() {
|
|
||||||
var time, hourCell, quartersOffset;
|
var time, hourCell, quartersOffset;
|
||||||
if (Preferences.defaults.SOGoDayStartTime) {
|
if (Preferences.defaults.SOGoDayStartTime) {
|
||||||
time = Preferences.defaults.SOGoDayStartTime.split(':');
|
time = Preferences.defaults.SOGoDayStartTime.split(':');
|
||||||
|
@ -58,7 +57,7 @@
|
||||||
quartersOffset = parseInt(time[1]) * view.quarterHeight;
|
quartersOffset = parseInt(time[1]) * view.quarterHeight;
|
||||||
view.element.scrollTop = hourCell.offsetTop + quartersOffset;
|
view.element.scrollTop = hourCell.offsetTop + quartersOffset;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Expose quarter height to the controller
|
// Expose quarter height to the controller
|
||||||
// See sgNowLine directive
|
// See sgNowLine directive
|
||||||
|
|
Loading…
Reference in a new issue