From d84caa97c98fcb4589e04d42612ab4eb1e3fb744 Mon Sep 17 00:00:00 2001 From: iglocska Date: Tue, 1 Jun 2021 07:46:29 +0200 Subject: [PATCH] chg: [templates] updated to support the new functionalities of localtools --- templates/Broods/index.php | 7 +++++++ templates/Common/getForm.php | 2 ++ templates/Common/index.php | 2 +- .../IndexTable/Fields/actions.php | 20 ++++++++++++++----- .../IndexTable/Fields/array_lookup_field.php | 4 +++- .../IndexTable/Fields/generic_field.php | 1 - .../SingleViews/Fields/genericField.php | 1 + .../SingleViews/Fields/jsonField.php | 19 ++++++++++++++++++ 8 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 templates/Common/getForm.php create mode 100644 templates/element/genericElements/SingleViews/Fields/jsonField.php diff --git a/templates/Broods/index.php b/templates/Broods/index.php index 8e873d4..43d454a 100644 --- a/templates/Broods/index.php +++ b/templates/Broods/index.php @@ -66,8 +66,15 @@ echo $this->element('genericElements/IndexTable/index_table', [ [ 'url' => '/broods/view', 'url_params_data_paths' => ['id'], + 'title' => __('View details'), 'icon' => 'eye' ], + [ + 'url' => '/localTools/broodTools', + 'url_params_data_paths' => ['id'], + 'title' => __('List available local tools'), + 'icon' => 'wrench' + ], [ 'open_modal' => '/broods/edit/[onclick_params_data_path]', 'modal_params_data_path' => 'id', diff --git a/templates/Common/getForm.php b/templates/Common/getForm.php new file mode 100644 index 0000000..e147f14 --- /dev/null +++ b/templates/Common/getForm.php @@ -0,0 +1,2 @@ +element('genericElements/Form/genericForm', $data); diff --git a/templates/Common/index.php b/templates/Common/index.php index 969eb89..1f0a5f6 100644 --- a/templates/Common/index.php +++ b/templates/Common/index.php @@ -1,4 +1,4 @@ element('genericElements/IndexTable/index_table', $index_table); + echo $this->element('genericElements/IndexTable/index_table', $data); echo ''; ?> diff --git a/templates/element/genericElements/IndexTable/Fields/actions.php b/templates/element/genericElements/IndexTable/Fields/actions.php index ed94a65..4e4bf61 100644 --- a/templates/element/genericElements/IndexTable/Fields/actions.php +++ b/templates/element/genericElements/IndexTable/Fields/actions.php @@ -81,11 +81,21 @@ ); } else if (!empty($action['open_modal']) && !empty($action['modal_params_data_path'])) { - $modal_url = str_replace( - '[onclick_params_data_path]', - h(Cake\Utility\Hash::extract($row, $action['modal_params_data_path'])[0]), - $action['open_modal'] - ); + if (is_array($action['modal_params_data_path'])) { + foreach ($action['modal_params_data_path'] as $k => $v) { + $modal_url = str_replace( + sprintf('{{%s}}', $k), + h(Cake\Utility\Hash::extract($row, $v)[0]), + $action['open_modal'] + ); + } + } else { + $modal_url = str_replace( + '[onclick_params_data_path]', + h(Cake\Utility\Hash::extract($row, $action['modal_params_data_path'])[0]), + $action['open_modal'] + ); + } $reload_url = !empty($action['reload_url']) ? $action['reload_url'] : $this->Url->build(['action' => 'index']); $action['onclick'] = sprintf('UI.openModalFromURL(\'%s\', \'%s\', \'%s\')', $modal_url, $reload_url, $tableRandomValue); } diff --git a/templates/element/genericElements/IndexTable/Fields/array_lookup_field.php b/templates/element/genericElements/IndexTable/Fields/array_lookup_field.php index 9f929f2..d361ef1 100644 --- a/templates/element/genericElements/IndexTable/Fields/array_lookup_field.php +++ b/templates/element/genericElements/IndexTable/Fields/array_lookup_field.php @@ -1,4 +1,6 @@ Hash->extract($row, $field['data_path'])[0]]); ?> diff --git a/templates/element/genericElements/IndexTable/Fields/generic_field.php b/templates/element/genericElements/IndexTable/Fields/generic_field.php index edff114..2ef0980 100644 --- a/templates/element/genericElements/IndexTable/Fields/generic_field.php +++ b/templates/element/genericElements/IndexTable/Fields/generic_field.php @@ -16,7 +16,6 @@ '', $data ? 'check' : 'times' ); - $data = ''; } else { $data = h($data); if (!empty($field['privacy'])) { diff --git a/templates/element/genericElements/SingleViews/Fields/genericField.php b/templates/element/genericElements/SingleViews/Fields/genericField.php index 3c54be3..cba9ff6 100644 --- a/templates/element/genericElements/SingleViews/Fields/genericField.php +++ b/templates/element/genericElements/SingleViews/Fields/genericField.php @@ -2,6 +2,7 @@ if (isset($field['raw'])) { $string = $field['raw']; } else { + $value = 1; $value = Cake\Utility\Hash::extract($data, $field['path']); $string = empty($value[0]) ? '' : $value[0]; } diff --git a/templates/element/genericElements/SingleViews/Fields/jsonField.php b/templates/element/genericElements/SingleViews/Fields/jsonField.php new file mode 100644 index 0000000..9c8b16b --- /dev/null +++ b/templates/element/genericElements/SingleViews/Fields/jsonField.php @@ -0,0 +1,19 @@ +', + h($randomId) + ); +?> + +