fix: [users:view] Correctly reload authkey child panel when performing operations

cli-modification-summary
Sami Mokaddem 2022-01-27 10:21:55 +01:00
parent 789bd9926f
commit dc8710d89e
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'data' => [
'type' => 'simple',
'text' => __('Add authentication key'),
'popover_url' => '/authKeys/add'
'popover_url' => '/authKeys/add',
'reload_url' => $this->request->getRequestTarget()
]
]
],
@ -65,7 +66,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
[
'open_modal' => '/authKeys/delete/[onclick_params_data_path]',
'modal_params_data_path' => 'id',
'icon' => 'trash'
'icon' => 'trash',
'reload_url' => $this->request->getRequestTarget()
]
]
]

View File

@ -1,8 +1,10 @@
<?php
$seed = 'f_' . mt_rand();
if (!isset($data['requirement']) || $data['requirement']) {
if (!empty($data['popover_url'])) {
$onClick = sprintf(
'onClick="openModalForButton(this, \'%s\', \'%s\')"',
'onClick="openModalForButton%s(this, \'%s\', \'%s\')"',
$seed,
h($data['popover_url']),
h(!empty($data['reload_url']) ? $data['reload_url'] : '')
);
@ -70,7 +72,7 @@
?>
<script>
function openModalForButton(clicked, url, reloadUrl='') {
function openModalForButton<?= $seed ?>(clicked, url, reloadUrl='') {
const fallbackReloadUrl = '<?= $this->Url->build(['action' => 'index']); ?>'
reloadUrl = reloadUrl != '' ? reloadUrl : fallbackReloadUrl
UI.overlayUntilResolve(clicked, UI.submissionModalForIndex(url, reloadUrl, '<?= $tableRandomValue ?>'))