snappymail/dev/Model/FilterCondition.js
RainLoop Team d5eacb6a4d Interface optimization
Mark as important (compose)
2014-12-31 16:21:43 +04:00

67 lines
No EOL
1.2 KiB
JavaScript

(function () {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Common/Enums'),
AbstractModel = require('Knoin/AbstractModel')
;
/**
* @constructor
*/
function FilterConditionModel()
{
AbstractModel.call(this, 'FilterConditionModel');
this.field = ko.observable(Enums.FilterConditionField.From);
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
this.value = ko.observable('');
this.template = ko.computed(function () {
var sTemplate = '';
switch (this.type())
{
default:
sTemplate = 'SettingsFiltersConditionDefault';
break;
}
return sTemplate;
}, this);
this.regDisposables([this.template]);
}
_.extend(FilterConditionModel.prototype, AbstractModel.prototype);
FilterConditionModel.prototype.toJson = function ()
{
return {
'Field': this.field(),
'Type': this.type(),
'Value': this.value()
};
};
FilterConditionModel.prototype.cloneSelf = function ()
{
var oClone = new FilterConditionModel();
oClone.field(this.field());
oClone.type(this.type());
oClone.value(this.value());
return oClone;
};
module.exports = FilterConditionModel;
}());