diff --git a/src/digimarks/static/css/digimarks.css b/src/digimarks/static/css/digimarks.css index c37ef00..a88047b 100644 --- a/src/digimarks/static/css/digimarks.css +++ b/src/digimarks/static/css/digimarks.css @@ -22,4 +22,12 @@ .thumbnail img { /*width: 72px;*/ width: 60px; -} \ No newline at end of file +} + +#bookmarkEditForm fieldset { + border: none; +} + +#bookmarkEditForm fieldset input, #bookmarkEditForm textarea, #bookmarkEditForm select, #bookmarkEditForm label { + width: 100%; +} diff --git a/src/digimarks/static/js/digimarks.js b/src/digimarks/static/js/digimarks.js index b35cc71..447dd99 100644 --- a/src/digimarks/static/js/digimarks.js +++ b/src/digimarks/static/js/digimarks.js @@ -17,6 +17,7 @@ document.addEventListener('alpine:init', () => { showTags: Alpine.$persist(false).as('showTags'), /* Bookmark that is being edited, used to fill the form, etc. */ bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'), + bookmarkToEditError: null, /* Loading indicator */ loading: false, @@ -207,12 +208,42 @@ document.addEventListener('alpine:init', () => { /* Open 'add bookmark' page */ console.log('Start adding bookmark'); this.bookmarkToEdit = { - 'url': '' + 'url': '', + 'title': '', + 'note': '', + 'tags': '' } // this.show_bookmark_details = true; const editFormDialog = document.getElementById("editFormDialog"); editFormDialog.showModal(); }, + async bookmarkURLChanged() { + console.log('Bookmark URL changed'); + // let response = await fetch('/api/v1/' + this.userKey + '/autocomplete_bookmark/'); + try { + const response = await fetch('/api/v1/' + this.userKey + '/autocomplete_bookmark/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + // Bookmark form data + url: this.bookmarkToEdit.url, + title: this.bookmarkToEdit.title, + note: this.bookmarkToEdit.note, + tags: this.bookmarkToEdit.tags + }) + }); + const data = await response.json(); + // TODO: update form fields if needed (auto-fetched title for example + console.log(data); + this.bookmarkToEditError = 'lolwut'; + } catch (error) { + // enter your logic for when there is an error (ex. error toast) + + console.log(error) + } + }, async saveBookmark() { console.log('Saving bookmark'); // this.show_bookmark_details = false; diff --git a/src/digimarks/templates/user_index.html b/src/digimarks/templates/user_index.html index 21f0233..297dc38 100644 --- a/src/digimarks/templates/user_index.html +++ b/src/digimarks/templates/user_index.html @@ -170,8 +170,32 @@ #} -
- + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+