(fix #147) can now add multiple mail labels

This commit is contained in:
Ludovic Marcotte
2015-12-10 15:12:12 -05:00
parent 96e93c0eeb
commit 153c2c33e5
3 changed files with 17 additions and 2 deletions

View File

@@ -353,3 +353,11 @@ function contrast(hex) {
return 'white';
}
}
function guid() {
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
return (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase();
}

View File

@@ -166,8 +166,13 @@
// We swap _$key -> $key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
labels = _.object(_.map(preferences.defaults.SOGoMailLabelsColors, function(value, key) {
if (key.charAt(0) == '_' && key.charAt(1) == '$')
if (key.charAt(0) == '_' && key.charAt(1) == '$') {
// New key, let's take the value and flatten it
if (key.length > 2 && key.charAt(2) == '$') {
return [value[0].toLowerCase().replace(/[ \(\)\/\{%\*<>\\\"]/g, "_"), value];
}
return [key.substring(1), value];
}
return [key, value];
}));

View File

@@ -148,7 +148,9 @@
}
function addMailLabel() {
vm.preferences.defaults.SOGoMailLabelsColors.new_label = ["New label", "#aaa"];
// See $omit() in the Preferences services for real key generation
var key = '_$$' + guid();
vm.preferences.defaults.SOGoMailLabelsColors[key] = ["New label", "#aaa"];
}
function removeMailLabel(key) {