From da28f2f781117b4a9da9b42a02ddefa1709e94c5 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Tue, 23 Sep 2025 15:36:08 +0200 Subject: [PATCH] Ensure empty form data --- src/digimarks/static/js/digimarks.js | 15 +++++++++++---- src/digimarks/templates/user_index.html | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/digimarks/static/js/digimarks.js b/src/digimarks/static/js/digimarks.js index 447dd99..bd902eb 100644 --- a/src/digimarks/static/js/digimarks.js +++ b/src/digimarks/static/js/digimarks.js @@ -16,7 +16,7 @@ document.addEventListener('alpine:init', () => { showBookmarksCards: Alpine.$persist(false).as('showBookmarksCards'), showTags: Alpine.$persist(false).as('showTags'), /* Bookmark that is being edited, used to fill the form, etc. */ - bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'), + bookmarkToEdit: Alpine.$persist({}).as('bookmarkToEdit'), bookmarkToEditError: null, /* Loading indicator */ @@ -39,6 +39,9 @@ document.addEventListener('alpine:init', () => { /** Initialise the application after loading */ document.documentElement.setAttribute('data-theme', this.theme); console.log('Set theme', this.theme); + + /* Make sure the edit/add bookmark form has a fresh empty object */ + this.resetEditBookmark(); /* Bookmarks are refreshed through the getBookmarks() call in the HTML page */ /* await this.getBookmarks(); */ setInterval(() => { @@ -204,15 +207,19 @@ document.addEventListener('alpine:init', () => { this.showBookmarksCards = !this.showBookmarksList; }, - async startAddingBookmark() { - /* Open 'add bookmark' page */ - console.log('Start adding bookmark'); + resetEditBookmark() { this.bookmarkToEdit = { 'url': '', 'title': '', 'note': '', 'tags': '' } + + }, + async startAddingBookmark() { + /* Open 'add bookmark' page */ + console.log('Start adding bookmark'); + this.resetEditBookmark(); // this.show_bookmark_details = true; const editFormDialog = document.getElementById("editFormDialog"); editFormDialog.showModal(); diff --git a/src/digimarks/templates/user_index.html b/src/digimarks/templates/user_index.html index 297dc38..df9f2ad 100644 --- a/src/digimarks/templates/user_index.html +++ b/src/digimarks/templates/user_index.html @@ -170,7 +170,7 @@ #} -
+