mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
counter: speed counter click interface and auto scroll
This commit is contained in:
parent
9181e77d55
commit
405b938e08
@ -23,7 +23,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h4>{{ counter }}</h4>
|
||||
<h4 id="click_interface">{{ counter }}</h4>
|
||||
|
||||
<div id="user_info">
|
||||
<h5>{% trans %}Customer{% endtrans %}</h5>
|
||||
@ -127,17 +127,14 @@
|
||||
</div>
|
||||
<div id="products">
|
||||
<ul>
|
||||
{% for t in categories -%}
|
||||
{%- if counter.products.filter(product_type=t).exists() -%}
|
||||
<li><a href="#cat_{{ t|slugify }}">{{ t }}</a></li>
|
||||
{%- endif -%}
|
||||
{% for category in categories.keys() -%}
|
||||
<li><a href="#cat_{{ category|slugify }}">{{ category }}</a></li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
{% for t in categories -%}
|
||||
{%- if counter.products.filter(product_type=t).exists() -%}
|
||||
<div id="cat_{{ t|slugify }}">
|
||||
<h5>{{ t }}</h5>
|
||||
{% for p in counter.products.filter(product_type=t).all() -%}
|
||||
{% for category in categories.keys() -%}
|
||||
<div id="cat_{{ category|slugify }}">
|
||||
<h5>{{ category }}</h5>
|
||||
{% for p in categories[category] -%}
|
||||
{% set file = None %}
|
||||
{% if p.icon %}
|
||||
{% set file = p.icon.url %}
|
||||
@ -148,18 +145,20 @@
|
||||
{{ add_product(p.id, prod, "form_button") }}
|
||||
{%- endfor %}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
document.getElementById("click_interface").scrollIntoView();
|
||||
</script>
|
||||
{{ super() }}
|
||||
<script>
|
||||
$( function() {
|
||||
var products = [
|
||||
{% for p in counter.products.all() -%}
|
||||
{% for p in products -%}
|
||||
{
|
||||
value: "{{ p.code }}",
|
||||
label: "{{ p.name }}",
|
||||
@ -203,6 +202,3 @@ $( function() {
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
@ -708,10 +708,16 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
||||
def get_context_data(self, **kwargs):
|
||||
""" Add customer to the context """
|
||||
kwargs = super(CounterClick, self).get_context_data(**kwargs)
|
||||
kwargs["products"] = self.object.products.select_related("product_type")
|
||||
kwargs["categories"] = {}
|
||||
for product in kwargs["products"]:
|
||||
if product.product_type:
|
||||
kwargs["categories"].setdefault(product.product_type, []).append(
|
||||
product
|
||||
)
|
||||
kwargs["customer"] = self.customer
|
||||
kwargs["basket_total"] = self.sum_basket(self.request)
|
||||
kwargs["refill_form"] = self.refill_form or RefillForm()
|
||||
kwargs["categories"] = ProductType.objects.all()
|
||||
kwargs["student_card_max_uid_size"] = StudentCard.UID_SIZE
|
||||
return kwargs
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user