Added button to inverse part selection in tables

Fix issue #346
This commit is contained in:
Jan Böhmer 2023-08-21 22:48:47 +02:00
parent eaee4af715
commit 80bae4167f
3 changed files with 21 additions and 1 deletions

View file

@ -239,4 +239,16 @@ export default class extends Controller {
return this.element.dataset.select ?? false;
}
invertSelection() {
//Do nothing if the datatable is not selectable
if(!this.isSelectable()) {
return;
}
//Invert the selected rows on the datatable
const selected_rows = this._dt.rows({selected: true});
this._dt.rows().select();
selected_rows.deselect();
}
}

View file

@ -32,6 +32,8 @@
{# <span id="select_count"></span> #}
<div class="input-group">
<button class="btn btn-outline-secondary" type="button" {{ stimulus_action('elements/datatables/parts', 'invertSelection')}}
title="{% trans %}part_list.action.invert_selection{% endtrans %}" ><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
<span class="input-group-text">
<span class="badge bg-primary">{% trans with {'%count%': '<span ' ~ stimulus_target('elements/datatables/parts', 'selectCount') ~ '></span>'} %}part_list.action.part_count{% endtrans %}</span>
</span>
@ -75,7 +77,7 @@
{# This is left empty, as this will be filled by Javascript #}
</select>
<button type="submit" class="btn btn-secondary">{% trans %}part_list.action.submit{% endtrans %}</button>
<button type="submit" class="btn btn-primary">{% trans %}part_list.action.submit{% endtrans %}</button>
</div>
</div>

View file

@ -11615,5 +11615,11 @@ Please note, that you can not impersonate a disabled user. If you try you will g
<target>If this option is selected, the given withdraw quantities are used as given, no matter if more or less parts are actually required to build this project.</target>
</segment>
</unit>
<unit id="tfOeMsC" name="part_list.action.invert_selection">
<segment>
<source>part_list.action.invert_selection</source>
<target>Invert selection</target>
</segment>
</unit>
</file>
</xliff>