snappymail/dev/Model/FilterCondition.js

70 lines
1.5 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
;
/**
* @param {*} oKoList
* @constructor
*/
function FilterConditionModel(oKoList)
{
2014-10-04 19:58:01 +08:00
AbstractModel.call(this, 'FilterConditionModel');
2014-08-20 23:03:12 +08:00
this.parentList = oKoList;
this.field = ko.observable(Enums.FilterConditionField.From);
this.fieldOptions = [ // TODO i18n
{'id': Enums.FilterConditionField.From, 'name': 'From'},
{'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'},
{'id': Enums.FilterConditionField.Subject, 'name': 'Subject'}
];
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
this.typeOptions = [ // TODO i18n
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'},
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'},
{'id': Enums.FilterConditionType.Contains, 'name': 'Contains'},
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'}
];
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);
2014-08-20 23:03:12 +08:00
FilterConditionModel.prototype.removeSelf = function ()
{
this.parentList.remove(this);
};
module.exports = FilterConditionModel;
2014-09-05 06:49:03 +08:00
}());