diff options
| author | teddywing | 2018-04-25 17:59:33 +0200 |
|---|---|---|
| committer | GitHub | 2018-04-25 17:59:33 +0200 |
| commit | 9fec2b10fa947047e9a8a2f354d232c402b1ef40 (patch) | |
| tree | 2508ad56fcf1ca77e160e3a98b0b74eaf4bf0fec | |
| parent | 913dd3b3c6cfa0b519ac3043e8b0a4efc4d983b9 (diff) | |
| parent | 9050f4dde351e27e2cf33df7d1a4bc3b694ac04c (diff) | |
| download | chouette-core-9fec2b10fa947047e9a8a2f354d232c402b1ef40.tar.bz2 | |
Merge pull request #466 from af83/6431-line-and-stop-area-status
Refs #6431 small changes on line & stop area status
| -rw-r--r-- | app/helpers/referentials_helper.rb | 15 | ||||
| -rw-r--r-- | app/models/chouette/line.rb | 4 | ||||
| -rw-r--r-- | app/views/lines/_filters.html.slim | 10 | ||||
| -rw-r--r-- | app/views/lines/index.html.slim | 4 | ||||
| -rw-r--r-- | app/views/lines/show.html.slim | 2 | ||||
| -rw-r--r-- | app/views/referential_lines/show.html.slim | 2 | ||||
| -rw-r--r-- | app/views/referential_stop_areas/show.html.slim | 14 | ||||
| -rw-r--r-- | app/views/referentials/show.html.slim | 4 | ||||
| -rw-r--r-- | app/views/routes/show.html.slim | 5 | ||||
| -rw-r--r-- | app/views/stop_areas/_filters.html.slim | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.slim | 20 | ||||
| -rw-r--r-- | config/locales/lines.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/lines.fr.yml | 2 | ||||
| -rw-r--r-- | config/locales/stop_areas.en.yml | 6 | ||||
| -rw-r--r-- | config/locales/stop_areas.fr.yml | 7 |
16 files changed, 50 insertions, 51 deletions
diff --git a/app/helpers/referentials_helper.rb b/app/helpers/referentials_helper.rb index a01d901e6..9b5b13ace 100644 --- a/app/helpers/referentials_helper.rb +++ b/app/helpers/referentials_helper.rb @@ -1,15 +1,14 @@ module ReferentialsHelper # Outputs a green check icon and the text "Oui" or a red exclamation mark # icon and the text "Non" based on `status` - def line_status(status, verbose=true) - if status - out = content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') - out += t('activerecord.attributes.line.deactivated') if verbose - out + def line_status(status) + case status + when :deactivated + content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') + + Chouette::Line.tmf('deactivated') else - out = content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') - out += t('activerecord.attributes.line.activated') if verbose - out + content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') + + Chouette::Line.tmf('activated') end end diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index 4b5d1a68d..3ef2d8e1d 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -114,5 +114,9 @@ module Chouette def activated? !deactivated end + + def status + activated? ? :activated : :deactivated + end end end diff --git a/app/views/lines/_filters.html.slim b/app/views/lines/_filters.html.slim index f745d10a4..992d163fe 100644 --- a/app/views/lines/_filters.html.slim +++ b/app/views/lines/_filters.html.slim @@ -8,23 +8,23 @@ .ffg-row .form-group.togglable class=filter_item_class(params[:q], :network_id_eq_any) - = f.label Chouette::Line.human_attribute_name(:network_id), required: false, class: 'control-label' + = f.label Chouette::Line.tmf(:network_id), required: false, class: 'control-label' = f.input :network_id_eq_any, collection: @line_referential.networks.order(name: :asc), as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} .form-group.togglable class=filter_item_class(params[:q], :company_id_eq_any) - = f.label Chouette::Line.human_attribute_name(:company_id), required: false, class: 'control-label' + = f.label Chouette::Line.tmf(:company_id), required: false, class: 'control-label' = f.input :company_id_eq_any, collection: @line_referential.companies.order(name: :asc), as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} .form-group.togglable class=filter_item_class(params[:q], :transport_mode_eq_any) - = f.label Chouette::Line.human_attribute_name(:transport_mode), required: false, class: 'control-label' + = f.label Chouette::Line.tmf(:transport_mode), required: false, class: 'control-label' = f.input :transport_mode_eq_any, collection: StifTransportModeEnumerations.sorted_transport_modes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_mode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} .form-group.togglable class=filter_item_class(params[:q], :transport_submode_eq_any) - = f.label Chouette::Line.human_attribute_name(:transport_submode), required: false, class: 'control-label' + = f.label Chouette::Line.tmf(:transport_submode), required: false, class: 'control-label' = f.input :transport_submode_eq_any, collection: StifTransportSubmodeEnumerations.sorted_transport_submodes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_submode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} .form-group.togglable class=filter_item_class(params[:q], :status) - = f.label Chouette::Line.human_attribute_name(:state), required: false, class: 'control-label' + = f.label Chouette::Line.tmf(:status), required: false, class: 'control-label' .form-group.checkbox_list = f.simple_fields_for :status do |p| = p.input :activated, diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim index 4d4ba938d..02bb5ec6e 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -29,9 +29,9 @@ end \ ), \ TableBuilderHelper::Column.new( \ - name: t('activerecord.attributes.line.state'), \ + key: :status, \ class: :state, \ - attribute: Proc.new { |n| line_status(n.deactivated) } \ + attribute: Proc.new { |n| line_status(n.status) } \ ), \ TableBuilderHelper::Column.new( \ key: 'networks.name', \ diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index b683b9be6..fae32fb5d 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -7,7 +7,7 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { t('objectid') => @line.get_objectid.short_id, - Chouette::Line.tmf(:state) => line_status(@line.deactivated), + Chouette::Line.tmf(:status) => line_status(@line.status), Chouette::Line.tmf(:network_id) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name), Chouette::Line.tmf(:company_id) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), Chouette::Line.tmf(:secondary_companies) => (@line.secondary_companies.nil? ? t('lines.index.unset') : array_to_html_list(@line.secondary_companies.collect(&:name))), diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 4804da527..e387146d7 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -7,7 +7,7 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { t('id_codif') => @line.get_objectid.short_id, - Chouette::Line.tmf('state') => line_status(@line.deactivated), + Chouette::Line.tmf('status') => line_status(@line.status), Chouette::Line.tmf('network_id') => (@line.network.nil? ? t('lines.index.unset') : link_to(@line.network.name, [@referential, @line.network]) ), Chouette::Line.tmf('company') => (@line.company.nil? ? t('lines.index.unset') : link_to(@line.company.name, [@referential, @line.company]) ), Chouette::Line.tmf('secondary_companies') => (@line.secondary_companies.nil? ? t('lines.index.unset') : @line.secondary_companies.collect(&:name).join(', ')), diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index cb04ab7a6..beee0383f 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -7,10 +7,10 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { t('id_reflex') => @stop_area.try(:user_objectid), - 'Activé' => (@stop_area.deleted_at ? t('false') : t('true')), - @stop_area.human_attribute_name(:comment) => @stop_area.try(:comment), - @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), - @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number, - 'Coordonnées' => geo_data(@stop_area, @stop_area_referential), - @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, - @stop_area.human_attribute_name(:city_name) => @stop_area.city_name } + Chouette::StopArea.tmf(:status) => stop_area_status(@stop_area), + Chouette::StopArea.tmf(:comment) => @stop_area.try(:comment), + Chouette::StopArea.tmf(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), + Chouette::StopArea.tmf(:registration_number) => @stop_area.registration_number, + Chouette::StopArea.tmf(:coordinates) => geo_data(@stop_area, @stop_area_referential), + Chouette::StopArea.tmf(:zip_code) => @stop_area.zip_code, + Chouette::StopArea.tmf(:city_name) => @stop_area.city_name }
\ No newline at end of file diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index b2a079ab4..3cdcff63b 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -40,8 +40,8 @@ end \ ), \ TableBuilderHelper::Column.new( \ - key: :state, \ - attribute: Proc.new { |n| line_status(n.deactivated?) } \ + key: :status, \ + attribute: Proc.new { |n| line_status(n.status) } \ ), \ TableBuilderHelper::Column.new( \ key: :transport_mode, \ diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index d4571c173..aea824a89 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -34,8 +34,9 @@ end \ ), \ TableBuilderHelper::Column.new( \ - name: Chouette::Line.tmf('activated'), \ - attribute: Proc.new { |s| line_status(s.try(:stop_area).deleted_at) } \ + key: :status, \ + name: Chouette::StopArea.tmf('status'), \ + attribute: Proc.new { |s| stop_area_status(s.try(:stop_area)) } \ ), \ TableBuilderHelper::Column.new( \ key: :zip_code, \ diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim index c698eaaa5..caa264d5e 100644 --- a/app/views/stop_areas/_filters.html.slim +++ b/app/views/stop_areas/_filters.html.slim @@ -15,7 +15,7 @@ = 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], :status) - = f.label Chouette::StopArea.human_attribute_name(:state), required: false, class: 'control-label' + = f.label Chouette::StopArea.tmf('status'), required: false, class: 'control-label' .form-group.checkbox_list = f.simple_fields_for :status do |p| = p.input :in_creation, diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index fbdb54e02..62b873c36 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -32,7 +32,7 @@ attribute: 'registration_number' \ ), \ TableBuilderHelper::Column.new( \ - name: Chouette::StopArea.tmf('state'), \ + key: :status, \ attribute: Proc.new { |s| stop_area_status(s) } \ ), \ TableBuilderHelper::Column.new( \ diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index 851bd9b82..c4d06f61d 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -10,18 +10,18 @@ - if has_feature?(:stop_area_localized_names) - @stop_area.localized_names.each do |k, v| - - attributes.merge!({label_for_country(k, @stop_area.human_attribute_name(:name)) => v }) if v.present? - - attributes.merge!({ @stop_area.human_attribute_name(:parent) => @stop_area.parent ? link_to(@stop_area.parent.name, stop_area_referential_stop_area_path(@stop_area_referential, @stop_area.parent)) : "-" }) if @stop_area.commercial? - - attributes.merge!({ @stop_area.human_attribute_name(:stop_area_type) => Chouette::AreaType.find(@stop_area.area_type).try(:label), - @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number, + - attributes.merge!({label_for_country(k, Chouette::StopArea.tmf('name')) => v }) if v.present? + - attributes.merge!({ Chouette::StopArea.tmf('parent') => @stop_area.parent ? link_to(@stop_area.parent.name, stop_area_referential_stop_area_path(@stop_area_referential, @stop_area.parent)) : "-" }) if @stop_area.commercial? + - attributes.merge!({ Chouette::StopArea.tmf('stop_area_type') => Chouette::AreaType.find(@stop_area.area_type).try(:label), + Chouette::StopArea.tmf('registration_number') => @stop_area.registration_number, }) - - attributes.merge!(@stop_area.human_attribute_name(:waiting_time) => @stop_area.waiting_time_text) if has_feature?(:stop_area_waiting_time) + - 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), - @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, - @stop_area.human_attribute_name(:city_name) => @stop_area.city_name, - @stop_area.human_attribute_name(:country_code) => @stop_area.country_code.presence || '-', - t('activerecord.attributes.stop_area.state') => stop_area_status(@stop_area), - @stop_area.human_attribute_name(:comment) => @stop_area.try(:comment), + Chouette::StopArea.tmf('zip_code') => @stop_area.zip_code, + Chouette::StopArea.tmf('city_name') => @stop_area.city_name, + Chouette::StopArea.tmf('country_code') => @stop_area.country_code.presence || '-', + Chouette::StopArea.tmf('status') => stop_area_status(@stop_area), + Chouette::StopArea.tmf('comment') => @stop_area.try(:comment), }) - @stop_area.custom_fields.each do |code, field| - attributes.merge!(field.name => field.display_value) diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml index c1f9063a7..6501faa57 100644 --- a/config/locales/lines.en.yml +++ b/config/locales/lines.en.yml @@ -118,7 +118,7 @@ en: creator_id: "Created by" footnotes: "Footnotes" stable_id: External permanent idenifier" - state: Status + status: Status activated: Activated deactivated: Deactivated formtastic: diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml index 487cae35c..587453e83 100644 --- a/config/locales/lines.fr.yml +++ b/config/locales/lines.fr.yml @@ -118,7 +118,7 @@ fr: creator_id: "Créé par" footnotes: "Notes de bas de page" stable_id: "Identifiant externe pérenne" - state: État + status: État activated: Activée deactivated: Désactivée formtastic: diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml index 4d19a77e9..7f460381c 100644 --- a/config/locales/stop_areas.en.yml +++ b/config/locales/stop_areas.en.yml @@ -71,9 +71,6 @@ en: access_managment: "Access Points and Links managment" access_points: "Access Points" not_editable: "The area type is not editable" - state: - active: Active - deactivated: Deactivated genealogical: genealogical: "Links between stop area" genealogical_routing: "Routing constraint's links" @@ -115,6 +112,7 @@ en: confirmed: "Activated" confirmed_at: "Activated at" deleted: "Deactivated" + deactivated: "Deactivated" deleted_at: "Deactivated at" comment: "Description" stop_area_type: "Area type" @@ -148,7 +146,7 @@ en: zip_code: "Zip code" city_name: "City" waiting_time: Waiting time (minutes) - state: Status + status: Status formtastic: titles: stop_area: diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml index 6a5fbf24b..c85faaf7d 100644 --- a/config/locales/stop_areas.fr.yml +++ b/config/locales/stop_areas.fr.yml @@ -72,9 +72,6 @@ fr: access_managment: "Gestion des accès et liens associés" access_points: "Points d'accès" not_editable: "Le type d'arrêt est non modifiable" - state: - active: Actif - deactivated: Désactivé genealogical: genealogical: "Lien entre arrêts" genealogical_routing: "Liens de l'ITL" @@ -114,7 +111,7 @@ fr: registration_number: "Numéro d'enregistrement" published_name: "Nom public" in_creation: "En création" - confirmed: "Actif" + confirmed: "Activé" confirmed_at: "Activé le" deleted: "Désactivé" deactivated: "Désactivé" @@ -151,7 +148,7 @@ fr: zip_code: "Code postal" city_name: "Commune" waiting_time: Temps de desserte (minutes) - state: État + status: État formtastic: titles: stop_area: |
