diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/modules/_vj_collection.sass | 3 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 1 | ||||
| -rw-r--r-- | app/controllers/vehicle_journeys_controller.rb | 2 | ||||
| -rw-r--r-- | app/javascript/helpers/master_slave.coffee | 8 | ||||
| -rw-r--r-- | app/javascript/helpers/stop_area_header_manager.js | 4 | ||||
| -rw-r--r-- | app/models/chouette/stop_area.rb | 8 | ||||
| -rw-r--r-- | app/policies/stop_area_policy.rb | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 6 |
8 files changed, 25 insertions, 9 deletions
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass index 56769e52b..81c1fe43e 100644 --- a/app/assets/stylesheets/modules/_vj_collection.sass +++ b/app/assets/stylesheets/modules/_vj_collection.sass @@ -9,6 +9,9 @@ position: relative padding-left: 25px + .fa + margin-left: 5px + > .headlined &:before margin-left: -25px diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 79ffea72e..8e9df7157 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -203,6 +203,7 @@ class StopAreasController < ChouetteController :url, :waiting_time, :zip_code, + :kind, ) end diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index c1762c13e..ed6ba6ed1 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -66,6 +66,8 @@ class VehicleJourneysController < ChouetteController :city_name => sp.stop_area.try(:city_name), :comment => sp.stop_area.try(:comment), :area_type => sp.stop_area.try(:area_type), + :area_type_i18n => I18n.t(sp.stop_area.try(:area_type), scope: 'area_types.label'), + :area_kind => sp.stop_area.try(:kind), :stop_area_id => sp.stop_area_id, :registration_number => sp.stop_area.try(:registration_number), :nearest_topic_name => sp.stop_area.try(:nearest_topic_name), diff --git a/app/javascript/helpers/master_slave.coffee b/app/javascript/helpers/master_slave.coffee index 11f6bca7e..4866a55e3 100644 --- a/app/javascript/helpers/master_slave.coffee +++ b/app/javascript/helpers/master_slave.coffee @@ -3,16 +3,16 @@ class MasterSlave $(selector).find('[data-master]').each (i, slave)-> $slave = $(slave) master = $($slave.data().master) - console.log $slave.data().master - console.log master + console.log $slave + console.log $slave.find("input:disabled, select:disabled") + $slave.find("input:disabled, select:disabled").attr "data-slave-force-disabled", "true" toggle = -> val = master.filter(":checked").val() if master.filter("[type=radio]").length > 0 val ||= master.val() selected = val == $slave.data().value $slave.toggle selected - $slave.find("input, select").attr "disabled", !selected + $slave.find("input, select").filter(":not([data-slave-force-disabled])").attr "disabled", !selected master.change toggle toggle() - # $slave.toggle master.val() == $slave.data().value export default MasterSlave diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js index c9f397dee..2c820caf9 100644 --- a/app/javascript/helpers/stop_area_header_manager.js +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -19,7 +19,7 @@ export default class StopAreaHeaderManager { <div className={(showHeadline) ? 'headlined' : ''} data-headline={showHeadline} - title={sp.city_name + ' (' + sp.zip_code +')'} + title={sp.city_name ? sp.city_name + ' (' + sp.zip_code +')' : ""} > <span> <span> @@ -27,6 +27,8 @@ export default class StopAreaHeaderManager { {sp.time_zone_formatted_offset && <span className="small"> ({sp.time_zone_formatted_offset}) </span>} + {sp.area_kind == 'non_commercial' && <span className="fa fa-question-circle" title={sp.area_type_i18n}> + </span>} </span> </span> </div> diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index d270a8696..75a4a34bb 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -32,6 +32,7 @@ module Chouette validates_format_of :registration_number, :with => %r{\A[\d\w_\-]+\Z}, :allow_blank => true validates_presence_of :name + validates_presence_of :kind validates_presence_of :latitude, :if => :longitude validates_presence_of :longitude, :if => :latitude validates_numericality_of :latitude, :less_than_or_equal_to => 90, :greater_than_or_equal_to => -90, :allow_nil => true @@ -42,6 +43,7 @@ module Chouette validates_numericality_of :waiting_time, greater_than_or_equal_to: 0, only_integer: true, if: :waiting_time validate :parent_area_type_must_be_greater + validate :area_type_of_right_kind def self.nullable_attributes [:registration_number, :street_name, :country_code, :fare_code, @@ -57,6 +59,12 @@ module Chouette end end + def area_type_of_right_kind + unless Chouette::AreaType.send(self.kind).include?(self.area_type) + errors.add(:area_type, I18n.t('stop_areas.errors.incorrect_kind_area_type')) + end + end + after_update :clean_invalid_access_links before_save :coordinates_to_lat_lng diff --git a/app/policies/stop_area_policy.rb b/app/policies/stop_area_policy.rb index 6db48b702..fd73b7092 100644 --- a/app/policies/stop_area_policy.rb +++ b/app/policies/stop_area_policy.rb @@ -3,7 +3,7 @@ class StopAreaPolicy < ApplicationPolicy def search_scope scope_name scope = resolve if scope_name&.to_s == "route_editor" - scope = scope.where(area_type: 'zdep') unless user.organisation.has_feature?("route_stop_areas_all_types") + scope = scope.where("kind = ? OR area_type = ?", :non_commercial, 'zdep') unless user.organisation.has_feature?("route_stop_areas_all_types") end scope end diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 699381d50..6b75209b4 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -7,13 +7,13 @@ = f.input :id, as: :hidden = f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} - = f.input :kind, as: :radio_buttons, :input_html => {:disabled => !@stop_area.new_record?}, :include_blank => false, item_wrapper_class: 'radio-inline', wrapper: :horizontal_form, item_class: "fooo" + = f.input :kind, as: :radio_buttons, :input_html => {:disabled => !@stop_area.new_record?}, :include_blank => false, item_wrapper_class: 'radio-inline', wrapper: :horizontal_form, item_class: "fooo", 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(commercial non_commercial).each do |kind| + - %i(non_commercial commercial).each do |kind| .slave data-master="[name='stop_area[kind]']" data-value=kind - = f.input :area_type, as: :select, :input_html => {:disabled => !@stop_area.new_record?}, :collection => Chouette::AreaType.options(kind), :include_blank => false + = f.input :area_type, as: :select, :input_html => {id: kind, :disabled => !@stop_area.new_record?}, :collection => Chouette::AreaType.options(kind), :include_blank => false, disabled: !@stop_area.new_record? .location_info h3 = t("stop_areas.stop_area.localisation") |
