diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/application.sass | 2 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 1 | ||||
| -rw-r--r-- | app/helpers/stop_areas_helper.rb | 6 | ||||
| -rw-r--r-- | app/models/chouette/stop_area.rb | 7 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 6 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.slim | 6 | 
6 files changed, 23 insertions, 5 deletions
| diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 50f8b64cb..3f8467efe 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -19,3 +19,5 @@  @import 'modules/vj_collection'  @import 'modules/timetables'  @import 'modules/import_messages' + +@import 'flag-icon' diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 076de922c..41a1a8c6d 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -202,6 +202,7 @@ class StopAreasController < ChouetteController        :waiting_time,        :zip_code,        :kind, +      localized_names: Chouette::StopArea::AVAILABLE_LOCALIZATIONS      )    end diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb index 3e04fac7d..05ae042f5 100644 --- a/app/helpers/stop_areas_helper.rb +++ b/app/helpers/stop_areas_helper.rb @@ -11,6 +11,10 @@ module StopAreasHelper      ( "<img src='#{stop_area_picture_url(stop_area)}'/>" + " <span style='height:25px; line-height:25px; margin-left: 5px; '>" + name + " <small style='height:25px; line-height:25px; margin-left: 10px; color: #555;'>" + localization + "</small></span>").html_safe    end +  def label_for_country country, txt=nil +    "#{txt} <span title='#{ISO3166::Country[country]&.translation(I18n.locale)}' class='flag-icon flag-icon-#{country}'></span>".html_safe +  end +    def genealogical_title      return t("stop_areas.genealogical.genealogical_routing") if @stop_area.stop_area_type == 'itl'      t("stop_areas.genealogical.genealogical") @@ -33,12 +37,10 @@ module StopAreasHelper      @stop_area.stop_area_type == 'stop_place' || @stop_area.stop_area_type == 'commercial_stop_point'    end -    def pair_key(access_link)      "#{access_link.access_point.id}-#{access_link.stop_area.id}"    end -    def geo_data(sa, sar)      if sa.long_lat_type.nil?        content_tag :span, '-' diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index c6feaf940..bb8747faa 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -12,6 +12,8 @@ module Chouette      enumerize :area_type, in: Chouette::AreaType::ALL      enumerize :kind, in: %i(commercial non_commercial) +    AVAILABLE_LOCALIZATIONS = %i(gb nl de fr it es) +      with_options dependent: :destroy do |assoc|        assoc.has_many :stop_points        assoc.has_many :access_points @@ -50,6 +52,11 @@ module Chouette        :nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone]      end +    def localized_names +      val = read_attribute(:localized_names) || {} +      Hash[*AVAILABLE_LOCALIZATIONS.map{|k| [k, val[k.to_s]]}.flatten] +    end +      def parent_area_type_must_be_greater        return unless self.parent diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 1bc3e77ef..c2b9a7f4f 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -6,8 +6,12 @@          /= @map.to_html          = f.input :id, as: :hidden          = f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} +        .form-group +          .col-sm-3.col-xs-5 +          .col-sm-9.col-xs-7 +            - f.object.localized_names.each do |k, v| +              .col-md-6= f.input "localized_names[#{k}]", input_html: {value: v}, label: label_for_country(k)          = f.input :kind, as: :radio_buttons, checked: @stop_area.kind, :input_html => {:disabled => !@stop_area.new_record?}, :include_blank => false, item_wrapper_class: 'radio-inline', wrapper: :horizontal_form, disabled: !@stop_area.new_record? -          .slave data-master="[name='stop_area[kind]']" data-value="commercial"            = f.input :parent_id, as: :select, :collection => [f.object.parent_id], input_html: { data: { select2_ajax: 'true', url: autocomplete_stop_area_referential_stop_areas_path(@stop_area_referential), initvalue: {id: f.object.parent_id, text: f.object.parent.try(:full_name)}}}          - %i(non_commercial commercial).each do |kind| diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index b0896c1e0..67f309cef 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -7,10 +7,12 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          - attributes = { t('id_reflex') => @stop_area.get_objectid.short_id } +        - @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, -            }) +            @stop_area.human_attribute_name(: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!({ "Coordonnées" => geo_data(@stop_area, @stop_area_referential),              @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, | 
