From dbe85dd49847a0f2df30ae6362c26d85e3c09859 Mon Sep 17 00:00:00 2001 From: Harrys Ravalomanana Date: Thu, 30 Apr 2020 15:15:31 +0400 Subject: [PATCH] PHRAS-3047 Tools metadatas tab --- .../Controller/Prod/SubdefsController.php | 1 + .../Controller/Prod/ToolsController.php | 4 +- .../web/prod/actions/Tools/index.html.twig | 56 ++++++++++++------- .../web/prod/actions/Tools/metadata.html.twig | 2 +- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/SubdefsController.php b/lib/Alchemy/Phrasea/Controller/Prod/SubdefsController.php index eb5741d492..31658384d9 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/SubdefsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/SubdefsController.php @@ -48,6 +48,7 @@ class SubdefsController extends Controller return $this->render('prod/actions/Tools/metadata.html.twig', [ 'record' => $record, 'metadatas' => $metadataBag, + 'subdef_name' => $subdef_name ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 20291ec2c3..3b88e81237 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -47,6 +47,8 @@ class ToolsController extends Controller $record = $records->first(); $databox = $record->getDatabox(); + /**Array list of subdefs**/ + $listsubdef = array_keys($record-> get_subdefs()); // fetch subdef list: $subdefs = $record->get_subdefs(); @@ -57,7 +59,6 @@ class ToolsController extends Controller && $acl->has_right_on_base($record->getBaseId(), \ACL::IMGTOOLS) ) { $databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType()); - foreach ($subdefs as $subdef) { $label = $subdefName = $subdef->get_name(); if (null === $permalink = $subdef->get_permalink()) { @@ -94,6 +95,7 @@ class ToolsController extends Controller 'record' => $record, 'recordSubdefs' => $recordAccessibleSubdefs, 'metadatas' => $metadatas, + 'listsubdef' => $listsubdef ]); } diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 3d4cb6029c..8a043a16a6 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -194,6 +194,14 @@ {# exiftool section #} {% if metadatas %}
+
+ +
@@ -202,13 +210,12 @@
{% for subdef in recordSubdefs %} -
-
+
+
{{ subdef.label }}
-
-

- -

{% endfor %} @@ -288,20 +294,32 @@ }; {% if record is not null %} + function loadMetadataTab (url) { + console.log(url); + $.ajax({ + "url": url, + "type": "GET", + beforeSend: function () { + $('#metadata-content').empty(); + $('#metadata-load').removeClass('hidden').addClass('loading'); + }, + success: function (data) { + $('#metadata-load').removeClass('loading').addClass('hidden'); + $('#metadata-content').append(data); + } + }); + } $(document).ready(function(){ - $('.tool-metadata').click(function(e){ - $.ajax({ - "url": "{{ path('prod_subdefs_metadata', {'databox_id': record.get_sbas_id(), 'record_id': record.get_record_id, 'subdef_name': 'document'}) }}", - "type": "GET", - beforeSend: function(){ - $('#metadata-content').empty(); - $('#metadata-load').removeClass('hidden').addClass('loading'); - }, - success: function (data) { - $('#metadata-load').removeClass('loading').addClass('hidden'); - $('#metadata-content').append(data); - } - }); + /**load default Subdef info **/ + loadMetadataTab( '{{ path('prod_subdefs_metadata', {'databox_id': record.get_sbas_id(), 'record_id': record.get_record_id, 'subdef_name': 'document' }) }}'); + /**load selected Subdef info **/ + $('#select-meta-subdef').on('change', function (e) { + var selectedSubdef = $(this).children('option:selected'); + if (selectedSubdef.val() !== "") { + var url = '{{ path('prod_subdefs_metadata', {'databox_id': record.get_sbas_id(), 'record_id': record.get_record_id, 'subdef_name': 'subdefName' }) }}'; + url = url.replace("subdefName", selectedSubdef.val() ); + loadMetadataTab(url); + } }); }); {% endif %} diff --git a/templates/web/prod/actions/Tools/metadata.html.twig b/templates/web/prod/actions/Tools/metadata.html.twig index 04c2f48da0..9d3515c05d 100644 --- a/templates/web/prod/actions/Tools/metadata.html.twig +++ b/templates/web/prod/actions/Tools/metadata.html.twig @@ -6,7 +6,7 @@ height="{{thumbnail.get_height()}}" />
-

Metadatas

+

{{"prod::tool:metadata:metadatas" | trans}} : {{ subdef_name }}