diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/resources/META-INF/resources/package.json | 2 | ||||
-rw-r--r-- | src/main/resources/templates/benki/wiki/wikiPage.html | 35 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/main/resources/META-INF/resources/package.json b/src/main/resources/META-INF/resources/package.json index 2a3623e..d0657d4 100644 --- a/src/main/resources/META-INF/resources/package.json +++ b/src/main/resources/META-INF/resources/package.json @@ -21,7 +21,7 @@ "ContentTools/build/content-tools.min.css", "ContentTools/build/images/*", "bosonic", - "elix", + "elix/define/*.js", "lit-html", "normalize-opentype.css/normalize-opentype.css", "normalize.css/normalize.css", diff --git a/src/main/resources/templates/benki/wiki/wikiPage.html b/src/main/resources/templates/benki/wiki/wikiPage.html index 9f3c741..3cd522c 100644 --- a/src/main/resources/templates/benki/wiki/wikiPage.html +++ b/src/main/resources/templates/benki/wiki/wikiPage.html @@ -6,6 +6,15 @@ {#head} <link rel="stylesheet" type="text/css" href="/web_modules/ContentTools/build/content-tools.min.css" /> +<script type="module" src="/web_modules/elix/define/ExpandablePanel.js"></script> + +<style type="text/css"> + #warning-panel { + background-color: lightcoral; + font-style: italic; + } +</style> + <script type="module"> import ContentTools from "/web_modules/ContentTools.js"; @@ -14,6 +23,8 @@ editor.init('*[data-editable]', 'data-name'); editor.addEventListener('saved', async function (ev) { + document.getElementById("warning-panel").close(); + let regions = ev.detail().regions; if (Object.getOwnPropertyNames(regions).length === 0) { // Nothing changed. @@ -32,13 +43,23 @@ body: requestParams }); + if (!response.ok) { + document.getElementById("warning-panel").open(); + document.getElementById("warning-text").innerText = "Failed to save page: " + response.statusText; + this.busy(false); + return; + } + let status = await response.json(); - if (status.status === "ok") { - if (status.hasOwnProperty("content")) { - document.getElementById("wiki-content").innerHTML = status.content; - } - } else { - alert("Failed to save page: " + JSON.stringify(status)); + if (status.status !== "ok") { + document.getElementById("warning-panel").open(); + document.getElementById("warning-text").innerText = "Failed to save page: " + JSON.stringify(status); + this.busy(false); + return; + } + + if (status.hasOwnProperty("content")) { + document.getElementById("wiki-content").innerHTML = status.content; } this.busy(false); @@ -53,6 +74,8 @@ <div data-editable data-name="wiki-title"> <h1>{page.title}</h1> </div> + + <elix-expandable-panel id="warning-panel"><div id="warning-text"></div></elix-expandable-panel> </header> <main> |