Skip to content

Commit

Permalink
Merge pull request #696 from plural/link-formats-to-banlists
Browse files Browse the repository at this point in the history
Link up banlists from formats page.
  • Loading branch information
plural authored Sep 30, 2022
2 parents 36a8a78 + 20aa5f1 commit 2a136d3
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 233 deletions.
20 changes: 14 additions & 6 deletions app/Resources/views/Banlists/banlists.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
<div id="restrictions-root" role="tabpanel" style="display: none;">
<!-- Nav tabs -->
<ul class="nav nav-pills nav-justified" role="tablist" style="margin-bottom:20px">
<li role="presentation"><a href="#tab-pane-startup" role="tab" data-toggle="tab">Startup</a></li>
<li role="presentation" class="active"><a href="#tab-pane-standard" role="tab" data-toggle="tab">Standard</a></li>
<li role="presentation"><a href="#tab-pane-eternal" role="tab" data-toggle="tab">Eternal</a></li>
<li role="presentation" {% if format == 'startup' %}class="active"{% endif %}><a href="#tab-pane-startup" role="tab" data-toggle="tab">Startup</a></li>
<li role="presentation" {% if format == 'standard' or format == null %}class="active"{% endif %}><a href="#tab-pane-standard" role="tab" data-toggle="tab">Standard</a></li>
<li role="presentation" {% if format == 'eternal' %}class="active"{% endif %}><a href="#tab-pane-eternal" role="tab" data-toggle="tab">Eternal</a></li>
</ul>
<hr>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane" id="tab-pane-startup"></div>
<div role="tabpanel" class="tab-pane active" id="tab-pane-standard"></div>
<div role="tabpanel" class="tab-pane" id="tab-pane-eternal"></div>
<div role="tabpanel" class="tab-pane{% if format == 'startup' %} active{% endif %}" id="tab-pane-startup"></div>
<div role="tabpanel" class="tab-pane{% if format == 'standard' or format == null %} active{% endif %}" id="tab-pane-standard"></div>
<div role="tabpanel" class="tab-pane{% if format == 'eternal' %} active{% endif %}" id="tab-pane-eternal"></div>
</div>
</div>

Expand Down Expand Up @@ -80,6 +80,9 @@ async function buildBanlistsView() {
// Remove the loading indicator
$('.temp-loading').remove();
const query_format = {% if format %}'{{ format | e('js') }}'{% else %}null{% endif %};
const query_restriction = {% if restriction %}'{{ restriction | e('js') }}'{% else %}null{% endif %};
// Add each format to the page
formats.forEach(f => {
const jqPane = $(`#tab-pane-${f.id}`);
Expand Down Expand Up @@ -144,6 +147,11 @@ async function buildBanlistsView() {
Object.keys(runnerUFC).sort().reverse().forEach(p => { jqRunner.append(generateList(`+${p} Universal Influence`, runnerUFC[p])); });
if (runnerPen.length > 0) { jqRunner.append(generateList('Identity Influence Reduction', runnerPen)); }
Object.keys(runnerPts).sort().reverse().forEach(p => { jqRunner.append(generateList(`${p} ${p == 1 ? 'Point' : 'Points'}`, runnerPts[p])); });
// Fill in searchbox specific format/restriction pair passed in.
if (f.id == query_format && query_restriction) {
jqPane.find('.panel-search input').val(query_restriction).keyup();
}
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/views/Formats/formats.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function buildFormatsView() {
$(`#${format.id}`).append(`<h4>Current Ban List</h4>`);
if (format.attributes.restriction_id) {
const r = restrictions.get(format.attributes.restriction_id);
$(`#${format.id}`).append(`<p><strong><a href="#">${r.attributes.name}</a></strong><br />active as of <strong>${r.attributes.date_start}</strong></p>`);
$(`#${format.id}`).append(`<p><strong><a href="${Routing.generate('banlists', {'format': format.attributes.format_id, 'restriction': r.attributes.name})}">${r.attributes.name}</a></strong><br />active as of <strong>${r.attributes.date_start}</strong></p>`);
} else {
$(`#${format.id}`).append(`<p><strong>None<br />&nbsp;</p>`);
}
Expand Down
Loading

0 comments on commit 2a136d3

Please sign in to comment.