diff options
| author | cedricnjanga | 2018-04-24 08:17:36 -0700 |
|---|---|---|
| committer | cedricnjanga | 2018-05-28 22:09:12 -0700 |
| commit | 415b2e285553ec0bb06de90c242a8fa519b401b4 (patch) | |
| tree | 1ed67df33f311e8cba396ededaa70087a3db3ad6 | |
| parent | 6c0fbf9906096fed881a5af5510772a50a17acfb (diff) | |
| download | chouette-core-415b2e285553ec0bb06de90c242a8fa519b401b4.tar.bz2 | |
Refs #5642 Add local_code attribute to StopArea
| -rw-r--r-- | app/views/stop_areas/_filters.html.slim | 34 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 1 | ||||
| -rw-r--r-- | app/views/stop_areas/autocomplete.rabl | 1 | ||||
| -rw-r--r-- | app/views/stop_areas/index.html.slim | 4 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.slim | 2 | ||||
| -rw-r--r-- | config/locales/stop_areas.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/stop_areas.fr.yml | 9 | ||||
| -rw-r--r-- | config/locales/stop_points.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/stop_points.fr.yml | 3 | ||||
| -rw-r--r-- | db/migrate/20180424140219_add_local_code_to_stop_areas.rb | 5 | ||||
| -rw-r--r-- | lib/stif/reflex_synchronization.rb | 2 | ||||
| -rw-r--r-- | spec/tasks/reflex_rake_spec.rb | 2 |
12 files changed, 52 insertions, 14 deletions
diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim index 88ed6a772..fcf8036a1 100644 --- a/app/views/stop_areas/_filters.html.slim +++ b/app/views/stop_areas/_filters.html.slim @@ -10,15 +10,37 @@ .ffg-row = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.tmf('zip_code'), required: false, wrapper_html: {class: filter_item_class(params[:q], :zip_code_cont)} - = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.tmf('city_name'), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)} + = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.tmf(:city_name), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)} .form-group.togglable class=filter_item_class(params[:q], :area_type_eq_any) - = f.label Chouette::StopArea.tmf('area_type'), required: false, class: 'control-label' + = f.label Chouette::StopArea.tmf(:area_type), required: false, class: 'control-label' = f.input :area_type_eq_any, checked: params[:q] && params[:q][:area_type_eq_any], collection: Chouette::AreaType.options, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + w[0] + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' } - - .form-group.togglable class=filter_item_class(params[:q], :by_status) - = f.label Chouette::StopArea.tmf('status'), required: false, class: 'control-label' - = f.input :by_status, checked: params[:q] && params[:q][:by_status], collection: [:in_creation, :confirmed, :deactivated], as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + stop_area_status(w) + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' } + + .form-group.togglable class=filter_item_class(params[:q], :status) + = f.label Chouette::StopArea.tmf(:state), required: false, class: 'control-label' + .form-group.checkbox_list + = f.simple_fields_for :status do |p| + = p.input :in_creation, + label: ("<span>#{t('activerecord.attributes.stop_area.in_creation')}<span class='fa fa-pencil text-info'></span></span>").html_safe, + as: :boolean, + wrapper_html: { class: 'checkbox-wrapper' }, + checked_value: true, + unchecked_value: false, + input_html: { checked: @status.try(:[], :in_creation) } + = p.input :confirmed, + label: ("<span>#{t('activerecord.attributes.stop_area.confirmed')}<span class='fa fa-check-circle text-success'></span></span>").html_safe, + as: :boolean, + wrapper_html: { class: 'checkbox-wrapper' }, + checked_value: true, + unchecked_value: false, + input_html: { checked: @status.try(:[], :confirmed) } + = p.input :deactivated, + label: ("<span>#{t('activerecord.attributes.stop_area.deleted')}<span class='fa fa-exclamation-circle text-danger'></span></span>").html_safe, + as: :boolean, + wrapper_html: { class: 'checkbox-wrapper' }, + checked_value: true, + unchecked_value: false, + input_html: { checked: @status.try(:[], :deactivated) } .actions = link_to t('actions.erase'), @workbench, class: 'btn btn-link' diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 2ac316632..e04df00ac 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -39,6 +39,7 @@ = f.input :coordinates, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")} = f.input :street_name = f.input :zip_code, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} + = f.input :local_code, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} = f.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")} = f.input :country_code, as: :country, priority: ['FR', 'GB', 'DE', 'ES'], :include_blank => true diff --git a/app/views/stop_areas/autocomplete.rabl b/app/views/stop_areas/autocomplete.rabl index 26fca36b2..dd0c7eb56 100644 --- a/app/views/stop_areas/autocomplete.rabl +++ b/app/views/stop_areas/autocomplete.rabl @@ -7,6 +7,7 @@ node do |stop_area| :short_registration_number => truncate(stop_area.registration_number, :length => 10) || "", :name => stop_area.name || "", :short_name => truncate(stop_area.name, :length => 30) || "", + :local_code => stop_area.local_code || "", :zip_code => stop_area.zip_code || "", :city_name => stop_area.city_name || "", :short_city_name => truncate(stop_area.city_name, :length => 15) || "", diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index e5ca82ee2..1cc4a2883 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -36,8 +36,8 @@ attribute: Proc.new { |s| stop_area_status(s.status) } \ ), \ TableBuilderHelper::Column.new( \ - key: :zip_code, \ - attribute: 'zip_code' \ + key: :local_code, \ + attribute: 'local_code' \ ), \ TableBuilderHelper::Column.new( \ key: :city_name, \ diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index c1965c161..c083fcd0b 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -18,6 +18,7 @@ - attributes.merge!(Chouette::StopArea.tmf('waiting_time') => @stop_area.waiting_time_text) if has_feature?(:stop_area_waiting_time) - attributes.merge!({ "Coordonnées" => geo_data(@stop_area, @stop_area_referential), Chouette::StopArea.tmf('zip_code') => @stop_area.zip_code, + Chouette::StopArea.tmf('local_code') => @stop_area.try(:local_code), Chouette::StopArea.tmf('city_name') => @stop_area.city_name, Chouette::StopArea.tmf('country_code') => @stop_area.country_code.presence || '-', Chouette::StopArea.tmf('time_zone') => @stop_area.time_zone.presence || '-', @@ -27,3 +28,4 @@ - @stop_area.custom_fields.each do |code, field| - attributes.merge!(field.name => field.display_value) = definition_list t('metadatas'), attributes + diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml index 7f460381c..624db9820 100644 --- a/config/locales/stop_areas.en.yml +++ b/config/locales/stop_areas.en.yml @@ -49,6 +49,7 @@ en: filters: name_or_objectid: "Search by name or by objectid..." zip_code: Enter a zip code... + local_code: Enter a local code... city_name: Enter a city name... area_type: Enter an area type... new: @@ -144,6 +145,7 @@ en: parent: "Parent" coordinates: "Coordinates (lat,lng) WGS84" zip_code: "Zip code" + local_code: "Local code" city_name: "City" waiting_time: Waiting time (minutes) status: Status diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml index 03640b1ec..3eed84ea6 100644 --- a/config/locales/stop_areas.fr.yml +++ b/config/locales/stop_areas.fr.yml @@ -49,7 +49,8 @@ fr: export_hub_physical: "Export HUB des arrêts physiques" filters: name_or_objectid: "Recherche par nom ou par objectid..." - zip_code: Indiquez un code INSEE... + local_code: Indiquez un code INSEE... + zip_code: Indiquez un code postal... city_name: Indiquez un nom de commune... area_type: "Indiquez un type d'arrêt..." new: @@ -83,7 +84,8 @@ fr: access_link_legend_2: "cliquer sur les flêches pour créer/éditer un lien" index: name: "Recherche par nom..." - zip_code: "Code INSEE" + zip_code: "Code postal" + local_code: "Code INSEE" city_name: "Commune" title: "Arrêts" selection: "Filtrer sur" @@ -145,7 +147,8 @@ fr: routing_line_ids: "Lignes affectées par l'ITL" parent: "Parent" coordinates: "Coordonnées (lat,lng) WGS84" - zip_code: "Code INSEE" + zip_code: "Code postal" + local_code: "Code INSEE" city_name: "Commune" waiting_time: Temps de desserte (minutes) status: État diff --git a/config/locales/stop_points.en.yml b/config/locales/stop_points.en.yml index bcdb56de8..32815c656 100644 --- a/config/locales/stop_points.en.yml +++ b/config/locales/stop_points.en.yml @@ -48,6 +48,7 @@ en: area_type: "Area type" city_name: "City name" zip_code: "Zip code" + local_code: "Local code" position: "Position" simple_form: labels: diff --git a/config/locales/stop_points.fr.yml b/config/locales/stop_points.fr.yml index efd34f4dd..38b7e32d5 100644 --- a/config/locales/stop_points.fr.yml +++ b/config/locales/stop_points.fr.yml @@ -47,7 +47,8 @@ fr: for_alighting: "Descente" area_type: "Type d'arrêt" city_name: "Commune" - zip_code: "Code INSEE" + zip_code: "Code postal" + local_code: "Code INSEE" position: "Position" simple_form: labels: diff --git a/db/migrate/20180424140219_add_local_code_to_stop_areas.rb b/db/migrate/20180424140219_add_local_code_to_stop_areas.rb new file mode 100644 index 000000000..16c9ba1e1 --- /dev/null +++ b/db/migrate/20180424140219_add_local_code_to_stop_areas.rb @@ -0,0 +1,5 @@ +class AddLocalCodeToStopAreas < ActiveRecord::Migration + def change + add_column :stop_areas, :local_code, :string + end +end diff --git a/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb index 508d28b40..3a56a80f7 100644 --- a/lib/stif/reflex_synchronization.rb +++ b/lib/stif/reflex_synchronization.rb @@ -156,7 +156,7 @@ module Stif name: 'Name', area_type: 'TypeOfPlaceRef', object_version: 'version', - zip_code: 'PostalRegion', + local_code: 'PostalRegion', city_name: 'Town', stif_type: 'OBJECT_STATUS', }.each do |k, v| stop[k] = entry[v] end diff --git a/spec/tasks/reflex_rake_spec.rb b/spec/tasks/reflex_rake_spec.rb index 6ece223d2..bdbdcfb2d 100644 --- a/spec/tasks/reflex_rake_spec.rb +++ b/spec/tasks/reflex_rake_spec.rb @@ -35,7 +35,7 @@ describe 'reflex:sync' do it 'should map xml data to StopArea attribute' do stop_area = Chouette::StopArea.find_by(objectid: 'FR:77153:LDA:69325:STIF') - expect(stop_area.zip_code).to eq '77153' + expect(stop_area.local_code).to eq '77153' expect(stop_area.area_type).to eq 'lda' end |
