1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 23:05:10 +01:00

Ensure empty form data

This commit is contained in:
2025-09-23 15:36:08 +02:00
parent 987a030c4f
commit da28f2f781
2 changed files with 12 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ document.addEventListener('alpine:init', () => {
showBookmarksCards: Alpine.$persist(false).as('showBookmarksCards'), showBookmarksCards: Alpine.$persist(false).as('showBookmarksCards'),
showTags: Alpine.$persist(false).as('showTags'), showTags: Alpine.$persist(false).as('showTags'),
/* Bookmark that is being edited, used to fill the form, etc. */ /* Bookmark that is being edited, used to fill the form, etc. */
bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'), bookmarkToEdit: Alpine.$persist({}).as('bookmarkToEdit'),
bookmarkToEditError: null, bookmarkToEditError: null,
/* Loading indicator */ /* Loading indicator */
@@ -39,6 +39,9 @@ document.addEventListener('alpine:init', () => {
/** Initialise the application after loading */ /** Initialise the application after loading */
document.documentElement.setAttribute('data-theme', this.theme); document.documentElement.setAttribute('data-theme', this.theme);
console.log('Set 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 */ /* Bookmarks are refreshed through the getBookmarks() call in the HTML page */
/* await this.getBookmarks(); */ /* await this.getBookmarks(); */
setInterval(() => { setInterval(() => {
@@ -204,15 +207,19 @@ document.addEventListener('alpine:init', () => {
this.showBookmarksCards = !this.showBookmarksList; this.showBookmarksCards = !this.showBookmarksList;
}, },
async startAddingBookmark() { resetEditBookmark() {
/* Open 'add bookmark' page */
console.log('Start adding bookmark');
this.bookmarkToEdit = { this.bookmarkToEdit = {
'url': '', 'url': '',
'title': '', 'title': '',
'note': '', 'note': '',
'tags': '' 'tags': ''
} }
},
async startAddingBookmark() {
/* Open 'add bookmark' page */
console.log('Start adding bookmark');
this.resetEditBookmark();
// this.show_bookmark_details = true; // this.show_bookmark_details = true;
const editFormDialog = document.getElementById("editFormDialog"); const editFormDialog = document.getElementById("editFormDialog");
editFormDialog.showModal(); editFormDialog.showModal();

View File

@@ -170,7 +170,7 @@
</span> </span>
</div> </div>
#} #}
<form method="dialog" id="bookmarkEditForm"> <form method="dialog" id="bookmarkEditForm" x-if="$store.digimarks.bookmarkToEdit">
<fieldset class="form-group"> <fieldset class="form-group">
<label for="bookmark_url">URL</label> <label for="bookmark_url">URL</label>
<input id="bookmark_url" type="text" name="bookmark_url" placeholder="url" <input id="bookmark_url" type="text" name="bookmark_url" placeholder="url"