chg: [genericElements:indexTable] Added option in toggle field to skip full index reload

pull/37/head
mokaddem 2020-12-15 16:14:06 +01:00
parent 0347d7dfda
commit dddc7d1a12
2 changed files with 9 additions and 2 deletions

View File

@ -35,7 +35,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'function' => function($row, $options) {
return true;
}
]
],
'skip_full_reload' => true
]
],
[

View File

@ -78,9 +78,15 @@
})
function submitForm(api, url) {
const reloadUrl = '<?= isset($field['toggle_data']['reload_url']) ? $field['toggle_data']['reload_url'] : $this->Url->build(['action' => 'index']) ?>'
return api.fetchAndPostForm(url, {})
.then(() => {
UI.reload('/meta-templates', $('#table-container-<?= $tableRandomValue ?>'), $('#table-container-<?= $tableRandomValue ?> table.table'))
<?php if (!empty($field['toggle_data']['skip_full_reload'])): ?>
const isChecked = $('#<?= $checkboxId ?>').prop('checked')
$('#<?= $checkboxId ?>').prop('checked', !$('#<?= $checkboxId ?>').prop('checked'))
<?php else: ?>
UI.reload(reloadUrl, $('#table-container-<?= $tableRandomValue ?>'), $('#table-container-<?= $tableRandomValue ?> table.table'))
<?php endif; ?>
})
}
}())