fix: [js:bootstrap-helper] Correctly returns promise

pull/37/head
mokaddem 2021-01-12 11:36:33 +01:00
parent cd8d537273
commit 41f96dedcb
2 changed files with 8 additions and 4 deletions

View File

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

View File

@ -52,7 +52,7 @@ class UIFactory {
* @return {Promise<Object>} Promise object resolving to the ModalFactory object
*/
openModalFromURL(url, reloadUrl=false, tableId=false) {
UI.modalFromURL(url, () => {
return UI.modalFromURL(url, () => {
if (reloadUrl === false || tableId === false) { // Try to get information from the DOM
let $elligibleTable = $('table.table')
let currentModel = location.pathname.split('/')[1]