mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
Sieve filters (alpha / beta version coming soon)
This commit is contained in:
parent
02ba68868f
commit
94789632f0
33 changed files with 544 additions and 81 deletions
|
|
@ -307,6 +307,7 @@
|
|||
'MoveTo': 'MoveTo',
|
||||
'Discard': 'Discard',
|
||||
'Vacation': 'Vacation',
|
||||
'Reject': 'Reject',
|
||||
'Forward': 'Forward'
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
this.actionSkipOthers = ko.observable(false);
|
||||
|
||||
this.keepForward = ko.observable(true);
|
||||
this.actionKeep = ko.observable(true);
|
||||
|
||||
this.actionType = ko.observable(Enums.FiltersAction.MoveTo);
|
||||
|
||||
|
|
@ -79,6 +79,9 @@
|
|||
case Enums.FiltersAction.Vacation:
|
||||
sResult = 'Vacation message @i18n';
|
||||
break;
|
||||
case Enums.FiltersAction.Reject:
|
||||
sResult = 'Reject @i18n';
|
||||
break;
|
||||
case Enums.FiltersAction.Discard:
|
||||
sResult = 'Discard @i18n';
|
||||
break;
|
||||
|
|
@ -103,6 +106,9 @@
|
|||
case Enums.FiltersAction.Vacation:
|
||||
sTemplate = 'SettingsFiltersActionVacation';
|
||||
break;
|
||||
case Enums.FiltersAction.Reject:
|
||||
sTemplate = 'SettingsFiltersActionReject';
|
||||
break;
|
||||
case Enums.FiltersAction.None:
|
||||
sTemplate = 'SettingsFiltersActionNone';
|
||||
break;
|
||||
|
|
@ -161,6 +167,7 @@
|
|||
if (-1 < Utils.inArray(this.actionType(), [
|
||||
Enums.FiltersAction.MoveTo,
|
||||
Enums.FiltersAction.Forward,
|
||||
Enums.FiltersAction.Reject,
|
||||
Enums.FiltersAction.Vacation
|
||||
]))
|
||||
{
|
||||
|
|
@ -197,8 +204,8 @@
|
|||
'ActionValueSecond': this.actionValueSecond(),
|
||||
'ActionType': this.actionType(),
|
||||
|
||||
'Keep': this.actionKeep() ? '1' : '0',
|
||||
'MarkAsRead': this.actionMarkAsRead() ? '1' : '0',
|
||||
'KeepForward': this.keepForward() ? '1' : '0',
|
||||
'SkipOthers': this.actionSkipOthers() ? '1' : '0'
|
||||
};
|
||||
};
|
||||
|
|
@ -241,8 +248,8 @@
|
|||
this.actionValue(Utils.pString(oItem['ActionValue']));
|
||||
this.actionValueSecond(Utils.pString(oItem['ActionValueSecond']));
|
||||
|
||||
this.actionKeep(!!oItem['Keep']);
|
||||
this.actionMarkAsRead(!!oItem['MarkAsRead']);
|
||||
this.keepForward(!!oItem['KeepForward']);
|
||||
this.actionSkipOthers(!!oItem['SkipOthers']);
|
||||
|
||||
bResult = true;
|
||||
|
|
@ -274,7 +281,7 @@
|
|||
|
||||
oClone.actionValueSecond(this.actionValueSecond());
|
||||
|
||||
oClone.keepForward(this.keepForward());
|
||||
oClone.actionKeep(this.actionKeep());
|
||||
|
||||
oClone.conditions(_.map(this.conditions(), function (oCondition) {
|
||||
return oCondition.cloneSelf();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/User/Data'),
|
||||
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
||||
|
|
@ -25,12 +27,19 @@
|
|||
this.processText = ko.observable('');
|
||||
this.visibility = ko.observable(false);
|
||||
|
||||
this.modules = Data.filterModules;
|
||||
|
||||
this.filters = ko.observableArray([]);
|
||||
this.filters.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.filters.saving = ko.observable(false).extend({'throttle': 200});
|
||||
|
||||
this.filters.subscribe(Utils.windowResizeCallback);
|
||||
|
||||
this.filterRaw = ko.observable('');
|
||||
this.filterRaw.capa = ko.observable('');
|
||||
this.filterRaw.active = ko.observable(false);
|
||||
this.filterRaw.allow = ko.observable(false);
|
||||
|
||||
this.processText = ko.computed(function () {
|
||||
return this.filters.loading() ? Utils.i18n('SETTINGS_FILTERS/LOADING_PROCESS') : '';
|
||||
}, this);
|
||||
|
|
@ -58,7 +67,7 @@
|
|||
self.updateList();
|
||||
}
|
||||
|
||||
}, this.filters());
|
||||
}, this.filters(), this.filterRaw(), this.filterRaw.active());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -70,6 +79,14 @@
|
|||
this.filters.subscribe(function () {
|
||||
this.haveChanges(true);
|
||||
}, this);
|
||||
|
||||
this.filterRaw.subscribe(function () {
|
||||
this.haveChanges(true);
|
||||
}, this);
|
||||
|
||||
this.filterRaw.active.subscribe(function () {
|
||||
this.haveChanges(true);
|
||||
}, this);
|
||||
}
|
||||
|
||||
FiltersUserSettings.prototype.scrollableOptions = function ()
|
||||
|
|
@ -93,18 +110,28 @@
|
|||
self.filters.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData &&
|
||||
oData.Result && Utils.isArray(oData.Result))
|
||||
oData.Result && Utils.isArray(oData.Result.Filters))
|
||||
{
|
||||
var aResult = _.compact(_.map(oData.Result, function (aItem) {
|
||||
var aResult = _.compact(_.map(oData.Result.Filters, function (aItem) {
|
||||
var oNew = new FilterModel();
|
||||
return (oNew && oNew.parse(aItem)) ? oNew : null;
|
||||
}));
|
||||
|
||||
self.filters(aResult);
|
||||
|
||||
self.modules(oData.Result.Modules ? oData.Result.Modules : {});
|
||||
|
||||
self.filterRaw(oData.Result.Raw || '');
|
||||
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : '');
|
||||
self.filterRaw.active(!!oData.Result.RawIsActive);
|
||||
self.filterRaw.allow(!!oData.Result.RawIsAllow);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.filters([]);
|
||||
self.modules({});
|
||||
self.filterRaw('');
|
||||
self.filterRaw.capa({});
|
||||
}
|
||||
|
||||
self.haveChanges(false);
|
||||
|
|
@ -130,6 +157,7 @@
|
|||
require('View/Popup/Filter'), [oNew, function () {
|
||||
self.filters.push(oNew);
|
||||
self.haveChanges(true);
|
||||
self.filterRaw.active(false);
|
||||
}, false]);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@
|
|||
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
|
||||
bCreate, sName,
|
||||
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
|
||||
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
|
||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
|
||||
sWhiteList)
|
||||
{
|
||||
|
|
@ -226,6 +226,7 @@
|
|||
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
||||
|
||||
'UseSieve': bUseSieve ? '1' : '0',
|
||||
'SieveAllowRaw': sSieveAllowRaw ? '1' : '0',
|
||||
'SieveHost': sSieveHost,
|
||||
'SievePort': iSievePort,
|
||||
'SieveSecure': sSieveSecure,
|
||||
|
|
|
|||
|
|
@ -445,6 +445,7 @@
|
|||
}, this);
|
||||
|
||||
// other
|
||||
this.filterModules = ko.observable({});
|
||||
this.composeInEdit = ko.observable(false);
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
this.openpgpkeys = ko.observableArray([]);
|
||||
|
|
|
|||
|
|
@ -233,9 +233,12 @@
|
|||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteUserStorage.prototype.filtersSave = function (fCallback, aFilters)
|
||||
RemoteUserStorage.prototype.filtersSave = function (fCallback,
|
||||
aFilters, sRaw, bRawIsActive)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'FiltersSave', {
|
||||
'Raw': sRaw,
|
||||
'RawIsActive': bRawIsActive ? '1' : '0',
|
||||
'Filters': _.map(aFilters, function (oItem) {
|
||||
return oItem.toJson();
|
||||
})
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.useSieve = ko.observable(false);
|
||||
this.sieveAllowRaw = ko.observable(false);
|
||||
this.sieveServer = ko.observable('');
|
||||
this.sievePort = ko.observable('' + Consts.Values.SieveDefaulPort);
|
||||
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
|
||||
|
|
@ -126,6 +127,7 @@
|
|||
this.imapShortLogin(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
|
@ -353,6 +355,7 @@
|
|||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||
this.sieveServer(Utils.trim(oDomain.SieveHost));
|
||||
this.sievePort('' + Utils.pInt(oDomain.SievePort));
|
||||
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
|
||||
|
|
@ -396,6 +399,7 @@
|
|||
this.imapShortLogin(false);
|
||||
|
||||
this.useSieve(false);
|
||||
this.sieveAllowRaw(false);
|
||||
this.sieveServer('');
|
||||
this.sievePort('' + Consts.Values.SieveDefaulPort);
|
||||
this.sieveSecure(Enums.ServerSecure.None);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
this.fTrueCallback = null;
|
||||
this.filter = ko.observable(null);
|
||||
|
||||
this.modules = Data.filterModules;
|
||||
this.allowMarkAsRead = ko.observable(false);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.folderSelectList = Data.folderMenuForFilters;
|
||||
this.selectedFolderValue = ko.observable('');
|
||||
|
|
@ -68,13 +71,55 @@
|
|||
return true;
|
||||
});
|
||||
|
||||
this.actionTypeOptions = [
|
||||
// {'id': Enums.FiltersAction.None, 'name': 'None @i18n'},
|
||||
{'id': Enums.FiltersAction.MoveTo, 'name': ' Move to @i18n'},
|
||||
{'id': Enums.FiltersAction.Forward, 'name': 'Forward to @i18n'},
|
||||
{'id': Enums.FiltersAction.Vacation, 'name': 'Vacation message @i18n'},
|
||||
{'id': Enums.FiltersAction.Discard, 'name': 'Discard @i18n'}
|
||||
];
|
||||
this.actionTypeOptions = [];
|
||||
this.fieldOptions = [];
|
||||
this.typeOptions = [];
|
||||
|
||||
this.populateOptions();
|
||||
|
||||
this.modules.subscribe(this.populateOptions, this)
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FilterPopupView.prototype.populateOptions = function ()
|
||||
{
|
||||
this.actionTypeOptions = []
|
||||
// this.actionTypeOptions.push({'id': Enums.FiltersAction.None, 'name': 'None @i18n'});
|
||||
|
||||
var oModules = this.modules();
|
||||
if (oModules)
|
||||
{
|
||||
if (oModules.markasread)
|
||||
{
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
|
||||
if (oModules.moveto)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.MoveTo, 'name': 'Move to @i18n'});
|
||||
}
|
||||
|
||||
if (oModules.redirect)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Forward, 'name': 'Forward to @i18n'});
|
||||
}
|
||||
|
||||
if (oModules.reject)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Reject, 'name': 'Reject @i18n'});
|
||||
}
|
||||
|
||||
if (oModules.vacation)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Vacation, 'name': 'Vacation message @i18n'});
|
||||
}
|
||||
}
|
||||
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Discard, 'name': 'Discard @i18n'});
|
||||
|
||||
this.fieldOptions = [
|
||||
{'id': Enums.FilterConditionField.From, 'name': 'From @i18n'},
|
||||
|
|
@ -88,12 +133,8 @@
|
|||
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To @i18n'},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To @i18n'}
|
||||
];
|
||||
};
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FilterPopupView.prototype.removeCondition = function (oConditionToDelete)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue