From beb57b3af2f6fa716e4b1b5f8be1557e0407a4e2 Mon Sep 17 00:00:00 2001 From: Harrys Ravalomanana Date: Mon, 11 Nov 2019 15:47:11 +0400 Subject: [PATCH] PHRAS-2816 #comment hidden fields on roll over and detailled view depending on gui_editable attribute #time 6h --- .../Phrasea/Twig/PhraseanetExtension.php | 24 +++++++++++++++++++ templates/web/common/macro_caption.html.twig | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index c39271db6a..1c48a54d52 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -48,6 +48,7 @@ class PhraseanetExtension extends \Twig_Extension new \Twig_SimpleFunction('border_checker_from_fqcn', array($this, 'getCheckerFromFQCN')), new \Twig_SimpleFunction('caption_field', array($this, 'getCaptionField')), new \Twig_SimpleFunction('caption_field_label', array($this, 'getCaptionFieldLabel')), + new \Twig_SimpleFunction('caption_field_gui_editable', array($this, 'getCaptionFieldGuiEditable')), new \Twig_SimpleFunction('caption_field_order', array($this, 'getCaptionFieldOrder')), new \Twig_SimpleFunction('flag_slugify', array(Flag::class, 'normalizeName')), @@ -77,6 +78,29 @@ class PhraseanetExtension extends \Twig_Extension return ''; } + /** + * get localized field's gui_editable + * @param RecordInterface $record + * @param $fieldName + * @return string - the name gui_editable + */ + public function getCaptionFieldGuiEditable(RecordInterface $record, $fieldName) + { + if ($record) { + /** @var \appbox $appbox */ + $appbox = $this->app['phraseanet.appbox']; + $databox = $appbox->get_databox($record->getDataboxId()); + foreach ($databox->get_meta_structure() as $meta) { + /** @var \databox_field $meta */ + if ($meta->get_name() === $fieldName) { + return $meta->get_gui_editable($this->app['locale']); + } + } + } + + return ''; + } + public function getCaptionField(RecordInterface $record, $field, $value) { if ($record instanceof ElasticsearchRecord) { diff --git a/templates/web/common/macro_caption.html.twig b/templates/web/common/macro_caption.html.twig index 21a1fab40d..78b269515f 100644 --- a/templates/web/common/macro_caption.html.twig +++ b/templates/web/common/macro_caption.html.twig @@ -1,8 +1,10 @@ {% macro caption(record, can_see_business, display_exif, limitedWidth = false) %}
{% for name, value in record.getCaption(caption_field_order(record, can_see_business)) %} -
{{ caption_field_label(record, name) }}
-
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
+ {% if caption_field_gui_editable(record, name) == 1 %} +
{{ caption_field_label(record, name) }}
+
{{ caption_field(record, name, value)|e|highlight|linkify|parseColor }}
+ {% endif %} {% endfor %}
{% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %}