2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* JavaScript for SOGoPreferences */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
2015-10-08 22:42:24 +02:00
|
|
|
FiltersDialogController.$inject = ['$scope', '$window', '$mdDialog', 'filter', 'mailboxes', 'labels'];
|
|
|
|
function FiltersDialogController($scope, $window, $mdDialog, filter, mailboxes, labels) {
|
2016-02-09 20:15:23 +01:00
|
|
|
var vm = this,
|
|
|
|
sieveCapabilities = $window.sieveCapabilities,
|
|
|
|
forwardEnabled = $window.forwardEnabled,
|
|
|
|
vacationEnabled = $window.vacationEnabled;
|
2015-10-05 16:45:30 +02:00
|
|
|
|
|
|
|
vm.filter = filter;
|
|
|
|
vm.mailboxes = mailboxes;
|
|
|
|
vm.labels = labels;
|
|
|
|
vm.cancel = cancel;
|
2016-06-08 21:21:36 +02:00
|
|
|
vm.hasRulesAndActions = hasRulesAndActions;
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.save = save;
|
|
|
|
vm.addMailFilterRule = addMailFilterRule;
|
|
|
|
vm.removeMailFilterRule = removeMailFilterRule;
|
|
|
|
vm.addMailFilterAction = addMailFilterAction;
|
|
|
|
vm.removeMailFilterAction = removeMailFilterAction;
|
|
|
|
|
|
|
|
vm.fieldLabels = {
|
2015-05-06 04:06:13 +02:00
|
|
|
"subject": l("Subject"),
|
|
|
|
"from": l("From"),
|
|
|
|
"to": l("To"),
|
|
|
|
"cc": l("Cc"),
|
|
|
|
"to_or_cc": l("To or Cc"),
|
|
|
|
"size": l("Size (Kb)"),
|
2015-08-19 14:47:33 +02:00
|
|
|
"header": l("Header")
|
2015-05-06 04:06:13 +02:00
|
|
|
};
|
|
|
|
|
2015-08-19 14:47:33 +02:00
|
|
|
if (sieveCapabilities.indexOf("body") > -1)
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.fieldLabels.body = l("Body");
|
2015-08-19 14:47:33 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.methodLabels = {
|
2015-05-06 04:06:13 +02:00
|
|
|
"discard": l("Discard the message"),
|
|
|
|
"keep": l("Keep the message"),
|
|
|
|
"stop": l("Stop processing filter rules")
|
|
|
|
};
|
|
|
|
|
2016-02-09 20:15:23 +01:00
|
|
|
if (forwardEnabled)
|
|
|
|
vm.methodLabels.redirect = l("Forward the message to");
|
|
|
|
|
2016-06-23 20:35:48 +02:00
|
|
|
//if (vacationEnabled)
|
|
|
|
// vm.methodLabels.vacation = l("Send a vacation message");
|
2016-02-09 20:15:23 +01:00
|
|
|
|
2015-08-19 14:47:33 +02:00
|
|
|
if (sieveCapabilities.indexOf("reject") > -1)
|
2015-12-11 21:11:53 +01:00
|
|
|
vm.methodLabels.reject = l("Send a reject message");
|
2015-08-19 14:47:33 +02:00
|
|
|
|
|
|
|
if (sieveCapabilities.indexOf("fileinto") > -1)
|
2015-12-11 21:11:53 +01:00
|
|
|
vm.methodLabels.fileinto = l("File the message in");
|
2015-08-19 14:47:33 +02:00
|
|
|
|
|
|
|
if (sieveCapabilities.indexOf("imapflags") > -1 || sieveCapabilities.indexOf("imap4flags") > -1)
|
2015-12-11 21:11:53 +01:00
|
|
|
vm.methodLabels.addflag = l("Flag the message with");
|
2015-08-19 14:47:33 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.numberOperatorLabels = {
|
2015-05-06 04:06:13 +02:00
|
|
|
"under": l("is under"),
|
|
|
|
"over": l("is over")
|
|
|
|
};
|
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.textOperatorLabels = {
|
2015-05-06 04:06:13 +02:00
|
|
|
"is": l("is"),
|
|
|
|
"is_not": l("is not"),
|
|
|
|
"contains": l("contains"),
|
|
|
|
"contains_not": l("does not contain"),
|
|
|
|
"matches": l("matches"),
|
2015-08-19 14:47:33 +02:00
|
|
|
"matches_not": l("does not match")
|
2015-05-06 04:06:13 +02:00
|
|
|
};
|
|
|
|
|
2015-08-19 14:47:33 +02:00
|
|
|
if (sieveCapabilities.indexOf("regex") > -1) {
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.textOperatorLabels.regex = l("matches regex");
|
|
|
|
vm.textOperatorLabels.regex_not = l("does not match regex");
|
2015-08-19 14:47:33 +02:00
|
|
|
}
|
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.flagLabels = {
|
2015-05-06 04:06:13 +02:00
|
|
|
"seen": l("Seen"),
|
|
|
|
"deleted": l("Deleted"),
|
|
|
|
"answered": l("Answered"),
|
|
|
|
"flagged": l("Flagged"),
|
|
|
|
"junk": l("Junk"),
|
|
|
|
"not_junk": l("Not Junk")
|
|
|
|
};
|
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function cancel() {
|
2015-05-06 04:06:13 +02:00
|
|
|
$mdDialog.cancel();
|
2015-10-05 16:45:30 +02:00
|
|
|
}
|
2016-06-08 21:21:36 +02:00
|
|
|
|
|
|
|
function hasRulesAndActions() {
|
|
|
|
return vm.filter.rules && vm.filter.rules.length > 0 &&
|
|
|
|
vm.filter.actions && vm.filter.actions.length > 0;
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function save(form) {
|
2015-05-06 04:06:13 +02:00
|
|
|
$mdDialog.hide();
|
2015-10-05 16:45:30 +02:00
|
|
|
}
|
2016-06-08 21:21:36 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function addMailFilterRule(event) {
|
|
|
|
if (!vm.filter.rules)
|
|
|
|
vm.filter.rules = [];
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.filter.rules.push({ field: 'subject', operator: 'contains' });
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function removeMailFilterRule(index) {
|
|
|
|
vm.filter.rules.splice(index, 1);
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function addMailFilterAction(event) {
|
|
|
|
if (!vm.filter.actions)
|
|
|
|
vm.filter.actions = [];
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
vm.filter.actions.push({ method: 'discard' });
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-10-05 16:45:30 +02:00
|
|
|
function removeMailFilterAction(index) {
|
|
|
|
vm.filter.actions.splice(index, 1);
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('SOGo.PreferencesUI')
|
|
|
|
.controller('FiltersDialogController', FiltersDialogController);
|
|
|
|
|
|
|
|
})();
|