chg: [genericElements] Perform ajax call when filtering with context
parent
79e34052c8
commit
3d647680a0
|
@ -82,7 +82,7 @@
|
||||||
function submitForm(api, url) {
|
function submitForm(api, url) {
|
||||||
return api.fetchAndPostForm(url, {})
|
return api.fetchAndPostForm(url, {})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
reloadElement('/meta-templates', $('#table-container-<?= $tableRandomValue ?>'), $('#table-container-<?= $tableRandomValue ?> table.table'))
|
UI.reload('/meta-templates', $('#table-container-<?= $tableRandomValue ?>'), $('#table-container-<?= $tableRandomValue ?> table.table'))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}())
|
}())
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
if (!isset($data['requirement']) || $data['requirement']) {
|
if (!isset($data['requirement']) || $data['requirement']) {
|
||||||
$onClickActive = false;
|
|
||||||
if (!empty($data['popover_url'])) {
|
if (!empty($data['popover_url'])) {
|
||||||
$onClick = sprintf(
|
$onClick = sprintf(
|
||||||
'onClick="populateAndLoadModal(%s)"',
|
'onClick="populateAndLoadModal(%s)"',
|
||||||
sprintf("'%s'", h($data['popover_url']))
|
sprintf("'%s'", h($data['popover_url']))
|
||||||
);
|
);
|
||||||
$onClickActive = true;
|
|
||||||
}
|
}
|
||||||
if (empty($onClick)) {
|
if (empty($onClick)) {
|
||||||
if (!empty($data['onClick']) || empty($data['url'])) {
|
if (!empty($data['onClick']) || empty($data['url'])) {
|
||||||
|
@ -30,7 +28,6 @@
|
||||||
$onClickParams
|
$onClickParams
|
||||||
) : '')
|
) : '')
|
||||||
);
|
);
|
||||||
$onClickActive = true;
|
|
||||||
} else if(!empty($data['url'])) {
|
} else if(!empty($data['url'])) {
|
||||||
$onClick = sprintf(
|
$onClick = sprintf(
|
||||||
'onClick = "%s"',
|
'onClick = "%s"',
|
||||||
|
@ -52,7 +49,7 @@
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
'<button class="btn btn-sm %s %s" %s href="%s" %s %s %s %s %s>%s%s%s</button>',
|
'<button class="btn btn-sm %s %s" %s href="%s" %s %s %s %s %s>%s%s%s</button>',
|
||||||
empty($data['class']) ? '' : h($data['class']),
|
empty($data['class']) ? '' : h($data['class']),
|
||||||
$onClickActive ? 'btn-primary' : (empty($data['active']) ? 'btn-light' : 'btn-secondary'), // Change the default class for highlighted/active toggles here
|
!$data['isFilter'] ? 'btn-primary' : (empty($data['active']) ? 'btn-light' : 'btn-secondary'), // Change the default class for highlighted/active toggles here
|
||||||
empty($data['id']) ? '' : 'id="' . h($data['id']) . '"',
|
empty($data['id']) ? '' : 'id="' . h($data['id']) . '"',
|
||||||
empty($data['url']) ? '#' : h($data['url']), // prevent default is passed if the url is not set
|
empty($data['url']) ? '#' : h($data['url']), // prevent default is passed if the url is not set
|
||||||
empty($onClick) ? '' : $onClick, // pass $data['onClick'] for the function name to call and $data['onClickParams'] for the parameter list
|
empty($onClick) ? '' : $onClick, // pass $data['onClick'] for the function name to call and $data['onClickParams'] for the parameter list
|
||||||
|
|
|
@ -11,7 +11,13 @@
|
||||||
unset($currentQuery['page'], $currentQuery['limit'], $currentQuery['sort']);
|
unset($currentQuery['page'], $currentQuery['limit'], $currentQuery['sort']);
|
||||||
$contextArray[] = [
|
$contextArray[] = [
|
||||||
'active' => $currentQuery == $filteringContext['filterCondition'],
|
'active' => $currentQuery == $filteringContext['filterCondition'],
|
||||||
'url' => $this->Url->build($urlParams),
|
'isFilter' => true,
|
||||||
|
'onClick' => 'UI.reload',
|
||||||
|
'onClickParams' => [
|
||||||
|
$this->Url->build($urlParams),
|
||||||
|
"#table-container-${tableRandomValue}",
|
||||||
|
"#table-container-${tableRandomValue} table.table",
|
||||||
|
],
|
||||||
'text' => $filteringContext['label'],
|
'text' => $filteringContext['label'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,20 @@ class UIFactory {
|
||||||
theModal.show()
|
theModal.show()
|
||||||
return theModal
|
return theModal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reload (url, $container, $statusNode=null) {
|
||||||
|
$container = $($container)
|
||||||
|
$statusNode = $($statusNode)
|
||||||
|
if (!$statusNode) {
|
||||||
|
$statusNode = $container
|
||||||
|
}
|
||||||
|
const tmpApi = new AJAXApi({
|
||||||
|
statusNode: $statusNode[0],
|
||||||
|
})
|
||||||
|
tmpApi.fetchURL(url).then((data) => {
|
||||||
|
$container.html(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Toaster {
|
class Toaster {
|
||||||
|
|
|
@ -42,16 +42,4 @@ var AjaxApi, UI
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
AjaxApi = new AJAXApi()
|
AjaxApi = new AJAXApi()
|
||||||
UI = new UIFactory()
|
UI = new UIFactory()
|
||||||
})
|
})
|
||||||
|
|
||||||
function reloadElement(url, $container, $statusNode=null) {
|
|
||||||
if (!$statusNode) {
|
|
||||||
$statusNode = $container
|
|
||||||
}
|
|
||||||
tmpApi = new AJAXApi({
|
|
||||||
statusNode: $statusNode[0],
|
|
||||||
})
|
|
||||||
tmpApi.fetchURL(url).then((data) => {
|
|
||||||
$container.html(data)
|
|
||||||
})
|
|
||||||
}
|
|
Loading…
Reference in New Issue