0001-js-make-it-possible-to-dynamically-show-hide-widgets.patch
wcs/qommon/form.py | ||
---|---|---|
124 | 124 |
attributes['data-' + k] = v |
125 | 125 |
if hasattr(self, 'div_id') and self.div_id: |
126 | 126 |
attributes['id'] = self.div_id |
127 |
for attr in ('data-dynamic-display-child-of', 'data-dynamic-display-value'): |
|
128 |
if attr in self.attrs: |
|
129 |
attributes[attr] = self.attrs.pop(attr) |
|
127 | 130 |
attributes['class'] = classnames |
128 | 131 |
r += htmltext('<div %s>' % ' '.join(['%s="%s"' % x for x in attributes.items()])) |
129 | 132 |
r += self.render_title(self.get_title()) |
wcs/qommon/static/js/qommon.js | ||
---|---|---|
9 | 9 |
error: function(error) { windows.console && console.log('bouh', error); } |
10 | 10 |
}); |
11 | 11 |
}); |
12 |
$('[data-dynamic-display-parent]').change(function() { |
|
13 |
var sel1 = '[data-dynamic-display-child-of="' + $(this).attr('name') + '"]'; |
|
14 |
var sel2 = '[data-dynamic-display-value="' + $(this).val() + '"]'; |
|
15 |
$(sel1).hide(); |
|
16 |
$(sel1 + sel2).show(); |
|
17 |
}); |
|
18 |
$('[data-dynamic-display-child-of]').hide(); |
|
19 |
$('[data-dynamic-display-parent]:checked').trigger('change'); |
|
12 | 20 |
}); |
13 |
- |