From 288d49021d014c6a1ba0cf19bc07f8194ff9d050 Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Tue, 28 May 2024 16:57:48 +0300 Subject: [PATCH] PHRAS-4068 expose mapping label (#4514) --- Phraseanet-production-client/config/config.js | 2 +- Phraseanet-production-client/dist/authenticate.js | 2 +- .../dist/authenticate.min.js | 2 +- Phraseanet-production-client/dist/commons.js | 2 +- Phraseanet-production-client/dist/commons.min.js | 2 +- Phraseanet-production-client/dist/production.js | 15 +++++++++++++++ .../dist/production.min.js | 15 +++++++++++++++ .../src/components/ui/workzone/index.js | 15 +++++++++++++++ .../Controller/PSExposeController.php | 12 +++++++----- lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php | 2 +- .../WorkerManager/Worker/ExposeUploadWorker.php | 12 +++++------- .../web/prod/WorkZone/ExposeFieldList.html.twig | 11 +++++++---- 12 files changed, 70 insertions(+), 22 deletions(-) diff --git a/Phraseanet-production-client/config/config.js b/Phraseanet-production-client/config/config.js index fc3e1d569a..f6aeabba9b 100644 --- a/Phraseanet-production-client/config/config.js +++ b/Phraseanet-production-client/config/config.js @@ -13,5 +13,5 @@ module.exports = { setupDir: _root + 'tests/setup/node.js', karmaConf: _root + 'config/karma.conf.js', // change this version when you change JS file for lazy loading - assetFileVersion: 104 + assetFileVersion: 105 }; diff --git a/Phraseanet-production-client/dist/authenticate.js b/Phraseanet-production-client/dist/authenticate.js index d54615cd90..44b76d7583 100644 --- a/Phraseanet-production-client/dist/authenticate.js +++ b/Phraseanet-production-client/dist/authenticate.js @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=104"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=105"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/authenticate.min.js b/Phraseanet-production-client/dist/authenticate.min.js index af3e511e76..1ef1cfd33c 100644 --- a/Phraseanet-production-client/dist/authenticate.min.js +++ b/Phraseanet-production-client/dist/authenticate.min.js @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=104"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=105"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/commons.js b/Phraseanet-production-client/dist/commons.js index 53d71ce7de..7358e8570e 100644 --- a/Phraseanet-production-client/dist/commons.js +++ b/Phraseanet-production-client/dist/commons.js @@ -91,7 +91,7 @@ /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=104"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=105"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/commons.min.js b/Phraseanet-production-client/dist/commons.min.js index cc7f876e06..2d0281bc42 100644 --- a/Phraseanet-production-client/dist/commons.min.js +++ b/Phraseanet-production-client/dist/commons.min.js @@ -91,7 +91,7 @@ /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=104"; +/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=105"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { diff --git a/Phraseanet-production-client/dist/production.js b/Phraseanet-production-client/dist/production.js index 6b1e8d2625..b5d4c0e385 100644 --- a/Phraseanet-production-client/dist/production.js +++ b/Phraseanet-production-client/dist/production.js @@ -10239,6 +10239,21 @@ var workzone = function workzone(services) { } }); + (0, _jquery2.default)('#DIALOG-field-mapping').on('click', '.checkbox-field-mapping', function () { + if ((0, _jquery2.default)(this).is(":checked")) { + var nameEl = (0, _jquery2.default)(this).attr('data-field-name'); + var inputName = (0, _jquery2.default)(this).closest('div').find('.name-expose-side'); + var labelText = (0, _jquery2.default)(this).closest('label').find('span').text(); + inputName.attr('name', nameEl); + inputName.attr('value', labelText); + inputName.removeClass('hidden'); + } else { + var _inputName = (0, _jquery2.default)(this).closest('div').find('.name-expose-side'); + _inputName.removeAttr('name'); + _inputName.addClass('hidden'); + } + }); + (0, _jquery2.default)('#DIALOG-field-mapping').on('click', '#save-subdef-mapping', function (event) { event.preventDefault(); if ((0, _jquery2.default)('#subdef-profile-mapping').val() == '') { diff --git a/Phraseanet-production-client/dist/production.min.js b/Phraseanet-production-client/dist/production.min.js index 6b1e8d2625..b5d4c0e385 100644 --- a/Phraseanet-production-client/dist/production.min.js +++ b/Phraseanet-production-client/dist/production.min.js @@ -10239,6 +10239,21 @@ var workzone = function workzone(services) { } }); + (0, _jquery2.default)('#DIALOG-field-mapping').on('click', '.checkbox-field-mapping', function () { + if ((0, _jquery2.default)(this).is(":checked")) { + var nameEl = (0, _jquery2.default)(this).attr('data-field-name'); + var inputName = (0, _jquery2.default)(this).closest('div').find('.name-expose-side'); + var labelText = (0, _jquery2.default)(this).closest('label').find('span').text(); + inputName.attr('name', nameEl); + inputName.attr('value', labelText); + inputName.removeClass('hidden'); + } else { + var _inputName = (0, _jquery2.default)(this).closest('div').find('.name-expose-side'); + _inputName.removeAttr('name'); + _inputName.addClass('hidden'); + } + }); + (0, _jquery2.default)('#DIALOG-field-mapping').on('click', '#save-subdef-mapping', function (event) { event.preventDefault(); if ((0, _jquery2.default)('#subdef-profile-mapping').val() == '') { diff --git a/Phraseanet-production-client/src/components/ui/workzone/index.js b/Phraseanet-production-client/src/components/ui/workzone/index.js index d9a8cc2f86..e8f096e947 100644 --- a/Phraseanet-production-client/src/components/ui/workzone/index.js +++ b/Phraseanet-production-client/src/components/ui/workzone/index.js @@ -285,6 +285,21 @@ const workzone = (services) => { } }); + $('#DIALOG-field-mapping').on('click', '.checkbox-field-mapping', function() { + if ($(this).is(":checked")) { + let nameEl = $(this).attr('data-field-name'); + let inputName = $(this).closest('div').find('.name-expose-side'); + let labelText = $(this).closest('label').find('span').text(); + inputName.attr('name', nameEl); + inputName.attr('value', labelText); + inputName.removeClass('hidden'); + } else { + let inputName = $(this).closest('div').find('.name-expose-side'); + inputName.removeAttr('name'); + inputName.addClass('hidden'); + } + }); + $('#DIALOG-field-mapping').on('click', '#save-subdef-mapping', function(event) { event.preventDefault(); if ($('#subdef-profile-mapping').val() == '') { diff --git a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php index 473d941c8f..ec72aaadd7 100644 --- a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php +++ b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php @@ -1035,7 +1035,7 @@ public function saveFieldMappingAction(PhraseaApplication $app, Request $request $sendGeolocField = !empty($request->request->get('sendGeolocField')) ? array_keys($request->request->get('sendGeolocField')): []; $sendVttField = !empty($request->request->get('sendVttField')) ? array_keys($request->request->get('sendVttField')) : []; - $fields = ($request->request->get('fields') === null) ? null : array_keys($request->request->get('fields')); + $fields = ($request->request->get('fields') === null) ? null : $request->request->get('fields'); $fieldMapping = [ 'sendGeolocField' => $sendGeolocField, @@ -1214,26 +1214,28 @@ private function getFields($actualFieldsList) $databoxes = $this->getApplicationBox()->get_databoxes(); $fieldFromProfile = []; - foreach ($actualFieldsList as $value) { - $t = explode('_', $value); + foreach ($actualFieldsList as $key => $value) { + $t = explode('_', $key); $databox = $this->getApplicationBox()->get_databox($t[0]); $viewName = $t[0]. ':::' .$databox->get_viewname(); - $fieldFromProfile[$viewName][$t[1]]['id'] = $value; + $fieldFromProfile[$viewName][$t[1]]['id'] = $key; $fieldFromProfile[$viewName][$t[1]]['name'] = $databox->get_meta_structure()->get_element($t[1])->get_label($this->app['locale']); + $fieldFromProfile[$viewName][$t[1]]['exposeSideName'] = $value; $fieldFromProfile[$viewName][$t[1]]['checked'] = true; } $fields = $fieldFromProfile; foreach ($databoxes as $databox) { + $viewName = $databox->get_sbas_id().':::'.$databox->get_viewname(); foreach ($databox->get_meta_structure() as $meta) { - $viewName = $databox->get_sbas_id().':::'.$databox->get_viewname(); if (!empty($fields[$viewName][$meta->get_id()]) && in_array($databox->get_sbas_id().'_'.$meta->get_id(), $fields[$viewName][$meta->get_id()])) { continue; } // get databoxID_metaID for the checkbox name $fields[$viewName][$meta->get_id()]['id'] = $databox->get_sbas_id().'_'.$meta->get_id(); $fields[$viewName][$meta->get_id()]['name'] = $meta->get_label($this->app['locale']); + $fields[$viewName][$meta->get_id()]['exposeSideName'] = $meta->get_label($this->app['locale']);; } } diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index 29b7c57c29..c6f9316873 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -63,7 +63,7 @@ public function getGlobals() { return [ // change this version when you change JS file to force the navigation to reload js file - 'assetFileVersion' => 104 + 'assetFileVersion' => 105 ]; } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php index d27cd6c182..87761c2df9 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php @@ -123,9 +123,9 @@ public function process(array $payload) $description = "
"; - foreach ($fieldListToUpload as $value) { - // value as databoxId_metaId - $t = explode('_', $value); + foreach ($fieldListToUpload as $key => $fieldLabel) { + // key as databoxId_metaId + $t = explode('_', $key); // check if it is on the same databox if ($payload['databoxId'] == $t[0]) { @@ -134,12 +134,10 @@ public function process(array $payload) // retrieve value for the corresponding field $captionField = $record->get_caption()->get_field($fieldName); $fieldValues = $captionField->get_values(); - $fieldType = $captionField->get_databox_field()->get_type(); - $fieldLabel = $helpers->getCaptionFieldLabel($record, $fieldName); - $description .= "
" . $fieldLabel. "
"; - $description .= "
" . $helpers->getCaptionField($record, $fieldName, $fieldValues). "
"; + $description .= "
" . $fieldLabel. "
"; + $description .= "
" . $helpers->getCaptionField($record, $fieldName, $fieldValues). "
"; } } } diff --git a/templates/web/prod/WorkZone/ExposeFieldList.html.twig b/templates/web/prod/WorkZone/ExposeFieldList.html.twig index daac8e64e9..26b121e39a 100644 --- a/templates/web/prod/WorkZone/ExposeFieldList.html.twig +++ b/templates/web/prod/WorkZone/ExposeFieldList.html.twig @@ -25,10 +25,13 @@
{% for metaField in field %} - +
+ + +
{% endfor %}