Enable add/delete of Sieve scripts

This commit is contained in:
djmaze 2021-01-19 16:59:43 +01:00
parent 1a07109d80
commit ee37ad67bb
12 changed files with 24 additions and 22 deletions

View file

@ -16,7 +16,7 @@ class SieveScriptModel extends AbstractModel
nameError: false,
bodyError: false,
deleteAccess: false,
canBeDeleted: false,
canBeDeleted: true,
hasChanges: false
});

View file

@ -67,26 +67,11 @@ class FiltersUserSettings {
}
addScript() {
const script = new SieveScriptModel();
showScreenPopup(require('View/Popup/SieveScript'), [
script,
() => {
if (!this.scripts[script.name]) {
this.scripts[script.name] = script.name;
}
},
false
]);
showScreenPopup(require('View/Popup/SieveScript'), [new SieveScriptModel()]);
}
editScript(script) {
showScreenPopup(require('View/Popup/SieveScript'), [
script,
() => {
// TODO on save
},
true
]);
showScreenPopup(require('View/Popup/SieveScript'), [script]);
}
deleteScript(script) {

View file

@ -42,6 +42,11 @@ class SieveScriptPopupView extends AbstractViewNext {
return false;
}
if (this.isNew() && SieveStore.scripts.find(item => item.name() === script.name())) {
script.nameError(true);
return false;
}
this.saving = true;
this.saveError(false);
@ -51,6 +56,7 @@ class SieveScriptPopupView extends AbstractViewNext {
if (StorageResultType.Success === result && data && data.Result) {
script.hasChanges(false);
SieveStore.scripts.push(script);
} else {
this.saveError(true);
this.saveErrorText((data && data.ErrorCode)
@ -110,11 +116,10 @@ class SieveScriptPopupView extends AbstractViewNext {
});
}
onShow(oScript, fTrueCallback, bEdit) {
this.fTrueCallback = fTrueCallback;
onShow(oScript) {
this.script(oScript);
this.rawActive(!oScript.allowFilters());
this.isNew(!bEdit);
this.isNew(!oScript.name());
this.saveError(false);
}

View file

@ -440,6 +440,7 @@ en:
BUTTON_BACK: "Back"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filters"
BUTTON_ADD_SCRIPT: "Add a Script"
BUTTON_DELETE: "Delete"
SUBNAME_NONE: "None"
SUBNAME_MOVE_TO: "Move to \"%FOLDER%\""

View file

@ -440,6 +440,7 @@ de_DE:
BUTTON_BACK: "Zurück"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filter"
BUTTON_ADD_SCRIPT: "Skript hinzufügen"
BUTTON_DELETE: "Löschen"
SUBNAME_NONE: "Keine"
SUBNAME_MOVE_TO: "Verschieben nach \"%FOLDER%\""

View file

@ -440,6 +440,7 @@ en_GB:
BUTTON_BACK: "Back"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filters"
BUTTON_ADD_SCRIPT: "Add a Script"
BUTTON_DELETE: "Delete"
SUBNAME_NONE: "None"
SUBNAME_MOVE_TO: "Move to \"%FOLDER%\""

View file

@ -440,6 +440,7 @@ en_US:
BUTTON_BACK: "Back"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filters"
BUTTON_ADD_SCRIPT: "Add a Script"
BUTTON_DELETE: "Delete"
SUBNAME_NONE: "None"
SUBNAME_MOVE_TO: "Move to \"%FOLDER%\""

View file

@ -441,6 +441,7 @@ es_ES:
BUTTON_BACK: "Atrás"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filtros"
BUTTON_ADD_SCRIPT: "Añadir un Script"
BUTTON_DELETE: "Borrar"
SUBNAME_NONE: "Ninguno"
SUBNAME_MOVE_TO: "Mover a \"%FOLDER%\""

View file

@ -441,6 +441,7 @@ fr_FR:
BUTTON_BACK: "Retour"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filtres"
BUTTON_ADD_SCRIPT: "Ajouter un Script"
BUTTON_DELETE: "Effacer"
SUBNAME_NONE: "Aucun"
SUBNAME_MOVE_TO: "Déplacer vers \"%FOLDER%\""

View file

@ -439,6 +439,7 @@ nl_NL:
BUTTON_BACK: "Terug"
SETTINGS_FILTERS:
LEGEND_FILTERS: "Filters"
BUTTON_ADD_SCRIPT: "Script toevoegen"
BUTTON_DELETE: "Verwijder"
SUBNAME_NONE: "Geen"
SUBNAME_MOVE_TO: "Verplaats naar map \"%FOLDER%\""

View file

@ -438,6 +438,7 @@ zh_CN:
BUTTON_BACK: "返回"
SETTINGS_FILTERS:
LEGEND_FILTERS: "筛选器"
BUTTON_ADD_SCRIPT: "Add a Script"
BUTTON_DELETE: "删除"
SUBNAME_NONE: "无"
SUBNAME_MOVE_TO: "移动到 \"%FOLDER%\""

View file

@ -21,7 +21,6 @@
data-bind="i18nUpdate: scripts">
<colgroup>
<col style="width: 30px" />
<col style="width: 16px" />
<col />
<col style="width: 140px" />
<col style="width: 1%" />
@ -47,6 +46,11 @@
</tr>
</tbody>
</table>
<a class="btn" data-bind="click: $root.addScript">
<i class="icon-plus"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n="SETTINGS_FILTERS/BUTTON_ADD_SCRIPT"></span>
</a>
</div>
</div>
</div>