diff --git a/loko/assets/static/assets/unified_index.js b/loko/assets/static/assets/unified_index.js index 8526b5d..dbeebad 100644 --- a/loko/assets/static/assets/unified_index.js +++ b/loko/assets/static/assets/unified_index.js @@ -519,7 +519,7 @@ function zoomFormatter(value, row) { function buildColumns() { return [ - { field: 'check', checkbox: true, width: 36, widthUnit: 'px', align: 'center', valign: 'middle' }, + { field: 'state', checkbox: true, width: 36, widthUnit: 'px', align: 'center', valign: 'middle' }, { field: 'actions', title: '', formatter: zoomFormatter, width: 44, widthUnit: 'px', align: 'center', valign: 'middle' }, { field: 'code', title: gettext('Code'), sortable: true, width: 135, widthUnit: 'px', valign: 'middle', @@ -896,6 +896,8 @@ $(document).ready(function () { } $('#unified-table').bootstrapTable({ + idField: 'id', + selectItemName: 'btSelectItem', columns: buildColumns(), rowStyle: function (row) { if (row && (row.is_dead || row.vitality === 'dead' || row.status === 'dead' || row.status === 'archived')) { @@ -914,12 +916,14 @@ $(document).ready(function () { }, onCheck: function (row) { row.state = true; + row.check = true; selectedIds.add(row.id); updateSelectionStatus(); setMapFeatureSelectionState(row, true); }, onUncheck: function (row) { row.state = false; + row.check = false; selectedIds.delete(row.id); updateSelectionStatus(); setMapFeatureSelectionState(row, false); @@ -2848,9 +2852,16 @@ function loadTableData(features) { const length = Number(p.length ?? p.length_m ?? 0); const area = Number(p.area ?? p.area_m2 ?? p.surface_area ?? p.surface ?? 0); const usageType = p.usage_type_display || ''; + const isSelected = selectedIds.has(f.id) || + selectedIds.has(String(f.id)) || + (p.id != null && (selectedIds.has(p.id) || selectedIds.has(String(p.id)))); + if (isSelected) { + selectedIds.add(f.id); + } return { id: f.id, - state: selectedIds.has(f.id), + state: isSelected, + check: isSelected, code: p.code || '', name: name, asset_type: p.asset_type || '', @@ -2884,6 +2895,8 @@ function loadTableData(features) { $('#unified-spinner').hide(); $('#unified-table').bootstrapTable('load', rows); + syncSelectAllCheckbox(); + updateSelectionStatus(); const countBadge = document.getElementById('assets-counter-badge'); if (countBadge) countBadge.textContent = rows.length; @@ -3307,6 +3320,7 @@ function selectAllTableRows() { allRows.forEach(r => { selectedIds.add(r.id); r.state = true; + r.check = true; setMapFeatureSelectionState(r, true); }); $('#unified-table tbody tr').addClass('selected'); @@ -3324,6 +3338,7 @@ function deselectAllTableRows() { const allRows = getAllTableRows(); allRows.forEach(r => { r.state = false; + r.check = false; setMapFeatureSelectionState(r, false); }); selectedIds.forEach(id => { diff --git a/loko/assets/templates/assets/unified_index.html b/loko/assets/templates/assets/unified_index.html index fe7f6b1..4f88f0a 100644 --- a/loko/assets/templates/assets/unified_index.html +++ b/loko/assets/templates/assets/unified_index.html @@ -1409,6 +1409,8 @@ {# Table #}