mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29:20 +03:00
eslint (additional rules)
This commit is contained in:
parent
77a1d3f3df
commit
8e8a041032
150 changed files with 21911 additions and 23106 deletions
|
|
@ -1,117 +1,110 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
AbstractModel = require('Knoin/AbstractModel');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterConditionModel()
|
||||
{
|
||||
AbstractModel.call(this, 'FilterConditionModel');
|
||||
|
||||
AbstractModel = require('Knoin/AbstractModel')
|
||||
;
|
||||
this.field = ko.observable(Enums.FilterConditionField.From);
|
||||
this.type = ko.observable(Enums.FilterConditionType.Contains);
|
||||
this.value = ko.observable('');
|
||||
this.value.error = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterConditionModel()
|
||||
this.valueSecond = ko.observable('');
|
||||
this.valueSecond.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(function() {
|
||||
|
||||
var sTemplate = '';
|
||||
switch (this.field())
|
||||
{
|
||||
case Enums.FilterConditionField.Size:
|
||||
sTemplate = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
case Enums.FilterConditionField.Header:
|
||||
sTemplate = 'SettingsFiltersConditionMore';
|
||||
break;
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(function() {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}, this);
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
}
|
||||
|
||||
_.extend(FilterConditionModel.prototype, AbstractModel.prototype);
|
||||
|
||||
FilterConditionModel.prototype.verify = function()
|
||||
{
|
||||
if ('' === this.value())
|
||||
{
|
||||
AbstractModel.call(this, 'FilterConditionModel');
|
||||
|
||||
this.field = ko.observable(Enums.FilterConditionField.From);
|
||||
this.type = ko.observable(Enums.FilterConditionType.Contains);
|
||||
this.value = ko.observable('');
|
||||
this.value.error = ko.observable(false);
|
||||
|
||||
this.valueSecond = ko.observable('');
|
||||
this.valueSecond.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(function () {
|
||||
|
||||
var sTemplate = '';
|
||||
switch (this.field())
|
||||
{
|
||||
case Enums.FilterConditionField.Size:
|
||||
sTemplate = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
case Enums.FilterConditionField.Header:
|
||||
sTemplate = 'SettingsFiltersConditionMore';
|
||||
break;
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(function () {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}, this);
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
this.value.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
_.extend(FilterConditionModel.prototype, AbstractModel.prototype);
|
||||
|
||||
FilterConditionModel.prototype.verify = function ()
|
||||
if (Enums.FilterConditionField.Header === this.field() && '' === this.valueSecond())
|
||||
{
|
||||
if ('' === this.value())
|
||||
{
|
||||
this.value.error(true);
|
||||
return false;
|
||||
}
|
||||
this.valueSecond.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Enums.FilterConditionField.Header === this.field() && '' === this.valueSecond())
|
||||
{
|
||||
this.valueSecond.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));
|
||||
this.valueSecond(Utils.pString(oItem.ValueSecond));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
FilterConditionModel.prototype.toJson = function()
|
||||
{
|
||||
return {
|
||||
Field: this.field(),
|
||||
Type: this.type(),
|
||||
Value: this.value(),
|
||||
ValueSecond: this.valueSecond()
|
||||
};
|
||||
};
|
||||
|
||||
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));
|
||||
this.valueSecond(Utils.pString(oItem.ValueSecond));
|
||||
FilterConditionModel.prototype.cloneSelf = function()
|
||||
{
|
||||
var oClone = new FilterConditionModel();
|
||||
|
||||
return true;
|
||||
}
|
||||
oClone.field(this.field());
|
||||
oClone.type(this.type());
|
||||
oClone.value(this.value());
|
||||
oClone.valueSecond(this.valueSecond());
|
||||
|
||||
return false;
|
||||
};
|
||||
return oClone;
|
||||
};
|
||||
|
||||
FilterConditionModel.prototype.toJson = function ()
|
||||
{
|
||||
return {
|
||||
Field: this.field(),
|
||||
Type: this.type(),
|
||||
Value: this.value(),
|
||||
ValueSecond: this.valueSecond()
|
||||
};
|
||||
};
|
||||
|
||||
FilterConditionModel.prototype.cloneSelf = function ()
|
||||
{
|
||||
var oClone = new FilterConditionModel();
|
||||
|
||||
oClone.field(this.field());
|
||||
oClone.type(this.type());
|
||||
oClone.value(this.value());
|
||||
oClone.valueSecond(this.valueSecond());
|
||||
|
||||
return oClone;
|
||||
};
|
||||
|
||||
module.exports = FilterConditionModel;
|
||||
|
||||
}());
|
||||
module.exports = FilterConditionModel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue