snappymail/dev/Model/FilterCondition.js

67 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-09-05 06:49:03 +08:00
(function () {
2014-08-20 23:03:12 +08:00
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-20 23:03:12 +08:00
var
2014-10-04 19:58:01 +08:00
_ = require('_'),
2014-08-25 23:49:01 +08:00
ko = require('ko'),
2014-10-04 19:58:01 +08:00
Enums = require('Common/Enums'),
AbstractModel = require('Knoin/AbstractModel')
2014-08-20 23:03:12 +08:00
;
/**
* @constructor
*/
function FilterConditionModel()
2014-08-20 23:03:12 +08:00
{
2014-10-04 19:58:01 +08:00
AbstractModel.call(this, 'FilterConditionModel');
2014-08-20 23:03:12 +08:00
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);
2014-10-04 19:58:01 +08:00
this.regDisposables([this.template]);
2014-08-20 23:03:12 +08:00
}
2014-10-04 19:58:01 +08:00
_.extend(FilterConditionModel.prototype, AbstractModel.prototype);
FilterConditionModel.prototype.toJson = function ()
2014-08-20 23:03:12 +08:00
{
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;
2014-08-20 23:03:12 +08:00
};
module.exports = FilterConditionModel;
2014-09-05 06:49:03 +08:00
}());