From 63a86a70903a38e6d0e5ad0f11e6cbcf87403be9 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Mon, 16 Jun 2025 22:32:43 +0200 Subject: [PATCH] Edit/Add bookmark modal --- src/digimarks/static/css/digui.css | 12 ++++++++++ src/digimarks/static/js/digimarks.js | 18 ++++++++------ src/digimarks/templates/user_index.html | 32 ++++++++++++++++--------- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/digimarks/static/css/digui.css b/src/digimarks/static/css/digui.css index e896185..12bf6cc 100644 --- a/src/digimarks/static/css/digui.css +++ b/src/digimarks/static/css/digui.css @@ -322,6 +322,7 @@ th, td { /*padding: 1em;*/ } +[data-theme='nebula'] :modal, [data-theme='nebula'] .card, [data-theme='nebula'] button, [data-theme='nebula'] .button, @@ -329,6 +330,7 @@ th, td { [data-theme='nebula'] select, [data-theme='nebula'] textarea, [data-theme='nebula'] table, +[data-theme='nebula-dark'] :modal, [data-theme='nebula-dark'] .card, [data-theme='nebula-dark'] button, [data-theme='nebula-dark'] .button, @@ -427,6 +429,16 @@ th, td { } +/** Modal, e.g. for showing info or filling in a form; on top of the other content */ + +:modal { + color: var(--text-color); + background-color: var(--background-color); + border: 2px solid var(--border-color); + border-radius: var(--border-radius); +} + + /** Footer */ footer { diff --git a/src/digimarks/static/js/digimarks.js b/src/digimarks/static/js/digimarks.js index 1e65117..0401684 100644 --- a/src/digimarks/static/js/digimarks.js +++ b/src/digimarks/static/js/digimarks.js @@ -1,17 +1,13 @@ document.addEventListener('alpine:init', () => { Alpine.store('digimarks', { /** Main digimarks application, state etc */ - // userKey: Alpine.$persist(0).as('userKey'), userKey: -1, /* cache consists of cache[userKey] = {'bookmarks': [], 'tags': [], ??} */ cache: Alpine.$persist({}).as('cache'), bookmarks: [], - /* Bookmark that is being edited, used to fill the form etc */ - bookmark_to_edit: null, - - /* nebula (dropshadows), bbs (monospace, right lines), silo (like bbs but dark) ?? */ + /* nebula (drop-shadows), bbs (monospace, right lines), silo (like bbs but dark) ?? */ themes: ['nebula', 'nebula-dark', 'bbs', 'silo'], theme: Alpine.$persist('nebula').as('theme'), @@ -19,6 +15,8 @@ document.addEventListener('alpine:init', () => { show_bookmarks_list: Alpine.$persist(true).as('show_bookmarks_list'), show_bookmarks_cards: Alpine.$persist(false).as('show_bookmarks_cards'), show_tags: Alpine.$persist(false).as('show_tags'), + /* Bookmark that is being edited, used to fill the form, etc. */ + bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'), /* Loading indicator */ loading: false, @@ -196,7 +194,6 @@ document.addEventListener('alpine:init', () => { async toggleTagPage() { /* Show or hide the tag page instead of the bookmarks */ - console.log('Toggle tag page'); this.show_bookmarks = !this.show_bookmarks; this.show_tags = !this.show_bookmarks; }, @@ -209,9 +206,16 @@ document.addEventListener('alpine:init', () => { async startAddingBookmark() { /* Open 'add bookmark' page */ console.log('Start adding bookmark'); - this.bookmark_to_edit = { + this.bookmarkToEdit = { 'url': '' } + // this.show_bookmark_details = true; + const editFormDialog = document.getElementById("editFormDialog"); + editFormDialog.showModal(); + }, + async saveBookmark() { + console.log('Saving bookmark'); + // this.show_bookmark_details = false; }, async addBookmark() { /* Post new bookmark to the backend */ diff --git a/src/digimarks/templates/user_index.html b/src/digimarks/templates/user_index.html index 2707c4d..be85b29 100644 --- a/src/digimarks/templates/user_index.html +++ b/src/digimarks/templates/user_index.html @@ -28,8 +28,7 @@
-
+

Bookmarks

@@ -123,8 +122,7 @@

-
+

Tags

@@ -147,7 +145,13 @@
-
+

Add/Edit bookmark

{#
@@ -166,14 +170,20 @@
#} -
+ - +

+ +

+
+ + +
-
+