Skip to content

Commit 33588c0

Browse files
Guillaume PerotLuc Donnet
authored andcommitted
Merged in CHOUETTE-3254-migrate-stop-area-type-for (pull request #1539)
CHOUETTE-3254 migrate stop area type form Approved-by: Luc Donnet
2 parents 2c0a41b + 274bd22 commit 33588c0

File tree

3 files changed

+5
-42
lines changed

3 files changed

+5
-42
lines changed

app/packs/entrypoints/stop_areas/form.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/packs/src/stop_areas/form_helper.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

app/views/stop_areas/_form.html.slim

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
- javascript_additional_packs 'stop_areas/form'
2-
31
= simple_form_for [@workbench, :stop_area_referential, @stop_area], html: {class: 'form-horizontal', id: 'stop_area_form'}, wrapper: :horizontal_form do |f|
42
.row
53
.col-lg-12
@@ -28,27 +26,26 @@
2826
.separator.section_separator
2927

3028
.row
31-
.col-lg-12
29+
.col-lg-12 x-data="{ kind: '#{@stop_area.kind}' || 'commercial'}"
3230
h2.mb-lg= t("stop_areas.form.sections.hierarchy")
3331
// as: :radio_buttons
3432
- if has_feature?("route_stop_areas_all_types")
3533
= f.input :kind,
3634
as: :radio_buttons,
3735
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' },
3937
include_blank: false,
4038
item_wrapper_class: 'radio-inline',
4139
wrapper: :horizontal_form,
4240
disabled: !@stop_area.new_record?
4341
- unless @stop_area.new_record?
4442
= f.input :kind, as: :hidden, input_html: { value: @stop_area.kind }
45-
.slave data-master="[name='stop_area[kind]']" data-value="commercial"
4643
- else
4744
= f.input :kind, as: :hidden, input_html: { value: :commercial }
4845
- %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)}}}
5249

5350
.separator.section_separator
5451

0 commit comments

Comments
 (0)