summaryrefslogtreecommitdiff
path: root/src/main/resources/META-INF
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-13 05:00:54 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-13 05:00:54 +0100
commitfc427e26493d4bd070c09e5dbc348a1355c00e38 (patch)
treedf04f0b158373549c6cc333f0de834f3e2be9f80 /src/main/resources/META-INF
parent6991257cd67631efae78e141b8ae7794129483c1 (diff)
Add /bookmarks/new endpoint.
Change-Id: I903dbf5f918e1478fff82e5ebf6f3e3e2766572d
Diffstat (limited to 'src/main/resources/META-INF')
-rw-r--r--src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js22
-rw-r--r--src/main/resources/META-INF/resources/bookmarks/newBookmark.js4
2 files changed, 21 insertions, 5 deletions
diff --git a/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js b/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js
index 25de54b..313268d 100644
--- a/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js
+++ b/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js
@@ -21,7 +21,16 @@ export class MlkBookmarkSubmissionForm extends HTMLElement {
focus() {
let uriInput = this.shadowRoot.getElementById('uri-input');
- uriInput.focus();
+ let titleInput = this.shadowRoot.getElementById('title-input');
+ let descriptionInput = this.shadowRoot.getElementById('description-input');
+
+ if (!uriInput.value) {
+ uriInput.focus();
+ } else if (!titleInput.value) {
+ titleInput.focus();
+ } else {
+ descriptionInput.focus();
+ }
}
async onUriBlur() {
@@ -54,25 +63,28 @@ export class MlkBookmarkSubmissionForm extends HTMLElement {
const template = html`
<link rel="stylesheet" type="text/css" href="/cms2/base.css" />
- <form class="pure-form pure-form-aligned" method="post">
+ <form class="pure-form pure-form-aligned" method="post" action="/bookmarks">
<fieldset>
<legend>New Bookmark</legend>
<div class="pure-control-group">
<label for="uri-input">URI:</label>
<input name="uri" id="uri-input" type="text" placeholder="URI" required
- @blur=${this.onUriBlur.bind(this)}/>
+ value=${this.getAttribute("uri") || ""}
+ @blur=${this.onUriBlur.bind(this)} />
<elix-progress-spinner id="uri-spinner" hidden></elix-progress-spinner>
</div>
<div class="pure-control-group">
<label for="title-input">Title:</label>
- <input name="title" id="title-input" type="text" placeholder="Title" required/>
+ <input name="title" id="title-input" type="text" placeholder="Title" required
+ value="${this.getAttribute("title") || ""}" />
</div>
<div class="pure-control-group">
<label for="description-input">Description:</label>
- <textarea name="description" id="description-input" placeholder="Description"></textarea>
+ <textarea name="description" id="description-input" placeholder="Description"
+ >${this.getAttribute("description") || ""}</textarea>
</div>
<div class="pure-control-group">
diff --git a/src/main/resources/META-INF/resources/bookmarks/newBookmark.js b/src/main/resources/META-INF/resources/bookmarks/newBookmark.js
new file mode 100644
index 0000000..0594c67
--- /dev/null
+++ b/src/main/resources/META-INF/resources/bookmarks/newBookmark.js
@@ -0,0 +1,4 @@
+document.addEventListener('DOMContentLoaded', () => {
+ let bookmarkSubmissionForm = document.getElementById('bookmark-submission-form');
+ bookmarkSubmissionForm.focus();
+});