diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 30 | ||||
| -rw-r--r-- | app/decorators/stop_area_decorator.rb | 6 | ||||
| -rw-r--r-- | app/models/chouette/stop_area.rb | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.slim | 11 | 
5 files changed, 46 insertions, 5 deletions
| diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index d4d996adb..498493f1e 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -171,7 +171,35 @@ class StopAreasController < ChouetteController    helper_method :current_referential    def stop_area_params -    params.require(:stop_area).permit( :routing_stop_ids, :routing_line_ids, :children_ids, :parent_id, :objectid, :object_version, :name, :comment, :area_type, :registration_number, :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :zip_code, :city_name, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs, :coordinates, :url, :time_zone ) +    params.require(:stop_area).permit( +      :area_type, +      :children_ids, +      :city_name, +      :comment, +      :coordinates, +      :country_code, +      :fare_code, +      :int_user_needs, +      :latitude, +      :lift_availability, +      :long_lat_type, +      :longitude, +      :mobility_restricted_suitability, +      :name, +      :nearest_topic_name, +      :object_version, +      :objectid, +      :parent_id, +      :registration_number, +      :routing_line_ids, +      :routing_stop_ids, +      :stairs_availability, +      :street_name, +      :time_zone, +      :url, +      :waiting_time, +      :zip_code, +    )    end  end diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb index 8b2ebf490..cf3612f79 100644 --- a/app/decorators/stop_area_decorator.rb +++ b/app/decorators/stop_area_decorator.rb @@ -31,4 +31,10 @@ class StopAreaDecorator < Draper::Decorator      links    end + +  def waiting_time_text +    return '-' if [nil, 0].include? waiting_time +    h.t('stop_areas.waiting_time_format', value: waiting_time) +  end +  end diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index f216ce449..3a9b44d59 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -39,6 +39,8 @@ module Chouette      validates_format_of :coordinates, :with => %r{\A *-?(0?[0-9](\.[0-9]*)?|[0-8][0-9](\.[0-9]*)?|90(\.[0]*)?) *\, *-?(0?[0-9]?[0-9](\.[0-9]*)?|1[0-7][0-9](\.[0-9]*)?|180(\.[0]*)?) *\Z}, :allow_nil => true, :allow_blank => true      validates_format_of :url, :with => %r{\Ahttps?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\Z}, :allow_nil => true, :allow_blank => true +    validates_numericality_of :waiting_time, greater_than_or_equal_to: 0, only_integer: true, if: :waiting_time +      def self.nullable_attributes        [:registration_number, :street_name, :country_code, :fare_code,        :nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone] diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index ac2cb4e87..6c8129d77 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -26,6 +26,8 @@          .stop_areas.stop_area.general_info            h3 = t("stop_areas.stop_area.general") +          = f.input :waiting_time +            = f.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")}            = f.input :fare_code            = f.input :nearest_topic_name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index 1b1209a68..0b79f5736 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -15,12 +15,15 @@    .container-fluid      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12 -        = definition_list t('metadatas'), -          { t('id_reflex') => @stop_area.get_objectid.short_id, +        - attributes = { t('id_reflex') => @stop_area.get_objectid.short_id,              @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, -            'Coordonnées' => geo_data(@stop_area, @stop_area_referential), +            } +        - attributes.merge!(@stop_area.human_attribute_name(:waiting_time) => @stop_area.waiting_time_text) +        - 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,              'Etat' => (@stop_area.deleted_at ? 'Supprimé' : 'Actif'), -            @stop_area.human_attribute_name(:comment) => @stop_area.try(:comment) } +            @stop_area.human_attribute_name(:comment) => @stop_area.try(:comment), +            }) +        = definition_list t('metadatas'), attributes | 
