diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-03-13 13:30:02 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-03-13 15:48:10 +0100 |
commit | ce71f7f286819ee1399fef5f1819f9cc812149a6 (patch) | |
tree | 958d29dbd53c737182fadb61705daf50b0f6a81e /ishtar_common/templates | |
parent | 61cb345d6e39eac393c6fd8e4a8246b5221c69a9 (diff) | |
download | Ishtar-ce71f7f286819ee1399fef5f1819f9cc812149a6.tar.bz2 Ishtar-ce71f7f286819ee1399fef5f1819f9cc812149a6.zip |
✨ sheets: refactor document listing - add edit and unlink actions (refs #6221)
Diffstat (limited to 'ishtar_common/templates')
6 files changed, 73 insertions, 16 deletions
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 %} <thead> - {% for value in values %}<th class="text-center">{{value}}</th>{% endfor %} + <tr> + {% for value in values %}<th class="text-center">{{value}}</th>{% endfor %} + </tr> </thead> {% else %} <tr> 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 %} + <h3>{% trans "Associated documents" %}</h3> + {% if item.documents.count %} + <table class='table table-striped datatables' + id="{{window_id}}-docs-table"> + {% for doc in item.documents.all %}{% if not forloop.counter0 %} + <thead> + <tr> + <th> </th> + <th>{% trans "Title" %}</th> + <th>{% trans "Type" %}</th> + <th>{% trans "Authors" %}</th> + <th>{% trans "Numerical ressource" %}</th> + {% if not IS_HISTORY and permission_change_document %}<th> </th>{% endif %} + {% if not IS_HISTORY and permission_change_item %}<th> </th>{% endif %} + </tr> + </thead> + {% endif %} + <tr> + <td> + <a class="display_details" href="#" onclick="load_window('{% url 'show-document' doc.id '' %}')"><i class="fa fa-info-circle" aria-hidden="true"></i></a> + </td> + <td> + {{doc.title|default:'-'}} + </td> + <td> + {{doc.source_type|default:'-'}} + </td> + <td> + {{doc.authors_list|default:'-'}} + </td> + <td>{% if doc.associated_url %} + <a href='{{doc.associated_url}}' target="_blank">{% trans "Link" %} <i class="fa fa-external-link" aria-hidden="true"></i></a> + {% else%}-{% endif %} + </td> + {% if not IS_HISTORY and permission_change_document %}<td> + {% autoescape off %}{% if doc|can_edit_item:request %} + <a class="btn btn-success btn-sm" title="{% trans 'Edit' %}" href="{% url 'edit-document' doc.pk %}"><i class="fa fa-pencil"></i></a> + {% else %}–{% endif %}{% endautoescape %} + </td>{% endif %} + {% if not IS_HISTORY and permission_change_item %}<td> + {% autoescape off %} + <a class="btn-qa btn btn-danger btn-sm wait-button" title="{% trans 'Unlink' %}" href="#" data-target='{% url 'document-qa-unlink' doc.pk model_slug item.pk %}'><i class="fa fa-chain-broken" aria-hidden="true"></i></a> + {% endautoescape %} + </td>{% endif %} + </tr> + {% endfor %} + </table> + {% 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 %} <table id='{{window_id}}-geographic-data' class="table table-striped"> <tr> - {% if not IS_HISTORY and permission_change_geo %}<th> </th>{% endif %} <th>{% trans "Main" %}</th> <th>{% trans "Data type" %}</th> <th>{% trans "Source" %}</th> @@ -13,14 +12,10 @@ <th>{% trans "Acquisition date" %}</th> <th>{% trans "Comment" %}</th> {% if not IS_HISTORY and permission_change_geo %}<th> </th>{% endif %} + {% if not IS_HISTORY and permission_change_geo %}<th> </th>{% endif %} </tr> {% for geo in geo_item.geodata.all %} <tr> - {% if not IS_HISTORY and permission_change_geo %}<td> - {% autoescape off %} - <a title="{% trans 'Edit' %}" href="{% url 'edit-geo' geo.pk %}{% if search_url or find_id %}?{% endif %}{% if find_id %}find_id={{find_id|unlocalize}}&{% endif %}{% if search_url %}back_url={{search_url}}%3Fopen_item={{geo_item.pk|unlocalize}}{% endif %}">{% if geo|can_edit_item:request %}<i class="fa fa-pencil"></i></a>{% else %}–{% endif %} - {% endautoescape %} - </td>{% endif %} <td>{% if geo.id == geo_item.main_geodata_id %}<i class="fa fa-check-circle text-success" aria-hidden="true"></i>{% else %}–{% endif %}</td> <td>{% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %}</td> <td>{{ geo.source_label }}</td> @@ -30,11 +25,16 @@ <td>{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}</td> <td>{% if geo.acquisition_date %}{{ geo.acquisition_date|date:"DATE_FORMAT"|default:"-" }}{% else %}-{% endif %}</td> <td>{% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %}</td> + {% if not IS_HISTORY and permission_change_geo %}<td> + {% autoescape off %} + {% if geo|can_edit_item:request %}<a class="btn btn-success btn-sm" title="{% trans 'Edit' %}" href="{% url 'edit-geo' geo.pk %}{% if search_url or find_id %}?{% endif %}{% if find_id %}find_id={{find_id|unlocalize}}&{% endif %}{% if search_url %}back_url={{search_url}}%3Fopen_item={{geo_item.pk|unlocalize}}{% endif %}"><i class="fa fa-pencil"></i></a>{% else %}–{% endif %} + {% endautoescape %} + </td>{% endif %} {% if not IS_HISTORY and permission_change_geo and output != "ODT" and output != "PDF" %}<td> {% autoescape off %} - <a title="{% trans 'Delete' %}" + {% if geo|can_edit_item:request %}<a class="btn btn-danger btn-sm" title="{% trans 'Delete' %}" href="{% url 'delete-geo' geo.pk %}{% if search_url or find_id %}?{% endif %}{% if find_id %}find_id={{find_id|unlocalize}}&{% endif %}{% if search_url %}back_url={{search_url}}%3Fopen_item={{geo_item.pk|unlocalize}}{% endif %}"> - {% if geo|can_edit_item:request %}<i class="fa fa-trash text-danger"></i></a>{% else %}–{% endif %} + <i class="fa fa-trash"></i></a>{% else %}–{% endif %} {% endautoescape %} </td>{% endif %} </tr> 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 %} </div> @@ -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 @@ <h4 class="col-12">{% trans "Content" %}</h4> {% 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 %} |