chg: [genericElement:index_table] Generic support of bulk operations

pull/59/head
mokaddem 2021-06-23 11:15:22 +02:00
parent 7ec0dabd0b
commit bb6489778f
4 changed files with 12 additions and 14 deletions

View File

@ -13,7 +13,7 @@
}
}
echo sprintf(
'<input class="select_attribute select" type="checkbox" data-rowid="%s" %s>',
'<input class="selectable_row select" type="checkbox" data-rowid="%s" %s>',
h($k),
empty($data) ? '' : implode(' ', $data)
);

View File

@ -14,7 +14,7 @@
$header_data = sprintf(
'<input id="select_all" class="%s" type="checkbox" %s>',
empty($header['select_all_class']) ? 'select_all' : $header['select_all_class'],
empty($header['select_all_function']) ? 'onclick="toggleAllAttributeCheckboxes();"' : 'onclick="' . $header['select_all_function'] . '"'
empty($header['select_all_function']) ? 'onclick="toggleAllAttributeCheckboxes(this);"' : 'onclick="' . $header['select_all_function'] . '"'
);
} else {
$header_data = h($header['name']);
@ -38,14 +38,3 @@
$thead .= '</thead>';
echo $thead;
?>
<script type="text/javascript">
$(document).ready(function() {
$('.select_attribute').add('#select_all').on('change', function() {
if ($('.select_attribute:checked').length > 0) {
$('.mass-select').show();
} else {
$('.mass-select').hide();
}
});
});
</script>

View File

@ -93,7 +93,8 @@
}
$tbody = '<tbody>' . $rows . '</tbody>';
echo sprintf(
'<table class="table table-hover" id="index-table-%s">%s%s</table>',
'<table class="table table-hover" id="index-table-%s" data-table-random-value="%s">%s%s</table>',
$tableRandomValue,
$tableRandomValue,
$this->element(
'/genericElements/IndexTable/headers',
@ -114,6 +115,7 @@
?>
<script type="text/javascript">
$(document).ready(function() {
$('#index-table-<?= $tableRandomValue ?>').data('data', <?= json_encode($data['data']) ?>);
$('.privacy-toggle').on('click', function() {
var $privacy_target = $(this).parent().find('.privacy-value');
if ($(this).hasClass('fa-eye')) {

View File

@ -18,6 +18,13 @@ function executeStateDependencyChecks(dependenceSourceSelector) {
});
}
function toggleAllAttributeCheckboxes(clicked) {
let $clicked = $(clicked)
let $table = $clicked.closest('table')
let $inputs = $table.find('input.selectable_row')
$inputs.prop('checked', $clicked.prop('checked'))
}
function testConnection(id) {
$container = $(`#connection_test_${id}`)
UI.overlayUntilResolve(