0001-update-items-fields-in-live_process_fields.patch
wcs/fields.py | ||
---|---|---|
1867 | 1867 |
data_source_type.set_value(None) |
1868 | 1868 |
data_source_type.transfer_form_value(get_request()) |
1869 | 1869 | |
1870 |
def get_extended_options(self): |
|
1871 |
if self.data_source: |
|
1872 |
return data_sources.get_structured_items( |
|
1873 |
self.data_source, mode='lazy', include_disabled=self.display_disabled_items |
|
1874 |
) |
|
1875 |
if self.items: |
|
1876 |
return [{'id': x, 'text': x} for x in self.items] |
|
1877 |
return [] |
|
1878 | ||
1870 | 1879 | |
1871 | 1880 |
class ItemField(WidgetField, MapOptionsMixin, ItemFieldMixin): |
1872 | 1881 |
key = 'item' |
... | ... | |
1921 | 1930 |
return [(x, x) for x in self.items] |
1922 | 1931 |
return [] |
1923 | 1932 | |
1924 |
def get_extended_options(self): |
|
1925 |
if self.data_source: |
|
1926 |
return data_sources.get_structured_items( |
|
1927 |
self.data_source, mode='lazy', include_disabled=self.display_disabled_items |
|
1928 |
) |
|
1929 |
if self.items: |
|
1930 |
return [{'id': x, 'text': x} for x in self.items] |
|
1931 |
return [] |
|
1932 | ||
1933 | 1933 |
def get_display_mode(self, data_source=None): |
1934 | 1934 |
if not data_source: |
1935 | 1935 |
data_source = data_sources.get_object(self.data_source) |
... | ... | |
2260 | 2260 |
data_source = {} |
2261 | 2261 |
in_filters = False |
2262 | 2262 |
display_disabled_items = False |
2263 |
display_mode = None |
|
2263 | 2264 | |
2264 | 2265 |
widget_class = CheckboxesWidget |
2265 | 2266 |
wcs/formdef.py | ||
---|---|---|
825 | 825 |
if varname not in live_condition_fields: |
826 | 826 |
live_condition_fields[varname] = [] |
827 | 827 |
live_condition_fields[varname].append(field) |
828 |
if field.key == 'item' and field.data_source:
|
|
828 |
if field.key in ('item', 'items') and field.data_source:
|
|
829 | 829 |
data_source = data_sources.get_object(field.data_source) |
830 | 830 |
if data_source.type not in ('json', 'geojson') and not data_source.type.startswith( |
831 | 831 |
'carddef:' |
wcs/forms/common.py | ||
---|---|---|
758 | 758 |
break |
759 | 759 | |
760 | 760 |
for field in displayed_fields: |
761 |
if field.key == 'item' and field.data_source:
|
|
761 |
if field.key in ('item', 'items') and field.data_source:
|
|
762 | 762 |
data_source = data_sources.get_object(field.data_source) |
763 | 763 |
if data_source.type not in ('json', 'geojson') and not data_source.type.startswith( |
764 | 764 |
'carddef:' |
wcs/qommon/static/js/qommon.forms.js | ||
---|---|---|
473 | 473 |
} else { |
474 | 474 |
$widget.hide(); |
475 | 475 |
} |
476 |
if (value.items && $widget.is('.RadiobuttonsWidget')) { |
|
476 |
if (value.items && $widget.is('.CheckboxesWidget')) { |
|
477 |
var input_name = $widget.data('widget-name'); |
|
478 |
/* get current list */ |
|
479 |
var current_value = {}; |
|
480 |
var items = []; |
|
481 |
$widget.find('li').each(function (i, elt) { |
|
482 |
var label = $(elt).find('label span').text(); |
|
483 |
items.push(label); |
|
484 |
if ($(elt).find('input:checked')) { |
|
485 |
current_value[label] = true; |
|
486 |
} |
|
487 |
}); |
|
488 |
var $ul = $widget.find('.content ul'); |
|
489 |
var new_items = value.items.map(function (item) { return item.text }); |
|
490 |
$ul.empty() |
|
491 |
for (var i=0; i<value.items.length; i++) { |
|
492 |
var item = value.items[i]; |
|
493 |
var $li = $('<li>'); |
|
494 |
var $label = $('<label>'); |
|
495 |
$label.appendTo($li); |
|
496 |
var input_value = ''; |
|
497 |
if (current_value[item.text]) { |
|
498 |
input_value = 'yes'; |
|
499 |
} |
|
500 |
var name = input_name + '$element' + (i + 1) |
|
501 |
var $input = $('<input>', {type: 'checkbox', value: input_value, name: name}); |
|
502 |
if (item.disabled) { |
|
503 |
$input.prop('disabled', true); |
|
504 |
$label.addClass('disabled'); |
|
505 |
} |
|
506 |
$input.appendTo($label); |
|
507 |
var $span = $('<span>', {text: item.text}); |
|
508 |
$span.appendTo($label); |
|
509 |
$li.appendTo($ul); |
|
510 |
} |
|
511 |
} else if (value.items && $widget.is('.RadiobuttonsWidget')) { |
|
477 | 512 |
var current_value = $widget.find('input:checked').val(); |
478 | 513 |
var $hint = $widget.find('.hint').detach(); |
479 | 514 |
var input_name = $widget.data('widget-name'); |
480 |
- |