mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Sieve filters (pre release)
This commit is contained in:
parent
63a286a6b6
commit
0152f1583b
38 changed files with 175 additions and 63 deletions
|
|
@ -26,6 +26,9 @@
|
|||
this.modules = FilterStore.modules;
|
||||
this.filters = FilterStore.collection;
|
||||
|
||||
this.inited = ko.observable(false);
|
||||
this.serverError = ko.observable(false);
|
||||
this.serverErrorDesc = ko.observable('');
|
||||
this.haveChanges = ko.observable(false);
|
||||
|
||||
this.processText = ko.observable('');
|
||||
|
|
@ -35,6 +38,13 @@
|
|||
|
||||
this.filters.subscribe(Utils.windowResizeCallback);
|
||||
|
||||
this.serverError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.serverErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.filterRaw = FilterStore.raw;
|
||||
this.filterRaw.capa = FilterStore.capa;
|
||||
this.filterRaw.active = ko.observable(false);
|
||||
|
|
@ -118,39 +128,52 @@
|
|||
FilterModel = require('Model/Filter')
|
||||
;
|
||||
|
||||
this.filters.loading(true);
|
||||
if (!this.filters.loading())
|
||||
{
|
||||
this.filters.loading(true);
|
||||
|
||||
Remote.filtersGet(function (sResult, oData) {
|
||||
Remote.filtersGet(function (sResult, oData) {
|
||||
|
||||
self.filters.loading(false);
|
||||
self.filters.loading(false);
|
||||
self.serverError(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData &&
|
||||
oData.Result && Utils.isArray(oData.Result.Filters))
|
||||
{
|
||||
var aResult = _.compact(_.map(oData.Result.Filters, function (aItem) {
|
||||
var oNew = new FilterModel();
|
||||
return (oNew && oNew.parse(aItem)) ? oNew : null;
|
||||
}));
|
||||
if (Enums.StorageResultType.Success === sResult && oData &&
|
||||
oData.Result && Utils.isArray(oData.Result.Filters))
|
||||
{
|
||||
self.inited(true);
|
||||
self.serverError(false);
|
||||
|
||||
self.filters(aResult);
|
||||
var aResult = _.compact(_.map(oData.Result.Filters, function (aItem) {
|
||||
var oNew = new FilterModel();
|
||||
return (oNew && oNew.parse(aItem)) ? oNew : null;
|
||||
}));
|
||||
|
||||
self.modules(oData.Result.Modules ? oData.Result.Modules : {});
|
||||
self.filters(aResult);
|
||||
|
||||
self.filterRaw(oData.Result.Raw || '');
|
||||
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : '');
|
||||
self.filterRaw.active(!!oData.Result.RawIsActive);
|
||||
self.filterRaw.allow(!!oData.Result.RawIsAllow);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.filters([]);
|
||||
self.modules({});
|
||||
self.filterRaw('');
|
||||
self.filterRaw.capa({});
|
||||
}
|
||||
self.modules(oData.Result.Modules ? oData.Result.Modules : {});
|
||||
|
||||
self.haveChanges(false);
|
||||
});
|
||||
self.filterRaw(oData.Result.Raw || '');
|
||||
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : '');
|
||||
self.filterRaw.active(!!oData.Result.RawIsActive);
|
||||
self.filterRaw.allow(!!oData.Result.RawIsAllow);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.filters([]);
|
||||
self.modules({});
|
||||
self.filterRaw('');
|
||||
self.filterRaw.capa({});
|
||||
|
||||
self.serverError(true);
|
||||
self.serverErrorDesc('ERROR');
|
||||
|
||||
self.serverErrorDesc(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
||||
Translator.getNotification(Enums.Notification.CantGetFilters));
|
||||
}
|
||||
|
||||
self.haveChanges(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
FiltersUserSettings.prototype.deleteFilter = function (oFilter)
|
||||
|
|
@ -215,7 +238,10 @@
|
|||
}
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
FiltersUserSettings.prototype.onShow = function ()
|
||||
{
|
||||
this.updateList();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
IdentityStore = require('Stores/User/Identity'),
|
||||
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
|
@ -37,13 +39,13 @@
|
|||
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.identities = Data.identities;
|
||||
this.defaultIdentityID = Data.defaultIdentityID;
|
||||
this.identities = IdentityStore.identities;
|
||||
this.defaultIdentityID = IdentityStore.defaultIdentityID;
|
||||
|
||||
this.identitiesOptions = ko.computed(function () {
|
||||
|
||||
var
|
||||
aList = this.identities(),
|
||||
aList = IdentityStore.identities(),
|
||||
aResult = []
|
||||
;
|
||||
|
||||
|
|
@ -75,7 +77,7 @@
|
|||
}, this);
|
||||
|
||||
this.processText = ko.computed(function () {
|
||||
return Data.identitiesLoading() ? Translator.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
|
||||
return IdentityStore.identities.loading() ? Translator.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
|
||||
}, this);
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
|
|
@ -132,7 +134,7 @@
|
|||
|
||||
if (oIdentityToRemove)
|
||||
{
|
||||
this.identities.remove(function (oIdentity) {
|
||||
IdentityStore.identities.remove(function (oIdentity) {
|
||||
return oIdentityToRemove === oIdentity;
|
||||
});
|
||||
|
||||
|
|
@ -192,7 +194,7 @@
|
|||
f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self)
|
||||
;
|
||||
|
||||
Data.defaultIdentityID.subscribe(function (sValue) {
|
||||
IdentityStore.defaultIdentityID.subscribe(function (sValue) {
|
||||
Remote.saveSettings(f4, {
|
||||
'DefaultIdentityID': sValue
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue