Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds all/none selection toggles to decks ui. #675

Merged
merged 1 commit into from
Dec 6, 2020
Merged
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
33 changes: 25 additions & 8 deletions assets/js/ui.decks.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@
location.href = Routing.generate('decks_diff', {deck1_uuid: ids[0], deck2_uuid: ids[1]});
};

ui.handle_deck_selection_change = function handle_deck_selection_change()
{
var checked = $('#decks').find('input[type=checkbox]:checked');
var button = $('#btn-group-selection button');
if (checked.size()) {
button.removeClass('btn-default').addClass('btn-primary')
} else {
button.addClass('btn-default').removeClass('btn-primary')
}
}

ui.do_action_selection = function do_action_selection(event)
{
event.stopPropagation();
Expand Down Expand Up @@ -208,18 +219,24 @@
*/
ui.on_dom_loaded = function on_dom_loaded()
{
$('#decks .select_all').on('click', function ()
{
$('.list-decks-deck input[type="checkbox"]:not(:checked)').prop('checked', true);
ui.handle_deck_selection_change();
return false;
});

$('#decks .select_none').on('click', function ()
{
$('.list-decks-deck input[type="checkbox"]:checked').prop('checked', false);
ui.handle_deck_selection_change();
return false;
});

$('#decks').on('click', 'button.btn-delete-deck', ui.confirm_delete);
$('#decks').on('click', 'input[type=checkbox]', function (event)
{
var checked = $(this).closest('tbody').find('input[type=checkbox]:checked');
var button = $('#btn-group-selection button');
if(checked.size()) {
button.removeClass('btn-default').addClass('btn-primary')
} else {
button.addClass('btn-default').removeClass('btn-primary')
}

ui.handle_deck_selection_change();
});

$('#btn-group-selection').on('click', 'button[id],a[id]', ui.do_action_selection);
Expand Down
15 changes: 14 additions & 1 deletion templates/Builder/decks.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,21 @@

<table class="table table-expanded list-decks">
<tbody id="decks">
{% if decks.count %}
<tr>
<td colspan="4">
<a href="#" class="select_all clickable">
<span class="fas fa-check"></span> {{ 'decks.all' | trans }}
</a>
/
<a href="#" class="select_none clickable">
<span class="fas fa-times"></span> {{ 'decks.none' | trans }}
</a>
</td>
</tr>
{% endif %}
{% for deck in decks %}
<tr data-id="{{ deck.id }}" data-uuid="{{ deck.uuid }}">
<tr data-id="{{ deck.id }}" data-uuid="{{ deck.uuid }}" class="list-decks-deck">
<td><input type="checkbox"></td>
<td class="hidden-xs">
<img
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ forms:
sort: Sortieren

decks:
all: Alle
none: Keine
privatedecks: Meine privaten Decklisten
slotcount: "(%current%/%max% Decklisten)"
version: Version %version%
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ forms:
sort: Sort

decks:
all: all
none: none
privatedecks: My private decks
slotcount: "(%current%/%max% slots)"
version: Version %version%
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ forms:
sort: Ordenar

decks:
all: todo
none: ninguno
privatedecks: Mis mazos privados
slotcount: "(%current%/%max% mazos)"
version: Versión %version%
Expand Down