chg: [templates] updated to support the new functionalities of localtools

connector
iglocska 2021-06-01 07:46:29 +02:00
parent cc31a22527
commit d84caa97c9
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
8 changed files with 48 additions and 8 deletions

View File

@ -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',

View File

@ -0,0 +1,2 @@
<?php
echo $this->element('genericElements/Form/genericForm', $data);

View File

@ -1,4 +1,4 @@
<?php
echo $this->element('genericElements/IndexTable/index_table', $index_table);
echo $this->element('genericElements/IndexTable/index_table', $data);
echo '</div>';
?>

View File

@ -81,11 +81,21 @@
);
} else if (!empty($action['open_modal']) && !empty($action['modal_params_data_path'])) {
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);
}

View File

@ -1,4 +1,6 @@
<?php
if (!isset($arrayData) && isset($field['arrayData'])) {
$arrayData = $field['arrayData'];
}
echo h($arrayData[$this->Hash->extract($row, $field['data_path'])[0]]);
?>

View File

@ -16,7 +16,6 @@
'<i class="fa fa-%s"></i>',
$data ? 'check' : 'times'
);
$data = '';
} else {
$data = h($data);
if (!empty($field['privacy'])) {

View File

@ -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];
}

View File

@ -0,0 +1,19 @@
<?php
$randomId = Cake\Utility\Security::randomString(8);
if (isset($field['raw'])) {
$string = $field['raw'];
} else {
$value = Cake\Utility\Hash::extract($data, $field['path']);
$string = empty($value[0]) ? '' : $value[0];
}
echo sprintf(
'<div class="json_container_%s"></div>',
h($randomId)
);
?>
<script type="text/javascript">
$(document).ready(function() {
$('.json_container_<?php echo h($randomId);?>').html(syntaxHighlightJson(<?php echo json_encode($string); ?>, 4));
});
</script>