(js) Various improvements and fixes
This commit is contained in:
parent
333d279246
commit
5a5b4cc829
|
@ -7,8 +7,8 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
AdministrationController.$inject = ['$state', '$mdDialog', '$mdToast', 'Dialog', 'encodeUriFilter', 'User', 'Administration'];
|
AdministrationController.$inject = ['$state', '$mdToast', 'Dialog', 'encodeUriFilter', 'User', 'Administration'];
|
||||||
function AdministrationController($state, $mdDialog, $mdToast, Dialog, encodeUriFilter, User, Administration) {
|
function AdministrationController($state, $mdToast, Dialog, encodeUriFilter, User, Administration) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.administration = Administration;
|
vm.administration = Administration;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
Dialog.alert = function(title, content) {
|
Dialog.alert = function(title, content) {
|
||||||
var alert = this.$modal.alert()
|
var alert = this.$modal.alert()
|
||||||
.title(title)
|
.title(title)
|
||||||
.content(content)
|
.textContent(content)
|
||||||
.ok(l('OK'));
|
.ok(l('OK'));
|
||||||
this.$modal.show(alert);
|
this.$modal.show(alert);
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
Dialog.confirm = function(title, content, options) {
|
Dialog.confirm = function(title, content, options) {
|
||||||
var confirm = this.$modal.confirm()
|
var confirm = this.$modal.confirm()
|
||||||
.title(title)
|
.title(title)
|
||||||
.content(content)
|
.textContent(content)
|
||||||
.ok((options && options.ok)? options.ok : l('OK'))
|
.ok((options && options.ok)? options.ok : l('OK'))
|
||||||
.cancel((options && options.cancel)? options.cancel : l('Cancel'));
|
.cancel((options && options.cancel)? options.cancel : l('Cancel'));
|
||||||
return this.$modal.show(confirm);
|
return this.$modal.show(confirm);
|
||||||
|
@ -67,14 +67,14 @@
|
||||||
' ng-model="name" required="required"/>',
|
' ng-model="name" required="required"/>',
|
||||||
' </md-input-container>',
|
' </md-input-container>',
|
||||||
' </md-dialog-content>',
|
' </md-dialog-content>',
|
||||||
' <div class="md-actions">',
|
' <md-dialog-actions>',
|
||||||
' <md-button ng-click="cancel()">',
|
' <md-button ng-click="cancel()">',
|
||||||
' ' + l('Cancel'),
|
' ' + l('Cancel'),
|
||||||
' </md-button>',
|
' </md-button>',
|
||||||
' <md-button class="md-primary" ng-click="ok()" ng-disabled="!name.length">',
|
' <md-button class="md-primary" ng-click="ok()" ng-disabled="!name.length">',
|
||||||
' ' + l('OK'),
|
' ' + l('OK'),
|
||||||
' </md-button>',
|
' </md-button>',
|
||||||
' </div>',
|
' </md-dialog-actions>',
|
||||||
'</md-dialog>'
|
'</md-dialog>'
|
||||||
].join(''),
|
].join(''),
|
||||||
controller: PromptDialogController
|
controller: PromptDialogController
|
||||||
|
|
|
@ -506,7 +506,7 @@
|
||||||
AddressBook.prototype.$unwrap = function(futureAddressBookData) {
|
AddressBook.prototype.$unwrap = function(futureAddressBookData) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
// Expose and sesolve the promise
|
// Expose and resolve the promise
|
||||||
this.$futureAddressBookData = futureAddressBookData.then(function(data) {
|
this.$futureAddressBookData = futureAddressBookData.then(function(data) {
|
||||||
return AddressBook.$timeout(function() {
|
return AddressBook.$timeout(function() {
|
||||||
// Extend AddressBook instance from data of addressbooks list.
|
// Extend AddressBook instance from data of addressbooks list.
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
AddressBookController.$inject = ['$scope', '$q', '$state', '$timeout', '$mdDialog', 'sgFocus', 'Account', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook'];
|
AddressBookController.$inject = ['$scope', '$q', '$state', '$timeout', '$mdDialog', 'Account', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook'];
|
||||||
function AddressBookController($scope, $q, $state, $timeout, $mdDialog, focus, Account, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {
|
function AddressBookController($scope, $q, $state, $timeout, $mdDialog, Account, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
AddressBook.selectedFolder = stateAddressbook;
|
AddressBook.selectedFolder = stateAddressbook;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
MailboxController.$inject = ['$state', '$timeout', '$mdDialog', 'stateAccounts', 'stateAccount', 'stateMailbox', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox'];
|
MailboxController.$inject = ['$state', '$timeout', '$mdDialog', 'stateAccounts', 'stateAccount', 'stateMailbox', 'encodeUriFilter', 'Dialog', 'Account', 'Mailbox'];
|
||||||
function MailboxController($state, $timeout, $mdDialog, stateAccounts, stateAccount, stateMailbox, encodeUriFilter, focus, Dialog, Account, Mailbox) {
|
function MailboxController($state, $timeout, $mdDialog, stateAccounts, stateAccount, stateMailbox, encodeUriFilter, Dialog, Account, Mailbox) {
|
||||||
var vm = this, messageDialog = null;
|
var vm = this, messageDialog = null;
|
||||||
|
|
||||||
Mailbox.selectedFolder = stateMailbox;
|
Mailbox.selectedFolder = stateMailbox;
|
||||||
|
@ -93,9 +93,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAll() {
|
function selectAll() {
|
||||||
_.each(vm.selectedFolder.$messages, function(message) {
|
var i = 0, length = vm.selectedFolder.$messages.length;
|
||||||
message.selected = true;
|
for (; i < length; i++)
|
||||||
});
|
vm.selectedFolder.$messages[i].selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function markSelectedMessagesAsFlagged() {
|
function markSelectedMessagesAsFlagged() {
|
||||||
|
|
|
@ -128,7 +128,11 @@
|
||||||
* @return an object literal copy of the Preferences instance
|
* @return an object literal copy of the Preferences instance
|
||||||
*/
|
*/
|
||||||
Preferences.prototype.$omit = function(deep) {
|
Preferences.prototype.$omit = function(deep) {
|
||||||
var preferences = {};
|
var preferences, labels, whitelist;
|
||||||
|
|
||||||
|
preferences = {};
|
||||||
|
whitelist = {};
|
||||||
|
|
||||||
angular.forEach(this, function(value, key) {
|
angular.forEach(this, function(value, key) {
|
||||||
if (key != 'constructor' && key[0] != '$') {
|
if (key != 'constructor' && key[0] != '$') {
|
||||||
if (deep)
|
if (deep)
|
||||||
|
@ -139,7 +143,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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 = _.object(_.map(preferences.defaults.SOGoMailLabelsColors, function(value, key) {
|
labels = _.object(_.map(preferences.defaults.SOGoMailLabelsColors, function(value, key) {
|
||||||
if (key.charAt(0) == '_' && key.charAt(1) == '$')
|
if (key.charAt(0) == '_' && key.charAt(1) == '$')
|
||||||
return [key.substring(1), value];
|
return [key.substring(1), value];
|
||||||
return [key, value];
|
return [key, value];
|
||||||
|
@ -163,11 +167,10 @@
|
||||||
preferences.defaults.Forward.forwardAddress = preferences.defaults.Forward.forwardAddress.split(",");
|
preferences.defaults.Forward.forwardAddress = preferences.defaults.Forward.forwardAddress.split(",");
|
||||||
|
|
||||||
if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) {
|
if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) {
|
||||||
var h = {};
|
|
||||||
_.each(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) {
|
_.each(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) {
|
||||||
h[user.uid] = user.$shortFormat();
|
whitelist[user.uid] = user.$shortFormat();
|
||||||
});
|
});
|
||||||
preferences.settings.Calendar.PreventInvitationsWhitelist = h;
|
preferences.settings.Calendar.PreventInvitationsWhitelist = whitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
return preferences;
|
return preferences;
|
||||||
|
|
|
@ -200,7 +200,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
var sendForm = true;
|
var i, sendForm, addresses, defaultAddresses, domains, domain;
|
||||||
|
|
||||||
|
sendForm = true;
|
||||||
|
domains = [];
|
||||||
|
|
||||||
// We do some sanity checks
|
// We do some sanity checks
|
||||||
if (window.forwardConstraints > 0 &&
|
if (window.forwardConstraints > 0 &&
|
||||||
|
@ -208,11 +211,10 @@
|
||||||
vm.preferences.defaults.Forward.enabled &&
|
vm.preferences.defaults.Forward.enabled &&
|
||||||
angular.isDefined(vm.preferences.defaults.Forward.forwardAddress)) {
|
angular.isDefined(vm.preferences.defaults.Forward.forwardAddress)) {
|
||||||
|
|
||||||
var addresses = vm.preferences.defaults.Forward.forwardAddress.split(",");
|
addresses = vm.preferences.defaults.Forward.forwardAddress.split(",");
|
||||||
|
|
||||||
// We first extract the list of 'known domains' to SOGo
|
// We first extract the list of 'known domains' to SOGo
|
||||||
var defaultAddresses = window.defaultEmailAddresses.split(/, */);
|
defaultAddresses = window.defaultEmailAddresses.split(/, */);
|
||||||
var domains = [];
|
|
||||||
|
|
||||||
_.forEach(defaultAddresses, function(adr) {
|
_.forEach(defaultAddresses, function(adr) {
|
||||||
var domain = adr.split("@")[1];
|
var domain = adr.split("@")[1];
|
||||||
|
@ -222,8 +224,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// We check if we're allowed or not to forward based on the domain defaults
|
// We check if we're allowed or not to forward based on the domain defaults
|
||||||
for (var i = 0; i < addresses.length && sendForm; i++) {
|
for (i = 0; i < addresses.length && sendForm; i++) {
|
||||||
var domain = addresses[i].split("@")[1].toLowerCase();
|
domain = addresses[i].split("@")[1].toLowerCase();
|
||||||
if (domains.indexOf(domain) < 0 && window.forwardConstraints == 1) {
|
if (domains.indexOf(domain) < 0 && window.forwardConstraints == 1) {
|
||||||
Dialog.alert(l('Error'), l("You are not allowed to forward your messages to an external email address."));
|
Dialog.alert(l('Error'), l("You are not allowed to forward your messages to an external email address."));
|
||||||
sendForm = false;
|
sendForm = false;
|
||||||
|
@ -236,14 +238,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendForm)
|
if (sendForm)
|
||||||
vm.preferences.$save().then(function(data) {
|
return vm.preferences.$save().then(function(data) {
|
||||||
$mdToast.show(
|
$mdToast.show({
|
||||||
$mdToast.simple()
|
controller: 'savePreferencesToastCtrl',
|
||||||
.content(l('Preferences saved'))
|
template: [
|
||||||
.position('top right')
|
'<md-toast>',
|
||||||
.hideDelay(3000)
|
' <span flex>' + l('Preferences saved') + '</span>',
|
||||||
);
|
' <md-button class="md-icon-button md-primary" ng-click="closeToast()">',
|
||||||
|
' <md-icon>close</md-icon>',
|
||||||
|
' </md-button>',
|
||||||
|
'</md-toast>'
|
||||||
|
].join(''),
|
||||||
|
hideDelay: 2000,
|
||||||
|
position: 'top right'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return $q.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
function canChangePassword() {
|
function canChangePassword() {
|
||||||
|
@ -260,7 +271,7 @@
|
||||||
var alert = $mdDialog.alert({
|
var alert = $mdDialog.alert({
|
||||||
title: l('Password'),
|
title: l('Password'),
|
||||||
content: l('The password was changed successfully.'),
|
content: l('The password was changed successfully.'),
|
||||||
ok: 'OK'
|
ok: l('OK')
|
||||||
});
|
});
|
||||||
$mdDialog.show( alert )
|
$mdDialog.show( alert )
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
|
@ -270,7 +281,7 @@
|
||||||
var alert = $mdDialog.alert({
|
var alert = $mdDialog.alert({
|
||||||
title: l('Password'),
|
title: l('Password'),
|
||||||
content: msg,
|
content: msg,
|
||||||
ok: 'OK'
|
ok: l('OK')
|
||||||
});
|
});
|
||||||
$mdDialog.show( alert )
|
$mdDialog.show( alert )
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
|
@ -286,8 +297,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
savePreferencesToastCtrl.$inject = ['$scope', '$mdToast'];
|
||||||
|
function savePreferencesToastCtrl($scope, $mdToast) {
|
||||||
|
$scope.closeToast = function() {
|
||||||
|
$mdToast.hide();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.module('SOGo.PreferencesUI')
|
.module('SOGo.PreferencesUI')
|
||||||
|
.controller('savePreferencesToastCtrl', savePreferencesToastCtrl)
|
||||||
.controller('PreferencesController', PreferencesController);
|
.controller('PreferencesController', PreferencesController);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue