From 7e45ffab7416f014c34d03da71ec65ad38d9a455 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 22 Sep 2024 18:53:42 +0200 Subject: [PATCH] Get the Sieve GUI partially working --- dev/Sieve/Commands/Tests.js | 4 ++-- dev/Sieve/Model/Script.js | 5 +++++ dev/Sieve/Parser.js | 1 + dev/Sieve/View/Script.js | 5 +++++ snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html | 4 +++- snappymail/v/0.0.0/app/templates/Views/Sieve/AnyOfTest.html | 4 +++- .../v/0.0.0/app/templates/Views/Sieve/ElsIfCommand.html | 4 +++- .../v/0.0.0/app/templates/Views/Sieve/ElseCommand.html | 4 +++- snappymail/v/0.0.0/app/templates/Views/Sieve/IfCommand.html | 4 +++- snappymail/v/0.0.0/app/templates/Views/Sieve/NotTest.html | 2 +- .../v/0.0.0/app/templates/Views/User/PopupsSieveScript.html | 4 ++++ 11 files changed, 33 insertions(+), 8 deletions(-) diff --git a/dev/Sieve/Commands/Tests.js b/dev/Sieve/Commands/Tests.js index ef6ba50d7..e5eb4a341 100644 --- a/dev/Sieve/Commands/Tests.js +++ b/dev/Sieve/Commands/Tests.js @@ -40,7 +40,7 @@ export class AddressTest extends TestCommand this.header_list = new GrammarStringList; this.key_list = new GrammarStringList; // rfc5260#section-6 - this.index = new GrammarNumber; + this.index = new GrammarNumber(''); this.last = false; // rfc5703#section-6 // this.mime @@ -234,7 +234,7 @@ export class HeaderTest extends TestCommand this.header_names = new GrammarStringList; this.key_list = new GrammarStringList; // rfc5260#section-6 - this.index = new GrammarNumber; + this.index = new GrammarNumber(''); this.last = false; // rfc5703#section-6 this.mime = false; diff --git a/dev/Sieve/Model/Script.js b/dev/Sieve/Model/Script.js index d9182dd98..445062604 100644 --- a/dev/Sieve/Model/Script.js +++ b/dev/Sieve/Model/Script.js @@ -1,6 +1,7 @@ import { AbstractModel } from 'Sieve/Model/Abstract'; import { FilterModel } from 'Sieve/Model/Filter'; import { koArrayWithDestroy } from 'Sieve/Utils'; +import { parseScript } from 'Sieve/Parser'; const SIEVE_FILE_NAME = 'rainloop.user'; @@ -299,6 +300,10 @@ export class SieveScriptModel extends AbstractModel return SIEVE_FILE_NAME === this.name(); } + parse() { + return parseScript(this.body(), this.name()); + } + /** * @static * @param {FetchJsonScript} json diff --git a/dev/Sieve/Parser.js b/dev/Sieve/Parser.js index 467efc3bf..6d36eea04 100644 --- a/dev/Sieve/Parser.js +++ b/dev/Sieve/Parser.js @@ -291,5 +291,6 @@ export const parseScript = (script, name = 'script.sieve') => { } tree.requires = requires; + tree.toString = () => tree.join('\r\n'); return tree; }; diff --git a/dev/Sieve/View/Script.js b/dev/Sieve/View/Script.js index 047eae50f..c7c3dcfcf 100644 --- a/dev/Sieve/View/Script.js +++ b/dev/Sieve/View/Script.js @@ -132,6 +132,11 @@ export class SieveScriptPopupView extends rl.pluginPopupView { }); } + templateName(obj) { + const id = 'Sieve' + obj.constructor.name; + return document.getElementById(id) ? id : null; + } + beforeShow(oScript) { // onShow(oScript) { this.sieveCapabilities(capa.join(' ')); diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html index 897692357..8a93257f9 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html @@ -1,3 +1,5 @@ allof -
+