chg: [element:generic_index] Added more flexibility in topbar

pull/37/head
mokaddem 2021-01-18 17:25:18 +01:00
parent d974f784b6
commit 2288e8f66f
3 changed files with 14 additions and 7 deletions

View File

@ -2,8 +2,9 @@
if (!isset($data['requirement']) || $data['requirement']) {
if (!empty($data['popover_url'])) {
$onClick = sprintf(
'onClick="openModalForButton(this, %s)"',
sprintf("'%s'", h($data['popover_url']))
'onClick="openModalForButton(this, \'%s\', \'%s\')"',
h($data['popover_url']),
h(!empty($data['reload_url']) ? $data['reload_url'] : '')
);
}
if (empty($onClick)) {
@ -69,10 +70,12 @@
?>
<script>
function openModalForButton(clicked, url) {
function openModalForButton(clicked, url, reloadUrl='') {
const loadingOverlay = new OverlayFactory(clicked);
const fallbackReloadUrl = '<?= $this->Url->build(['action' => 'index']); ?>'
reloadUrl = reloadUrl != '' ? reloadUrl : fallbackReloadUrl
loadingOverlay.show()
UI.openModalFromURL(url, '<?= $this->Url->build(['action' => 'index']); ?>', '<?= $tableRandomValue ?>').finally(() => {
UI.openModalFromURL(url, reloadUrl, '<?= $tableRandomValue ?>').finally(() => {
loadingOverlay.hide()
})
}

View File

@ -44,7 +44,7 @@
var controller = '<?= $this->request->getParam('controller') ?>';
var action = '<?= $this->request->getParam('action') ?>';
var additionalUrlParams = '';
var quickFilter = <?= json_encode($quickFilter) ?>;
var quickFilter = <?= json_encode(!empty($quickFilter) ? $quickFilter : []) ?>;
<?php
if (!empty($data['additionalUrlParams'])) {
echo sprintf(

View File

@ -7,12 +7,16 @@
</button>
</div>
<div class="modal-body">
<p><?= __('Are you sure you want to delete {0} #{1}?', h(Cake\Utility\Inflector::singularize($this->request->getParam('controller'))), h($id)) ?></p>
<?php if (empty($deletionText)): ?>
<p><?= __('Are you sure you want to delete {0} #{1}?', h(Cake\Utility\Inflector::singularize($this->request->getParam('controller'))), h($id)) ?></p>
<?php else: ?>
<p><?= h($deletionText) ?></p>
<?php endif; ?>
</div>
<div class="modal-footer">
<?= $this->Form->postLink(
'Delete',
['action' => 'delete', $id],
(empty($postLinkParameters) ? ['action' => 'delete', $id] : $postLinkParameters),
['class' => 'btn btn-primary button-execute', 'id' => 'submitButton']
)
?>