0001-arles-2020-always-prepend-an-empty-item-for-custom-l.patch
templates/variants/arles-2020/qommon/forms/widgets/select--with-images.html | ||
---|---|---|
3 | 3 |
{% block widget-control %} |
4 | 4 |
<select id="form_{{widget.name}}" name="{{widget.name}}" style="display: none" |
5 | 5 |
{% if widget.required %}data-required="true"{% endif %}> |
6 |
{% if not widget.separate_hint and widget.hint %} |
|
7 |
<option value="" data-hint="{{ widget.hint }}">{% if not widget.select2 %}{{ widget.hint }}{% endif %}</option> |
|
8 |
{% endif %} |
|
6 | 9 |
{% for option in widget.get_options %} |
7 | 10 |
<option{% for attr in option.attrs.items %} {{attr.0}}="{{attr.1}}"{% endfor %} |
8 | 11 |
data-image-url="{{ option.options.image_url }}" |
... | ... | |
22 | 25 |
var $list = $('#form_{{widget.name}}_images_list'); |
23 | 26 | |
24 | 27 |
function build_list(items) { |
28 |
var hint = $select.find('option[data-hint]').data('hint'); |
|
25 | 29 |
$select.empty(); |
30 |
if (hint) { |
|
31 |
var $option = $('<option></option>', {value: '', text: hint}); |
|
32 |
$option.attr('data-hint', hint); |
|
33 |
$option.appendTo($select); |
|
34 |
} |
|
26 | 35 |
for (var i=0; i<items.length; i++) { |
27 | 36 |
var $option = $('<option></option>', {value: items[i].id, text: items[i].text}); |
28 | 37 |
if (items[i].disabled) { |
29 | 38 |
$option.prop('disabled', true); |
30 | 39 |
} |
40 |
$option.appendTo($select); |
|
31 | 41 |
} |
32 | 42 |
} |
33 | 43 | |
... | ... | |
39 | 49 |
var $options = $select.find('option'); |
40 | 50 |
var $items = $(); |
41 | 51 |
for (var i=0; i<$options.length; i++) { |
42 |
if ($options[i].value == '---') {
|
|
52 |
if (!$options[i].value) {
|
|
43 | 53 |
continue; |
44 | 54 |
} |
45 | 55 |
var $item = $('<li style="--bg-image: url(' + $options[i].dataset.imageUrl + ')"/>'); |
46 |
- |