Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ILIAS/UI/resources/js/Table/dist/table.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions components/ILIAS/UI/resources/js/Table/src/datatable.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ export default class DataTable {
const col = cols[i];
col.addEventListener('change', () => this.selectionChange());
}

this.#checkForStateChanges();
}

#checkForStateChanges()
{
const checkboxes = Array.from(this.#component.querySelectorAll('input.c-table-data__row-selector'));
const updateState = () => {
const allSame = Array.from(new Set(checkboxes.map(n => n.checked)));
if (allSame.length === 1) {
this.selectAll(allSame[0]);
} else {
const d = document.querySelector('.c-table-data__header__rowselection.state');
d.classList.remove('all');
d.classList.remove('none');
d.classList.add('some');
}
};
checkboxes.forEach(n => n.addEventListener('input', updateState));
}

/**
Expand Down Expand Up @@ -178,8 +197,7 @@ export default class DataTable {
*/
selectAll(state) {
const cols = this.#table.getElementsByClassName('c-table-data__row-selector');
const selectorAll = this.#table.getElementsByClassName('c-table-data__selection_all').item(0);
const selectorNone = this.#table.getElementsByClassName('c-table-data__selection_none').item(0);
const header = this.#table.querySelector('.c-table-data__header__rowselection.state');

for (let i = 0; i < cols.length; i += 1) {
const col = cols[i];
Expand All @@ -191,13 +209,14 @@ export default class DataTable {
}
}

header.classList.remove('some');
if (state) {
selectorAll.style.display = 'none';
selectorNone.style.display = 'block';
header.classList.add('none');
header.classList.remove('all');
} else {
this.#disableRowSelection(false);
selectorAll.style.display = 'block';
selectorNone.style.display = 'none';
header.classList.add('all');
header.classList.remove('none');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,13 @@ protected function renderActionsHeader(
$signal = $component->getSelectionSignal();
$sig_all = clone $signal;
$sig_all->addOption('select', true);
$select_all = $glyph_factory->add()->withOnClick($sig_all);
$select_all = $glyph_factory->unselect()->withOnClick($sig_all);
$clear = $glyph_factory->clear()->withOnClick($sig_all);
$signal->addOption('select', false);
$select_none = $glyph_factory->close()->withOnClick($signal);
$select_none = $glyph_factory->select()->withOnClick($signal);
$tpl->setVariable('SELECTION_CONTROL_SELECT', $default_renderer->render($select_all));
$tpl->setVariable('SELECTION_CONTROL_DESELECT', $default_renderer->render($select_none));
$tpl->setVariable('SELECTION_CONTROL_CLEAR', $default_renderer->render($clear));
}

if ($component instanceof Component\Table\Ordering) {
Expand Down
Loading
Loading