From f76f9e42d6097f326a3ed2039f7b09de27953896 Mon Sep 17 00:00:00 2001 From: roberto Date: Mon, 20 Jan 2025 16:09:33 +0100 Subject: [PATCH] Item shares list on form --- assets/static/js/main.js | 16 +++---- assets/templates/items/form.tmpl | 8 ++-- assets/templates/items/relations.tmpl | 4 +- assets/templates/items/shares.tmpl | 63 +++++++++------------------ cmd/web/items_handlers.go | 19 +++++++- models/item.go | 13 ++++++ 6 files changed, 64 insertions(+), 59 deletions(-) diff --git a/assets/static/js/main.js b/assets/static/js/main.js index 41f1663..9fbc2b7 100644 --- a/assets/static/js/main.js +++ b/assets/static/js/main.js @@ -192,21 +192,21 @@ function bm_type_field_undelete(sender, type_field_id) { document.getElementById('Field-' + type_field_id).classList.remove('field-opaque'); } -function bm_item_relation_delete(sender, relation_name, relation_name_remove) { - document.getElementById(relation_name_remove).value = '1'; +function bm_element_list_delete(sender, element_name, element_name_remove) { + document.getElementById(element_name_remove).value = '1'; sender.hidden = true; - document.getElementById('Undelete-' + relation_name).hidden = false; - var x = document.getElementsByClassName(relation_name + "-Col"); + document.getElementById('Undelete-' + element_name).hidden = false; + var x = document.getElementsByClassName(element_name + "-Col"); for (var i = 0; i < x.length; i++) { x[i].classList.add("field-opaque"); } } -function bm_item_relation_undelete(sender, relation_name, relation_name_remove) { - document.getElementById(relation_name_remove).value = ''; +function bm_element_list_undelete(sender, element_name, element_name_remove) { + document.getElementById(element_name_remove).value = ''; sender.hidden = true; - document.getElementById('Delete-' + relation_name).hidden = false; - var x = document.getElementsByClassName(relation_name + "-Col"); + document.getElementById('Delete-' + element_name).hidden = false; + var x = document.getElementsByClassName(element_name + "-Col"); for (var i = 0; i < x.length; i++) { x[i].classList.remove("field-opaque"); } diff --git a/assets/templates/items/form.tmpl b/assets/templates/items/form.tmpl index c0b04f3..c791662 100644 --- a/assets/templates/items/form.tmpl +++ b/assets/templates/items/form.tmpl @@ -6,7 +6,7 @@ {{ end }} {{ $shares_present := false }} -{{ if (gt (len (index .item.FieldsSection "fields")) 0) }} +{{ if (gt (len .item.Shares) 0) }} {{ $shares_present = true }} {{ end }} @@ -18,7 +18,7 @@ Fields {{ end }} Relations - {{ if $fields_present }} + {{ if $shares_present }} Shares {{ end }} @@ -108,9 +108,9 @@ {{ if $shares_present }} -