Added chips for prevent invitations

This commit is contained in:
Ludovic Marcotte
2015-04-20 17:28:43 -04:00
committed by Francis Lachapelle
parent 781d55cc37
commit a25a01495f
4 changed files with 53 additions and 31 deletions
+15 -18
View File
@@ -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">
<main class="view md-layout-fill" ui-view="preferences" layout="row"
ng-controller="navController"><!-- preferences --> </main>
@@ -438,24 +438,21 @@
<var:string label:value="Prevent from being invited to appointments"/>
</md-checkbox>
<md-list>
<md-list-item ng-repeat="(key, value) in
preferences.settings.Calendar.PreventInvitationsWhitelist">
<md-input-container>
<input type="text" ng-model="key"/>
</md-input-container>
</md-list-item>
</md-list>
<div class="bottomToolbar">
<md-button ng-click="addPreventInvitationsWhitelist()" type="button">
<div class="md-icon-add"><!-- create --></div>
</md-button>
<md-button ng-click="removePreventInvitationsWhitelist()" type="button">
<div class="md-icon-remove"><!-- delete --></div>
</md-button>
<div class="pseudo-input-container">
<label class="pseudo-input-label">
<var:string label:value="White list for appointment invitations:"/>
</label>
<md-contact-chips
ng-model="preferences.settings.Calendar.PreventInvitationsWhitelist"
md-contacts="userFilter($query)"
md-contact-name="shortFormat"
md-contact-image="image"
md-contact-email="c_email"
md-require-match="md-require-match"
placeholder="Add">
</md-contact-chips>
</div>
</div>
</md-tab>
@@ -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;
};
@@ -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;
};
+10 -9
View File
@@ -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() {