use "remove" link to clear evaluation
gitea/publik-base-theme/pipeline/head This commit looks good
Details
gitea/publik-base-theme/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c664b256c6
commit
037b100b03
|
@ -11,30 +11,37 @@
|
|||
</select>
|
||||
<div class="star-choice">
|
||||
{% for option in widget.get_options %}
|
||||
<span class="star" data-index="{{ forloop.counter }}"></span>
|
||||
<span role="button" class="star" data-index="{{ forloop.counter }}"></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if not widget.is_required %}
|
||||
<a role="button" title="remove evaluation" class="remove-evaluation" id="remove-evaluation-{{widget.name}}" hidden>
|
||||
Remove Evaluation
|
||||
</a>
|
||||
{% endif %}
|
||||
<script>
|
||||
$(function() {
|
||||
var $widget = $('[name="{{widget.name}}"]');
|
||||
$widget.parent().find('.star-choice span').on('click', function() {
|
||||
prop_selected = true
|
||||
var $remove_evaluation = $('#remove-evaluation-{{widget.name}}');
|
||||
var $stars = $widget.parent().find('.star-choice .star');
|
||||
$stars.on('click', function() {
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).nextAll().removeClass('selected');
|
||||
|
||||
// unselect first star if it is the only one selected
|
||||
if ($(this).data('index') == 1 && ! $(this).next().hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
prop_selected = false
|
||||
}
|
||||
} else {
|
||||
$(this).prevAll().addClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$(this).nextAll().removeClass('selected');
|
||||
}
|
||||
$widget.find('option[data-index=' + $(this).data('index') + ']').prop('selected', prop_selected);
|
||||
$widget.find('option[data-index=' + $(this).data('index') + ']').prop('selected', true);
|
||||
$remove_evaluation.prop('hidden', false);
|
||||
});
|
||||
$widget.parent().find('.star-choice [data-index=' + $widget.find('option:selected').data('index') + ']').trigger('click');
|
||||
$remove_evaluation.on('click', function(){
|
||||
var $no_value_option = $widget.find('option').eq(0);
|
||||
$no_value_option.prop('selected', true);
|
||||
$stars.removeClass('selected');
|
||||
$remove_evaluation.prop('hidden', true);
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue