Sith/counter/templates/counter/product_list.jinja

89 lines
3.3 KiB
Django/Jinja
Raw Normal View History

{% extends "core/base.jinja" %}
2024-12-13 23:10:34 +00:00
{% from "core/macros.jinja" import paginate_alpine %}
2016-07-27 15:23:02 +00:00
{% block title %}
{% trans %}Product list{% endtrans %}
2016-07-27 15:23:02 +00:00
{% endblock %}
2024-12-13 23:10:34 +00:00
{% block additional_js %}
<script type="module" src="{{ static("bundled/counter/product-list-index.ts") }}"></script>
2016-07-27 15:23:02 +00:00
{% endblock %}
2024-12-14 01:45:11 +00:00
{% block additional_css %}
<link rel="stylesheet" href="{{ static("core/components/card.scss") }}">
<link rel="stylesheet" href="{{ static("counter/css/admin.scss") }}">
{% endblock %}
2024-12-13 23:10:34 +00:00
{% block content %}
<main x-data="productList">
2024-12-13 23:36:12 +00:00
<form id="search-form" class="margin-bottom">
<h4 class="margin-bottom">{% trans %}Filter products{% endtrans %}</h4>
2024-12-13 23:10:34 +00:00
<fieldset>
<label for="search-input">{% trans %}Product name{% endtrans %}</label>
<input
id="search-input"
type="text"
name="search"
x-model.debounce.500ms="search"
/>
</fieldset>
<fieldset>
<div class="row">
2024-12-14 02:13:14 +00:00
<input type="radio" id="filter-active-products" x-model="productStatus" value="active">
2024-12-13 23:10:34 +00:00
<label for="filter-active-products">{% trans %}Active products{% endtrans %}</label>
</div>
<div class="row">
2024-12-14 02:13:14 +00:00
<input type="radio" id="filter-inactive-products" x-model="productStatus" value="archived">
2024-12-13 23:10:34 +00:00
<label for="filter-inactive-products">{% trans %}Archived products{% endtrans %}</label>
</div>
<div class="row">
2024-12-14 02:13:14 +00:00
<input type="radio" id="filter-all-products" x-model="productStatus" value="both">
2024-12-13 23:10:34 +00:00
<label for="filter-all-products">{% trans %}All products{% endtrans %}</label>
</div>
</fieldset>
</form>
2024-12-13 23:36:12 +00:00
<h3 @click="console.log(totalCount, nbPages())" class="margin-bottom">
{% trans %}Product list{% endtrans %}
</h3>
2016-07-27 15:23:02 +00:00
2024-12-13 23:36:12 +00:00
<div class="row margin-bottom">
<a href="{{ url('counter:new_product') }}" class="btn btn-blue">
{% trans %}New product{% endtrans %} <i class="fa fa-plus"></i>
</a>
<button
class="btn btn-blue"
@click="downloadCsv()"
:disabled="csvLoading"
:aria-busy="csvLoading"
>
{% trans %}Download as cvs{% endtrans %} <i class="fa fa-file-arrow-down"></i>
</button>
</div>
2016-07-27 15:23:02 +00:00
2024-12-13 23:36:12 +00:00
<div class="aria-busy-grow" :aria-busy="loading">
<template x-for="[category, cat_products] of Object.entries(products)" :key="category">
<section>
2024-12-14 01:45:11 +00:00
<h4 x-text="category" class="margin-bottom"></h4>
2024-12-14 02:13:14 +00:00
<div class="product-group">
2024-12-13 23:36:12 +00:00
<template x-for="p in cat_products" :key="p.id">
2024-12-14 01:45:11 +00:00
<a class="card card-row shadow clickable" :href="p.url">
<template x-if="p.icon">
<img class="card-image" :src="p.icon" :alt="`icon ${p.name}`">
</template>
<template x-if="!p.icon">
<i class="fa-regular fa-image fa-2x card-image"></i>
</template>
<span class="card-content">
<strong class="card-title" x-text="`${p.name} (${p.code})`"></strong>
<p x-text="`${p.selling_price} €`"></p>
</span>
</a>
2024-12-13 23:36:12 +00:00
</template>
2024-12-14 01:45:11 +00:00
</div>
2024-12-13 23:36:12 +00:00
</section>
</template>
2024-12-13 23:10:34 +00:00
{{ paginate_alpine("page", "nbPages") }}
2024-12-13 23:36:12 +00:00
</div>
2024-12-13 23:10:34 +00:00
</main>
{% endblock %}