Skip to content

Commit

Permalink
Add default row actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jskowronski39 committed Sep 13, 2021
1 parent 4aba706 commit 7ce759f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
14 changes: 12 additions & 2 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import './app.scss';

import jQuery from 'jquery';
import yall from 'yall-js';

// Init Bootstrap jQuery plugins
Expand All @@ -24,6 +22,18 @@ $(() => {
});
});

$('[data-row-action-url]').on('click', e => {
if (e.target.nodeName === 'A') return;
window.location = e.delegateTarget.dataset['rowActionUrl'];
});

$('[data-row-action-checkbox]').on('click', e => {
if (e.target.nodeName === 'A') return;
let checkbox = $(e.delegateTarget).find('[type=checkbox]');
checkbox.prop('checked', !checkbox.prop('checked'));
checkbox.trigger('change');
});

form.initConfirmModals();

// Image lazy loading
Expand Down
4 changes: 4 additions & 0 deletions assets/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ html, body {
cursor: pointer;
}

[data-row-action-url], [data-row-action-checkbox] {
cursor: pointer;
}

td span[title] {
text-decoration-line: underline;
text-decoration-style: dotted;
Expand Down
2 changes: 1 addition & 1 deletion templates/_partial/dlc_tabs/_dlc_tabs_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% for child in form.children %}
{% set dlc = form.vars.choices[loop.index0].data %}

<tr>
<tr data-row-action-checkbox>
<th scope="row">{{ rowNo }}</th>
<td>{{ tableMacro.row_name_with_description(dlc.name, dlc.description) }}</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% for child in form.children %}
{% set modGroup = form.vars.choices[loop.index0].data %}

<tr>
<tr data-row-action-checkbox>
<th scope="row">{{ rowNo }}</th>
<td>{{ tableMacro.row_name_with_description(modGroup.name, modGroup.description) }}</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion templates/_partial/mod_tabs/_mod_tabs_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% for child in form.children %}
{% set mod = form.vars.choices[loop.index0].data %}
{% if mod.type.value == modType %}
<tr>
<tr data-row-action-checkbox>
<th scope="row">{{ rowNo }}</th>
<td>
{{ tableMacro.row_mod_status_icon(mod) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{# @var mod \App\Entity\Mod\SteamWorkshopMod #}
{% for mod in optionalMods %}
{% if not mod.statusDisabled %}
<tr>
<tr data-row-action-checkbox>
<th scope="row">{{ rowNo }}</th>
<td>{{ tableMacro.row_mod_status_icon(mod) }}</td>
<td>{{ tableMacro.row_name_with_description(mod.name, mod.description) }}</td>
Expand Down
2 changes: 1 addition & 1 deletion templates/mod_list_public/select.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% block table_body %}
{# @var modList \App\Entity\ModList\ModList #}
{% for modList in modLists %}
<tr>
<tr data-row-action-url="{{ path('app_mod_list_public_customize', { name: modList.name }) }}">
<th scope="row">{{ loop.index }}</th>
<td>
{% if modList.approved %}
Expand Down
2 changes: 1 addition & 1 deletion templates/user_group/_partial/_users_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% for child in form.children %}
{% set user = form.vars.choices[loop.index0].data %}

<tr>
<tr data-row-action-checkbox>
<th scope="row">{{ loop.index }}</th>
<td>{{ user.username }}</td>
<td>{{ user.externalId }}</td>
Expand Down

0 comments on commit 7ce759f

Please sign in to comment.