mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added checkbox in parts table header to quickly select/unselect all parts
This commit is contained in:
parent
9d1cd0477a
commit
c39a9a4da7
2 changed files with 63 additions and 2 deletions
|
@ -137,6 +137,27 @@ export default class extends Controller {
|
||||||
dt.fixedHeader.headerOffset($("#navbar").outerHeight());
|
dt.fixedHeader.headerOffset($("#navbar").outerHeight());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Register event handler to selectAllRows checkbox if available
|
||||||
|
if (this.isSelectable()) {
|
||||||
|
promise.then((dt) => {
|
||||||
|
const selectAllCheckbox = this.element.querySelector('thead th.select-checkbox');
|
||||||
|
selectAllCheckbox.addEventListener('click', () => {
|
||||||
|
if(selectAllCheckbox.parentElement.classList.contains('selected')) {
|
||||||
|
dt.rows().deselect();
|
||||||
|
selectAllCheckbox.parentElement.classList.remove('selected');
|
||||||
|
} else {
|
||||||
|
dt.rows().select();
|
||||||
|
selectAllCheckbox.parentElement.classList.add('selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//When any row is deselected, also deselect the selectAll checkbox
|
||||||
|
dt.on('deselect.dt', () => {
|
||||||
|
selectAllCheckbox.parentElement.classList.remove('selected');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//Allow to further configure the datatable
|
//Allow to further configure the datatable
|
||||||
promise.then(this._afterLoaded.bind(this));
|
promise.then(this._afterLoaded.bind(this));
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ th.select-checkbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fix datatables select-checkbox position */
|
/** Fix datatables select-checkbox position */
|
||||||
table.dataTable tr.selected td.select-checkbox:after, table.dataTable tr.selected th.select-checkbox:after {
|
table.dataTable tr.selected td.select-checkbox:after
|
||||||
|
{
|
||||||
margin-top: -28px !important;
|
margin-top: -28px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,4 +103,43 @@ Classes for Datatables export
|
||||||
#export-messageTop,
|
#export-messageTop,
|
||||||
.export-helper{
|
.export-helper{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************
|
||||||
|
* Styling for the select all checkbox in the parts table
|
||||||
|
* Should match the styling of the select checkbox
|
||||||
|
******************************************************/
|
||||||
|
table.dataTable > thead > tr > th.select-checkbox {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
table.dataTable > thead > tr > th.select-checkbox:before,
|
||||||
|
table.dataTable > thead > tr > th.select-checkbox:after {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 1.2em;
|
||||||
|
left: 50%;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
table.dataTable > thead > tr > th.select-checkbox:before {
|
||||||
|
content: " ";
|
||||||
|
margin-top: -5px;
|
||||||
|
margin-left: -6px;
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
table.dataTable > thead > tr.selected > th.select-checkbox:after {
|
||||||
|
content: "✓";
|
||||||
|
font-size: 20px;
|
||||||
|
margin-top: -23px;
|
||||||
|
margin-left: -6px;
|
||||||
|
text-align: center;
|
||||||
|
/*text-shadow: 1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9; */
|
||||||
|
}
|
||||||
|
table.dataTable.compact > thead > tr > th.select-checkbox:before {
|
||||||
|
margin-top: -12px;
|
||||||
|
}
|
||||||
|
table.dataTable.compact > thead > tr.selected > th.select-checkbox:after {
|
||||||
|
margin-top: -16px;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue