chg: [element:metafield_panel] Metafield now relying on their index type when being displayed on singleViews

develop-unstable
Sami Mokaddem 2022-11-28 12:12:01 +01:00
parent 6d2f3f2ef9
commit 3dddd96eeb
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 11 additions and 5 deletions

View File

@ -79,10 +79,6 @@ class PermissionLimitationsTable extends AppTable
foreach ($metaTemplate['meta_template_fields'] as &$meta_template_field) {
$boolean = $meta_template_field['type'] === 'boolean';
foreach ($meta_template_field['metaFields'] as &$metaField) {
if ($boolean) {
$metaField['value'] = '<i class="fas fa-' . ((bool)$metaField['value'] ? 'check' : 'times') . '"></i>';
$metaField['no_escaping'] = true;
}
if (isset($permissionLimitations[$metaField['field']])) {
foreach ($permissionLimitations[$metaField['field']] as $scope => $value) {
$messageType = 'warning';

View File

@ -1,10 +1,12 @@
<?php
use \Cake\Routing\Router;
use \Cake\Utility\Hash;
$tabData = [
'navs' => [],
'content' => []
];
$viewElementCandidatePath = '/genericElements/SingleViews/Fields/';
foreach($data['MetaTemplates'] as $metaTemplate) {
if (!empty($metaTemplate->meta_template_fields)) {
$tabData['navs'][] = [
@ -15,9 +17,17 @@ foreach($data['MetaTemplates'] as $metaTemplate) {
$labelPrintedOnce = false;
if (!empty($metaTemplateField->metaFields)) {
foreach ($metaTemplateField->metaFields as $metaField) {
$viewElementCandidate = $metaTemplateField->index_type == 'text' ? 'generic' : $metaTemplateField->index_type; // Currently, single-view generic fields are not using index-view fields
$fields[] = [
'key' => !$labelPrintedOnce ? $metaField->field : '',
'raw' => $metaField->value,
// Not relying on the `type` option as this table is a special case where not all values have a label
'raw' => $this->element(sprintf('%s%sField', $viewElementCandidatePath, $viewElementCandidate), [
'data' => $metaField,
'field' => [
'path' => 'value',
]
]),
'rawNoEscaping' => true,
'warning' => $metaField->warning ?? null,
'info' => $metaField->info ?? null,
'danger' => $metaField->danger ?? null