mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Cleanup Sieve Filter editor code
This commit is contained in:
parent
0bf891ba9d
commit
86374433b9
2 changed files with 22 additions and 44 deletions
|
@ -24,8 +24,6 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
selectedFolderValue: ''
|
||||
});
|
||||
|
||||
this.fTrueCallback = null;
|
||||
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
this.folderSelectList = koComputable(() =>
|
||||
folderListOptionsBuilder(
|
||||
|
@ -35,7 +33,7 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
)
|
||||
);
|
||||
|
||||
this.selectedFolderValue.subscribe(() => this.filter() && this.filter().actionValueError(false));
|
||||
this.selectedFolderValue.subscribe(() => this.filter().actionValueError(false));
|
||||
|
||||
['actionTypeOptions','fieldOptions','typeOptions','typeOptionsSize','typeOptionsBody'].forEach(
|
||||
key => this[key] = ko.observableArray()
|
||||
|
@ -47,21 +45,14 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
saveFilter() {
|
||||
if (this.filter()) {
|
||||
if (FilterAction.MoveTo === this.filter().actionType()) {
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
if (!this.filter().verify()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.fTrueCallback && this.fTrueCallback(this.filter());
|
||||
|
||||
this.modalVisibility() && this.closeCommand();
|
||||
if (FilterAction.MoveTo === this.filter().actionType()) {
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
return true;
|
||||
if (this.filter().verify()) {
|
||||
this.fTrueCallback();
|
||||
this.closeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
populateOptions() {
|
||||
|
@ -88,9 +79,7 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
// name: i18n('GLOBAL/NONE')});
|
||||
const modules = SieveUserStore.capa;
|
||||
if (modules) {
|
||||
if (modules.includes('imap4flags')) {
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
this.allowMarkAsRead(modules.includes('imap4flags'));
|
||||
|
||||
if (modules.includes('fileinto')) {
|
||||
this.actionTypeOptions.push({
|
||||
|
@ -137,9 +126,7 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
removeCondition(oConditionToDelete) {
|
||||
if (this.filter()) {
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
}
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
}
|
||||
|
||||
onShow(oFilter, fTrueCallback, bEdit) {
|
||||
|
@ -148,16 +135,12 @@ export class FilterPopupView extends AbstractViewPopup {
|
|||
this.fTrueCallback = fTrueCallback;
|
||||
this.filter(oFilter);
|
||||
|
||||
if (oFilter) {
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
}
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
|
||||
if (!bEdit && oFilter) {
|
||||
oFilter.nameFocused(true);
|
||||
}
|
||||
bEdit || oFilter.nameFocused(true);
|
||||
}
|
||||
|
||||
afterShow() {
|
||||
this.isNew() && this.filter() && this.filter().nameFocused(true);
|
||||
this.isNew() && this.filter().nameFocused(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ export class SieveScriptPopupView extends AbstractViewPopup {
|
|||
script = self.script();
|
||||
if (!self.saving/* && script.hasChanges()*/) {
|
||||
if (!script.verify()) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!script.exists() && SieveUserStore.scripts.find(item => item.name() === script.name())) {
|
||||
script.nameError(true);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
self.saving = true;
|
||||
|
@ -66,8 +66,6 @@ export class SieveScriptPopupView extends AbstractViewPopup {
|
|||
script.toJson()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
deleteFilter(filter) {
|
||||
|
@ -80,10 +78,7 @@ export class SieveScriptPopupView extends AbstractViewPopup {
|
|||
filter.generateID();
|
||||
showScreenPopup(FilterPopupView, [
|
||||
filter,
|
||||
() => {
|
||||
this.filters.push(filter);
|
||||
},
|
||||
false
|
||||
() => this.filters.push(filter)
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -105,13 +100,12 @@ export class SieveScriptPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
toggleFiltersRaw() {
|
||||
if (!this.rawActive()) {
|
||||
let script = this.script(),
|
||||
changed = script.hasChanges();
|
||||
let script = this.script(), notRaw = !this.rawActive();
|
||||
if (notRaw) {
|
||||
script.body(script.filtersToRaw());
|
||||
script.hasChanges(changed);
|
||||
script.hasChanges(script.hasChanges());
|
||||
}
|
||||
this.rawActive(!this.rawActive());
|
||||
this.rawActive(notRaw);
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
@ -123,9 +117,10 @@ export class SieveScriptPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onShow(oScript) {
|
||||
let raw = !oScript.allowFilters();
|
||||
this.script(oScript);
|
||||
this.rawActive(!oScript.allowFilters());
|
||||
this.allowToggle(oScript.allowFilters());
|
||||
this.rawActive(raw);
|
||||
this.allowToggle(!raw);
|
||||
this.saveError(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue