From ce71f7f286819ee1399fef5f1819f9cc812149a6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 13 Mar 2025 13:30:02 +0100 Subject: ✨ sheets: refactor document listing - add edit and unlink actions (refs #6221) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/ishtar/blocks/api_document_list.html | 4 +- .../ishtar/blocks/sheet_document_list.html | 53 ++++++++++++++++++++++ .../templates/ishtar/blocks/sheet_geographic.html | 16 +++---- ishtar_common/templates/ishtar/sheet_area.html | 7 +-- ishtar_common/templates/ishtar/sheet_document.html | 2 +- ishtar_common/templates/ishtar/sheet_town.html | 7 +-- 6 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 ishtar_common/templates/ishtar/blocks/sheet_document_list.html (limited to 'ishtar_common/templates') diff --git a/ishtar_common/templates/ishtar/blocks/api_document_list.html b/ishtar_common/templates/ishtar/blocks/api_document_list.html index 251885a19..2b2380496 100644 --- a/ishtar_common/templates/ishtar/blocks/api_document_list.html +++ b/ishtar_common/templates/ishtar/blocks/api_document_list.html @@ -2,7 +2,9 @@ id="{{window_id}}-docs-table"> {% for values in item.documents_list %}{% if not forloop.counter0 %} - {% for value in values %}{{value}}{% endfor %} + + {% for value in values %}{{value}}{% endfor %} + {% else %} diff --git a/ishtar_common/templates/ishtar/blocks/sheet_document_list.html b/ishtar_common/templates/ishtar/blocks/sheet_document_list.html new file mode 100644 index 000000000..1a1849636 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/sheet_document_list.html @@ -0,0 +1,53 @@ +{% load i18n l10n ishtar_helpers link_to_window %} + {% with can_edit_current_item=item|can_edit_item:request %} +

{% trans "Associated documents" %}

+ {% if item.documents.count %} + + {% for doc in item.documents.all %}{% if not forloop.counter0 %} + + + + + + + + {% if not IS_HISTORY and permission_change_document %}{% endif %} + {% if not IS_HISTORY and permission_change_item %}{% endif %} + + + {% endif %} + + + + + + + {% if not IS_HISTORY and permission_change_document %}{% endif %} + {% if not IS_HISTORY and permission_change_item %}{% endif %} + + {% endfor %} +
 {% trans "Title" %}{% trans "Type" %}{% trans "Authors" %}{% trans "Numerical ressource" %}  
+ + + {{doc.title|default:'-'}} + + {{doc.source_type|default:'-'}} + + {{doc.authors_list|default:'-'}} + {% if doc.associated_url %} + {% trans "Link" %} + {% else%}-{% endif %} + + {% autoescape off %}{% if doc|can_edit_item:request %} + + {% else %}–{% endif %}{% endautoescape %} + + {% autoescape off %} + + {% endautoescape %} +
+ {% elif item.documents_list %} + {% include "ishtar/blocks/api_document_list.html" %} + {% endif %} + {% endwith %} diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html index 12846ef78..6212c9573 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html @@ -2,7 +2,6 @@ {% with search_url=item.get_search_url %} - {% if not IS_HISTORY and permission_change_geo %}{% endif %} @@ -13,14 +12,10 @@ {% if not IS_HISTORY and permission_change_geo %}{% endif %} + {% if not IS_HISTORY and permission_change_geo %}{% endif %} {% for geo in geo_item.geodata.all %} - {% if not IS_HISTORY and permission_change_geo %}{% endif %} @@ -30,11 +25,16 @@ + {% if not IS_HISTORY and permission_change_geo %}{% endif %} {% if not IS_HISTORY and permission_change_geo and output != "ODT" and output != "PDF" %}{% endif %} diff --git a/ishtar_common/templates/ishtar/sheet_area.html b/ishtar_common/templates/ishtar/sheet_area.html index c4f67885e..682722dcd 100644 --- a/ishtar_common/templates/ishtar/sheet_area.html +++ b/ishtar_common/templates/ishtar/sheet_area.html @@ -92,8 +92,9 @@ {% endcomment %} {% if display_documents and item.documents.count %} - {% trans "Documents" as area_docs %} - {% dynamic_table_document area_docs 'documents' 'areas' item.pk '' output %} + {% with permission_change_item=item|can_edit_item:request %} + {% include "ishtar/blocks/sheet_document_list.html" %} + {% endwith %} {% endif %} @@ -126,4 +127,4 @@ $(document).ready( function () { {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/ishtar_common/templates/ishtar/sheet_document.html b/ishtar_common/templates/ishtar/sheet_document.html index 02c32638b..ca382f137 100644 --- a/ishtar_common/templates/ishtar/sheet_document.html +++ b/ishtar_common/templates/ishtar/sheet_document.html @@ -58,7 +58,7 @@

{% trans "Content" %}

{% trans "File" context "Not directory" as file_label %} {% field_flex_file file_label item.associated_file %} - {% trans "Web link" as weblink_label %} + {% trans "Numerical ressource (web address)" as weblink_label %} {% field_flex_url weblink_label item.associated_url %} {% field_flex_multiple_obj "Tags" item 'tags' %} {% endif %} diff --git a/ishtar_common/templates/ishtar/sheet_town.html b/ishtar_common/templates/ishtar/sheet_town.html index e92c03b54..235182993 100644 --- a/ishtar_common/templates/ishtar/sheet_town.html +++ b/ishtar_common/templates/ishtar/sheet_town.html @@ -116,8 +116,9 @@ {% endif %} {% if display_documents and item.documents.count %} - {% trans "Documents" as town_docs %} - {% dynamic_table_document town_docs 'documents' 'towns' item.pk '' output %} + {% with permission_change_item=item|can_edit_item:request %} + {% include "ishtar/blocks/sheet_document_list.html" %} + {% endwith %} {% endif %} {% if perm_files and item.file.count %} @@ -167,4 +168,4 @@ $(document).ready( function () { {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} -{% endblock %} \ No newline at end of file +{% endblock %} -- cgit v1.2.3
 {% trans "Main" %} {% trans "Data type" %} {% trans "Source" %}{% trans "Acquisition date" %} {% trans "Comment" %}  
- {% autoescape off %} - {% if geo|can_edit_item:request %}{% else %}–{% endif %} - {% endautoescape %} - {% if geo.id == geo_item.main_geodata_id %}{% else %}–{% endif %} {% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %} {{ geo.source_label }}{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %} {% if geo.acquisition_date %}{{ geo.acquisition_date|date:"DATE_FORMAT"|default:"-" }}{% else %}-{% endif %} {% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %} + {% autoescape off %} + {% if geo|can_edit_item:request %}{% else %}–{% endif %} + {% endautoescape %} + {% autoescape off %} - - {% if geo|can_edit_item:request %}{% else %}–{% endif %} + {% else %}–{% endif %} {% endautoescape %}