From 1f8d2759c545e60ab2989fc6331e55e95a3b0e67 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 10 Apr 2018 09:40:58 -0700 Subject: Refs #6431 small changes on line & stop area status --- app/helpers/referentials_helper.rb | 15 +++++++-------- app/models/chouette/line.rb | 4 ++++ app/views/lines/_filters.html.slim | 10 +++++----- app/views/lines/index.html.slim | 4 ++-- app/views/referentials/show.html.slim | 4 ++-- app/views/stop_areas/_filters.html.slim | 2 +- app/views/stop_areas/index.html.slim | 2 +- app/views/stop_areas/show.html.slim | 20 ++++++++++---------- config/locales/lines.en.yml | 2 +- config/locales/lines.fr.yml | 2 +- config/locales/stop_areas.en.yml | 4 ++-- config/locales/stop_areas.fr.yml | 4 ++-- 12 files changed, 38 insertions(+), 35 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| ("" + l.name + "").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| ("" + l.name + "").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| ("" + t("enumerize.transport_mode.#{l}") + "").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| ("" + t("enumerize.transport_submode.#{l}") + "").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/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/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| ("" + w[0] + "").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..81a0cf26f 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'), \ + name: Chouette::StopArea.tmf('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..d1af3e319 100644 --- a/config/locales/stop_areas.en.yml +++ b/config/locales/stop_areas.en.yml @@ -71,7 +71,7 @@ en: access_managment: "Access Points and Links managment" access_points: "Access Points" not_editable: "The area type is not editable" - state: + status: active: Active deactivated: Deactivated genealogical: @@ -148,7 +148,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..12cb6d718 100644 --- a/config/locales/stop_areas.fr.yml +++ b/config/locales/stop_areas.fr.yml @@ -72,7 +72,7 @@ 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: + status: active: Actif deactivated: Désactivé genealogical: @@ -151,7 +151,7 @@ fr: zip_code: "Code postal" city_name: "Commune" waiting_time: Temps de desserte (minutes) - state: État + status: État formtastic: titles: stop_area: -- cgit v1.2.3 From 9050f4dde351e27e2cf33df7d1a4bc3b694ac04c Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 24 Apr 2018 13:03:04 -0700 Subject: Refs #6431 Add small changes on stop area & line status display to have the same logic --- app/views/lines/show.html.slim | 2 +- app/views/referential_lines/show.html.slim | 2 +- app/views/referential_stop_areas/show.html.slim | 14 +++++++------- app/views/routes/show.html.slim | 5 +++-- app/views/stop_areas/index.html.slim | 2 +- config/locales/stop_areas.en.yml | 4 +--- config/locales/stop_areas.fr.yml | 5 +---- 7 files changed, 15 insertions(+), 19 deletions(-) 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/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/index.html.slim b/app/views/stop_areas/index.html.slim index 81a0cf26f..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('status'), \ + key: :status, \ attribute: Proc.new { |s| stop_area_status(s) } \ ), \ TableBuilderHelper::Column.new( \ diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml index d1af3e319..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" - status: - 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" diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml index 12cb6d718..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" - status: - 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é" -- cgit v1.2.3