summaryrefslogtreecommitdiff
path: root/src/main/resources
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-02 20:30:36 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-02 20:30:36 +0100
commit93da53a69a835e23ac745b9215d1cad2d0495cb1 (patch)
tree0505896b51aa8b2e5fb027f6b62a8c6961dfb1ad /src/main/resources
parentc52eb74574835eae5f3c4574065da661bde721d7 (diff)
Wiki: Show warning if attempt to save the page fails.
Change-Id: I3fbacfca1c5d5f5834797ef029d79228cdb4dde2
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/META-INF/resources/package.json2
-rw-r--r--src/main/resources/templates/benki/wiki/wikiPage.html35
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>