counter: speed counter click interface and auto scroll

This commit is contained in:
Antoine Bartuccio 2019-09-10 13:41:43 +02:00
parent 9181e77d55
commit 405b938e08
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 18 additions and 16 deletions

View File

@ -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 %}

View File

@ -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