(fix) Show/save whitelisted users for invitations

This commit is contained in:
Francis Lachapelle 2015-05-19 11:32:12 -04:00
parent 18cf3d5f9c
commit 9db7d3b85d

View file

@ -40,12 +40,11 @@
Preferences.$$resource.fetch("jsonSettings").then(function(data) { Preferences.$$resource.fetch("jsonSettings").then(function(data) {
Preferences.$timeout(function() { Preferences.$timeout(function() {
// We convert our PreventInvitationsWhitelist hash into a array of user // We convert our PreventInvitationsWhitelist hash into a array of user
if (data.Calendar && data.Calendar.PreventInvitationsWhitelist) if (data.Calendar && data.Calendar.PreventInvitationsWhitelist)
data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) { data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) {
return new Preferences.$User({uid: key, shortFormat: value}); var match = /^(.+)\s<(\S+)>$/.exec(value);
return new Preferences.$User({uid: key, cn: match[1], c_email: match[2]});
}); });
else else
data.Calendar.PreventInvitationsWhitelist = []; data.Calendar.PreventInvitationsWhitelist = [];
@ -85,11 +84,8 @@
*/ */
Preferences.prototype.$save = function() { Preferences.prototype.$save = function() {
var _this = this; var _this = this;
console.debug("save in model...");
return Preferences.$$resource.save("Preferences", return Preferences.$$resource.save("Preferences", this.$omit(true))
this.$omit(),
undefined)
.then(function(data) { .then(function(data) {
// Make a copy of the data for an eventual reset // Make a copy of the data for an eventual reset
//_this.$shadowData = _this.$omit(true); //_this.$shadowData = _this.$omit(true);
@ -133,10 +129,9 @@
if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) { if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) {
var h = {}; var h = {};
_.each(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) { _.each(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) {
h[user.uid] = user.$$shortFormat; h[user.uid] = user.$shortFormat();
preferences.settings.Calendar.PreventInvitationsWhitelist = h;
}); });
preferences.settings.Calendar.PreventInvitationsWhitelist = h;
} }
return preferences; return preferences;