mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Sieve filters (pre release)
This commit is contained in:
parent
63a286a6b6
commit
0152f1583b
38 changed files with 175 additions and 63 deletions
|
|
@ -24,6 +24,7 @@
|
|||
SocialStore = require('Stores/Social'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
IdentityStore = require('Stores/User/Identity'),
|
||||
|
||||
Local = require('Storage/Client'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
|
@ -517,12 +518,12 @@
|
|||
var self = this;
|
||||
|
||||
AccountStore.loading(true);
|
||||
Data.identitiesLoading(true);
|
||||
IdentityStore.identities.loading(true);
|
||||
|
||||
Remote.accountsAndIdentities(function (sResult, oData) {
|
||||
|
||||
AccountStore.loading(false);
|
||||
Data.identitiesLoading(false);
|
||||
IdentityStore.identities.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
|
|
@ -554,8 +555,9 @@
|
|||
|
||||
if (Utils.isArray(oData.Result['Identities']))
|
||||
{
|
||||
Utils.delegateRunOnDestroy(Data.identities());
|
||||
Data.identities(_.map(oData.Result['Identities'], function (oIdentityData) {
|
||||
Utils.delegateRunOnDestroy(IdentityStore.identities());
|
||||
|
||||
IdentityStore.identities(_.map(oData.Result['Identities'], function (oIdentityData) {
|
||||
|
||||
var
|
||||
sId = Utils.pString(oIdentityData['Id']),
|
||||
|
|
@ -1383,6 +1385,7 @@
|
|||
require('Stores/User/App').populate();
|
||||
require('Stores/User/Settings').populate();
|
||||
require('Stores/User/Notification').populate();
|
||||
require('Stores/User/Identity').populate();
|
||||
|
||||
Data.populateDataOnStart();
|
||||
|
||||
|
|
|
|||
|
|
@ -400,7 +400,8 @@
|
|||
'InvalidRecipients': 303,
|
||||
|
||||
'CantSaveFilters': 351,
|
||||
'FiltersAreNotCorrect': 352,
|
||||
'CantGetFilters': 352,
|
||||
'FiltersAreNotCorrect': 355,
|
||||
|
||||
'CantCreateFolder': 400,
|
||||
'CantRenameFolder': 401,
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@
|
|||
oN[Enums.Notification.InvalidRecipients] = this.i18n('NOTIFICATIONS/INVALID_RECIPIENTS');
|
||||
|
||||
oN[Enums.Notification.CantSaveFilters] = this.i18n('NOTIFICATIONS/CANT_SAVE_FILTERS');
|
||||
oN[Enums.Notification.CantGetFilters] = this.i18n('NOTIFICATIONS/CANT_GET_FILTERS');
|
||||
oN[Enums.Notification.FiltersAreNotCorrect] = this.i18n('NOTIFICATIONS/FILTERS_ARE_NOT_CORRECT');
|
||||
|
||||
oN[Enums.Notification.CantCreateFolder] = this.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER');
|
||||
|
|
|
|||
2
dev/External/ko.js
vendored
2
dev/External/ko.js
vendored
|
|
@ -113,7 +113,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
$(oElement).data('tooltip3-data', sValue).tooltip('show');
|
||||
$(oElement).data('tooltip3-data', sValue);
|
||||
|
||||
_.delay(function () {
|
||||
if ($(oElement).is(':visible'))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
|
|
@ -99,11 +99,6 @@
|
|||
// security
|
||||
this.enableTwoFactor = ko.observable(false);
|
||||
|
||||
// identities
|
||||
this.defaultIdentityID = ko.observable('');
|
||||
this.identities = ko.observableArray([]);
|
||||
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
// contacts
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
|
|
@ -484,8 +479,6 @@
|
|||
this.accountOutLogin(Settings.settingsGet('OutLogin'));
|
||||
this.projectHash(Settings.settingsGet('ProjectHash'));
|
||||
|
||||
this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID'));
|
||||
|
||||
this.displayName(Settings.settingsGet('DisplayName'));
|
||||
this.replyTo(Settings.settingsGet('ReplyTo'));
|
||||
this.signature(Settings.settingsGet('Signature'));
|
||||
|
|
|
|||
30
dev/Stores/User/Identity.js
Normal file
30
dev/Stores/User/Identity.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function IdentityUserStore()
|
||||
{
|
||||
this.defaultIdentityID = ko.observable('');
|
||||
|
||||
this.identities = ko.observableArray([]);
|
||||
this.identities.loading = ko.observable(false).extend({'throttle': 100});
|
||||
}
|
||||
|
||||
IdentityUserStore.prototype.populate = function ()
|
||||
{
|
||||
this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID'));
|
||||
};
|
||||
|
||||
module.exports = new IdentityUserStore();
|
||||
|
||||
}());
|
||||
|
|
@ -22,7 +22,8 @@
|
|||
Translator = require('Common/Translator'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
SettingsUserStore = require('Stores/User/Settings'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
IdentityStore = require('Stores/User/Identity'),
|
||||
SocialStore = require('Stores/Social'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
|
@ -66,7 +67,7 @@
|
|||
|
||||
this.bSkipNextHide = false;
|
||||
this.composeInEdit = Data.composeInEdit;
|
||||
this.editorDefaultType = SettingsUserStore.editorDefaultType;
|
||||
this.editorDefaultType = SettingsStore.editorDefaultType;
|
||||
|
||||
this.capaOpenPGP = Data.capaOpenPGP;
|
||||
|
||||
|
|
@ -157,8 +158,8 @@
|
|||
|
||||
this.composeEditorArea = ko.observable(null);
|
||||
|
||||
this.identities = Data.identities;
|
||||
this.defaultIdentityID = Data.defaultIdentityID;
|
||||
this.identities = IdentityStore.identities;
|
||||
this.defaultIdentityID = IdentityStore.defaultIdentityID;
|
||||
this.currentIdentityID = ko.observable('');
|
||||
|
||||
this.currentIdentityString = ko.observable('');
|
||||
|
|
@ -171,7 +172,7 @@
|
|||
'optText': this.formattedFrom(false)
|
||||
}];
|
||||
|
||||
_.each(Data.identities(), function (oItem) {
|
||||
_.each(IdentityStore.identities(), function (oItem) {
|
||||
aList.push({
|
||||
'optValue': oItem.id,
|
||||
'optText': oItem.formattedNameForCompose()
|
||||
|
|
@ -188,7 +189,7 @@
|
|||
sResult = '',
|
||||
sResultEmail = '',
|
||||
oItem = null,
|
||||
aList = this.identities(),
|
||||
aList = IdentityStore.identities(),
|
||||
sID = this.currentIdentityID()
|
||||
;
|
||||
|
||||
|
|
@ -281,7 +282,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
if (SettingsUserStore.replySameFolder())
|
||||
if (SettingsStore.replySameFolder())
|
||||
{
|
||||
if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
|
||||
{
|
||||
|
|
@ -577,7 +578,7 @@
|
|||
|
||||
if (this.bCapaAdditionalIdentities)
|
||||
{
|
||||
_.each(this.identities(), function (oItem) {
|
||||
_.each(IdentityStore.identities(), function (oItem) {
|
||||
oIDs[oItem.email()] = oItem['id'];
|
||||
});
|
||||
}
|
||||
|
|
@ -604,7 +605,7 @@
|
|||
|
||||
if ('' === sResult)
|
||||
{
|
||||
sResult = this.defaultIdentityID();
|
||||
sResult = IdentityStore.defaultIdentityID();
|
||||
}
|
||||
|
||||
if ('' === sResult)
|
||||
|
|
|
|||
|
|
@ -309,13 +309,19 @@
|
|||
this.testingSieveErrorDesc(oData.Result.Sieve);
|
||||
}
|
||||
|
||||
if (bImap)
|
||||
if (this.sieveSettings())
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
if (!bSieve && bImap)
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
}
|
||||
else if (bSieve)
|
||||
else
|
||||
{
|
||||
this.sieveSettings(true);
|
||||
if (bSieve && !bImap)
|
||||
{
|
||||
this.sieveSettings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue