|
1 | | -- javascript_additional_packs 'stop_areas/form' |
2 | | - |
3 | 1 | = simple_form_for [@workbench, :stop_area_referential, @stop_area], html: {class: 'form-horizontal', id: 'stop_area_form'}, wrapper: :horizontal_form do |f| |
4 | 2 | .row |
5 | 3 | .col-lg-12 |
|
28 | 26 | .separator.section_separator |
29 | 27 |
|
30 | 28 | .row |
31 | | - .col-lg-12 |
| 29 | + .col-lg-12 x-data="{ kind: '#{@stop_area.kind}' || 'commercial'}" |
32 | 30 | h2.mb-lg= t("stop_areas.form.sections.hierarchy") |
33 | 31 | // as: :radio_buttons |
34 | 32 | - if has_feature?("route_stop_areas_all_types") |
35 | 33 | = f.input :kind, |
36 | 34 | as: :radio_buttons, |
37 | 35 | checked: @stop_area.new_record? ? :commercial : @stop_area.kind, |
38 | | - input_html: { disabled: !@stop_area.new_record? }, |
| 36 | + input_html: { disabled: !@stop_area.new_record?, 'x-on:change': 'kind = $event.target.value' }, |
39 | 37 | include_blank: false, |
40 | 38 | item_wrapper_class: 'radio-inline', |
41 | 39 | wrapper: :horizontal_form, |
42 | 40 | disabled: !@stop_area.new_record? |
43 | 41 | - unless @stop_area.new_record? |
44 | 42 | = f.input :kind, as: :hidden, input_html: { value: @stop_area.kind } |
45 | | - .slave data-master="[name='stop_area[kind]']" data-value="commercial" |
46 | 43 | - else |
47 | 44 | = f.input :kind, as: :hidden, input_html: { value: :commercial } |
48 | 45 | - %i(non_commercial commercial).each do |kind| |
49 | | - .slave data-master="[name='stop_area[kind]']" data-value=kind |
50 | | - = f.input :area_type, as: :select, input_html: {id: kind, disabled: !@stop_area.new_record?}, collection: area_type_options(kind), include_blank: false, disabled: !@stop_area.new_record? |
51 | | - = f.input :parent_id, as: :select, collection: [f.object.parent_id], input_html: { data: { select2ed_placeholder: Chouette::StopArea.tmf('parent'), select2ed_allow_clear: 'true', select2_ajax: 'true', url: autocomplete_workbench_stop_area_referential_stop_areas_path(@workbench), initvalue: {id: f.object.parent_id, text: f.object.parent.try(:formatted_selection_details)}}} |
| 46 | + .kind x-show="kind === '#{kind}'" |
| 47 | + = f.input :area_type, as: :select, input_html: { id: kind, disabled: !@stop_area.new_record?, 'x-bind:disabled': "kind != '#{kind}'" }, collection: area_type_options(kind), include_blank: false, disabled: !@stop_area.new_record? |
| 48 | + = f.input :parent_id, as: :select, collection: [f.object.parent_id], input_html: {'x-bind:disabled': "kind === 'non_commercial' || #{@stop_area.kind == 'non_commercial' }", data: { select2ed_placeholder: Chouette::StopArea.tmf('parent'), select2ed_allow_clear: 'true', select2_ajax: 'true', url: autocomplete_workbench_stop_area_referential_stop_areas_path(@workbench), initvalue: {id: f.object.parent_id, text: f.object.parent.try(:formatted_selection_details)}}} |
52 | 49 |
|
53 | 50 | .separator.section_separator |
54 | 51 |
|
|
0 commit comments