(js) Fix handling of prevent invitations whitelist

pull/186/head
Francis Lachapelle 2015-12-07 11:05:01 -05:00
parent a4bc4fc652
commit ecf297208a
4 changed files with 40 additions and 28 deletions

View File

@ -391,34 +391,36 @@
<md-tab id="calendarInvitationsTab"
aria-controls="calendarInvitationsTab-content"
label:label="Invitations">
<div layout="column" layout-align="space-around start"
layout-padding="layout-padding"
aria-labelledby="calendarInvitationsTab"
id="calendarInvitationsTab-content">
<md-content layout="row" layout-align="space-around start"
class="md-padding"
aria-labelledby="calendarInvitationsTab"
id="calendarInvitationsTab-content">
<md-checkbox
ng-model="app.preferences.settings.Calendar.PreventInvitations"
ng-true-value="1"
ng-false-value="0">
<var:string label:value="Prevent from being invited to appointments"/>
</md-checkbox>
<div ng-show="app.preferences.settings.Calendar.PreventInvitations == 1">
<label>
<var:string label:value="White list for appointment invitations"/>
</label>
<md-contact-chips
ng-model="app.preferences.settings.Calendar.PreventInvitationsWhitelist"
md-contacts="app.userFilter($query, app.preferences.settings.Calendar.PreventInvitationsWhitelist)"
md-contact-name="cn"
md-contact-image="$$image"
md-contact-email="c_email"
md-require-match="md-require-match"
filter-selected="false"
label:placeholder="Add"><!-- users --></md-contact-chips>
<div layout="column" flex="100">
<md-checkbox
ng-model="app.preferences.settings.Calendar.PreventInvitations"
ng-true-value="1"
ng-false-value="0">
<var:string label:value="Prevent from being invited to appointments"/>
</md-checkbox>
<div flex-offset="5"
ng-show="app.preferences.settings.Calendar.PreventInvitations == 1">
<label>
<var:string label:value="White list for appointment invitations"/>
</label>
<md-contact-chips
flex="100"
ng-model="app.preferences.settings.Calendar.PreventInvitationsWhitelist"
md-contacts="app.userFilter($query, app.preferences.settings.Calendar.PreventInvitationsWhitelist)"
md-contact-name="cn"
md-contact-image="$$image"
md-contact-email="c_email"
md-require-match="md-require-match"
filter-selected="false"
label:placeholder="Add"><!-- users --></md-contact-chips>
</div>
</div>
</div>
</md-content>
</md-tab>
</md-tabs>

View File

@ -110,7 +110,7 @@
if (!this.$$shortFormat)
this.$$shortFormat = this.$shortFormat();
if (!this.$$image)
this.$$image = this.image || User.$gravatar(this.c_email);
this.$$image = this.image || User.$gravatar(this.c_email, 32, User.$alternateAvatar);
// An empty attribute to trick md-autocomplete when adding users from the ACLs editor
this.empty = ' ';

View File

@ -52,11 +52,15 @@
this.settingsPromise = Preferences.$$resource.fetch("jsonSettings").then(function(data) {
// We convert our PreventInvitationsWhitelist hash into a array of user
if (data.Calendar && data.Calendar.PreventInvitationsWhitelist)
if (data.Calendar) {
if (data.Calendar.PreventInvitationsWhitelist)
data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) {
var match = /^(.+)\s<(\S+)>$/.exec(value);
return new Preferences.$User({uid: key, cn: match[1], c_email: match[2]});
});
else
data.Calendar.PreventInvitationsWhitelist = [];
}
angular.extend(_this.settings, data);

View File

@ -49,6 +49,12 @@
}
});
// Set alternate avatar in User service
statePreferences.ready().then(function() {
if (statePreferences.defaults.SOGoAlternateAvatar)
User.$alternateAvatar = statePreferences.defaults.SOGoAlternateAvatar;
});
function go(module) {
$state.go('preferences.' + module);
}