mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Filters / Interface (part 2)
This commit is contained in:
parent
333c063cf1
commit
b1327c933b
20 changed files with 456 additions and 127 deletions
50
dev/Models/FilterActionModel.js
Normal file
50
dev/Models/FilterActionModel.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterActionModel(oKoList, oKoCanBeDeleted)
|
||||
{
|
||||
this.parentList = oKoList;
|
||||
this.canBeDeleted = oKoCanBeDeleted;
|
||||
|
||||
this.value = ko.observable('');
|
||||
|
||||
this.type = ko.observable(Enums.FiltersAction.Move);
|
||||
this.typeOptions = [ // TODO i18n
|
||||
{'id': Enums.FiltersAction.Move, 'name': 'Move to'},
|
||||
{'id': Enums.FiltersAction.Forward, 'name': 'Forward to'},
|
||||
{'id': Enums.FiltersAction.Delete, 'name': 'Discard'},
|
||||
{'id': Enums.FiltersAction.MarkAsRead, 'name': 'Mark as read'}
|
||||
];
|
||||
|
||||
this.template = ko.computed(function () {
|
||||
|
||||
var sTemplate = '';
|
||||
switch (this.type())
|
||||
{
|
||||
default:
|
||||
case Enums.FiltersAction.Move:
|
||||
sTemplate = 'SettingsFiltersActionValueAsFolders';
|
||||
break;
|
||||
case Enums.FiltersAction.Forward:
|
||||
sTemplate = 'SettingsFiltersActionWithValue';
|
||||
break;
|
||||
case Enums.FiltersAction.MarkAsRead:
|
||||
case Enums.FiltersAction.Delete:
|
||||
sTemplate = 'SettingsFiltersActionNoValue';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
FilterActionModel.prototype.removeSelf = function ()
|
||||
{
|
||||
if (this.canBeDeleted())
|
||||
{
|
||||
this.parentList.remove(this);
|
||||
}
|
||||
};
|
||||
|
|
@ -3,6 +3,48 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterConditionModel()
|
||||
function FilterConditionModel(oKoList, oKoCanBeDeleted)
|
||||
{
|
||||
this.parentList = oKoList;
|
||||
this.canBeDeleted = oKoCanBeDeleted;
|
||||
|
||||
this.field = ko.observable(Enums.FilterConditionField.Subject);
|
||||
this.fieldOptions = [ // TODO i18n
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': 'Subject'},
|
||||
{'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'},
|
||||
{'id': Enums.FilterConditionField.From, 'name': 'From'},
|
||||
{'id': Enums.FilterConditionField.To, 'name': 'To'}
|
||||
];
|
||||
|
||||
this.type = ko.observable(Enums.FilterConditionType.Contains);
|
||||
this.typeOptions = [ // TODO i18n
|
||||
{'id': Enums.FilterConditionType.Contains, 'name': 'Contains'},
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'},
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'}
|
||||
];
|
||||
|
||||
this.value = ko.observable('');
|
||||
|
||||
this.template = ko.computed(function () {
|
||||
|
||||
var sTemplate = '';
|
||||
switch (this.type())
|
||||
{
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
FilterConditionModel.prototype.removeSelf = function ()
|
||||
{
|
||||
if (this.canBeDeleted())
|
||||
{
|
||||
this.parentList.remove(this);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,19 +7,38 @@ function FilterModel()
|
|||
{
|
||||
this.enabled = ko.observable(true);
|
||||
|
||||
this.name = ko.observable('');
|
||||
|
||||
this.conditionsType = ko.observable(Enums.FilterRulesType.And);
|
||||
|
||||
this.conditions = ko.observableArray([]);
|
||||
this.actions = ko.observableArray([]);
|
||||
|
||||
this.action = ko.observable(Enums.FiltersAction.None);
|
||||
this.conditions.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
});
|
||||
|
||||
this.actions.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
});
|
||||
|
||||
this.conditionsCanBeDeleted = ko.computed(function () {
|
||||
return 1 < this.conditions().length;
|
||||
}, this);
|
||||
|
||||
this.actionsCanBeDeleted = ko.computed(function () {
|
||||
return 1 < this.actions().length;
|
||||
}, this);
|
||||
}
|
||||
|
||||
FilterModel.prototype.deleteCondition = function (oCondition)
|
||||
{
|
||||
this.conditions.remove(oCondition);
|
||||
};
|
||||
|
||||
FilterModel.prototype.addCondition = function ()
|
||||
{
|
||||
this.conditions.push(new FilterConditionModel());
|
||||
this.conditions.push(new FilterConditionModel(this.conditions, this.conditionsCanBeDeleted));
|
||||
};
|
||||
|
||||
FilterModel.prototype.addAction = function ()
|
||||
{
|
||||
this.actions.push(new FilterActionModel(this.actions, this.actionsCanBeDeleted));
|
||||
};
|
||||
|
||||
FilterModel.prototype.parse = function (oItem)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue