From 8825aa8a4513931afafeda107f9543fed9d8e175 Mon Sep 17 00:00:00 2001 From: Andria Capai Date: Fri, 22 Mar 2024 13:15:25 +0100 Subject: [PATCH] feat: dataTable on media Add sort, paginate, search features on table article Reviewed-by: andriac --- atlas/static/otherInformations.js | 36 +++++++++ .../speciesSheet/otherInformations.html | 78 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 atlas/static/otherInformations.js diff --git a/atlas/static/otherInformations.js b/atlas/static/otherInformations.js new file mode 100644 index 00000000..b1c15b74 --- /dev/null +++ b/atlas/static/otherInformations.js @@ -0,0 +1,36 @@ +$(document).ready(function() { + const table = $("#table_articles").DataTable({ + "paging": true, + "ordering": true, + "info": true, + "language": { + url: '//cdn.datatables.net/plug-ins/2.0.2/i18n/fr-FR.json', + }, + "columnDefs": [ + { "orderable": false, "targets": [0, 3] } + ] + }); + + $("#table_articles").on("click", "tr", function () { + const row = table.row(this); + const iconElement = $(this).find('.btn-more'); + if (row.child.isShown()) { + row.child.hide(); + $(this).removeClass("shown"); + iconElement.removeClass("fa-chevron-down").addClass("fa-chevron-right"); + } else { + const articleIndex = row.index(); + const article = articles[articleIndex]; + + row.child( + "
" + + "Description:" + + `${article.description}` + "
" + + "Date: " + `${article.date}` + + "
" + ).show(); + $(this).addClass("shown"); + iconElement.removeClass("fa-chevron-right").addClass("fa-chevron-down") + } + }); +}); diff --git a/atlas/templates/speciesSheet/otherInformations.html b/atlas/templates/speciesSheet/otherInformations.html index ef6a9e1b..004f56a8 100644 --- a/atlas/templates/speciesSheet/otherInformations.html +++ b/atlas/templates/speciesSheet/otherInformations.html @@ -1,3 +1,12 @@ +{% block additionalHeaderAssets %} + + + + + + +{% endblock %} + {% block otherInformations %}
@@ -31,6 +40,68 @@ +
+ + {% if articles | length != 0 %} +
+ + + + + + + + + + + {% for article in articles %} + {% set data = article %} + + + + + + + {% endfor %} + +
{{ _('title') }}{{ _('author') }}
+ {% if article.id_type == 3 %} + + {% else %} + + {% endif %} + + {{ article.title | safe }} + {{ article.author }} + +
+ +
+ {% endif %} + {% if articles | length != 0 %} +