mirror of
https://github.com/ae-utbm/sith.git
synced 2026-08-26 15:19:15 +00:00
StarList uses proper inheritance and properly passes initial values and attributes + add empty comment clause
This commit is contained in:
@@ -1,44 +1,52 @@
|
||||
<fieldset
|
||||
class="star"
|
||||
x-data="{ 'value': -1, 'hover': -1 }"
|
||||
@mouseover.outside="hover = -1"
|
||||
>
|
||||
{# Do not vote button #}
|
||||
<label
|
||||
<link-once rel="stylesheet" type="text/css" href="{{ statics.css }}" defer></link-once>
|
||||
<fieldset
|
||||
class="star"
|
||||
@mouseover="hover = -1"
|
||||
x-data="{ 'value': {% if widget.value.0 %}{{ widget.value.0 }}{% else %}-1{% endif %}, 'hover': -1 }"
|
||||
@mouseover.outside="hover = -1"
|
||||
{% include "django/forms/widgets/attrs.html" %}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="{{ widget.name }}"
|
||||
value="-1"
|
||||
@click="value = -1"
|
||||
>
|
||||
<i class="fa fa-times-circle"></i>
|
||||
{{ translations.do_not_vote }}
|
||||
</label>
|
||||
|
||||
{# Star widget #}
|
||||
{% for i in number_of_stars %}
|
||||
{# Do not vote button #}
|
||||
<label
|
||||
class="star"
|
||||
@mouseover="hover = {{ forloop.counter0 }}"
|
||||
@mouseover="hover = -1"
|
||||
for="{{ widget.optgroups.0.1.0.attrs.id }}"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="{{ widget.name }}"
|
||||
value="{{ forloop.counter0 }}"
|
||||
@click="value = {{ forloop.counter0 }}"
|
||||
value="{{ widget.optgroups.0.1.0.value }}"
|
||||
@click="value = -1"
|
||||
{% with widget=widget.optgroups.0.1.0 %}
|
||||
{% include "django/forms/widgets/attrs.html" %}
|
||||
{% endwith %}
|
||||
>
|
||||
<i
|
||||
class="{{ widget.name }} fa fa-star"
|
||||
:class="{
|
||||
'checked': value >= {{ forloop.counter0 }},
|
||||
'unchecked': value < {{ forloop.counter0 }},
|
||||
'hovered': hover >= {{ forloop.counter0 }},
|
||||
'removed': hover >= 0 && value >= {{ forloop.counter0 }} && hover < {{ forloop.counter0 }},
|
||||
}"
|
||||
></i>
|
||||
<i class="fa fa-times-circle"></i>
|
||||
{{ widget.optgroups.0.1.0.label }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
{# Star widget #}
|
||||
{% for opt in widget.optgroups|slice:"1:" %}
|
||||
<label
|
||||
@mouseover="hover = {{ opt.1.0.value }}"
|
||||
for="{{ opt.1.0.attrs.id }}"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="{{ widget.name }}"
|
||||
value="{{ opt.1.0.value }}"
|
||||
@click="value = {{ opt.1.0.value }}"
|
||||
{% with widget=opt.1.0 %}
|
||||
{% include "django/forms/widgets/attrs.html" %}
|
||||
{% endwith %}
|
||||
>
|
||||
<i
|
||||
class="{{ widget.name }} fa fa-star"
|
||||
:class="{
|
||||
'checked': value >= {{ opt.1.0.value }},
|
||||
'unchecked': value < {{ opt.1.0.value }},
|
||||
'hovered': hover >= {{ opt.1.0.value }},
|
||||
'removed': hover >= 0 && value >= {{ opt.1.0.value }} && hover < {{ opt.1.0.value }},
|
||||
}"
|
||||
></i>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
@@ -89,13 +89,14 @@
|
||||
<p>{% trans %}You already posted a comment on this UE. If you want to comment again, please modify or delete your previous comment.{% endtrans %}</p>
|
||||
</div>
|
||||
{% elif user.has_perm("pedagogy.add_uecomment") %}
|
||||
<details class="accordion" id="leave_comment">
|
||||
<details class="accordion" id="leave_comment" {% if form.errors %}open{%endif%}>
|
||||
<summary>{% trans %}Leave comment{% endtrans %}</summary>
|
||||
<div class="accordion-content">
|
||||
<form action="{{ url('pedagogy:ue_detail', ue_id=object.id) }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="leave-comment-grid-container">
|
||||
<div class="form-stars">
|
||||
{{ form.non_field_errors() }}
|
||||
{{ form.author.errors }}
|
||||
{{ form.ue.errors }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user