mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Filter improvements
This commit is contained in:
parent
f91f74fe7c
commit
05b1c1dfe5
14 changed files with 222 additions and 68 deletions
|
|
@ -128,7 +128,7 @@
|
|||
'FLAGGED': 11,
|
||||
'ALL': 12
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
|
@ -321,7 +321,9 @@
|
|||
Enums.FilterConditionField = {
|
||||
'From': 'From',
|
||||
'Recipient': 'Recipient',
|
||||
'Subject': 'Subject'
|
||||
'Subject': 'Subject',
|
||||
'Header': 'Header',
|
||||
'Size': 'Size'
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -331,7 +333,9 @@
|
|||
'Contains': 'Contains',
|
||||
'NotContains': 'NotContains',
|
||||
'EqualTo': 'EqualTo',
|
||||
'NotEqualTo': 'NotEqualTo'
|
||||
'NotEqualTo': 'NotEqualTo',
|
||||
'Over': 'Over',
|
||||
'Under': 'Under'
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,11 +25,20 @@
|
|||
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.type())
|
||||
switch (this.field())
|
||||
{
|
||||
case Enums.FilterConditionField.Size:
|
||||
sTemplate = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
case Enums.FilterConditionField.Header:
|
||||
sTemplate = 'SettingsFiltersConditionMore';
|
||||
break;
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
|
|
@ -39,6 +48,11 @@
|
|||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(function () {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}, this);
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +66,12 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Enums.FilterConditionField.Header === this.field() && '' === this.valueSecond())
|
||||
{
|
||||
this.valueSecond.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
@ -62,6 +82,7 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -74,7 +95,8 @@
|
|||
return {
|
||||
'Field': this.field(),
|
||||
'Type': this.type(),
|
||||
'Value': this.value()
|
||||
'Value': this.value(),
|
||||
'ValueSecond': this.valueSecond()
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -85,6 +107,7 @@
|
|||
oClone.field(this.field());
|
||||
oClone.type(this.type());
|
||||
oClone.value(this.value());
|
||||
oClone.valueSecond(this.valueSecond());
|
||||
|
||||
return oClone;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
this.actionTypeOptions = ko.observableArray([]);
|
||||
this.fieldOptions = ko.observableArray([]);
|
||||
this.typeOptions = ko.observableArray([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
|
||||
Translator.initOnStartOrLangChange(this.populateOptions, this);
|
||||
|
||||
|
|
@ -136,7 +137,9 @@
|
|||
this.fieldOptions([
|
||||
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')}
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||
]);
|
||||
|
||||
this.typeOptions([
|
||||
|
|
@ -145,6 +148,11 @@
|
|||
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||
]);
|
||||
|
||||
this.typeOptionsSize([
|
||||
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue