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, nameError: false,
bodyError: false, bodyError: false,
deleteAccess: false, deleteAccess: false,
canBeDeleted: false, canBeDeleted: true,
hasChanges: false hasChanges: false
}); });

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,7 +21,6 @@
data-bind="i18nUpdate: scripts"> data-bind="i18nUpdate: scripts">
<colgroup> <colgroup>
<col style="width: 30px" /> <col style="width: 30px" />
<col style="width: 16px" />
<col /> <col />
<col style="width: 140px" /> <col style="width: 140px" />
<col style="width: 1%" /> <col style="width: 1%" />
@ -47,6 +46,11 @@
</tr> </tr>
</tbody> </tbody>
</table> </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> </div>
</div> </div>