aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorvlatka pavisic2016-12-12 15:49:52 +0100
committervlatka pavisic2016-12-12 15:49:58 +0100
commit2d4e6b45b0295e8c01deaebb04f8be009a7f9d87 (patch)
treeefb5139d08a29e9e0c9017b35d34ca8aa611f34d /app
parent73ab4dfc33dcf6b32198ae902fea3f8504821dea (diff)
downloadchouette-core-2d4e6b45b0295e8c01deaebb04f8be009a7f9d87.tar.bz2
Refs #1955 : RoutingConstraintZone
Diffstat (limited to 'app')
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb15
-rw-r--r--app/helpers/breadcrumb_helper.rb8
-rw-r--r--app/helpers/newfront_helper.rb1
-rw-r--r--app/models/chouette/line.rb2
-rw-r--r--app/models/chouette/routing_constraint_zone.rb9
-rw-r--r--app/policies/routing_constraint_zone_policy.rb13
-rw-r--r--app/views/referential_lines/show.html.slim2
-rw-r--r--app/views/referentials/_form.html.slim2
-rw-r--r--app/views/routing_constraint_zones/_form.html.slim13
-rw-r--r--app/views/routing_constraint_zones/edit.html.slim5
-rw-r--r--app/views/routing_constraint_zones/index.html.slim10
-rw-r--r--app/views/routing_constraint_zones/new.html.slim5
-rw-r--r--app/views/routing_constraint_zones/show.html.slim18
13 files changed, 102 insertions, 1 deletions
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
new file mode 100644
index 000000000..1c2c40cbb
--- /dev/null
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -0,0 +1,15 @@
+class RoutingConstraintZonesController < ChouetteController
+ defaults resource_class: Chouette::RoutingConstraintZone
+
+ respond_to :html, :xml, :json
+
+ belongs_to :referential do
+ belongs_to :line, parent_class: Chouette::Line
+ end
+
+ private
+ def routing_constraint_zone_params
+ params.require(:routing_constraint_zone).permit(:name, { stop_area_ids: [] }, :line_id, :objectid, :object_version, :creation_time, :creator_id)
+ end
+
+end
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 9d503fe2e..dc68bd897 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -36,6 +36,8 @@ module BreadcrumbHelper
route_section_breadcrumb action
when "Chouette::Timeband"
timeband_breadcrumb action
+ when 'Chouette::RoutingConstraintZone'
+ routing_constraint_zone_breadcrumb action
when "StopAreaCopy"
stop_area_copy_breadcrumb action
when "Import"
@@ -159,6 +161,12 @@ module BreadcrumbHelper
add_breadcrumb breadcrumb_label(@route), referential_line_route_path(@referential, @line,@route),:title => breadcrumb_tooltip(@route) if action == :edit
end
+ def routing_constraint_zone_breadcrumb(action)
+ line_breadcrumb :edit
+ add_breadcrumb Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line) unless action == :index
+ add_breadcrumb breadcrumb_label(@routing_constraint_zone), referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), title: breadcrumb_tooltip(@routing_constraint_zone) if %i(show edit).include? action
+ end
+
def journey_pattern_breadcrumb(action)
route_breadcrumb :edit
add_breadcrumb breadcrumb_label(@journey_pattern), referential_line_route_journey_pattern_path(@referential, @line,@route,@journey_pattern),:title => breadcrumb_tooltip(@journey_pattern) if action == :edit
diff --git a/app/helpers/newfront_helper.rb b/app/helpers/newfront_helper.rb
index 806502391..2abfd589d 100644
--- a/app/helpers/newfront_helper.rb
+++ b/app/helpers/newfront_helper.rb
@@ -57,6 +57,7 @@ module NewfrontHelper
if current_referential
polymorph_url << current_referential
+ polymorph_url << item.line if item.respond_to? :line
elsif item.respond_to? :referential
polymorph_url << item.referential
elsif item.respond_to? :line_referential
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index 3f7a72021..6c5d8501f 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -23,6 +23,8 @@ class Chouette::Line < Chouette::ActiveRecord
has_many :footnotes, :inverse_of => :line, :validate => :true, :dependent => :destroy
accepts_nested_attributes_for :footnotes, :reject_if => :all_blank, :allow_destroy => true
+ has_many :routing_constraint_zones
+
attr_reader :group_of_line_tokens
# validates_presence_of :network
diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb
new file mode 100644
index 000000000..681069416
--- /dev/null
+++ b/app/models/chouette/routing_constraint_zone.rb
@@ -0,0 +1,9 @@
+class Chouette::RoutingConstraintZone < Chouette::TridentActiveRecord
+ belongs_to :line
+ has_array_of :stop_areas, class_name: 'Chouette::StopArea'
+
+ validates_presence_of :name, :stop_area_ids, :line_id
+ validates :stop_areas, length: { minimum: 2 }
+
+ self.primary_key = 'id'
+end
diff --git a/app/policies/routing_constraint_zone_policy.rb b/app/policies/routing_constraint_zone_policy.rb
new file mode 100644
index 000000000..c6caf4ec5
--- /dev/null
+++ b/app/policies/routing_constraint_zone_policy.rb
@@ -0,0 +1,13 @@
+class RoutingConstraintZonePolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
+ end
+ end
+
+ def create? ; true end
+ def update? ; true end
+ def new? ; true end
+ def edit? ; true end
+ def destroy? ; true end
+end
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 9b754a5aa..ad455862d 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -112,6 +112,8 @@ h2
/ p
/ label = "#{@line.human_attribute_name('comment')} : "
/ = @line.comment
+ p
+ label = link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line)
.row
#mobility_restricted_suitability.col-md-6
diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim
index f1c7a0192..9fb6c6ced 100644
--- a/app/views/referentials/_form.html.slim
+++ b/app/views/referentials/_form.html.slim
@@ -71,7 +71,7 @@
.alert.alert-danger
- @referential.errors[:metadatas].each do |msg|
p.small = "- #{msg}"
-
+
= form.simple_fields_for :metadatas do |subform|
= subform.simple_fields_for :periods do |period_form|
.row
diff --git a/app/views/routing_constraint_zones/_form.html.slim b/app/views/routing_constraint_zones/_form.html.slim
new file mode 100644
index 000000000..d9e243746
--- /dev/null
+++ b/app/views/routing_constraint_zones/_form.html.slim
@@ -0,0 +1,13 @@
+= simple_form_for [@referential, @line, @routing_constraint_zone] do |f|
+ .row
+ .col-lg-6.col-sm-12
+ = f.input :name, label: t('activerecord.models.attributes.routing_constraint_zone.name')
+ .row
+ .col-lg-6.col-sm-12
+ = f.input :stop_area_ids, as: :select, collection: Chouette::StopArea.all, selected: @routing_constraint_zone.stop_area_ids, label: Chouette::StopArea.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'SĂ©lection de arrĂȘts', 'multiple': 'multiple', style: 'width: 100%' }
+
+ .row
+ .col-lg-12.text-right
+ = link_to 'Annuler', :back, class: 'btn btn-link'
+ = f.button :submit, class: 'btn btn-danger'
+
diff --git a/app/views/routing_constraint_zones/edit.html.slim b/app/views/routing_constraint_zones/edit.html.slim
new file mode 100644
index 000000000..fcb0d08a8
--- /dev/null
+++ b/app/views/routing_constraint_zones/edit.html.slim
@@ -0,0 +1,5 @@
+= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name)
+
+.row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2
+ == render 'form'
diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim
new file mode 100644
index 000000000..b12fbd3dd
--- /dev/null
+++ b/app/views/routing_constraint_zones/index.html.slim
@@ -0,0 +1,10 @@
+= title_tag Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr)
+
+= link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path
+
+- if @routing_constraint_zones.any?
+ = table_builder @routing_constraint_zones,
+ { @routing_constraint_zones.human_attribute_name(:name) => 'name' },
+ [:show, :edit, :delete],
+ 'table table-bordered'
+
diff --git a/app/views/routing_constraint_zones/new.html.slim b/app/views/routing_constraint_zones/new.html.slim
new file mode 100644
index 000000000..fcb0d08a8
--- /dev/null
+++ b/app/views/routing_constraint_zones/new.html.slim
@@ -0,0 +1,5 @@
+= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name)
+
+.row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2
+ == render 'form'
diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim
new file mode 100644
index 000000000..0f88f5b3f
--- /dev/null
+++ b/app/views/routing_constraint_zones/show.html.slim
@@ -0,0 +1,18 @@
+= title_tag @routing_constraint_zone.name
+
+p
+ label => "#{@routing_constraint_zone.human_attribute_name(:name)} : "
+ = @routing_constraint_zone.name
+
+p
+ label => "#{Chouette::Line.model_name.human.capitalize} : "
+ = link_to @routing_constraint_zone.line.name, referential_line_path(@referential, @line)
+
+p
+ label => "#{Chouette::StopArea.model_name.human.pluralize.capitalize} : "
+ br
+ - @routing_constraint_zone.stop_areas.each do |stop_area|
+ = link_to stop_area.name, referential_stop_area_path(@referential, stop_area)
+ br
+
+