chg: [ui] Various improvements in factories

pull/7487/head
mokaddem 2021-06-09 14:54:41 +02:00
parent 76aceedb2b
commit 40aa613379
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
8 changed files with 54 additions and 11 deletions

View File

@ -39,8 +39,15 @@
if (!empty($action['url_params_data_paths'])) {
if (is_array($action['url_params_data_paths'])) {
$temp = array();
foreach ($action['url_params_data_paths'] as $path) {
$temp[] = h(Hash::extract($row, $path)[0]);
foreach ($action['url_params_data_paths'] as $k => $path) {
$extracted_value = Hash::extract($row, $path);
if (!empty($extracted_value)) {
if (is_string($k)) { // associative array, use cake's parameter
$temp[] = h($k) . ':' . h($extracted_value[0]);
} else {
$temp[] = h($extracted_value[0]);
}
}
}
$url_param_data_paths = implode('/', $temp);
} else {
@ -85,9 +92,25 @@
) . ' ';
} else {
if (!empty($action['onclick']) && !empty($action['onclick_params_data_path'])) {
if (is_array($action['onclick_params_data_path'])) {
$temp = array();
foreach ($action['onclick_params_data_path'] as $k => $path) {
$extracted_value = Hash::extract($row, $path);
if (!empty($extracted_value)) {
if (is_string($k)) { // associative array, use cake's parameter
$temp[] = h($k) . ':' . h($extracted_value[0]);
} else {
$temp[] = h($extracted_value[0]);
}
}
}
$onclick_params_data_path = implode('/', $temp);
} else {
$onclick_params_data_path = h(Hash::extract($row, $action['onclick_params_data_path'])[0]);
}
$action['onclick'] = str_replace(
'[onclick_params_data_path]',
h(Hash::extract($row, $action['onclick_params_data_path'])[0]),
$onclick_params_data_path,
$action['onclick']
);
}

View File

@ -2,6 +2,9 @@
$flag = Hash::extract($row, $field['data_path']);
$flag = empty($flag) ? null : $flag[0];
$icon = $text = $aria = '';
if (!is_null($flag)) {
$flag = empty($field['boolean_reverse']) ? $flag : !$flag;
}
if (is_null($flag)) {
$text = __('N/A');
$aria = __('Not applicable');

View File

@ -9,10 +9,14 @@
if (!empty($field['url_params_data_paths'])) {
if (is_array($field['url_params_data_paths'])) {
$temp = array();
foreach ($field['url_params_data_paths'] as $path) {
foreach ($field['url_params_data_paths'] as $k => $path) {
$extracted_value = Hash::extract($row, $path);
if (!empty($extracted_value)) {
$temp[] = h($extracted_value[0]);
if (is_string($k)) { // associative array, use cake's parameter
$temp[] = h($k) . ':' . h($extracted_value[0]);
} else {
$temp[] = h($extracted_value[0]);
}
}
}
$url_param_data_paths = implode('/', $temp);

View File

@ -0,0 +1,8 @@
<?php
$tag = Hash::get($row, $field['data_path']);
if (!empty($tag)) {
echo $this->element(
'tag',
['tag' => $tag]
);
}

View File

@ -30,8 +30,8 @@
}
if (!empty($data['persistUrlParams'])) {
foreach ($data['persistUrlParams'] as $persistedParam) {
if (!empty($passedArgs[$persistedParam])) {
$data['paginatorOptions']['url'][] = $passedArgs[$persistedParam];
if (!empty($passedArgsArray[$persistedParam])) {
$data['paginatorOptions']['url'][] = $passedArgsArray[$persistedParam];
}
}
}

View File

@ -15,5 +15,6 @@
echo $this->element('genericElements/accordion', [
'url' => $child['url'],
'title' => $child['title'],
'elementId' => empty($child['elementId']) ? null : $child['elementId']
'elementId' => empty($child['elementId']) ? null : $child['elementId'],
'open' => !empty($child['open']) ? $child['open'] : false
]);

View File

@ -19,7 +19,7 @@
[
* 'title' => '',
* 'url' => '', //cakephp compatible url, can be actual url or array for the constructor
* 'collapsed' => 0|1 // defaults to 0, whether to display it by default or not
* 'open' => true|false // defaults to false, whether to display it by default or not
* 'loadOn' => 'ready|expand' // load the data directly or only when expanded from a collapsed state
*
* ],
@ -64,7 +64,7 @@
);
}
}
$ajaxLists = '';
$ajaxLists = '<br/>';
if (!empty($children)) {
foreach ($children as $child) {
$ajaxLists .= $this->element(

View File

@ -21,8 +21,9 @@
)
),
sprintf(
'<div id="%s" class="accordion-body collapse"><div id="%s" class="accordion-inner" data-url="%s">&nbsp;</div></div>',
'<div id="%s" class="accordion-body collapse %s"><div id="%s" class="accordion-inner" data-url="%s">&nbsp;</div></div>',
h($elementId) . '-collapse',
!empty($open) ? 'in' : '',
h($elementId) . '-collapse-inner',
h($url)
)
@ -49,5 +50,8 @@
}
});
});
<?php if (!empty($open)): ?>
$(elementId).collapse('show')
<?php endif; ?>
});
</script>