From fc427e26493d4bd070c09e5dbc348a1355c00e38 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 13 Feb 2020 05:00:54 +0100 Subject: Add /bookmarks/new endpoint. Change-Id: I903dbf5f918e1478fff82e5ebf6f3e3e2766572d --- .../bookmarks/MlkBookmarkSubmissionForm.js | 22 +++++++++++++----- .../META-INF/resources/bookmarks/newBookmark.js | 4 ++++ .../templates/benki/bookmarks/newBookmark.html | 26 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/META-INF/resources/bookmarks/newBookmark.js create mode 100644 src/main/resources/templates/benki/bookmarks/newBookmark.html (limited to 'src/main/resources') 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` -
+
New Bookmark
+ value=${this.getAttribute("uri") || ""} + @blur=${this.onUriBlur.bind(this)} />
- +
- +
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(); +}); diff --git a/src/main/resources/templates/benki/bookmarks/newBookmark.html b/src/main/resources/templates/benki/bookmarks/newBookmark.html new file mode 100644 index 0000000..cb3147d --- /dev/null +++ b/src/main/resources/templates/benki/bookmarks/newBookmark.html @@ -0,0 +1,26 @@ +{@java.util.List bookmarks} +{@java.lang.Boolean authenticated} + +{#include base.html} + +{#title}Benki Bookmarks{/title} +{#siteSection}Bookmarks{/siteSection} +{#bookmarksClass}this-page{/bookmarksClass} + +{#head}{/head} + +{#body} + + + + + + + +{/body} + +{/include} -- cgit v1.2.3