fix card badges to have better rarity visibility and other bugfixes
This commit is contained in:
parent
37d8bd5981
commit
262f0ea190
14 changed files with 4515 additions and 1255 deletions
|
|
@ -5,64 +5,42 @@
|
|||
|
||||
{% block content %}
|
||||
<div x-data="{
|
||||
// Initialize allExpanded from the URL if present, defaulting to false.
|
||||
allExpanded: new URLSearchParams(window.location.search).get('expanded') === 'true',
|
||||
page: {{ page_obj.number|default:1 }},
|
||||
loadOffers() {
|
||||
let url = new URL('{% url 'trade_offer_list' %}', window.location.origin);
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
params.set('page', this.page);
|
||||
// Include the expanded state if active
|
||||
if (this.allExpanded) {
|
||||
params.set('expanded', 'true');
|
||||
} else {
|
||||
params.delete('expanded');
|
||||
}
|
||||
url.search = params.toString();
|
||||
fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' }})
|
||||
.then(response => response.text())
|
||||
.then(html => { this.$refs.offersContainer.innerHTML = html; });
|
||||
},
|
||||
// Update the URL so that navigation preserves our expanded state.
|
||||
updateUrl() {
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
if (this.allExpanded) {
|
||||
params.set('expanded', 'true');
|
||||
} else {
|
||||
params.delete('expanded');
|
||||
}
|
||||
history.replaceState(null, '', window.location.pathname + '?' + params.toString());
|
||||
}
|
||||
}"
|
||||
x-init="loadOffers()"
|
||||
x-on:change-page.window="page = $event.detail.page; loadOffers()">
|
||||
|
||||
<!-- Header with the toggle -->
|
||||
<!-- Header without Expand All -->
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-2xl font-bold">Trade Offers</h1>
|
||||
<div>
|
||||
<div class="flex items-center gap-4">
|
||||
<form method="get" class="flex items-center gap-4" x-data>
|
||||
<label class="cursor-pointer flex items-center gap-2">
|
||||
<span x-text="allExpanded ? 'Collapse All' : 'Expand All'"></span>
|
||||
<input type="checkbox" name="all_expanded" value="true" class="toggle toggle-primary"
|
||||
@click="allExpanded = !allExpanded; $dispatch('toggle-all', { expanded: allExpanded }); updateUrl();">
|
||||
</label>
|
||||
<label class="cursor-pointer flex items-center gap-2">
|
||||
<span>Only Closed</span>
|
||||
<input type="checkbox" name="show_closed" value="true" class="toggle toggle-primary" @change="$el.form.submit()" {% if show_closed %}checked{% endif %}>
|
||||
<input type="checkbox" name="show_closed" value="true" class="toggle toggle-primary"
|
||||
@change="$el.form.submit()" {% if show_closed %}checked{% endif %}>
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary" x-show="false">Apply</button>
|
||||
</form>
|
||||
<div>
|
||||
<a href="{% url 'trade_offer_create' %}" class="btn btn-success">Create New Offer</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Trade Offers -->
|
||||
<section class="mb-12">
|
||||
<div class="flex justify-end mb-4">
|
||||
<a href="{% url 'trade_offer_create' %}" class="btn btn-success">Create New Offer</a>
|
||||
</div>
|
||||
|
||||
<div id="all-trade-offers" x-ref="offersContainer">
|
||||
{% include "trades/_trade_offer_list.html" with offers=offers page_obj=page_obj expanded=expanded %}
|
||||
{% include "trades/_trade_offer_list.html" with offers=offers page_obj=page_obj %}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue