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
68cc322bd5
commit
02ba68868f
12 changed files with 129 additions and 30 deletions
|
|
@ -8,6 +8,7 @@
|
|||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
AbstractModel = require('Knoin/AbstractModel')
|
||||
;
|
||||
|
|
@ -20,8 +21,9 @@
|
|||
AbstractModel.call(this, 'FilterConditionModel');
|
||||
|
||||
this.field = ko.observable(Enums.FilterConditionField.From);
|
||||
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
|
||||
this.type = ko.observable(Enums.FilterConditionType.Contains);
|
||||
this.value = ko.observable('');
|
||||
this.value.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(function () {
|
||||
|
||||
|
|
@ -42,6 +44,31 @@
|
|||
|
||||
_.extend(FilterConditionModel.prototype, AbstractModel.prototype);
|
||||
|
||||
FilterConditionModel.prototype.verify = function ()
|
||||
{
|
||||
if ('' === this.value())
|
||||
{
|
||||
this.value.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
FilterConditionModel.prototype.parse = function (oItem)
|
||||
{
|
||||
if (oItem && oItem['Field'] && oItem['Type'])
|
||||
{
|
||||
this.field(Utils.pString(oItem['Field']));
|
||||
this.type(Utils.pString(oItem['Type']));
|
||||
this.value(Utils.pString(oItem['Value']));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
FilterConditionModel.prototype.toJson = function ()
|
||||
{
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue