From a25a01495fd6b237e2241e3d4292b3017998df17 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 20 Apr 2015 17:28:43 -0400 Subject: [PATCH] Added chips for prevent invitations --- UI/Templates/PreferencesUI/UIxPreferences.wox | 33 +++++++++---------- UI/WebServerResources/js/Common/user-model.js | 10 ++++-- .../js/Preferences/preferences-model.js | 22 +++++++++++-- UI/WebServerResources/js/PreferencesUI.js | 19 ++++++----- 4 files changed, 53 insertions(+), 31 deletions(-) diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index a726d0514..bb890c838 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -9,7 +9,7 @@ xmlns:label="OGo:label" className="UIxPageFrame" title="title" - const:jsFiles="Common/resource.js,Common/SOGoAuthentication.js,Mailer/mailbox-model.js,Mailer/message-model.js,Preferences/preferences-model.js"> + const:jsFiles="Common/resource.js,Common/SOGoAuthentication.js,Mailer/mailbox-model.js,Mailer/message-model.js,Preferences/preferences-model.js,Common/user-model.js">
@@ -438,24 +438,21 @@ - - - - - - - - -
- -
-
- -
-
+
+ + +
- +
diff --git a/UI/WebServerResources/js/Common/user-model.js b/UI/WebServerResources/js/Common/user-model.js index 9cb41dc2f..e0248ef29 100644 --- a/UI/WebServerResources/js/Common/user-model.js +++ b/UI/WebServerResources/js/Common/user-model.js @@ -7,8 +7,14 @@ * @param {object} [userData] - some default values for the user */ function User(userData) { - if (userData) + if (userData) { angular.extend(this, userData); + + if (!this.shortFormat) + this.shortFormat = this.$shortFormat(); + + this.image = "http://www.gravatar.com/avatar/asdasdasdasd?d=identicon"; + } } /** @@ -60,7 +66,7 @@ var email = this.c_email; var no_email = options && options.email === false; if (!no_email && email && fullname != email) { - fullname += ' (' + email + ')'; + fullname += ' <' + email + '>'; } return fullname; }; diff --git a/UI/WebServerResources/js/Preferences/preferences-model.js b/UI/WebServerResources/js/Preferences/preferences-model.js index d4efdbb35..bfc8be34c 100644 --- a/UI/WebServerResources/js/Preferences/preferences-model.js +++ b/UI/WebServerResources/js/Preferences/preferences-model.js @@ -36,6 +36,14 @@ }); Preferences.$$resource.fetch("jsonSettings").then(function(data) { Preferences.$timeout(function() { + + + // We convert our PreventInvitationsWhitelist hash into a array of user + if (data.Calendar && data.Calendar.PreventInvitationsWhitelist) + data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) { + return new Preferences.$User({uid: key, shortFormat: value}); + }); + angular.extend(_this.settings, data); }); }); @@ -46,14 +54,15 @@ * @desc The factory we'll use to register with Angular * @returns the Preferences constructor */ - Preferences.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'sgResource', 'sgMailbox', function($q, $timeout, $log, Settings, Resource, Mailbox) { + Preferences.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'sgResource', 'sgMailbox', 'sgUser', function($q, $timeout, $log, Settings, Resource, Mailbox, User) { angular.extend(Preferences, { $q: $q, $timeout: $timeout, $log: $log, $$resource: new Resource(Settings.activeUser.folderURL, Settings.activeUser), activeUser: Settings.activeUser, - $Mailbox: Mailbox + $Mailbox: Mailbox, + $User: User }); return Preferences; // return constructor @@ -111,6 +120,15 @@ if (preferences.defaults.Vacation && preferences.defaults.Vacation.autoReplyEmailAddresses) preferences.defaults.Vacation.autoReplyEmailAddresses = preferences.defaults.Vacation.autoReplyEmailAddresses.split(","); + + if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) { + var h = {}; + _.each(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) { + h[user.uid] = user.shortFormat; + + preferences.settings.Calendar.PreventInvitationsWhitelist = h; + }); + } return preferences; }; diff --git a/UI/WebServerResources/js/PreferencesUI.js b/UI/WebServerResources/js/PreferencesUI.js index 1ff7cf9ac..7ca26b0a2 100644 --- a/UI/WebServerResources/js/PreferencesUI.js +++ b/UI/WebServerResources/js/PreferencesUI.js @@ -5,9 +5,10 @@ 'use strict'; angular.module('SOGo.Common', []); + angular.module('SOGo.ContactsUI', []); angular.module('SOGo.MailerUI', []); - angular.module('SOGo.PreferencesUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.UIDesktop', 'SOGo.UI', 'SOGo.Authentication']) + angular.module('SOGo.PreferencesUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.UIDesktop', 'SOGo.UI', 'SOGo.ContactsUI', 'SOGo.Authentication']) .constant('sgSettings', { baseURL: ApplicationBaseURL, @@ -72,10 +73,10 @@ $urlRouterProvider.otherwise('/general'); }]) - .controller('PreferencesCtrl', ['$scope', '$timeout', '$mdDialog', 'sgPreferences', 'statePreferences', 'Authentication', function($scope, $timeout, $mdDialog, Preferences, statePreferences, Authentication) { + .controller('PreferencesCtrl', ['$scope', '$timeout', '$q', '$mdDialog', 'sgPreferences', 'sgUser', 'statePreferences', 'Authentication', function($scope, $timeout, $q, $mdDialog, Preferences, User, statePreferences, Authentication) { $scope.preferences = statePreferences; - + $scope.addCalendarCategory = function() { var color = {"": "#000"}; $scope.preferences.defaults.SOGoCalendarCategories.push(""); @@ -169,12 +170,12 @@ $scope.preferences.defaults.SOGoSieveFilters.splice(index, 1); }; - $scope.addPreventInvitationsWhitelist = function() { - $scope.preferences.settings.Calendar.PreventInvitationsWhitelist.push(""); - }; - - $scope.removePreventInvitationsWhitelist = function() { - $scope.preferences.settings.Calendar.PreventInvitationsWhitelist.pop(); + $scope.userFilter = function($query) { + var deferred = $q.defer(); + User.$filter($query).then(function(results) { + deferred.resolve(results) + }); + return deferred.promise; }; $scope.save = function() {