mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Sieve filters (interface)
This commit is contained in:
parent
644f861347
commit
ef3042aff7
15 changed files with 449 additions and 55 deletions
|
|
@ -312,7 +312,7 @@
|
|||
*/
|
||||
Enums.FiltersAction = {
|
||||
'None': 'None',
|
||||
'Move': 'Move',
|
||||
'MoveTo': 'MoveTo',
|
||||
'Discard': 'Discard',
|
||||
'Forward': 'Forward'
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,15 +29,24 @@
|
|||
this.name.error = ko.observable(false);
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.raw = ko.observable('');
|
||||
|
||||
this.conditions = ko.observableArray([]);
|
||||
this.conditionsType = ko.observable(Enums.FilterRulesType.All);
|
||||
this.conditionsType = ko.observable(Enums.FilterRulesType.Any);
|
||||
|
||||
// Actions
|
||||
this.actionValue = ko.observable('');
|
||||
this.actionMarkAsRead = ko.observable(false);
|
||||
|
||||
this.actionSkipOthers = ko.observable(false);
|
||||
|
||||
this.actionType = ko.observable(Enums.FiltersAction.Move);
|
||||
this.keepForward = ko.observable(true);
|
||||
|
||||
this.actionType = ko.observable(Enums.FiltersAction.MoveTo);
|
||||
|
||||
this.actionType.subscribe(function (sValue) {
|
||||
this.actionValue('');
|
||||
}, this);
|
||||
|
||||
this.actionTemplate = ko.computed(function () {
|
||||
|
||||
|
|
@ -45,11 +54,14 @@
|
|||
switch (this.actionType())
|
||||
{
|
||||
default:
|
||||
case Enums.FiltersAction.Move:
|
||||
case Enums.FiltersAction.MoveTo:
|
||||
sTemplate = 'SettingsFiltersActionValueAsFolders';
|
||||
break;
|
||||
// case Enums.FiltersAction.Forward:
|
||||
// sTemplate = 'SettingsFiltersActionWithValue';
|
||||
// break;
|
||||
case Enums.FiltersAction.Forward:
|
||||
sTemplate = 'SettingsFiltersActionWithValue';
|
||||
sTemplate = 'SettingsFiltersActionForward';
|
||||
break;
|
||||
case Enums.FiltersAction.None:
|
||||
case Enums.FiltersAction.Discard:
|
||||
|
|
@ -86,17 +98,20 @@
|
|||
{
|
||||
return {
|
||||
'ID': this.id,
|
||||
'Enabled': this.enabled(),
|
||||
'Enabled': this.enabled() ? '1' : '0',
|
||||
'Name': this.name(),
|
||||
'ConditionsType': this.conditionsType(),
|
||||
'Conditions': _.map(this.conditions(), function (oItem) {
|
||||
return oItem.toJson();
|
||||
}),
|
||||
|
||||
|
||||
'ActionValue': this.actionValue(),
|
||||
'ActionType': this.actionType(),
|
||||
|
||||
'Raw': this.raw(),
|
||||
|
||||
'MarkAsRead': this.actionMarkAsRead() ? '1' : '0',
|
||||
'KeepForward': this.keepForward() ? '1' : '0',
|
||||
'SkipOthers': this.actionSkipOthers() ? '1' : '0'
|
||||
};
|
||||
};
|
||||
|
|
@ -117,7 +132,7 @@
|
|||
var bResult = false;
|
||||
if (oItem && 'Object/Filter' === oItem['@Object'])
|
||||
{
|
||||
this.ID = Utils.pString(oItem['ID']);
|
||||
this.id = Utils.pString(oItem['ID']);
|
||||
this.name(Utils.pString(oItem['Name']));
|
||||
|
||||
bResult = true;
|
||||
|
|
@ -130,13 +145,15 @@
|
|||
{
|
||||
var oClone = new FilterModel();
|
||||
|
||||
oClone.ID = this.ID;
|
||||
oClone.id = this.id;
|
||||
|
||||
oClone.enabled(this.enabled());
|
||||
|
||||
oClone.name(this.name());
|
||||
oClone.name.error(this.name.error());
|
||||
|
||||
oClone.raw(this.raw());
|
||||
|
||||
oClone.conditionsType(this.conditionsType());
|
||||
|
||||
oClone.actionMarkAsRead(this.actionMarkAsRead());
|
||||
|
|
@ -146,6 +163,8 @@
|
|||
|
||||
oClone.actionType(this.actionType());
|
||||
|
||||
oClone.keepForward(this.keepForward());
|
||||
|
||||
oClone.conditions(_.map(this.conditions(), function (oCondition) {
|
||||
return oCondition.cloneSelf();
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@
|
|||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
|
||||
self.haveChanges(false);
|
||||
self.updateList();
|
||||
}
|
||||
|
|
@ -86,9 +85,9 @@
|
|||
var self = this;
|
||||
|
||||
this.filters.loading(true);
|
||||
// Remote.filtersGet(function (sResult, oData) {
|
||||
Remote.filtersGet(function (sResult, oData) {
|
||||
self.filters.loading(false);
|
||||
// });
|
||||
});
|
||||
};
|
||||
|
||||
FiltersUserSettings.prototype.deleteFilter = function (oFilter)
|
||||
|
|
|
|||
|
|
@ -238,6 +238,14 @@
|
|||
});
|
||||
}, this);
|
||||
|
||||
this.folderMenuForFilters = ko.computed(function () {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [
|
||||
'INBOX'
|
||||
], null, null, null, null, function (oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
});
|
||||
}, this);
|
||||
|
||||
// message list
|
||||
this.staticMessageList = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -247,8 +247,7 @@
|
|||
*/
|
||||
RemoteUserStorage.prototype.filtersGet = function (fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'Filters', {
|
||||
});
|
||||
this.defaultRequest(fCallback, 'Filters', {});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
this.filter = ko.observable(null);
|
||||
|
||||
this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
this.folderSelectList = Data.folderMenuForMove;
|
||||
this.folderSelectList = Data.folderMenuForFilters;
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.saveFilter = Utils.createCommand(this, function () {
|
||||
|
|
@ -46,6 +46,15 @@
|
|||
|
||||
if (this.fTrueCallback)
|
||||
{
|
||||
if (Enums.FiltersAction.MoveTo === this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
else if (Enums.FiltersAction.Forward !== this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue('');
|
||||
}
|
||||
|
||||
this.fTrueCallback(this.filter());
|
||||
}
|
||||
|
||||
|
|
@ -60,8 +69,8 @@
|
|||
|
||||
this.actionTypeOptions = [
|
||||
{'id': Enums.FiltersAction.None, 'name': 'None @i18n'},
|
||||
{'id': Enums.FiltersAction.Move, 'name': ' Move to @i18n'},
|
||||
// {'id': Enums.FiltersAction.Forward, 'name': 'Forward to @i18n'},
|
||||
{'id': Enums.FiltersAction.MoveTo, 'name': ' Move to @i18n'},
|
||||
{'id': Enums.FiltersAction.Forward, 'name': 'Forward to @i18n'},
|
||||
{'id': Enums.FiltersAction.Discard, 'name': 'Discard @i18n'}
|
||||
];
|
||||
|
||||
|
|
@ -72,10 +81,10 @@
|
|||
];
|
||||
|
||||
this.typeOptions = [
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To @i18n'},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To @i18n'},
|
||||
{'id': Enums.FilterConditionType.Contains, 'name': 'Contains @i18n'},
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains @i18n'}
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains @i18n'},
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To @i18n'},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To @i18n'}
|
||||
];
|
||||
|
||||
kn.constructorEnd(this);
|
||||
|
|
@ -119,7 +128,7 @@
|
|||
{
|
||||
if (this.isNew() && this.filter())
|
||||
{
|
||||
this.filter().name.focused(true);
|
||||
this.filter().name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue