aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcedricnjanga2017-11-07 15:57:19 +0100
committerGitHub2017-11-07 15:57:19 +0100
commit55de3ba4ece8c1448bc219037ce744904cc0d3b3 (patch)
treea074f234a1a67df9c746ab116d4256c5af3cd9a9
parente5ba4a719f1ca563dee6cb109cb8d5a3e923ea03 (diff)
parent43033eef0f6582f4bc4e64199310cc624e18f1be (diff)
downloadchouette-core-compliance_controls_policy.tar.bz2
Merge branch 'master' into compliance_controls_policycompliance_controls_policy
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock5
-rw-r--r--app/assets/stylesheets/components/_breadcrumb.sass3
-rw-r--r--app/assets/stylesheets/components/_forms.sass4
-rw-r--r--app/assets/stylesheets/components/_modals.sass5
-rw-r--r--app/controllers/access_links_controller.rb16
-rw-r--r--app/controllers/access_points_controller.rb6
-rw-r--r--app/controllers/api_keys_controller.rb2
-rw-r--r--app/controllers/breadcrumb_controller.rb41
-rw-r--r--app/controllers/calendars_controller.rb6
-rw-r--r--app/controllers/chouette_controller.rb3
-rw-r--r--app/controllers/companies_controller.rb4
-rw-r--r--app/controllers/compliance_check_sets_controller.rb4
-rw-r--r--app/controllers/compliance_control_blocks_controller.rb4
-rw-r--r--app/controllers/compliance_control_sets_controller.rb12
-rw-r--r--app/controllers/compliance_controls_controller.rb11
-rw-r--r--app/controllers/concerns/policy_checker.rb1
-rw-r--r--app/controllers/connection_links_controller.rb6
-rw-r--r--app/controllers/dashboards_controller.rb2
-rw-r--r--app/controllers/exports_controller.rb16
-rw-r--r--app/controllers/group_of_lines_controller.rb7
-rw-r--r--app/controllers/import_messages_controller.rb2
-rw-r--r--app/controllers/import_resources_controller.rb4
-rw-r--r--app/controllers/imports_controller.rb13
-rw-r--r--app/controllers/journey_patterns_collections_controller.rb1
-rw-r--r--app/controllers/journey_patterns_controller.rb4
-rw-r--r--app/controllers/line_footnotes_controller.rb6
-rw-r--r--app/controllers/line_referentials_controller.rb2
-rw-r--r--app/controllers/lines_controller.rb5
-rw-r--r--app/controllers/networks_controller.rb6
-rw-r--r--app/controllers/organisations_controller.rb4
-rw-r--r--app/controllers/referential_companies_controller.rb2
-rw-r--r--app/controllers/referential_group_of_lines_controller.rb5
-rw-r--r--app/controllers/referential_lines_controller.rb2
-rw-r--r--app/controllers/referential_networks_controller.rb4
-rw-r--r--app/controllers/referential_stop_areas_controller.rb13
-rw-r--r--app/controllers/referentials_controller.rb5
-rw-r--r--app/controllers/route_sections_controller.rb5
-rw-r--r--app/controllers/routes_controller.rb3
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb4
-rw-r--r--app/controllers/rule_parameter_sets_controller.rb8
-rw-r--r--app/controllers/stop_area_referentials_controller.rb2
-rw-r--r--app/controllers/stop_areas_controller.rb17
-rw-r--r--app/controllers/time_tables_controller.rb10
-rw-r--r--app/controllers/timebands_controller.rb7
-rw-r--r--app/controllers/users_controller.rb2
-rw-r--r--app/controllers/vehicle_journey_imports_controller.rb4
-rw-r--r--app/controllers/vehicle_journeys_controller.rb1
-rw-r--r--app/controllers/workbenches_controller.rb6
-rw-r--r--app/helpers/breadcrumb_helper.rb310
-rw-r--r--app/helpers/compliance_control_blocks_helper.rb10
-rw-r--r--app/helpers/compliance_controls_helper.rb11
-rw-r--r--app/helpers/table_builder_helper.rb24
-rw-r--r--app/javascript/journey_patterns/actions/index.js5
-rw-r--r--app/javascript/journey_patterns/components/EditModal.js58
-rw-r--r--app/javascript/journey_patterns/components/JourneyPattern.js9
-rw-r--r--app/javascript/journey_patterns/containers/Modal.js1
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js9
-rw-r--r--app/javascript/vehicle_journeys/components/Tools.js53
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourney.js48
-rw-r--r--app/javascript/vehicle_journeys/components/tools/CreateModal.js6
-rw-r--r--app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js6
-rw-r--r--app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js19
-rw-r--r--app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js38
-rw-r--r--app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js154
-rw-r--r--app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js5
-rw-r--r--app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js94
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js6
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js5
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js4
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js6
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js3
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js7
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js7
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js4
-rw-r--r--app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js5
-rw-r--r--app/models/compliance_control.rb74
-rw-r--r--app/models/concerns/stif_transport_mode_enumerations.rb3
-rw-r--r--app/models/import.rb5
-rw-r--r--app/models/import_message.rb3
-rw-r--r--app/models/line_control/route.rb2
-rw-r--r--app/models/referential.rb12
-rw-r--r--app/models/referential_suite.rb13
-rw-r--r--app/models/route_control/opposite_route.rb2
-rw-r--r--app/models/route_control/opposite_route_terminus.rb2
-rw-r--r--app/views/calendars/edit.html.slim1
-rw-r--r--app/views/calendars/index.html.slim2
-rw-r--r--app/views/calendars/new.html.slim1
-rw-r--r--app/views/calendars/show.html.slim1
-rw-r--r--app/views/companies/index.html.slim1
-rw-r--r--app/views/companies/show.html.slim1
-rw-r--r--app/views/compliance_check_sets/index.html.slim1
-rw-r--r--app/views/compliance_check_sets/show.html.slim3
-rw-r--r--app/views/compliance_control_sets/edit.html.slim1
-rw-r--r--app/views/compliance_control_sets/index.html.slim7
-rw-r--r--app/views/compliance_control_sets/new.html.slim1
-rw-r--r--app/views/compliance_control_sets/show.html.slim98
-rw-r--r--app/views/compliance_controls/_filters.html.slim46
-rw-r--r--app/views/compliance_controls/new.html.slim5
-rw-r--r--app/views/compliance_controls/select_type.html.slim1
-rw-r--r--app/views/compliance_controls/show.html.slim14
-rw-r--r--app/views/group_of_lines/edit.html.slim3
-rw-r--r--app/views/group_of_lines/index.html.slim1
-rw-r--r--app/views/group_of_lines/new.html.slim3
-rw-r--r--app/views/group_of_lines/show.html.slim2
-rw-r--r--app/views/imports/index.html.slim1
-rw-r--r--app/views/imports/new.html.slim1
-rw-r--r--app/views/imports/show.html.slim1
-rw-r--r--app/views/journey_patterns_collections/show.html.slim5
-rw-r--r--app/views/layouts/application.html.slim5
-rw-r--r--app/views/layouts/navigation/_breadcrumb.html.slim3
-rw-r--r--app/views/layouts/navigation/_main_nav_left.html.slim21
-rw-r--r--app/views/line_footnotes/show.html.slim3
-rw-r--r--app/views/line_referentials/show.html.slim1
-rw-r--r--app/views/lines/index.html.slim1
-rw-r--r--app/views/lines/new.html.slim4
-rw-r--r--app/views/lines/show.html.slim1
-rw-r--r--app/views/networks/edit.html.slim3
-rw-r--r--app/views/networks/index.html.slim1
-rw-r--r--app/views/networks/new.html.slim3
-rw-r--r--app/views/networks/show.html.slim1
-rw-r--r--app/views/organisations/edit.html.slim3
-rw-r--r--app/views/organisations/show.html.slim2
-rw-r--r--app/views/referential_companies/index.html.slim1
-rw-r--r--app/views/referential_companies/new.html.slim3
-rw-r--r--app/views/referential_companies/show.html.slim1
-rw-r--r--app/views/referential_group_of_lines/index.html.slim1
-rw-r--r--app/views/referential_group_of_lines/new.html.slim3
-rw-r--r--app/views/referential_group_of_lines/show.html.slim9
-rw-r--r--app/views/referential_lines/edit.html.slim3
-rw-r--r--app/views/referential_lines/show.html.slim1
-rw-r--r--app/views/referential_networks/edit.html.slim3
-rw-r--r--app/views/referential_networks/index.html.slim3
-rw-r--r--app/views/referential_networks/new.html.slim4
-rw-r--r--app/views/referential_networks/show.html.slim1
-rw-r--r--app/views/referential_stop_areas/edit.html.slim3
-rw-r--r--app/views/referential_stop_areas/index.html.slim1
-rw-r--r--app/views/referential_stop_areas/new.html.slim3
-rw-r--r--app/views/referential_stop_areas/show.html.slim1
-rw-r--r--app/views/referentials/show.html.slim1
-rw-r--r--app/views/route_sections/index.html.slim3
-rw-r--r--app/views/route_sections/new.html.slim3
-rw-r--r--app/views/route_sections/show.html.slim3
-rw-r--r--app/views/routes/edit.html.slim1
-rw-r--r--app/views/routes/new.html.slim1
-rw-r--r--app/views/routes/show.html.slim3
-rw-r--r--app/views/routing_constraint_zones/edit.html.slim1
-rw-r--r--app/views/routing_constraint_zones/index.html.slim1
-rw-r--r--app/views/routing_constraint_zones/new.html.slim1
-rw-r--r--app/views/routing_constraint_zones/show.html.slim1
-rw-r--r--app/views/shared/_breadcrumb.html.slim3
-rw-r--r--app/views/stif/dashboards/_dashboard.html.slim8
-rw-r--r--app/views/stop_area_referentials/show.html.slim3
-rw-r--r--app/views/stop_areas/edit.html.slim3
-rw-r--r--app/views/stop_areas/index.html.slim1
-rw-r--r--app/views/stop_areas/new.html.slim3
-rw-r--r--app/views/stop_areas/show.html.slim1
-rw-r--r--app/views/time_tables/edit.html.slim1
-rw-r--r--app/views/time_tables/index.html.slim1
-rw-r--r--app/views/time_tables/new.html.slim1
-rw-r--r--app/views/time_tables/show.html.slim2
-rw-r--r--app/views/timebands/edit.html.slim3
-rw-r--r--app/views/timebands/index.html.slim1
-rw-r--r--app/views/timebands/new.html.slim3
-rw-r--r--app/views/timebands/show.html.slim5
-rw-r--r--app/views/vehicle_journeys/edit.html.slim2
-rw-r--r--app/views/vehicle_journeys/index.html.slim1
-rw-r--r--app/views/workbenches/show.html.slim4
-rw-r--r--app/workers/compliance_control_set_copy_worker.rb14
-rw-r--r--app/workers/workbench_import_worker.rb6
-rw-r--r--config/breadcrumbs.rb249
-rw-r--r--config/environments/test.rb3
-rw-r--r--config/locales/breadcrumbs.en.yml7
-rw-r--r--config/locales/breadcrumbs.fr.yml7
-rw-r--r--config/locales/compliance_controls.en.yml23
-rw-r--r--config/locales/compliance_controls.fr.yml28
-rw-r--r--config/locales/import_messages.en.yml5
-rw-r--r--config/locales/import_messages.fr.yml5
-rw-r--r--config/locales/imports.en.yml6
-rw-r--r--config/locales/imports.fr.yml6
-rw-r--r--config/locales/referential_suites.en.yml5
-rw-r--r--config/locales/referential_suites.fr.yml5
-rw-r--r--config/locales/referentials.en.yml1
-rw-r--r--config/locales/referentials.fr.yml7
-rw-r--r--config/locales/routes.fr.yml2
-rw-r--r--config/locales/workbenches.en.yml6
-rw-r--r--config/locales/workbenches.fr.yml6
-rw-r--r--config/routes.rb1
-rw-r--r--db/migrate/20171106111448_update_import_message_criticity_type_to_string.rb16
-rw-r--r--db/schema.rb6
-rw-r--r--lib/bootstrap_breadcrumbs_builder.rb31
-rw-r--r--lib/compliance_control_set_cloner.rb2
-rw-r--r--lib/compliance_control_set_copier.rb2
-rw-r--r--lib/stif/dashboard.rb2
-rw-r--r--package.json2
-rw-r--r--spec/controllers/api/v1/imports_controller_spec.rb2
-rw-r--r--spec/factories/referentials.rb10
-rw-r--r--spec/features/compliance_control_sets_spec.rb82
-rw-r--r--spec/features/connection_links_spec.rb2
-rw-r--r--spec/features/workbenches_spec.rb12
-rw-r--r--spec/helpers/table_builder_helper_spec.rb2
-rw-r--r--spec/lib/compliance_control_set_cloner_spec.rb3
-rw-r--r--spec/lib/compliance_control_set_copier_spec.rb4
-rw-r--r--spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb17
-rw-r--r--spec/models/compliance_control_spec.rb4
-rw-r--r--spec/models/import_spec.rb2
-rw-r--r--spec/models/referential/referential_org_through_workbench_spec.rb44
-rw-r--r--spec/models/referential_spec.rb2
-rw-r--r--spec/models/referential_suite/referential_suite_current_new_spec.rb64
-rw-r--r--spec/models/referential_suite/referential_suite_spec.rb (renamed from spec/models/referential_suite_spec.rb)0
-rw-r--r--spec/requests/api/v1/netex_import_spec.rb2
-rw-r--r--spec/workers/compliance_control_set_copy_worker_spec.rb35
-rw-r--r--spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb3
-rw-r--r--spec/workers/workbench_import/workbench_import_worker_spec.rb4
216 files changed, 1403 insertions, 1037 deletions
diff --git a/Gemfile b/Gemfile
index fbe8f4c4e..f03fb971b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -93,7 +93,7 @@ gem 'RedCloth', '~> 4.3.0'
gem 'simple_form', '~> 3.1.0'
gem 'font-awesome-sass', '~> 4.7'
gem 'will_paginate-bootstrap'
-gem 'breadcrumbs_on_rails'
+gem 'gretel'
# Format Output
gem 'json'
diff --git a/Gemfile.lock b/Gemfile.lock
index 3acc27613..48a8b638a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -105,7 +105,6 @@ GEM
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
- breadcrumbs_on_rails (3.0.1)
builder (3.2.3)
bundler-audit (0.5.0)
bundler (~> 1.2)
@@ -245,6 +244,8 @@ GEM
globalid (0.3.7)
activesupport (>= 4.1.0)
google-analytics-rails (1.1.0)
+ gretel (3.0.9)
+ rails (>= 3.1.0)
has_scope (0.7.0)
actionpack (>= 4.1, < 5.1)
activesupport (>= 4.1, < 5.1)
@@ -568,7 +569,6 @@ DEPENDENCIES
awesome_print
better_errors
binding_of_caller
- breadcrumbs_on_rails
bundler-audit
calendar_helper (= 0.2.5)
capistrano (= 2.13.5)
@@ -604,6 +604,7 @@ DEPENDENCIES
georuby (= 2.3.0)
georuby-ext (= 0.0.5)
google-analytics-rails
+ gretel
has_array_of!
hstore_accessor (~> 1.1)
htmlbeautifier
diff --git a/app/assets/stylesheets/components/_breadcrumb.sass b/app/assets/stylesheets/components/_breadcrumb.sass
new file mode 100644
index 000000000..62f167eb4
--- /dev/null
+++ b/app/assets/stylesheets/components/_breadcrumb.sass
@@ -0,0 +1,3 @@
+.breadcrumbs
+ a
+ color: white \ No newline at end of file
diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass
index 7a5323011..2b715d669 100644
--- a/app/assets/stylesheets/components/_forms.sass
+++ b/app/assets/stylesheets/components/_forms.sass
@@ -53,6 +53,8 @@ input
border-right: none
&:last-child
border-left: none
+ &[readonly]
+ background-color: white
+ span
display: table-cell
@@ -61,7 +63,7 @@ input
border-bottom: 1px solid #ccc
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075)
- &.disabled > .form-control + span
+ &[disabled], &.disabled > .form-control + span
background-color: #eee
// Validations
diff --git a/app/assets/stylesheets/components/_modals.sass b/app/assets/stylesheets/components/_modals.sass
index 2db4fe955..e52a2e125 100644
--- a/app/assets/stylesheets/components/_modals.sass
+++ b/app/assets/stylesheets/components/_modals.sass
@@ -38,6 +38,11 @@ $modalW: 600px
.modal-title
font-size: $h2-size
+ display: inline-block
+
+ .modal-close
+ text-align: right
+ display: inline-block
.modal-body
padding: 15px 30px
diff --git a/app/controllers/access_links_controller.rb b/app/controllers/access_links_controller.rb
index 6f1ad8bfd..936b8ea5e 100644
--- a/app/controllers/access_links_controller.rb
+++ b/app/controllers/access_links_controller.rb
@@ -21,9 +21,7 @@ class AccessLinksController < ChouetteController
@access_point = Chouette::AccessPoint.find(params[:access_point_id])
#@access_link = Chouette::AccessLink.find(params[:id])
@stop_area = @access_link.stop_area
- show! do |format|
- format.html {build_breadcrumb :show}
- end
+ show!
end
def new
@@ -41,9 +39,7 @@ class AccessLinksController < ChouetteController
data[:name] = name
end
@access_link = Chouette::AccessLink.new(data.permit!)
- new! do
- build_breadcrumb :new
- end
+ new!
end
def create
@@ -59,9 +55,7 @@ class AccessLinksController < ChouetteController
@access_link = Chouette::AccessLink.find(params[:id])
@stop_area = @access_link.stop_area
@orientation = @access_link.link_orientation_type
- edit! do
- build_breadcrumb :edit
- end
+ edit!
end
def update
@@ -69,9 +63,7 @@ class AccessLinksController < ChouetteController
@access_link = Chouette::AccessLink.find(params[:id])
@stop_area = @access_link.stop_area
@orientation = @access_link.link_orientation_type
- update! do |success, failure|
- build_breadcrumb :edit
- end
+ update!
end
protected
diff --git a/app/controllers/access_points_controller.rb b/app/controllers/access_points_controller.rb
index d43880c0b..477875cc9 100644
--- a/app/controllers/access_points_controller.rb
+++ b/app/controllers/access_points_controller.rb
@@ -6,7 +6,6 @@ class AccessPointsController < ChouetteController
end
respond_to :html, :kml, :xml, :json
-
include PolicyChecker
def index
@@ -32,7 +31,6 @@ class AccessPointsController < ChouetteController
}
end
- format.html {build_breadcrumb :show}
end
end
@@ -40,9 +38,7 @@ class AccessPointsController < ChouetteController
def edit
access_point.position ||= access_point.default_position
map.editable = true
- edit! do
- build_breadcrumb :edit
- end
+ edit!
end
diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb
index 7ae8d4732..eebad5e7b 100644
--- a/app/controllers/api_keys_controller.rb
+++ b/app/controllers/api_keys_controller.rb
@@ -1,4 +1,4 @@
-class ApiKeysController < BreadcrumbController
+class ApiKeysController < InheritedResources::Base
defaults resource_class: Api::V1::ApiKey
include PolicyChecker
diff --git a/app/controllers/breadcrumb_controller.rb b/app/controllers/breadcrumb_controller.rb
deleted file mode 100644
index cb639fdb8..000000000
--- a/app/controllers/breadcrumb_controller.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-class BreadcrumbController < InheritedResources::Base
- include Pundit
- include BreadcrumbHelper
-
- def show
- show! do
- build_breadcrumb :show
- end
- end
-
- def index
- index! do
- build_breadcrumb :index
- end
- end
-
- def edit
- edit! do
- build_breadcrumb :edit
- end
- end
-
- def update
- update! do |success, failure|
- build_breadcrumb :edit
- end
- end
-
- def new
- new! do
- build_breadcrumb :new
- end
- end
-
- def create
- create! do |success, failure|
- build_breadcrumb :new
- end
- end
-
-end
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index 1c342c718..e9ee7579a 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -1,4 +1,4 @@
-class CalendarsController < BreadcrumbController
+class CalendarsController < InheritedResources::Base
include PolicyChecker
defaults resource_class: Calendar
before_action :ransack_contains_date, only: [:index]
@@ -8,16 +8,12 @@ class CalendarsController < BreadcrumbController
def index
index! do
@calendars = ModelDecorator.decorate(@calendars, with: CalendarDecorator)
-
- build_breadcrumb :index
end
end
def show
show! do
@calendar = @calendar.decorate
-
- build_breadcrumb :show
end
end
diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb
index dc9ab4fa5..1313aa7cc 100644
--- a/app/controllers/chouette_controller.rb
+++ b/app/controllers/chouette_controller.rb
@@ -1,6 +1,5 @@
-class ChouetteController < BreadcrumbController
+class ChouetteController < InheritedResources::Base
include ApplicationHelper
- include BreadcrumbHelper
include ReferentialSupport
end
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb
index cf27c39cf..bc5bedd7f 100644
--- a/app/controllers/companies_controller.rb
+++ b/app/controllers/companies_controller.rb
@@ -1,4 +1,4 @@
-class CompaniesController < BreadcrumbController
+class CompaniesController < InheritedResources::Base
include ApplicationHelper
include PolicyChecker
defaults :resource_class => Chouette::Company
@@ -22,8 +22,6 @@ class CompaniesController < BreadcrumbController
format.json {
@companies = decorate_companies(@companies)
}
-
- build_breadcrumb :index
end
end
diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb
index fce8dcc56..95dcfbf05 100644
--- a/app/controllers/compliance_check_sets_controller.rb
+++ b/app/controllers/compliance_check_sets_controller.rb
@@ -1,4 +1,4 @@
-class ComplianceCheckSetsController < BreadcrumbController
+class ComplianceCheckSetsController < InheritedResources::Base
defaults resource_class: ComplianceCheckSet
include RansackDateFilter
before_action only: [:index] { set_date_time_params("created_at", DateTime) }
@@ -18,4 +18,4 @@ class ComplianceCheckSetsController < BreadcrumbController
}
end
end
-end \ No newline at end of file
+end
diff --git a/app/controllers/compliance_control_blocks_controller.rb b/app/controllers/compliance_control_blocks_controller.rb
index 2dd69a865..996f8a464 100644
--- a/app/controllers/compliance_control_blocks_controller.rb
+++ b/app/controllers/compliance_control_blocks_controller.rb
@@ -1,4 +1,4 @@
-class ComplianceControlBlocksController < BreadcrumbController
+class ComplianceControlBlocksController < InheritedResources::Base
defaults resource_class: ComplianceControlBlock
belongs_to :compliance_control_set
actions :all, :except => [:show, :index]
@@ -9,4 +9,4 @@ class ComplianceControlBlocksController < BreadcrumbController
params.require(:compliance_control_block).permit(:transport_mode, :transport_submode)
end
-end \ No newline at end of file
+end
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index e5c2e19dd..956f26112 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -1,4 +1,4 @@
-class ComplianceControlSetsController < BreadcrumbController
+class ComplianceControlSetsController < InheritedResources::Base
defaults resource_class: ComplianceControlSet
include RansackDateFilter
before_action only: [:index] { set_date_time_params("updated_at", DateTime) }
@@ -9,7 +9,7 @@ class ComplianceControlSetsController < BreadcrumbController
scope = self.ransack_period_range(scope: @compliance_control_sets, error_message: t('imports.filters.error_period_filter'), query: :where_updated_at_between)
@q_for_form = scope.ransack(params[:q])
format.html {
- @compliance_control_sets = decorate_compliance_control_sets(@q_for_form.result)
+ @compliance_control_sets = decorate_compliance_control_sets(@q_for_form.result.paginate(page: params[:page], per_page: 30))
}
end
end
@@ -17,8 +17,12 @@ class ComplianceControlSetsController < BreadcrumbController
def show
show! do |format|
format.html {
+ @q_controls_form = @compliance_control_set.compliance_controls.ransack(params[:q])
@compliance_control_set = @compliance_control_set.decorate
- @compliance_controls_without_block = decorate_compliance_controls(@compliance_control_set.compliance_controls.where(compliance_control_block_id: nil))
+ @compliance_controls =
+ decorate_compliance_controls( @q_controls_form.result)
+ .group_by(&:compliance_control_block)
+ @indirect_compliance_controls = @compliance_controls.delete nil
}
end
end
@@ -54,4 +58,4 @@ class ComplianceControlSetsController < BreadcrumbController
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
end
-end \ No newline at end of file
+end
diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb
index 0a9c7d52b..816d8897b 100644
--- a/app/controllers/compliance_controls_controller.rb
+++ b/app/controllers/compliance_controls_controller.rb
@@ -1,7 +1,7 @@
-class ComplianceControlsController < BreadcrumbController
+class ComplianceControlsController < InheritedResources::Base
defaults resource_class: ComplianceControl
belongs_to :compliance_control_set
- actions :all, :except => [:show, :index]
+ actions :all, :except => [:index]
def select_type
@sti_subclasses = ComplianceControl.subclasses
@@ -22,6 +22,13 @@ class ComplianceControlsController < BreadcrumbController
end
end
+ def update
+ update! do |success, failure|
+ success.html { redirect_to compliance_control_set_path(parent) }
+ failure.html { render( :action => 'edit' ) }
+ end
+ end
+
protected
alias_method :compliance_control_set, :parent
diff --git a/app/controllers/concerns/policy_checker.rb b/app/controllers/concerns/policy_checker.rb
index 65a4428e2..d84263f2c 100644
--- a/app/controllers/concerns/policy_checker.rb
+++ b/app/controllers/concerns/policy_checker.rb
@@ -1,4 +1,5 @@
module PolicyChecker
+ include Pundit
extend ActiveSupport::Concern
included do
diff --git a/app/controllers/connection_links_controller.rb b/app/controllers/connection_links_controller.rb
index 403f0ed9e..b56450291 100644
--- a/app/controllers/connection_links_controller.rb
+++ b/app/controllers/connection_links_controller.rb
@@ -18,23 +18,19 @@ class ConnectionLinksController < ChouetteController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
}
end
end
def show
@map = ConnectionLinkMap.new(resource).with_helpers(self)
- show! do
- build_breadcrumb :show
- end
+ show!
end
def select_areas
@connection_link = connection_link
@departure = connection_link.departure
@arrival = connection_link.arrival
- build_breadcrumb :show
end
protected
diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb
index 2585dafca..1c7876c58 100644
--- a/app/controllers/dashboards_controller.rb
+++ b/app/controllers/dashboards_controller.rb
@@ -3,7 +3,7 @@
# this controller will use a custom partial like
# custom/dashboards/_dashboard.html.slim for Custom::Dashboard
#
-class DashboardsController < BreadcrumbController
+class DashboardsController < InheritedResources::Base
respond_to :html, only: [:show]
def show
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
index 2cfa0b6fa..ad88c6dae 100644
--- a/app/controllers/exports_controller.rb
+++ b/app/controllers/exports_controller.rb
@@ -3,16 +3,14 @@ require 'open-uri'
class ExportsController < ChouetteController
defaults :resource_class => Export
-
+
respond_to :html, :only => [:show, :index, :destroy, :exported_file]
respond_to :js, :only => [:index]
belongs_to :referential
def index
begin
- index! do
- build_breadcrumb :index
- end
+ index!
rescue Ievkit::Error, Faraday::Error => error
logger.error("Iev failure : #{error.message}")
flash[:error] = t(error.locale_for_error)
@@ -22,9 +20,7 @@ class ExportsController < ChouetteController
def show
begin
- show! do
- build_breadcrumb :show
- end
+ show!
rescue Ievkit::Error, Faraday::Error => error
logger.error("Iev failure : #{error.message}")
flash[:error] = t(error.locale_for_error)
@@ -32,7 +28,7 @@ class ExportsController < ChouetteController
end
end
- def destroy
+ def destroy
begin
destroy!
rescue Ievkit::Error, Faraday::Error => error
@@ -57,11 +53,11 @@ class ExportsController < ChouetteController
end
protected
-
+
def export_service
ExportService.new(@referential)
end
-
+
def resource
@export ||= export_service.find( params[:id] )
@line_items = @export.report.line_items
diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb
index 5cadd40d3..1a59d39f7 100644
--- a/app/controllers/group_of_lines_controller.rb
+++ b/app/controllers/group_of_lines_controller.rb
@@ -1,4 +1,4 @@
-class GroupOfLinesController < BreadcrumbController
+class GroupOfLinesController < InheritedResources::Base
include ApplicationHelper
include PolicyChecker
defaults :resource_class => Chouette::GroupOfLine
@@ -13,9 +13,7 @@ class GroupOfLinesController < BreadcrumbController
def show
@map = GroupOfLineMap.new(resource).with_helpers(self)
@lines = resource.lines.order(:name)
- show! do
- build_breadcrumb :show
- end
+ show!
end
def index
@@ -24,7 +22,6 @@ class GroupOfLinesController < BreadcrumbController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
}
end
end
diff --git a/app/controllers/import_messages_controller.rb b/app/controllers/import_messages_controller.rb
index 4ad398cbb..c3c6b46b5 100644
--- a/app/controllers/import_messages_controller.rb
+++ b/app/controllers/import_messages_controller.rb
@@ -1,4 +1,4 @@
-class ImportMessagesController < BreadcrumbController
+class ImportMessagesController < InheritedResources::Base
defaults resource_class: ImportMessage, collection_name: 'import_messages', instance_name: 'import_message'
respond_to :csv
belongs_to :import, :parent_class => Import do
diff --git a/app/controllers/import_resources_controller.rb b/app/controllers/import_resources_controller.rb
index ac3dd042e..3e52233f2 100644
--- a/app/controllers/import_resources_controller.rb
+++ b/app/controllers/import_resources_controller.rb
@@ -1,4 +1,4 @@
-class ImportResourcesController < BreadcrumbController
+class ImportResourcesController < InheritedResources::Base
defaults resource_class: ImportResource, collection_name: 'import_resources', instance_name: 'import_resource'
respond_to :html
belongs_to :import
@@ -8,8 +8,6 @@ class ImportResourcesController < BreadcrumbController
format.html {
@import_resources = decorate_import_resources(@import_resources)
}
-
- build_breadcrumb :index
end
end
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 3c52dc935..6c9d81d82 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -1,4 +1,4 @@
-class ImportsController < BreadcrumbController
+class ImportsController < InheritedResources::Base
include PolicyChecker
include RansackDateFilter
before_action only: [:index] { set_date_time_params("started_at", DateTime) }
@@ -13,8 +13,6 @@ class ImportsController < BreadcrumbController
@import = @import.decorate(context: {
workbench: @workbench
})
-
- build_breadcrumb :show
end
end
@@ -24,17 +22,8 @@ class ImportsController < BreadcrumbController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
-
@imports = decorate_imports(@imports)
}
-
- build_breadcrumb :index
- end
- end
-
- def new
- new! do
- build_breadcrumb :new
end
end
diff --git a/app/controllers/journey_patterns_collections_controller.rb b/app/controllers/journey_patterns_collections_controller.rb
index e8924b7ad..546158fa8 100644
--- a/app/controllers/journey_patterns_collections_controller.rb
+++ b/app/controllers/journey_patterns_collections_controller.rb
@@ -45,7 +45,6 @@ class JourneyPatternsCollectionsController < ChouetteController
}
end
@stop_points_list = @stop_points_list.sort_by {|a| a[:position] }
- build_breadcrumb :index
end
def user_permissions
diff --git a/app/controllers/journey_patterns_controller.rb b/app/controllers/journey_patterns_controller.rb
index f4ae55b4e..a72e7da7f 100644
--- a/app/controllers/journey_patterns_controller.rb
+++ b/app/controllers/journey_patterns_controller.rb
@@ -30,9 +30,7 @@ class JourneyPatternsController < ChouetteController
def show
@map = JourneyPatternMap.new(journey_pattern).with_helpers(self)
@stop_points = journey_pattern.stop_points.paginate(:page => params[:page])
- show! do
- build_breadcrumb :show
- end
+ show!
end
def new_vehicle_journey
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb
index 581c921e8..2d4d10064 100644
--- a/app/controllers/line_footnotes_controller.rb
+++ b/app/controllers/line_footnotes_controller.rb
@@ -5,12 +5,6 @@ class LineFootnotesController < ChouetteController
before_action :authorize_resource, only: [:destroy_footnote, :edit_footnote, :show_footnote, :update_footnote]
before_action :authorize_resource_class, only: [:create_footnote, :index_footnote, :new_footnote]
- def edit
- edit! do
- build_breadcrumb :edit
- end
- end
-
def update
update! do |success, failure|
success.html { redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated') }
diff --git a/app/controllers/line_referentials_controller.rb b/app/controllers/line_referentials_controller.rb
index fc4ab3cf5..f70ddef41 100644
--- a/app/controllers/line_referentials_controller.rb
+++ b/app/controllers/line_referentials_controller.rb
@@ -1,4 +1,4 @@
-class LineReferentialsController < BreadcrumbController
+class LineReferentialsController < InheritedResources::Base
defaults :resource_class => LineReferential
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index 4b6448ce8..cf2908500 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -1,4 +1,4 @@
-class LinesController < BreadcrumbController
+class LinesController < InheritedResources::Base
include ApplicationHelper
include PolicyChecker
defaults :resource_class => Chouette::Line
@@ -26,7 +26,6 @@ class LinesController < BreadcrumbController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
}
end
end
@@ -38,8 +37,6 @@ class LinesController < BreadcrumbController
line_referential: @line_referential,
current_organisation: current_organisation
})
-
- build_breadcrumb :show
end
end
diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb
index 5dae1ba3f..98c840777 100644
--- a/app/controllers/networks_controller.rb
+++ b/app/controllers/networks_controller.rb
@@ -1,4 +1,4 @@
-class NetworksController < BreadcrumbController
+class NetworksController < InheritedResources::Base
include ApplicationHelper
include PolicyChecker
defaults :resource_class => Chouette::Network
@@ -17,8 +17,6 @@ class NetworksController < BreadcrumbController
@network = @network.decorate(context: {
line_referential: line_referential
})
-
- build_breadcrumb :show
end
end
@@ -43,8 +41,6 @@ class NetworksController < BreadcrumbController
format.js {
@networks = decorate_networks(@networks)
}
-
- build_breadcrumb :index
end
end
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 51a325586..d80541800 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -1,4 +1,4 @@
-class OrganisationsController < BreadcrumbController
+class OrganisationsController < InheritedResources::Base
defaults :resource_class => Organisation
respond_to :html, :only => [:edit, :show, :update]
@@ -18,6 +18,6 @@ class OrganisationsController < BreadcrumbController
def organisation_params
params.require(:organisation).permit(:name)
end
-
+
end
diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb
index 482f74ea0..fdbd83dc9 100644
--- a/app/controllers/referential_companies_controller.rb
+++ b/app/controllers/referential_companies_controller.rb
@@ -20,8 +20,6 @@ class ReferentialCompaniesController < ChouetteController
format.js {
@companies = decorate_companies(@companies)
}
-
- build_breadcrumb :index
end
end
diff --git a/app/controllers/referential_group_of_lines_controller.rb b/app/controllers/referential_group_of_lines_controller.rb
index 73520d00a..d88daab84 100644
--- a/app/controllers/referential_group_of_lines_controller.rb
+++ b/app/controllers/referential_group_of_lines_controller.rb
@@ -12,9 +12,7 @@ class ReferentialGroupOfLinesController < ChouetteController
def show
@map = GroupOfLineMap.new(resource).with_helpers(self)
@lines = resource.lines.order(:name)
- show! do
- build_breadcrumb :show
- end
+ show!
end
def index
@@ -23,7 +21,6 @@ class ReferentialGroupOfLinesController < ChouetteController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
}
end
end
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb
index ec0bbbb18..b9f8c0050 100644
--- a/app/controllers/referential_lines_controller.rb
+++ b/app/controllers/referential_lines_controller.rb
@@ -44,8 +44,6 @@ class ReferentialLinesController < ChouetteController
current_organisation: current_organisation
}
)
-
- build_breadcrumb :show
end
end
diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb
index ee2db8008..2131b8e57 100644
--- a/app/controllers/referential_networks_controller.rb
+++ b/app/controllers/referential_networks_controller.rb
@@ -18,8 +18,6 @@ class ReferentialNetworksController < ChouetteController
referential: referential
}
)
-
- build_breadcrumb :show
end
end
@@ -36,8 +34,6 @@ class ReferentialNetworksController < ChouetteController
format.js {
@networks = decorate_networks(@networks)
}
-
- build_breadcrumb :index
end
end
diff --git a/app/controllers/referential_stop_areas_controller.rb b/app/controllers/referential_stop_areas_controller.rb
index 7519418e7..78dcd6dd9 100644
--- a/app/controllers/referential_stop_areas_controller.rb
+++ b/app/controllers/referential_stop_areas_controller.rb
@@ -14,31 +14,26 @@ class ReferentialStopAreasController < ChouetteController
def select_parent
@stop_area = stop_area
@parent = stop_area.parent
- build_breadcrumb :edit
end
def add_children
@stop_area = stop_area
@children = stop_area.children
- build_breadcrumb :edit
end
def add_routing_lines
@stop_area = stop_area
@lines = stop_area.routing_lines
- build_breadcrumb :edit
end
def add_routing_stops
@stop_area = stop_area
- build_breadcrumb :edit
end
def access_links
@stop_area = stop_area
@generic_access_links = stop_area.generic_access_link_matrix
@detail_access_links = stop_area.detail_access_link_matrix
- build_breadcrumb :edit
end
def index
@@ -49,7 +44,6 @@ class ReferentialStopAreasController < ChouetteController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
}
end
end
@@ -57,9 +51,7 @@ class ReferentialStopAreasController < ChouetteController
def new
@map = StopAreaMap.new( Chouette::StopArea.new).with_helpers(self)
@map.editable = true
- new! do
- build_breadcrumb :show
- end
+ new!
end
def create
@@ -81,8 +73,6 @@ class ReferentialStopAreasController < ChouetteController
end
@stop_area = @stop_area.decorate
-
- build_breadcrumb :show
end
end
@@ -90,7 +80,6 @@ class ReferentialStopAreasController < ChouetteController
edit! do
stop_area.position ||= stop_area.default_position
map.editable = true
- build_breadcrumb :edit
end
end
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index c8984076a..6b479e938 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -1,4 +1,4 @@
-class ReferentialsController < BreadcrumbController
+class ReferentialsController < InheritedResources::Base
defaults :resource_class => Referential
include PolicyChecker
@@ -18,8 +18,6 @@ class ReferentialsController < BreadcrumbController
if !!@referential.created_from_id
format.html { redirect_to workbench_path(@referential.workbench) }
- else
- build_breadcrumb :new
end
end
end
@@ -45,7 +43,6 @@ class ReferentialsController < BreadcrumbController
:time_tables_count => resource.time_tables.count,
:referential_id => resource.id}
}
- format.html { build_breadcrumb :show}
end
end
diff --git a/app/controllers/route_sections_controller.rb b/app/controllers/route_sections_controller.rb
index c1aaf732e..03d6cf176 100644
--- a/app/controllers/route_sections_controller.rb
+++ b/app/controllers/route_sections_controller.rb
@@ -8,14 +8,9 @@ class RouteSectionsController < ChouetteController
belongs_to :referential
before_action :save_return_to_path, only: [:edit, :create_to_edit]
- before_action ->(controller) { build_breadcrumb controller.action_name }
helper_method :search
- def index
- index!
- end
-
def new
@stop_areas = referential.stop_areas.with_geometry.order :name
new!
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 78daffb30..93f30f4d5 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -19,7 +19,6 @@ class RoutesController < ChouetteController
def edit_boarding_alighting
@route = route
- build_breadcrumb :edit
end
def save_boarding_alighting
@@ -51,8 +50,6 @@ class RoutesController < ChouetteController
@route_sp,
with: StopPointDecorator
)
-
- build_breadcrumb :show
end
end
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index 78cd0e209..6c3da5980 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -20,8 +20,6 @@ class RoutingConstraintZonesController < ChouetteController
line: parent
}
)
-
- build_breadcrumb :index
end
end
@@ -31,8 +29,6 @@ class RoutingConstraintZonesController < ChouetteController
referential: referential,
line: parent
})
-
- build_breadcrumb :show
end
end
diff --git a/app/controllers/rule_parameter_sets_controller.rb b/app/controllers/rule_parameter_sets_controller.rb
index 6a23407d0..de4863a08 100644
--- a/app/controllers/rule_parameter_sets_controller.rb
+++ b/app/controllers/rule_parameter_sets_controller.rb
@@ -1,15 +1,13 @@
-class RuleParameterSetsController < BreadcrumbController
+class RuleParameterSetsController < InheritedResources::Base
defaults :resource_class => RuleParameterSet
respond_to :html
respond_to :js, :only => [ :mode ]
def new
@rule_parameter_set = RuleParameterSet.default( current_organisation)
- new! do
- build_breadcrumb :new
- end
+ new!
end
-
+
def destroy
if current_organisation.rule_parameter_sets.count == 1
flash[:alert] = t('rule_parameter_sets.destroy.last_rps_protected')
diff --git a/app/controllers/stop_area_referentials_controller.rb b/app/controllers/stop_area_referentials_controller.rb
index 5c87be43d..e2815e5fb 100644
--- a/app/controllers/stop_area_referentials_controller.rb
+++ b/app/controllers/stop_area_referentials_controller.rb
@@ -1,4 +1,4 @@
-class StopAreaReferentialsController < BreadcrumbController
+class StopAreaReferentialsController < InheritedResources::Base
defaults :resource_class => StopAreaReferential
def sync
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index cdb7c59ab..1d6f88068 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -1,5 +1,4 @@
-# -*- coding: utf-8 -*-
-class StopAreasController < BreadcrumbController
+class StopAreasController < InheritedResources::Base
include ApplicationHelper
defaults :resource_class => Chouette::StopArea
@@ -22,32 +21,27 @@ class StopAreasController < BreadcrumbController
def select_parent
@stop_area = stop_area
@parent = stop_area.parent
- build_breadcrumb :edit
end
def add_children
authorize stop_area
@stop_area = stop_area
@children = stop_area.children
- build_breadcrumb :edit
end
def add_routing_lines
@stop_area = stop_area
@lines = stop_area.routing_lines
- build_breadcrumb :edit
end
def add_routing_stops
@stop_area = stop_area
- build_breadcrumb :edit
end
def access_links
@stop_area = stop_area
@generic_access_links = stop_area.generic_access_link_matrix
@detail_access_links = stop_area.detail_access_link_matrix
- build_breadcrumb :edit
end
def index
@@ -64,8 +58,6 @@ class StopAreasController < BreadcrumbController
@stop_areas,
with: StopAreaDecorator
)
-
- build_breadcrumb :index
}
end
end
@@ -74,9 +66,7 @@ class StopAreasController < BreadcrumbController
authorize resource_class
@map = StopAreaMap.new( Chouette::StopArea.new).with_helpers(self)
@map.editable = true
- new! do
- build_breadcrumb :show
- end
+ new!
end
def create
@@ -99,8 +89,6 @@ class StopAreasController < BreadcrumbController
end
@stop_area = @stop_area.decorate
-
- build_breadcrumb :show
end
end
@@ -109,7 +97,6 @@ class StopAreasController < BreadcrumbController
edit! do
stop_area.position ||= stop_area.default_position
map.editable = true
- build_breadcrumb :edit
end
end
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index af74f635f..0c1769ad7 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -19,7 +19,6 @@ class TimeTablesController < ChouetteController
@time_table = @time_table.decorate(context: {
referential: @referential
})
- build_breadcrumb :show
end
end
@@ -30,9 +29,7 @@ class TimeTablesController < ChouetteController
def new
@autocomplete_items = ActsAsTaggableOn::Tag.all
- new! do
- build_breadcrumb :new
- end
+ new!
end
def create
@@ -66,7 +63,6 @@ class TimeTablesController < ChouetteController
def edit
edit! do
- build_breadcrumb :edit
@autocomplete_items = ActsAsTaggableOn::Tag.all
end
end
@@ -89,8 +85,6 @@ class TimeTablesController < ChouetteController
end
@time_tables = decorate_time_tables(@time_tables)
-
- build_breadcrumb :index
}
format.js {
@@ -101,8 +95,6 @@ class TimeTablesController < ChouetteController
def duplicate
@time_table = Chouette::TimeTable.find params[:id]
- # prepare breadcrumb before prepare data for new timetable
- build_breadcrumb :edit
@time_table = @time_table.duplicate
render :new
end
diff --git a/app/controllers/timebands_controller.rb b/app/controllers/timebands_controller.rb
index 446255cac..765557193 100644
--- a/app/controllers/timebands_controller.rb
+++ b/app/controllers/timebands_controller.rb
@@ -6,14 +6,7 @@ class TimebandsController < ChouetteController
belongs_to :referential
- def new
- new! do
- build_breadcrumb :new
- end
- end
-
private
-
def timeband_params
params.require(:timeband).permit( :name, :start_time, :end_time )
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 23ce3ef0a..2452a2796 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,4 +1,4 @@
-class UsersController < BreadcrumbController
+class UsersController < InheritedResources::Base
defaults :resource_class => User
diff --git a/app/controllers/vehicle_journey_imports_controller.rb b/app/controllers/vehicle_journey_imports_controller.rb
index 2e2a3a718..58f8816aa 100644
--- a/app/controllers/vehicle_journey_imports_controller.rb
+++ b/app/controllers/vehicle_journey_imports_controller.rb
@@ -12,9 +12,7 @@ class VehicleJourneyImportsController < ChouetteController
def new
@vehicle_journey_import = VehicleJourneyImport.new(:route => route)
- new! do
- build_breadcrumb :new
- end
+ new!
end
def create
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 70cca15ed..050f2f219 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -76,7 +76,6 @@ class VehicleJourneysController < ChouetteController
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
- build_breadcrumb :index
end
end
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index e271007d6..9b4f0d6c4 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -1,4 +1,4 @@
-class WorkbenchesController < BreadcrumbController
+class WorkbenchesController < InheritedResources::Base
before_action :query_params, only: [:show]
include RansackDateFilter
before_action only: [:show] { set_date_time_params("validity_period", Date) }
@@ -25,9 +25,7 @@ class WorkbenchesController < BreadcrumbController
current_workbench_id: params[:id]
}
)
- show! do
- build_breadcrumb :show
- end
+ show!
end
def delete_referentials
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
deleted file mode 100644
index da1f270ab..000000000
--- a/app/helpers/breadcrumb_helper.rb
+++ /dev/null
@@ -1,310 +0,0 @@
-# coding: utf-8
-module BreadcrumbHelper
-
- def build_breadcrumb(action)
- action = action.to_sym
- case resource_class.to_s
- when "Chouette::Network"
- network_breadcrumb action
- when "Chouette::Company"
- company_breadcrumb action
- when "Chouette::GroupOfLine"
- group_of_line_breadcrumb action
- when "Chouette::Line"
- line_breadcrumb action
- when "Chouette::Route"
- route_breadcrumb action
- when "Chouette::JourneyPattern"
- journey_pattern_breadcrumb action
- when "Chouette::VehicleJourney"
- vehicle_journey_breadcrumb action
- when "Chouette::VehicleJourneyFrequency"
- vehicle_journey_frequency_breadcrumb action
- when "VehicleJourneyImport"
- vehicle_journey_import_breadcrumb action
- when "Chouette::StopArea"
- stop_area_breadcrumb action
- when "Chouette::AccessPoint"
- access_point_breadcrumb action
- when "Chouette::AccessLink"
- access_link_breadcrumb action
- when "Chouette::ConnectionLink"
- connection_link_breadcrumb action
- when "Chouette::TimeTable"
- time_table_breadcrumb action
- when "Chouette::RouteSection"
- route_section_breadcrumb action
- when "Chouette::Timeband"
- timeband_breadcrumb action
- when 'Chouette::RoutingConstraintZone'
- routing_constraint_zone_breadcrumb action
- when 'Calendar'
- calendar_breadcrumb action
- when "StopAreaCopy"
- stop_area_copy_breadcrumb action
- when "Import"
- import_breadcrumb action
- when "Export"
- export_breadcrumb action
- when "ComplianceCheck"
- compliance_check_breadcrumb action
- when "ComplianceCheckTask"
- compliance_check_task_breadcrumb action
- when "ComplianceControlSets"
- compliance_control_sets_breadcrumb action
- when "RuleParameterSet"
- rule_parameter_breadcrumb action
- when "User"
- user_breadcrumb action
- when "Referential"
- referential_breadcrumb action
- when "LineReferential"
- line_referential_breadcrumb action
- when "Organisation"
- organisation_breadcrumb action
- when "Api::V1::ApiKey"
- referential_breadcrumb
- when "Workbench"
- workbench_breadcrumb action
- else
- Rails.logger.info "---------"
- Rails.logger.info ">>>>>>> "+resource_class.to_s+" unmapped"
- Rails.logger.info "---------"
- organisation_breadcrumb :index
- end
- end
-
- def calendar_breadcrumb(action)
- add_breadcrumb I18n.t('breadcrumbs.root'), root_path
- add_breadcrumb I18n.t('calendars.index.title'), calendars_path
- add_breadcrumb @calendar.name if %i(show edit).include? action
- end
-
- def workbench_breadcrumb(action)
- add_breadcrumb I18n.t("breadcrumbs.root"), root_path
- add_breadcrumb breadcrumb_label(@workbench), workbench_path(@workbench), :title => breadcrumb_tooltip(@workbench)
- end
-
- def network_breadcrumb(action)
- if @line_referential
- line_referential_breadcrumb
- add_breadcrumb Chouette::Network.model_name.human(:count => 2).capitalize, line_referential_networks_path(@line_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@network), line_referential_network_path(@line_referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit
- else
- referential_breadcrumb
- add_breadcrumb Chouette::Network.model_name.human(:count => 2).capitalize, referential_networks_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@network), referential_network_path(@referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit
- end
- end
-
- def group_of_line_breadcrumb(action)
- if @line_referential
- line_referential_breadcrumb
- add_breadcrumb Chouette::GroupOfLine.model_name.human(:count => 2).capitalize, line_referential_group_of_lines_path(@line_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@group_of_line), line_referential_group_of_line_path(@line_referential, @group_of_line),:title => breadcrumb_tooltip(@group_of_line) if action == :edit
- else
- referential_breadcrumb
- add_breadcrumb Chouette::GroupOfLine.model_name.human(:count => 2).capitalize, referential_group_of_lines_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@group_of_line), referential_group_of_line_path(@referential, @group_of_line),:title => breadcrumb_tooltip(@group_of_line) if action == :edit
- end
- end
-
- def stop_area_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::StopArea.model_name.human(:count => 2).capitalize, stop_area_referential_stop_areas_path(@stop_area.stop_area_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@stop_area), stop_area_referential_stop_area_path(@stop_area.stop_area_referential, @stop_area),:title => breadcrumb_tooltip(@stop_area) if action == :edit
- end
-
- def stop_area_copy_breadcrumb(action)
- stop_area_breadcrumb :edit
- end
-
- def access_point_breadcrumb(action)
- stop_area_breadcrumb :edit
- add_breadcrumb breadcrumb_label(@access_point), referential_stop_area_access_point_path(@referential, @access_point.stop_area,@access_point),:title => breadcrumb_tooltip(@access_point) if action == :edit
- end
-
- def access_link_breadcrumb(action)
- access_point_breadcrumb :edit
- add_breadcrumb Chouette::AccessLink.model_name.human(:count => 2).capitalize.capitalize, access_links_referential_stop_area_path(@referential, @stop_area)
- add_breadcrumb breadcrumb_label(@access_link), referential_access_point_access_link_path(@referential, @access_point,@access_link),:title => breadcrumb_tooltip(@access_link) if action == :edit
- end
-
- def connection_link_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::ConnectionLink.model_name.human.pluralize.capitalize, referential_connection_links_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@connection_link), referential_connection_link_path(@referential, @connection_link),:title => breadcrumb_tooltip(@connection_link) if action == :edit
- end
-
- def time_table_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::TimeTable.model_name.human(:count => 2).capitalize, referential_time_tables_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@time_table), referential_time_table_path(@referential, @time_table),:title => breadcrumb_tooltip(@time_table) if action == :edit
- end
-
- def route_section_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::RouteSection.model_name.human.pluralize, referential_route_sections_path(@referential)
- add_breadcrumb breadcrumb_label(resource), referential_route_section_path(@referential, resource),:title => breadcrumb_tooltip(resource) if action.in?([:show, :edit])
- end
-
- def timeband_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::Timeband.model_name.human(:count => 2).capitalize, referential_timebands_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@timeband), referential_timeband_path(@referential, @timeband),:title => breadcrumb_tooltip(@timeband) if action == :edit
- end
-
- def line_breadcrumb(action)
- if @line_referential
- line_referential_breadcrumb
- add_breadcrumb Chouette::Line.model_name.human(:count => 2).capitalize, line_referential_lines_path(@line_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@line), line_referential_line_path(@line_referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit
- else
- referential_breadcrumb
- add_breadcrumb breadcrumb_label(@line), referential_line_path(@referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit
- end
- end
-
- def route_breadcrumb(action)
- line_breadcrumb :edit
- 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
- end
-
- def vehicle_journey_breadcrumb(action)
- route_breadcrumb :edit
- add_breadcrumb I18n.t("breadcrumbs.vehicle_journeys"), referential_line_route_vehicle_journeys_path(@referential, @line,@route) unless action == :index
- add_breadcrumb breadcrumb_label(@vehicle_journey), referential_line_route_vehicle_journey_path(@referential, @line,@route,@vehicle_journey),:title => breadcrumb_tooltip(@vehicle_journey) if action == :edit
- end
-
- def vehicle_journey_frequency_breadcrumb(action)
- route_breadcrumb :edit
- add_breadcrumb I18n.t("breadcrumbs.vehicle_journey_frequencies"), referential_line_route_vehicle_journey_frequencies_path(@referential, @line, @route) unless action == :index
- add_breadcrumb breadcrumb_label(@vehicle_journey_frequency), referential_line_route_vehicle_journey_frequency_path(@referential, @line,@route, @vehicle_journey_frequency),:title => breadcrumb_tooltip(@vehicle_journey_frequency) if action == :edit
- end
-
- def vehicle_journey_import_breadcrumb (action)
- route_breadcrumb :edit
- end
-
- def line_referential_breadcrumb(action = :edit)
- organisation_breadcrumb
- if @line_referential
- add_breadcrumb breadcrumb_label(@line_referential), line_referential_path(@line_referential), :title => breadcrumb_tooltip(@line_referential) if action == :edit || action == :show || action == :update
- end
- end
-
- def company_breadcrumb (action)
- if @line_referential
- line_referential_breadcrumb
- add_breadcrumb Chouette::Company.model_name.human(:count => 2).capitalize, line_referential_companies_path(@line_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@company), line_referential_company_path(@line_referential, @company),:title => breadcrumb_tooltip(@company) if action == :edit
- else
- referential_breadcrumb
- add_breadcrumb Chouette::Company.model_name.human(:count => 2).capitalize, referential_companies_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@company), referential_company_path(@referential, @company),:title => breadcrumb_tooltip(@company) if action == :edit
- end
- end
-
- def import_breadcrumb (action)
- add_breadcrumb I18n.t("breadcrumbs.root"), root_path
- add_breadcrumb breadcrumb_label(@workbench), workbench_path(@workbench), :title => breadcrumb_tooltip(@workbench)
- add_breadcrumb I18n.t("breadcrumbs.imports"), workbench_imports_path(@workbench)
-
- end
-
- def export_breadcrumb (action)
- referential_breadcrumb
- add_breadcrumb Referential.human_attribute_name("exports"), referential_exports_path(@referential) unless action == :index
- end
-
- def compliance_check_breadcrumb (action)
- referential_breadcrumb
- add_breadcrumb Referential.human_attribute_name("compliance_checks"), referential_compliance_checks_path(@referential) unless action == :index
- add_breadcrumb @compliance_check.name, referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check
- add_breadcrumb t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, @rule_parameter_set.compliance_check.id) if action == :rule_parameter_set
- end
-
- def compliance_check_task_breadcrumb (action)
- referential_breadcrumb
- add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@compliance_check_task), referential_compliance_check_task_path(@referential, @compliance_check_task),:title => breadcrumb_tooltip(@compliance_check_task) if action == :edit
- end
-
- def compliance_control_sets_breadcrumb (action)
- add_breadcrumb I18n.t("breadcrumbs.root"), root_path
- #add_breadcrumb breadcrumb_label(@workbench), workbench_path(@workbench), :title => breadcrumb_tooltip(@workbench)
- end
-
- def rule_parameter_breadcrumb (action)
- organisation_breadcrumb
- add_breadcrumb Referential.human_attribute_name("rule_parameter_sets"), organisation_path unless action == :index
- add_breadcrumb breadcrumb_label(@rule_parameter_set), organisation_rule_parameter_set_path(@rule_parameter_set),:title => breadcrumb_tooltip(@rule_parameter_set) if action == :edit
- end
-
- def referential_breadcrumb (action = :edit)
- organisation_breadcrumb
- if @referential
- if workbench = @referential.workbench
- add_breadcrumb breadcrumb_label(workbench), workbench_path(workbench), :title => breadcrumb_tooltip(workbench)
- end
-
- add_breadcrumb breadcrumb_label(@referential), referential_path(@referential),:title => breadcrumb_tooltip(@referential) if action == :edit || action == :show || action == :update
- end
- end
-
- def organisation_breadcrumb (action = :index)
- add_breadcrumb I18n.t("breadcrumbs.root"), root_path
- add_breadcrumb breadcrumb_label(@organisation), organisation_path,:title => breadcrumb_tooltip(@organisation) unless action == :index
- end
-
- def user_breadcrumb (action)
- organisation_breadcrumb
- add_breadcrumb I18n.t("breadcrumbs.users"), organisation_path unless action == :index
- add_breadcrumb breadcrumb_label(@user), organisation_user_path(@user),:title => breadcrumb_tooltip(@user) if action == :edit
- end
-
- def breadcrumb_label(obj)
- label = breadcrumb_name(obj)
- if label.blank?
- label = obj.class.model_name.human+" "+obj.id.to_s
- end
-
- if label.length > 20
- label[0..16]+"..."
- else
- label
- end
- end
-
- def breadcrumb_tooltip(obj)
- label = breadcrumb_name(obj)
- if label.blank?
- label = obj.class.model_name.human+" ("+obj.id.to_s+")"
- else
- label = obj.class.model_name.human+" : "+label
- end
- label
- end
-
- def breadcrumb_name(obj)
- label = ""
- if obj.respond_to?('name')
- label = obj.name
- elsif obj.respond_to?('comment')
- label = obj.comment
- end
- label
- end
-
-end
diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb
index 09e22d6e9..311e6fb46 100644
--- a/app/helpers/compliance_control_blocks_helper.rb
+++ b/app/helpers/compliance_control_blocks_helper.rb
@@ -1,10 +1,10 @@
module ComplianceControlBlocksHelper
def transport_mode(transport_mode, transport_submode)
- if (transport_mode) && (transport_submode) != ""
- transportMode = "[" + t("enumerize.transport_mode.#{transport_mode}") + "]" + "[" + t("enumerize.transport_submode.#{transport_submode}") + "]"
+ return "[Tous les modes de transport]" if transport_mode == ""
+ if transport_submode == ""
+ "[" + t("enumerize.transport_mode.#{transport_mode}") + "]"
else
- transportMode = "[Tous les modes de transport]"
+ "[" + t("enumerize.transport_mode.#{transport_mode}") + "]" + "[" + t("enumerize.transport_submode.#{transport_submode}") + "]"
end
- transportMode
end
-end \ No newline at end of file
+end
diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb
new file mode 100644
index 000000000..ba0c538c9
--- /dev/null
+++ b/app/helpers/compliance_controls_helper.rb
@@ -0,0 +1,11 @@
+module ComplianceControlsHelper
+ def subclass_selection_list
+ ComplianceControl.subclass_patterns.map(&method(:make_subclass_selection_item))
+ end
+
+
+ def make_subclass_selection_item(key_pattern)
+ key, pattern = key_pattern
+ [t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"]
+ end
+end
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 95f53a90d..37f01ce0d 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -83,17 +83,21 @@ module TableBuilderHelper
cls: '',
# A set of content, over the th line...
- overhead: []
+ overhead: [],
+
+ # Possibility to override the result of collection.model
+ model: nil
+
)
content_tag :table,
- thead(collection, columns, sortable, selectable, links.any?, overhead) +
+ thead(collection, columns, sortable, selectable, links.any?, overhead, model || collection.model) +
tbody(collection, columns, selectable, links, overhead),
class: cls
end
private
- def thead(collection, columns, sortable, selectable, has_links, overhead)
+ def thead(collection, columns, sortable, selectable, has_links, overhead, model )
content_tag :thead do
# Inserts overhead content if any specified
over_head = ''
@@ -121,7 +125,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -137,7 +141,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -147,7 +151,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -160,7 +164,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -299,14 +303,14 @@ module TableBuilderHelper
def build_column_header(
column,
table_is_sortable,
- collection_model,
+ model,
params,
sort_on,
sort_direction
)
if !table_is_sortable || !column.sortable
- return column.header_label(collection_model)
+ return column.header_label(model)
end
direction =
@@ -331,7 +335,7 @@ module TableBuilderHelper
arrow_icons = content_tag :span, arrow_up + arrow_down, class: 'orderers'
(
- column.header_label(collection_model) +
+ column.header_label(model) +
arrow_icons
).html_safe
end
diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js
index 0c1cb5f5c..8bea5a990 100644
--- a/app/javascript/journey_patterns/actions/index.js
+++ b/app/javascript/journey_patterns/actions/index.js
@@ -90,7 +90,10 @@ const actions = {
resetValidation: (target) => {
$(target).parent().removeClass('has-error').children('.help-block').remove()
},
- humanOID : (oid) => oid.split(':')[2].split("-").pop(),
+ humanOID : (oid) => {
+ let shortOId = oid.split(':')[2].split("-").pop()
+ return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId
+ },
validateFields : (fields) => {
const test = []
diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js
index 699f89b85..e7ce24aa1 100644
--- a/app/javascript/journey_patterns/components/EditModal.js
+++ b/app/javascript/journey_patterns/components/EditModal.js
@@ -13,6 +13,19 @@ export default class EditModal extends Component {
}
}
+ renderModalTitle() {
+ if (this.props.editMode) {
+ return (
+ <h4 className='modal-title'>
+ Editer la mission
+ {this.props.modal.type == 'edit' && <em> "{this.props.modal.modalProps.journeyPattern.name}"</em>}
+ </h4>
+ )
+ } else {
+ return <h4 className='modal-title'> Informations </h4>
+ }
+ }
+
render() {
return (
<div className={ 'modal fade ' + ((this.props.modal.type == 'edit') ? 'in' : '') } id='JourneyPatternModal'>
@@ -20,12 +33,8 @@ export default class EditModal extends Component {
<div className='modal-dialog'>
<div className='modal-content'>
<div className='modal-header'>
- <h4 className='modal-title'>
- Editer la mission
- {(this.props.modal.type == 'edit') && (
- <em> "{this.props.modal.modalProps.journeyPattern.name}"</em>
- )}
- </h4>
+ {this.renderModalTitle()}
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'edit') && (
@@ -37,6 +46,7 @@ export default class EditModal extends Component {
type='text'
ref='name'
className='form-control'
+ disabled={!this.props.editMode}
id={this.props.modal.modalProps.index}
defaultValue={this.props.modal.modalProps.journeyPattern.name}
onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
@@ -52,6 +62,7 @@ export default class EditModal extends Component {
type='text'
ref='published_name'
className='form-control'
+ disabled={!this.props.editMode}
id={this.props.modal.modalProps.index}
defaultValue={this.props.modal.modalProps.journeyPattern.published_name}
onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
@@ -66,6 +77,7 @@ export default class EditModal extends Component {
type='text'
ref='registration_number'
className='form-control'
+ disabled={!this.props.editMode}
id={this.props.modal.modalProps.index}
defaultValue={this.props.modal.modalProps.journeyPattern.registration_number}
onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
@@ -74,24 +86,26 @@ export default class EditModal extends Component {
</div>
</div>
</div>
-
- <div className='modal-footer'>
- <button
- className='btn btn-link'
- data-dismiss='modal'
- type='button'
- onClick={this.props.onModalClose}
+ {
+ this.props.editMode &&
+ <div className='modal-footer'>
+ <button
+ className='btn btn-link'
+ data-dismiss='modal'
+ type='button'
+ onClick={this.props.onModalClose}
>
- Annuler
- </button>
- <button
- className='btn btn-primary'
- type='button'
- onClick={this.handleSubmit.bind(this)}
+ Annuler
+ </button>
+ <button
+ className='btn btn-primary'
+ type='button'
+ onClick={this.handleSubmit.bind(this)}
>
- Valider
- </button>
- </div>
+ Valider
+ </button>
+ </div>
+ }
</form>
)}
</div>
diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js
index dde73a957..34d102c5d 100644
--- a/app/javascript/journey_patterns/components/JourneyPattern.js
+++ b/app/javascript/journey_patterns/components/JourneyPattern.js
@@ -56,7 +56,7 @@ export default class JourneyPattern extends Component{
}
isDisabled(action) {
- return !this.props.status.policy[`journey_patterns.${action}`] && !this.props.editMode
+ return !this.props.status.policy[`journey_patterns.${action}`]
}
render() {
@@ -88,16 +88,17 @@ export default class JourneyPattern extends Component{
data-toggle='modal'
data-target='#JourneyPatternModal'
>
- Editer
+ {this.props.editMode ? 'Editer' : 'Consulter'}
</button>
</li>
<li className={this.props.value.object_id ? '' : 'disabled'}>
{this.vehicleJourneyURL(this.props.value.object_id)}
</li>
- <li className={'delete-action' + (this.isDisabled('destroy') ? ' disabled' : '')}>
+ <li className={'delete-action' + (this.isDisabled('destroy') || !this.props.editMode ? ' disabled' : '')}>
<button
type='button'
- disabled={this.isDisabled('destroy') ? 'disabled' : ''}
+ className="disabled"
+ disabled={this.isDisabled('destroy') || !this.props.editMode}
onClick={(e) => {
e.preventDefault()
this.props.onDeleteJourneyPattern(this.props.index)}
diff --git a/app/javascript/journey_patterns/containers/Modal.js b/app/javascript/journey_patterns/containers/Modal.js
index ace71a857..33ee8583c 100644
--- a/app/javascript/journey_patterns/containers/Modal.js
+++ b/app/javascript/journey_patterns/containers/Modal.js
@@ -5,6 +5,7 @@ import CreateModal from '../components/CreateModal'
const mapStateToProps = (state) => {
return {
+ editMode: state.editMode,
modal: state.modal,
journeyPattern: state.journeyPattern
}
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index 4272c7915..95c739893 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -269,7 +269,10 @@ const actions = {
type: 'RECEIVE_TOTAL_COUNT',
total
}),
- humanOID: (oid) => oid.split(':')[2].split("-").pop(),
+ humanOID: (oid) => {
+ let shortOId = oid.split(':')[2].split("-").pop()
+ return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId
+ },
fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => {
if(currentPage == undefined){
currentPage = 1
@@ -458,6 +461,10 @@ const actions = {
}
}
},
+ escapeWildcardCharacters(search) {
+ let newSearch = search.replace(/^_/, "\\_")
+ return newSearch.replace(/^%/, "\\%")
+ }
}
export default actions
diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js
index a717408b9..7621dfc10 100644
--- a/app/javascript/vehicle_journeys/components/Tools.js
+++ b/app/javascript/vehicle_journeys/components/Tools.js
@@ -1,4 +1,4 @@
-import React, { PropTypes } from 'react'
+import React, { PropTypes, Component } from 'react'
import actions from '../actions'
import AddVehicleJourney from '../containers/tools/AddVehicleJourney'
import DeleteVehicleJourneys from '../containers/tools/DeleteVehicleJourneys'
@@ -8,28 +8,37 @@ import EditVehicleJourney from '../containers/tools/EditVehicleJourney'
import NotesEditVehicleJourney from '../containers/tools/NotesEditVehicleJourney'
import TimetablesEditVehicleJourney from '../containers/tools/TimetablesEditVehicleJourney'
-export default function Tools({vehicleJourneys, onCancelSelection, filters: {policy}, editMode}) {
- return (
- <div>
- {
- (policy['vehicle_journeys.create'] && policy['vehicle_journeys.update'] && policy['vehicle_journeys.destroy'] && editMode) &&
- <div className='select_toolbox'>
- <ul>
- <AddVehicleJourney />
- <DuplicateVehicleJourney />
- <ShiftVehicleJourney />
- <EditVehicleJourney />
- <TimetablesEditVehicleJourney />
- <NotesEditVehicleJourney />
- <DeleteVehicleJourneys />
- </ul>
- <span className='info-msg'>{actions.getSelected(vehicleJourneys).length} course(s) sélectionnée(s)</span>
- <button className='btn btn-xs btn-link pull-right' onClick={onCancelSelection}>Annuler la sélection</button>
- </div>
- }
- </div>
- )
+export default class Tools extends Component {
+ constructor(props) {
+ super(props)
+ this.hasPolicy = this.hasPolicy.bind(this)
+ }
+
+ hasPolicy(key) {
+ // Check if the user has the policy to disable or not the action
+ return this.props.filters.policy[`vehicle_journeys.${key}`]
+ }
+
+ render() {
+ let { vehicleJourneys, onCancelSelection, editMode } = this.props
+ return (
+ <div className='select_toolbox'>
+ <ul>
+ <AddVehicleJourney disabled={this.hasPolicy("create") && !editMode} />
+ <DuplicateVehicleJourney disabled={this.hasPolicy("create") && this.hasPolicy("update") && !editMode}/>
+ <ShiftVehicleJourney disabled={this.hasPolicy("update") && !editMode}/>
+ <EditVehicleJourney disabled={!this.hasPolicy("update")}/>
+ <TimetablesEditVehicleJourney disabled={!this.hasPolicy("update")}/>
+ <NotesEditVehicleJourney disabled={!this.hasPolicy("update")}/>
+ <DeleteVehicleJourneys disabled={this.hasPolicy("destroy") && !editMode}/>
+ </ul>
+
+ <span className='info-msg'>{actions.getSelected(vehicleJourneys).length} course(s) sélectionnée(s)</span>
+ <button className='btn btn-xs btn-link pull-right' onClick={onCancelSelection}>Annuler la sélection</button>
+ </div>
+ )
+ }
}
Tools.propTypes = {
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js
index cb5407f81..13f8eced2 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js
@@ -44,6 +44,7 @@ export default class VehicleJourney extends Component {
render() {
this.previousCity = undefined
+ let {time_tables} = this.props.value
return (
<div className={'t2e-item' + (this.props.value.deletable ? ' disabled' : '') + (this.props.value.errors ? ' has-error': '')}>
@@ -51,39 +52,37 @@ export default class VehicleJourney extends Component {
<div className='strong mb-xs'>{this.props.value.objectid ? actions.humanOID(this.props.value.objectid) : '-'}</div>
<div>{actions.humanOID(this.props.value.journey_pattern.objectid)}</div>
<div>
- {this.props.value.time_tables.map((tt, i)=>
+ {time_tables.slice(0,3).map((tt, i)=>
<span key={i} className='vj_tt'>{this.timeTableURL(tt)}</span>
)}
+ {time_tables.length > 3 && <span className='vj_tt'> + {time_tables.length - 3}</span>}
+ </div>
+ <div className={(this.props.value.deletable ? 'disabled ' : '') + 'checkbox'}>
+ <input
+ id={this.props.index}
+ name={this.props.index}
+ style={{display: 'none'}}
+ onChange={(e) => this.props.onSelectVehicleJourney(this.props.index)}
+ type='checkbox'
+ disabled={this.props.value.deletable}
+ checked={this.props.value.selected}
+ ></input>
+ <label htmlFor={this.props.index}></label>
</div>
-
- {(this.props.filters.policy['vehicle_journeys.update'] == true && this.props.editMode) &&
- <div className={(this.props.value.deletable ? 'disabled ' : '') + 'checkbox'}>
- <input
- id={this.props.index}
- name={this.props.index}
- style={{display: 'none'}}
- onChange={(e) => this.props.onSelectVehicleJourney(this.props.index)}
- type='checkbox'
- disabled={this.props.value.deletable}
- checked={this.props.value.selected}
- ></input>
- <label htmlFor={this.props.index}></label>
- </div>
- }
-
</div>
{this.props.value.vehicle_journey_at_stops.map((vj, i) =>
<div key={i} className='td text-center'>
<div className={'cellwrap' + (this.cityNameChecker(vj) ? ' headlined' : '')}>
{this.props.filters.toggleArrivals &&
<div data-headline='Arrivée à'>
- <span className={((this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false) ? 'disabled ' : '') + 'input-group time'}>
+ <span className={((this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false) ? 'disabled ' : '') + 'input-group time'}>
<input
type='number'
min='00'
max='23'
className='form-control'
- disabled={(this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)}
+ disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false}
+ readOnly={!this.props.editMode && !vj.dummy}
onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'hour', false, false)}}
value={vj.arrival_time['hour']}
/>
@@ -93,7 +92,8 @@ export default class VehicleJourney extends Component {
min='00'
max='59'
className='form-control'
- disabled={((this.isDisabled(this.props.value.deletable), vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)}
+ disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false}
+ readOnly={!this.props.editMode && !vj.dummy}
onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'minute', false, false)}}
value={vj.arrival_time['minute']}
/>
@@ -106,13 +106,14 @@ export default class VehicleJourney extends Component {
}
</div>
<div data-headline='Départ à'>
- <span className={((this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false) ? 'disabled ' : '') + 'input-group time'}>
+ <span className={((this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false) ? 'disabled ' : '') + 'input-group time'}>
<input
type='number'
min='00'
max='23'
className='form-control'
- disabled={(this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)}
+ disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false}
+ readOnly={!this.props.editMode && !vj.dummy}
onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'hour', true, this.props.filters.toggleArrivals)}}
value={vj.departure_time['hour']}
/>
@@ -122,7 +123,8 @@ export default class VehicleJourney extends Component {
min='00'
max='59'
className='form-control'
- disabled={(this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)}
+ disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false}
+ readOnly={!this.props.editMode && !vj.dummy}
onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, "minute", true, this.props.filters.toggleArrivals)}}
value={vj.departure_time['minute']}
/>
diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js
index 5b5e2f849..2bffebdf6 100644
--- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js
+++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js
@@ -25,7 +25,7 @@ export default class CreateModal extends Component {
<li className='st_action'>
<button
type='button'
- disabled={((this.props.filters.policy['vehicle_journeys.update'] == true) ? '' : 'disabled')}
+ disabled={(this.props.disabled) }
data-toggle='modal'
data-target='#NewVehicleJourneyModal'
onClick={this.props.onOpenCreateModal}
@@ -39,6 +39,7 @@ export default class CreateModal extends Component {
<div className='modal-content'>
<div className='modal-header'>
<h4 className='modal-title'>Ajouter une course</h4>
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'create') && (
@@ -127,5 +128,6 @@ CreateModal.propTypes = {
onOpenCreateModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onAddVehicleJourney: PropTypes.func.isRequired,
- onSelect2JourneyPattern: PropTypes.func.isRequired
+ onSelect2JourneyPattern: PropTypes.func.isRequired,
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js
index 0a1dedd3c..fc13ae964 100644
--- a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js
@@ -1,12 +1,12 @@
import React, { PropTypes } from 'react'
import actions from '../../actions'
-export default function DeleteVehicleJourneys({onDeleteVehicleJourneys, vehicleJourneys, filters}) {
+export default function DeleteVehicleJourneys({onDeleteVehicleJourneys, vehicleJourneys, disabled}) {
return (
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(vehicleJourneys).length > 0 && filters.policy['vehicle_journeys.destroy']) ? '' : 'disabled'}
+ disabled={(actions.getSelected(vehicleJourneys).length == 0 || disabled)}
onClick={e => {
e.preventDefault()
onDeleteVehicleJourneys()
@@ -22,5 +22,5 @@ export default function DeleteVehicleJourneys({onDeleteVehicleJourneys, vehicleJ
DeleteVehicleJourneys.propTypes = {
onDeleteVehicleJourneys: PropTypes.func.isRequired,
vehicleJourneys: PropTypes.array.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js
index 0c1c81114..8083defb9 100644
--- a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js
@@ -8,6 +8,7 @@ export default class DuplicateVehicleJourney extends Component {
this.state = {}
this.onFormChange = this.onFormChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
+ this.disableValidateButton = this.disableValidateButton.bind(this)
}
componentWillReceiveProps() {
@@ -58,16 +59,26 @@ export default class DuplicateVehicleJourney extends Component {
return vjas.departure_time[type]
}
+ disableValidateButton() {
+ /* We disable the button in two cases :
+ - if the additional_time_hh or additional_time_mm are above their input max value
+ - if if their is no change in the other inputs to avoid making a coping of the selected VJ
+ */
+ let incorrectDT = isNaN(this.state.duplicate_time_hh) || isNaN(this.state.duplicate_time_mm) || this.state.duplicate_time_hh > 23 || this.state.duplicate_time_mm > 59
+ let noInputChanges = this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm
+ return incorrectDT || noInputChanges
+ }
+
render() {
if(this.props.status.isFetching == true) {
return false
}
- if(this.props.status.fetchSuccess == true && actions.getSelected(this.props.vehicleJourneys).length > 0) {
+ if(this.props.status.fetchSuccess == true) {
return (
<li className='st_action'>
<button
type='button'
- disabled={((actions.getSelected(this.props.vehicleJourneys).length >= 1 && this.props.filters.policy['vehicle_journeys.update']) ? '' : 'disabled')}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length == 0 || this.props.disabled)}
data-toggle='modal'
data-target='#DuplicateVehicleJourneyModal'
onClick={this.props.onOpenDuplicateModal}
@@ -83,6 +94,7 @@ export default class DuplicateVehicleJourney extends Component {
<h4 className='modal-title'>
Dupliquer { actions.getSelected(this.props.vehicleJourneys).length > 1 ? 'plusieurs courses' : 'une course' }
</h4>
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'duplicate') && (
@@ -171,6 +183,7 @@ export default class DuplicateVehicleJourney extends Component {
className={'btn btn-primary ' + (this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm ? 'disabled' : '')}
type='button'
onClick={this.handleSubmit}
+ disabled={this.disableValidateButton()}
>
Valider
</button>
@@ -192,5 +205,5 @@ export default class DuplicateVehicleJourney extends Component {
DuplicateVehicleJourney.propTypes = {
onOpenDuplicateModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
index 3a4a57024..7ad3cf510 100644
--- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
@@ -32,7 +32,7 @@ export default class EditVehicleJourney extends Component {
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length == 1 && this.props.filters.policy['vehicle_journeys.update']) ? '' : 'disabled'}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length != 1 || this.props.disabled)}
data-toggle='modal'
data-target='#EditVehicleJourneyModal'
onClick={() => this.props.onOpenEditModal(actions.getSelected(this.props.vehicleJourneys)[0])}
@@ -46,6 +46,7 @@ export default class EditVehicleJourney extends Component {
<div className='modal-content'>
<div className='modal-header'>
<h4 className='modal-title'>Informations</h4>
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'edit') && (
@@ -59,6 +60,7 @@ export default class EditVehicleJourney extends Component {
type='text'
ref='published_journey_name'
className='form-control'
+ disabled={!this.props.editMode}
defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_name}
onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
/>
@@ -85,6 +87,7 @@ export default class EditVehicleJourney extends Component {
type='text'
ref='published_journey_identifier'
className='form-control'
+ disabled={!this.props.editMode}
defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_identifier}
onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
/>
@@ -94,6 +97,7 @@ export default class EditVehicleJourney extends Component {
<div className='form-group'>
<label className='control-label'>Transporteur</label>
<CompanySelect2
+ editMode={this.props.editMode}
company = {this.props.modal.modalProps.vehicleJourney.company}
onSelect2Company = {(e) => this.props.onSelect2Company(e)}
onUnselect2Company = {() => this.props.onUnselect2Company()}
@@ -127,24 +131,26 @@ export default class EditVehicleJourney extends Component {
</div>
</div>
</div>
-
- <div className='modal-footer'>
- <button
- className='btn btn-link'
- data-dismiss='modal'
- type='button'
- onClick={this.props.onModalClose}
+ {
+ this.props.editMode &&
+ <div className='modal-footer'>
+ <button
+ className='btn btn-link'
+ data-dismiss='modal'
+ type='button'
+ onClick={this.props.onModalClose}
>
- Annuler
+ Annuler
</button>
- <button
- className='btn btn-primary'
- type='button'
- onClick={this.handleSubmit.bind(this)}
+ <button
+ className='btn btn-primary'
+ type='button'
+ onClick={this.handleSubmit.bind(this)}
>
- Valider
+ Valider
</button>
- </div>
+ </div>
+ }
</form>
)}
@@ -163,5 +169,5 @@ export default class EditVehicleJourney extends Component {
EditVehicleJourney.propTypes = {
onOpenEditModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js
index 1958faf5f..de97bc403 100644
--- a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js
@@ -13,21 +13,25 @@ export default class NotesEditVehicleJourney extends Component {
$('#NotesEditVehicleJourneyModal').modal('hide')
}
- renderFootnoteButton(lf, vjArray){
- let footnote_id = undefined
- vjArray.forEach((f) => {
- if(f.id == lf.id){
- footnote_id = f.id
- }
- })
+ footnotes() {
+ let { footnotes } = this.props.modal.modalProps.vehicleJourney
+ let fnIds = footnotes.map(fn => fn.id)
+ return {
+ associated: footnotes,
+ to_associate: window.line_footnotes.filter(fn => !fnIds.includes(fn.id))
+ }
+ }
+
+ renderFootnoteButton(lf) {
+ if (!this.props.editMode) return false
- if(footnote_id){
+ if (this.footnotes().associated.includes(lf)) {
return <button
type='button'
className='btn btn-outline-danger btn-xs'
onClick={() => this.props.onToggleFootnoteModal(lf, false)}
><span className="fa fa-trash"></span> Retirer</button>
- }else{
+ } else {
return <button
type='button'
className='btn btn-outline-primary btn-xs'
@@ -36,28 +40,64 @@ export default class NotesEditVehicleJourney extends Component {
}
}
- filterFN() {
- return _.filter(window.line_footnotes, (lf, i) => {
- let bool = true
- _.map(this.props.modal.modalProps.vehicleJourney.footnotes, (f, j) => {
- if(lf.id === f.id) {
- bool = false
- }
- })
- return bool
- })
+ renderAssociatedFN() {
+ if (this.footnotes().associated.length == 0) {
+ return <h3>Aucune note associée</h3>
+ } else {
+ return (
+ <div>
+ <h3>Notes associées :</h3>
+ {this.footnotes().associated.map((lf, i) =>
+ <div
+ key={i}
+ className='panel panel-default'
+ >
+ <div className='panel-heading'>
+ <h4 className='panel-title clearfix'>
+ <div className='pull-left' style={{ paddingTop: '3px' }}>{lf.code}</div>
+ <div className='pull-right'>{this.renderFootnoteButton(lf, this.props.modal.modalProps.vehicleJourney.footnotes)}</div>
+ </h4>
+ </div>
+ <div className='panel-body'><p>{lf.label}</p></div>
+ </div>
+ )}
+ </div>
+ )
+ }
+ }
+
+ renderToAssociateFN() {
+ if (window.line_footnotes.length == 0) return <h3>La ligne ne possède pas de notes</h3>
+
+ if (this.footnotes().to_associate.length == 0) return false
+
+ return (
+ <div>
+ <h3 className='mt-lg'>Sélectionnez les notes à associer à cette course :</h3>
+ {this.footnotes().to_associate.map((lf, i) =>
+ <div key={i} className='panel panel-default'>
+ <div className='panel-heading'>
+ <h4 className='panel-title clearfix'>
+ <div className='pull-left' style={{ paddingTop: '3px' }}>{lf.code}</div>
+ <div className='pull-right'>{this.renderFootnoteButton(lf)}</div>
+ </h4>
+ </div>
+ <div className='panel-body'><p>{lf.label}</p></div>
+ </div>
+ )}
+ </div>
+ )
}
render() {
- if(this.props.status.isFetching == true) {
- return false
- }
- if(this.props.status.fetchSuccess == true) {
+ if (this.props.status.isFetching == true) return false
+
+ if (this.props.status.fetchSuccess == true) {
return (
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length == 1 && this.props.filters.policy['vehicle_journeys.update']) ? '' : 'disabled'}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length != 1 || this.props.disabled)}
data-toggle='modal'
data-target='#NotesEditVehicleJourneyModal'
onClick={() => this.props.onOpenNotesEditModal(actions.getSelected(this.props.vehicleJourneys)[0])}
@@ -71,61 +111,35 @@ export default class NotesEditVehicleJourney extends Component {
<div className='modal-content'>
<div className='modal-header'>
<h4 className='modal-title'>Notes</h4>
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'notes_edit') && (
<form>
<div className='modal-body'>
- <h3>Notes associées</h3>
- {(this.props.modal.modalProps.vehicleJourney.footnotes).map((lf, i) =>
- <div
- key={i}
- className='panel panel-default'
- >
- <div className='panel-heading'>
- <h4 className='panel-title clearfix'>
- <div className='pull-left' style={{paddingTop: '3px'}}>{lf.code}</div>
- <div className='pull-right'>{this.renderFootnoteButton(lf, this.props.modal.modalProps.vehicleJourney.footnotes)}</div>
- </h4>
- </div>
- <div className='panel-body'><p>{lf.label}</p></div>
- </div>
- )}
-
- <h3 className='mt-lg'>Sélectionnez les notes à associer à cette course :</h3>
- {this.filterFN().map((lf, i) =>
- <div
- key={i}
- className='panel panel-default'
- >
- <div className='panel-heading'>
- <h4 className='panel-title clearfix'>
- <div className='pull-left' style={{paddingTop: '3px'}}>{lf.code}</div>
- <div className='pull-right'>{this.renderFootnoteButton(lf, this.props.modal.modalProps.vehicleJourney.footnotes)}</div>
- </h4>
- </div>
- <div className='panel-body'><p>{lf.label}</p></div>
- </div>
- )}
+ {this.renderAssociatedFN()}
+ {this.props.editMode && this.renderToAssociateFN()}
</div>
-
- <div className='modal-footer'>
- <button
- className='btn btn-link'
- data-dismiss='modal'
- type='button'
- onClick={this.props.onModalClose}
+ {
+ this.props.editMode &&
+ <div className='modal-footer'>
+ <button
+ className='btn btn-link'
+ data-dismiss='modal'
+ type='button'
+ onClick={this.props.onModalClose}
>
- Annuler
+ Annuler
</button>
- <button
- className='btn btn-primary'
- type='button'
- onClick={this.handleSubmit.bind(this)}
+ <button
+ className='btn btn-primary'
+ type='button'
+ onClick={this.handleSubmit.bind(this)}
>
- Valider
+ Valider
</button>
- </div>
+ </div>
+ }
</form>
)}
@@ -146,5 +160,5 @@ NotesEditVehicleJourney.propTypes = {
onModalClose: PropTypes.func.isRequired,
onToggleFootnoteModal: PropTypes.func.isRequired,
onNotesEditVehicleJourney: PropTypes.func.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
index c1e2de779..175106ac5 100644
--- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
@@ -34,7 +34,7 @@ export default class ShiftVehicleJourney extends Component {
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length == 1 && this.props.filters.policy['vehicle_journeys.update']) ? '' : 'disabled'}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length > 1 || this.props.disabled)}
data-toggle='modal'
data-target='#ShiftVehicleJourneyModal'
onClick={this.props.onOpenShiftModal}
@@ -51,6 +51,7 @@ export default class ShiftVehicleJourney extends Component {
{(this.props.modal.type == 'shift') && (
<em>Mettre à jour les horaires de la course {actions.humanOID(actions.getSelected(this.props.vehicleJourneys)[0].objectid)}</em>
)}
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'shift') && (
@@ -110,5 +111,5 @@ export default class ShiftVehicleJourney extends Component {
ShiftVehicleJourney.propTypes = {
onOpenShiftModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
index fd2304901..fef3cdcc9 100644
--- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
@@ -5,6 +5,8 @@ import TimetableSelect2 from './select2s/TimetableSelect2'
export default class TimetablesEditVehicleJourney extends Component {
constructor(props) {
super(props)
+ this.handleSubmit = this.handleSubmit.bind(this)
+ this.timeTableURL = this.timeTableURL.bind(this)
}
handleSubmit() {
@@ -13,6 +15,11 @@ export default class TimetablesEditVehicleJourney extends Component {
$('#CalendarsEditVehicleJourneyModal').modal('hide')
}
+ timeTableURL(tt) {
+ let refURL = window.location.pathname.split('/', 3).join('/')
+ return refURL + '/time_tables/' + tt.id
+ }
+
render() {
if(this.props.status.isFetching == true) {
return false
@@ -22,7 +29,7 @@ export default class TimetablesEditVehicleJourney extends Component {
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length > 0 && this.props.filters.policy['vehicle_journeys.update']) ? '' : 'disabled'}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length != 1 || this.props.disabled)}
data-toggle='modal'
data-target='#CalendarsEditVehicleJourneyModal'
onClick={() => this.props.onOpenCalendarsEditModal(actions.getSelected(this.props.vehicleJourneys))}
@@ -36,6 +43,7 @@ export default class TimetablesEditVehicleJourney extends Component {
<div className='modal-content'>
<div className='modal-header'>
<h4 className='modal-title'>Calendriers associés</h4>
+ <span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
{(this.props.modal.type == 'calendars_edit') && (
@@ -57,55 +65,63 @@ export default class TimetablesEditVehicleJourney extends Component {
{this.props.modal.modalProps.timetables.map((tt, i) =>
<div className='nested-fields' key={i}>
<div className='wrapper'>
- <div>{tt.comment}</div>
- <div>
- <a
- href='#'
- title='Supprimer'
- className='fa fa-trash remove_fields'
- style={{height: 'auto', lineHeight: 'normal'}}
- onClick={(e) => {
- e.preventDefault()
- this.props.onDeleteCalendarModal(tt)
- }}
+ <div> <a href={this.timeTableURL(tt)} target="_blank">{tt.comment}</a> </div>
+ {
+ this.props.editMode &&
+ <div>
+ <a
+ href='#'
+ title='Supprimer'
+ className='fa fa-trash remove_fields'
+ style={{ height: 'auto', lineHeight: 'normal' }}
+ onClick={(e) => {
+ e.preventDefault()
+ this.props.onDeleteCalendarModal(tt)
+ }}
></a>
- </div>
+ </div>
+ }
</div>
</div>
)}
- <div className='nested-fields'>
- <div className='wrapper'>
- <div>
- <TimetableSelect2
- onSelect2Timetable={this.props.onSelect2Timetable}
- chunkURL={'/autocomplete_time_tables.json'}
- isFilter={false}
- />
+ {
+ this.props.editMode &&
+ <div className='nested-fields'>
+ <div className='wrapper'>
+ <div>
+ <TimetableSelect2
+ onSelect2Timetable={this.props.onSelect2Timetable}
+ chunkURL={'/autocomplete_time_tables.json'}
+ isFilter={false}
+ />
+ </div>
</div>
</div>
- </div>
+ }
</div>
</div>
</div>
</div>
-
- <div className='modal-footer'>
- <button
- className='btn btn-link'
- data-dismiss='modal'
- type='button'
- onClick={this.props.onModalClose}
+ {
+ this.props.editMode &&
+ <div className='modal-footer'>
+ <button
+ className='btn btn-link'
+ data-dismiss='modal'
+ type='button'
+ onClick={this.props.onModalClose}
>
- Annuler
- </button>
- <button
- className='btn btn-primary'
- type='button'
- onClick={this.handleSubmit.bind(this)}
+ Annuler
+ </button>
+ <button
+ className='btn btn-primary'
+ type='button'
+ onClick={this.handleSubmit}
>
- Valider
- </button>
- </div>
+ Valider
+ </button>
+ </div>
+ }
</form>
)}
@@ -127,5 +143,5 @@ TimetablesEditVehicleJourney.propTypes = {
onTimetablesEditVehicleJourney: PropTypes.func.isRequired,
onDeleteCalendarModal: PropTypes.func.isRequired,
onSelect2Timetable: PropTypes.func.isRequired,
- filters: PropTypes.object.isRequired
+ disabled: PropTypes.bool.isRequired
} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
index 9c259630d..0697e9141 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
@@ -1,6 +1,7 @@
import _ from 'lodash'
import React, { PropTypes, Component } from 'react'
import Select2 from 'react-select2'
+import actions from '../../../actions'
// get JSON full path
let origin = window.location.origin
@@ -20,10 +21,11 @@ export default class BSelect4 extends Component {
value={(this.props.company) ? this.props.company.name : undefined}
onSelect={(e) => this.props.onSelect2Company(e) }
onUnselect={() => this.props.onUnselect2Company()}
+ disabled={!this.props.editMode}
multiple={false}
ref='company_id'
options={{
- allowClear: true,
+ allowClear: this.props.editMode,
theme: 'bootstrap',
width: '100%',
placeholder: 'Filtrer par transporteur...',
@@ -34,7 +36,7 @@ export default class BSelect4 extends Component {
delay: '500',
data: function(params) {
return {
- q: {name_cont: params.term},
+ q: { name_cont: actions.escapeWildcardCharacters(params.term)},
};
},
processResults: function(data, params) {
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
index e4abdd651..6069bf089 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
@@ -33,7 +33,7 @@ export default class BSelect4 extends Component {
delay: '500',
data: function(params) {
return {
- q: {published_name_or_objectid_or_registration_number_cont: params.term},
+ q: { published_name_or_objectid_or_registration_number_cont: actions.escapeWildcardCharacters(params.term)},
};
},
processResults: function(data, params) {
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
index 606bf8511..60c3eab83 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
@@ -32,12 +32,9 @@ export default class BSelect4 extends Component {
dataType: 'json',
delay: '500',
data: function(params) {
- let newParmas = params.term.split(" ")
return {
q: {
- objectid_cont_any: newParmas,
- comment_cont_any: newParmas,
- m: 'or'
+ comment_or_objectid_cont_any: actions.escapeWildcardCharacters(params.term)
}
};
},
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
index e1af8816d..7cccbbc05 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
@@ -33,7 +33,7 @@ export default class BSelect4b extends Component {
delay: '500',
data: function(params) {
return {
- q: {objectid_cont: params.term},
+ q: { objectid_cont: actions.escapeWildcardCharacters(params.term)},
};
},
processResults: function(data, params) {
diff --git a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js
index b3f777448..5da0bd3e9 100644
--- a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js
@@ -2,13 +2,13 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import CreateModal from '../../components/tools/CreateModal'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
+ disabled: ownProps.disabled,
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
status: state.status,
stopPointsList: state.stopPointsList,
- filters: state.filters
}
}
diff --git a/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js b/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js
index d7d315da4..95f2eb506 100644
--- a/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js
@@ -2,10 +2,10 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import DeleteVJComponent from '../../components/tools/DeleteVehicleJourneys'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
- vehicleJourneys: state.vehicleJourneys,
- filters: state.filters
+ disabled: ownProps.disabled,
+ vehicleJourneys: state.vehicleJourneys
}
}
diff --git a/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js
index e9ca88040..7b23a06dc 100644
--- a/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js
@@ -2,8 +2,9 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import DuplicateVJComponent from '../../components/tools/DuplicateVehicleJourney'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
+ disabled: ownProps.disabled,
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
status: state.status,
diff --git a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js
index 2d480aa0c..c2eabcc10 100644
--- a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js
@@ -2,12 +2,13 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import EditComponent from '../../components/tools/EditVehicleJourney'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
+ editMode: state.editMode,
+ disabled: ownProps.disabled,
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
- status: state.status,
- filters: state.filters
+ status: state.status
}
}
diff --git a/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js
index 5a96ff273..6290ae3bf 100644
--- a/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js
@@ -2,12 +2,13 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import NotesEditComponent from '../../components/tools/NotesEditVehicleJourney'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
+ editMode: state.editMode,
+ disabled: ownProps.disabled,
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
- status: state.status,
- filters: state.filters
+ status: state.status
}
}
diff --git a/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js
index a4b4fbe39..abd7dd145 100644
--- a/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js
@@ -2,12 +2,12 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import ShiftVJComponent from '../../components/tools/ShiftVehicleJourney'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
status: state.status,
- filters: state.filters
+ disabled: ownProps.disabled
}
}
diff --git a/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js
index 62150a06e..b4ba9d068 100644
--- a/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js
@@ -2,12 +2,13 @@ import actions from '../../actions'
import { connect } from 'react-redux'
import TimetablesEditComponent from '../../components/tools/TimetablesEditVehicleJourney'
-const mapStateToProps = (state) => {
+const mapStateToProps = (state, ownProps) => {
return {
+ editMode: state.editMode,
modal: state.modal,
vehicleJourneys: state.vehicleJourneys,
status: state.status,
- filters: state.filters
+ disabled: ownProps.disabled
}
}
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 08efa7e9a..146c4e838 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -1,30 +1,10 @@
class ComplianceControl < ActiveRecord::Base
- extend Enumerize
- belongs_to :compliance_control_set
- belongs_to :compliance_control_block
-
- enumerize :criticity, in: %i(warning error), scope: true, default: :warning
- hstore_accessor :control_attributes, {}
-
- validates :criticity, presence: true
- validates :name, presence: true
- validates :code, presence: true, uniqueness: { scope: :compliance_control_set }
- validates :origin_code, presence: true
- validates :compliance_control_set, presence: true
-
- validate def coherent_control_set
- return true if compliance_control_block_id.nil?
- ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
- return true if ids.first == ids.last
- names = ids.map{|id| ComplianceControlSet.find(id).name}
- errors.add(:coherent_control_set,
- I18n.t('compliance_controls.errors.incoherent_control_sets',
- indirect_set_name: names.first,
- direct_set_name: names.last))
- end
class << self
+ def criticities; %i(warning error) end
def default_code; "" end
+ def prerequisite; I18n.t('compliance_controls.metas.no_prerequisite'); end
+ def predicate; I18n.t("compliance_controls.#{self.name.underscore}.description") end
def dynamic_attributes
hstore_metadata_for_control_attributes.keys
end
@@ -33,6 +13,17 @@ class ComplianceControl < ActiveRecord::Base
ComplianceControlPolicy
end
+ def subclass_patterns
+ {
+ generic: 'Generic',
+ journey_pattern: 'JourneyPattern',
+ line: 'Line',
+ route: 'Route',
+ routing_constraint_zone: 'RoutingConstraint',
+ vehicle_journey: 'VehicleJourney'
+ }
+ end
+
def inherited(child)
child.instance_eval do
def model_name
@@ -43,12 +34,37 @@ class ComplianceControl < ActiveRecord::Base
end
end
- def initialize(attributes = {})
- super
- self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
- self.code ||= self.class.default_code
- self.origin_code ||= self.class.default_code
- end
+ extend Enumerize
+ belongs_to :compliance_control_set
+ belongs_to :compliance_control_block
+
+ enumerize :criticity, in: criticities, scope: true, default: :warning
+ hstore_accessor :control_attributes, {}
+
+ validates :criticity, presence: true
+ validates :name, presence: true
+ validates :code, presence: true, uniqueness: { scope: :compliance_control_set }
+ validates :origin_code, presence: true
+ validates :compliance_control_set, presence: true
+
+ validate def coherent_control_set
+ return true if compliance_control_block_id.nil?
+ ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
+ return true if ids.first == ids.last
+ names = ids.map{|id| ComplianceControlSet.find(id).name}
+ errors.add(:coherent_control_set,
+ I18n.t('compliance_controls.errors.incoherent_control_sets',
+ indirect_set_name: names.first,
+ direct_set_name: names.last))
+end
+
+
+def initialize(attributes = {})
+ super
+ self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
+ self.code ||= self.class.default_code
+ self.origin_code ||= self.class.default_code
+end
end
diff --git a/app/models/concerns/stif_transport_mode_enumerations.rb b/app/models/concerns/stif_transport_mode_enumerations.rb
index 68d481735..c2d38c2c6 100644
--- a/app/models/concerns/stif_transport_mode_enumerations.rb
+++ b/app/models/concerns/stif_transport_mode_enumerations.rb
@@ -6,7 +6,8 @@ module StifTransportModeEnumerations
enumerize :transport_mode, in: %w(bus
metro
rail
- tram)
+ tram
+ funicular)
def transport_modes
StifTransportModeEnumerations.transport_mode.values
diff --git a/app/models/import.rb b/app/models/import.rb
index 4ff8326ab..20e7f2d8a 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -16,9 +16,10 @@ class Import < ActiveRecord::Base
extend Enumerize
enumerize :status, in: %i(new pending successful warning failed running aborted canceled), scope: true, default: :new
+ validates :name, presence: true
validates :file, presence: true
validates_presence_of :workbench, :creator
- validates_format_of :file, with: %r{\.zip\z}i, message: I18n.t('activerecord.errors.models.imports.wrong_file_extension')
+ validates_format_of :file, with: %r{\.zip\z}i, message: I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')
before_create :initialize_fields
@@ -35,7 +36,7 @@ class Import < ActiveRecord::Base
end
def self.finished_statuses
- symbols_with_indifferent_access(%i(successful failed aborted canceled))
+ symbols_with_indifferent_access(%i(successful failed warning aborted canceled))
end
def notify_parent
diff --git a/app/models/import_message.rb b/app/models/import_message.rb
index 5d0f5c862..de70c35d1 100644
--- a/app/models/import_message.rb
+++ b/app/models/import_message.rb
@@ -1,7 +1,8 @@
class ImportMessage < ActiveRecord::Base
+ extend Enumerize
belongs_to :import
belongs_to :resource, class_name: ImportResource
- enum criticity: [:info, :warning, :error]
+ enumerize :criticity, in: %i(info warning error)
validates :criticity, presence: true
end
diff --git a/app/models/line_control/route.rb b/app/models/line_control/route.rb
index aabd2f347..b4b2bd9d8 100644
--- a/app/models/line_control/route.rb
+++ b/app/models/line_control/route.rb
@@ -2,5 +2,7 @@ module LineControl
class Route < ComplianceControl
def self.default_code; "3-Line-1" end
+
+ def self.prerequisite; I18n.t("compliance_controls.#{self.name.underscore}.prerequisite") end
end
end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index c7b52ddf8..ed13cd077 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
class Referential < ActiveRecord::Base
include DataFormatEnumerations
@@ -28,6 +27,15 @@ class Referential < ActiveRecord::Base
belongs_to :organisation
validates_presence_of :organisation
+ validate def validate_consistent_organisation
+ return true if workbench_id.nil?
+ ids = [workbench.organisation_id, organisation_id]
+ return true if ids.first == ids.last
+ errors.add(:inconsistent_organisation,
+ I18n.t('referentials.errors.inconsistent_organisation',
+ indirect_name: workbench.organisation.name,
+ direct_name: organisation.name))
+ end
belongs_to :line_referential
validates_presence_of :line_referential
@@ -290,7 +298,7 @@ class Referential < ActiveRecord::Base
end
def assign_prefix
- self.prefix = self.organisation.name.parameterize.gsub('-', '_')
+ self.prefix = organisation.name.parameterize.gsub('-', '_')
end
def assign_line_and_stop_area_referential
diff --git a/app/models/referential_suite.rb b/app/models/referential_suite.rb
index 9fd25ef3f..93c2c3f36 100644
--- a/app/models/referential_suite.rb
+++ b/app/models/referential_suite.rb
@@ -1,6 +1,19 @@
class ReferentialSuite < ActiveRecord::Base
belongs_to :new, class_name: 'Referential'
+ validate def validate_consistent_new
+ return true if new_id.nil?
+ return true if new.referential_suite_id == id
+ errors.add(:inconsistent_new,
+ I18n.t('referential_suites.errors.inconsistent_new', name: new.name))
+ end
+
belongs_to :current, class_name: 'Referential'
+ validate def validate_consistent_current
+ return true if current_id.nil?
+ return true if current.referential_suite_id == id
+ errors.add(:inconsistent_current,
+ I18n.t('referential_suites.errors.inconsistent_current', name: current.name))
+ end
has_many :referentials
end
diff --git a/app/models/route_control/opposite_route.rb b/app/models/route_control/opposite_route.rb
index 3921bb0a2..d5616ca6f 100644
--- a/app/models/route_control/opposite_route.rb
+++ b/app/models/route_control/opposite_route.rb
@@ -3,5 +3,7 @@ module RouteControl
enumerize :criticity, in: %i(error), scope: true, default: :error
def self.default_code; "3-Route-2" end
+
+ def self.prerequisite; I18n.t("compliance_controls.#{self.name.underscore}.prerequisite") end
end
end
diff --git a/app/models/route_control/opposite_route_terminus.rb b/app/models/route_control/opposite_route_terminus.rb
index e12690d48..24c557734 100644
--- a/app/models/route_control/opposite_route_terminus.rb
+++ b/app/models/route_control/opposite_route_terminus.rb
@@ -2,5 +2,7 @@ module RouteControl
class OppositeRouteTerminus < ComplianceControl
def self.default_code; "3-Route-5" end
+
+ def self.prerequisite; I18n.t("compliance_controls.#{self.name.underscore}.prerequisite") end
end
end
diff --git a/app/views/calendars/edit.html.slim b/app/views/calendars/edit.html.slim
index 426f27881..3463bd05c 100644
--- a/app/views/calendars/edit.html.slim
+++ b/app/views/calendars/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :calendar, @calendar
/ PageHeader
= pageheader 'modele-calendrier',
t('.title', calendar: @calendar.name),
diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim
index d3168fa3d..a95d54428 100644
--- a/app/views/calendars/index.html.slim
+++ b/app/views/calendars/index.html.slim
@@ -1,5 +1,5 @@
+- breadcrumb :calendars
/ PageHeader
-
- header_params = ['modele-calendrier',
t('.title'),
'']
diff --git a/app/views/calendars/new.html.slim b/app/views/calendars/new.html.slim
index 2cb6f8061..146173d35 100644
--- a/app/views/calendars/new.html.slim
+++ b/app/views/calendars/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :calendars
/ PageHeader
= pageheader 'modele-calendrier',
t('.title'),
diff --git a/app/views/calendars/show.html.slim b/app/views/calendars/show.html.slim
index eda4ef97c..b2ace0ccc 100644
--- a/app/views/calendars/show.html.slim
+++ b/app/views/calendars/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :calendar, @calendar
/ PageHeader
= pageheader 'modele-calendrier',
@calendar.name,
diff --git a/app/views/companies/index.html.slim b/app/views/companies/index.html.slim
index dad905c60..ba061f505 100644
--- a/app/views/companies/index.html.slim
+++ b/app/views/companies/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :companies, @line_referential
/ PageHeader
= pageheader 'transporteur',
t('companies.index.title'),
diff --git a/app/views/companies/show.html.slim b/app/views/companies/show.html.slim
index 4fb437115..668226938 100644
--- a/app/views/companies/show.html.slim
+++ b/app/views/companies/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :company, @company
/ PageHeader
= pageheader 'transporteur',
@company.name,
diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim
index 38c4babcf..4ca5a2ee7 100644
--- a/app/views/compliance_check_sets/index.html.slim
+++ b/app/views/compliance_check_sets/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_check_sets, @workbench
/ PageHeader
- header_params = ['jeux-de-donnees',
t('compliance_check_sets.index.title'),
diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim
index 4e965947d..eefa5363f 100644
--- a/app/views/compliance_check_sets/show.html.slim
+++ b/app/views/compliance_check_sets/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_check_set, @workbench, @compliance_check_set
/ PageHeader
= pageheader 'jeux-de-donnees',
@compliance_check_set.referential.name
@@ -8,4 +9,4 @@
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
ComplianceCheckSet.human_attribute_name(:id) => @compliance_check_set.referential.id,
- ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.referential.name \ No newline at end of file
+ ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.referential.name
diff --git a/app/views/compliance_control_sets/edit.html.slim b/app/views/compliance_control_sets/edit.html.slim
index 649154b91..dbe537c93 100644
--- a/app/views/compliance_control_sets/edit.html.slim
+++ b/app/views/compliance_control_sets/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_set, @compliance_control_set
/ PageHeader
= pageheader 'jeux-de-controle',
t('compliance_control_sets.edit.title', name: @compliance_control_set.name)
diff --git a/app/views/compliance_control_sets/index.html.slim b/app/views/compliance_control_sets/index.html.slim
index 1120ed186..69bff4725 100644
--- a/app/views/compliance_control_sets/index.html.slim
+++ b/app/views/compliance_control_sets/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_sets
/ PageHeader
- header_params = ['jeux-de-controle',
t('compliance_control_sets.index.title'),
@@ -33,7 +34,7 @@
), \
TableBuilderHelper::Column.new( \
key: :owner_jdc, \
- attribute: 'owner_jdc' \
+ attribute: Proc.new {|n| n.organisation.name } \
), \
TableBuilderHelper::Column.new( \
key: :control_numbers, \
@@ -47,10 +48,12 @@
sortable: true,
links: [:show],
cls: 'table has-filter has-search'
+
+ = new_pagination @compliance_control_sets, 'pull-right'
- unless @compliance_control_sets.any?
.row.mt-xs
.col-lg-12
= replacement_msg t('compliance_control_sets.search_no_results')
-= javascript_pack_tag 'date_filters' \ No newline at end of file
+= javascript_pack_tag 'date_filters'
diff --git a/app/views/compliance_control_sets/new.html.slim b/app/views/compliance_control_sets/new.html.slim
index 35654b4d6..d543a6395 100644
--- a/app/views/compliance_control_sets/new.html.slim
+++ b/app/views/compliance_control_sets/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_sets
/ PageHeader
= pageheader 'jeux-de-controle',
t('compliance_control_sets.index.new')
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index f45b0227a..d086c07c8 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_set, @compliance_control_set
/ PageHeader
= pageheader 'jeux-de-controle',
t('compliance_control_sets.show.title', name: @compliance_control_set.name),
@@ -22,55 +23,23 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name,
+ I18n.t('activerecord.attributes.compliance_control_set.owner_jdc') => @compliance_control_set.organisation.name
+ - if params[:q].present? or @compliance_controls.any?
+ .row
+ .col-lg-12
+ = render '/compliance_controls/filters'
+
.row
.col-lg-12
h2
= transport_mode("", "")
- .row
- .col-lg-12
- .select_table
- = table_builder_2 @compliance_controls_without_block,
- [ \
- TableBuilderHelper::Column.new( \
- key: :code, \
- attribute: 'code' \
- ), \
- TableBuilderHelper::Column.new( \
- key: :name, \
- attribute: 'name', \
- link_to: lambda do |compliance_control| \
- compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \
- end \
- ), \
- TableBuilderHelper::Column.new( \
- key: :criticity, \
- attribute: 'criticity' \
- ), \
- TableBuilderHelper::Column.new( \
- key: :comment, \
- attribute: 'comment' \
- ), \
- ],
- sortable: true,
- cls: 'table has-filter has-search'
- - @compliance_control_set.compliance_control_blocks.each do |block|
- .row
- .col-lg-12
- h2
- = transport_mode(block.transport_mode, block.transport_submode)
- .btn-group
- .btn.dropdown-toggle{ data-toggle="dropdown" }
- .span.fa.fa-cog
- ul.dropdown-menu
- li
- = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id)
- = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')}
+ - if @indirect_compliance_controls.try(:any?)
.row
.col-lg-12
.select_table
- = table_builder_2 ModelDecorator.decorate(block.compliance_controls, with: ComplianceControlDecorator),
+ = table_builder_2 @indirect_compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -93,7 +62,52 @@
), \
],
sortable: true,
- cls: 'table has-filter has-search'
+ cls: 'table has-filter has-search',
+ model: ComplianceControl
+
+ - @compliance_controls.each do |block, compliance_controls|
+
+ - if compliance_controls.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode(block.transport_mode, block.transport_submode)
+ .btn-group
+ .btn.dropdown-toggle{ data-toggle="dropdown" }
+ .span.fa.fa-cog
+ ul.dropdown-menu
+ li
+ = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id)
+ = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')}
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 compliance_controls,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :code, \
+ attribute: 'code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_control| \
+ compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :criticity, \
+ attribute: 'criticity' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :comment, \
+ attribute: 'comment' \
+ ), \
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search',
+ model: ComplianceControl
+
.select_toolbox
ul
li.st_action.with_text
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
new file mode 100644
index 000000000..c729190a0
--- /dev/null
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -0,0 +1,46 @@
+= search_form_for @q_controls_form,
+ url: compliance_control_set_path(@compliance_control_set),
+ builder: SimpleForm::FormBuilder,
+ class: 'form form-filter' do |f|
+
+ .ffg-row
+ .input-group.search_bar
+ = f.search_field :name_cont,
+ class: 'form-control',
+ placeholder: t('compliance_controls.filters.name')
+ span.input-group-btn
+ button.btn.btn-default type='submit'
+ span.fa.fa-search
+
+ .ffg-row
+ .form-group.togglable#compliance_control_block-filter
+ = f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label'
+ = f.input :compliance_control_block_id_eq_any,
+ collection: @compliance_control_set.compliance_control_blocks,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{transport_mode(w.transport_mode, w.transport_submode)}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#subclass-filter
+ = f.label t('compliance_controls.filters.subclass'), required: false, class: 'control-label'
+ = f.input :origin_code_cont_any,
+ collection: subclass_selection_list,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{w.first}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#severity-filter
+ = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
+ = f.input :criticity_eq_any,
+ collection: ComplianceControl.criticities,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{w}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+
+ .actions
+ = link_to t('actions.erase'), @compliance_control_set, class: 'btn btn-link'
+ = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_control_set_compliance_controls_filter_btn'
diff --git a/app/views/compliance_controls/new.html.slim b/app/views/compliance_controls/new.html.slim
index 181f49a15..bd2db230b 100644
--- a/app/views/compliance_controls/new.html.slim
+++ b/app/views/compliance_controls/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_set, parent
/ PageHeader
- header_params = ['jeux-de-controle',
t('compliance_controls.new.title'),
@@ -10,3 +11,7 @@
.row
.col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
= render 'form'
+
+ = definition_list t('metadatas'),
+ I18n.t('activerecord.attributes.compliance_control.predicate') => @compliance_control.class.predicate,
+ I18n.t('activerecord.attributes.compliance_control.prerequisite') => @compliance_control.class.prerequisite \ No newline at end of file
diff --git a/app/views/compliance_controls/select_type.html.slim b/app/views/compliance_controls/select_type.html.slim
index 98cc5a943..ec1c360cb 100644
--- a/app/views/compliance_controls/select_type.html.slim
+++ b/app/views/compliance_controls/select_type.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control_set, parent
/ PageHeader
- header_params = ['jeux-de-controle',
t('compliance_controls.select_type.title'),
diff --git a/app/views/compliance_controls/show.html.slim b/app/views/compliance_controls/show.html.slim
index 12a28cd4b..f7ec118b0 100644
--- a/app/views/compliance_controls/show.html.slim
+++ b/app/views/compliance_controls/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :compliance_control, @compliance_control
/ PageHeader
= pageheader 'jeux-de-controle',
t('compliance_controls.show.title'),
@@ -16,6 +17,8 @@
ComplianceControl.human_attribute_name(:code) => @compliance_control.code,
ComplianceControl.human_attribute_name(:criticity) => @compliance_control.criticity,
ComplianceControl.human_attribute_name(:comment) => @compliance_control.comment,
+ I18n.t('activerecord.attributes.compliance_control.predicate') => @compliance_control.class.predicate,
+ I18n.t('activerecord.attributes.compliance_control.prerequisite') => @compliance_control.class.prerequisite,
}.merge( \
{}.tap do |hash| \
@compliance_control.class.dynamic_attributes.each do |attribute| \
@@ -24,11 +27,6 @@
end \
)
- if @compliance_control.compliance_control_block
- = definition_list t('metadatas'),
- {}.merge( \
- {}.tap do |hash| \
- @compliance_control.compliance_control_block.condition_attributes.each do |k, v| \
- hash[ComplianceControl.human_attribute_name(k)] = v \
- end \
- end \
- )
+ = definition_list t('compliance_controls.show.metadatas.compliance_control_block'),
+ I18n.t('activerecord.attributes.compliance_control_blocks.transport_mode') => I18n.t("enumerize.transport_mode.#{@compliance_control.compliance_control_block.transport_mode}"),
+ I18n.t('activerecord.attributes.compliance_control_blocks.transport_submode') => I18n.t("enumerize.transport_submode.#{@compliance_control.compliance_control_block.transport_submode}") \ No newline at end of file
diff --git a/app/views/group_of_lines/edit.html.slim b/app/views/group_of_lines/edit.html.slim
index 75d530b08..ef7a405d3 100644
--- a/app/views/group_of_lines/edit.html.slim
+++ b/app/views/group_of_lines/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :group_of_line, @group_of_line
= title_tag t('group_of_lines.edit.title', :group_of_line => @group_of_line.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/group_of_lines/index.html.slim b/app/views/group_of_lines/index.html.slim
index 69b1cd0d6..28f3ab264 100644
--- a/app/views/group_of_lines/index.html.slim
+++ b/app/views/group_of_lines/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :group_of_lines, @line_referential
= title_tag t('group_of_lines.index.title')
= search_form_for @q, :url => line_referential_group_of_lines_path(@line_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
diff --git a/app/views/group_of_lines/new.html.slim b/app/views/group_of_lines/new.html.slim
index 36b5d6b4e..395c2b3e7 100644
--- a/app/views/group_of_lines/new.html.slim
+++ b/app/views/group_of_lines/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :group_of_lines, @line_referential
= title_tag t('group_of_lines.new.title')
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/group_of_lines/show.html.slim b/app/views/group_of_lines/show.html.slim
index b934cb1ef..de215bfa0 100644
--- a/app/views/group_of_lines/show.html.slim
+++ b/app/views/group_of_lines/show.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :group_of_line, @group_of_line
+
= title_tag t('group_of_lines.show.title', :group_of_line => @group_of_line.name )
.group_of_line_show
diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim
index cd236ef36..35cd666b1 100644
--- a/app/views/imports/index.html.slim
+++ b/app/views/imports/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :imports, @workbench
/ PageHeader
= pageheader 'importer',
t('.title'),
diff --git a/app/views/imports/new.html.slim b/app/views/imports/new.html.slim
index 5d5df0857..b74d8eaf2 100644
--- a/app/views/imports/new.html.slim
+++ b/app/views/imports/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :imports, @workbench
/ PageHeader
= pageheader 'importer',
t('.title')
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index 5f5974d69..69ee44f9f 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :import, @workbench, @import
/ PageHeader
= pageheader 'importer',
@import.name,
diff --git a/app/views/journey_patterns_collections/show.html.slim b/app/views/journey_patterns_collections/show.html.slim
index 8c0950536..7c62b69ee 100644
--- a/app/views/journey_patterns_collections/show.html.slim
+++ b/app/views/journey_patterns_collections/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :journey_patterns, @referential, @route
/ pageheader
= pageheader 'mission',
"Missions de #{@route.try(:stop_points).first.try(:stop_area).name} vers #{@route.try(:stop_points).last.try(:stop_area).name}",
@@ -5,8 +6,8 @@
''
- @journey_patterns.each do |jp|
- jp.errors.each do |error_message|
- = error_message
-
+ = error_message
+
/ PageContent
.page_content
.container-fluid
diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim
index 1bc9de136..8c731007d 100644
--- a/app/views/layouts/application.html.slim
+++ b/app/views/layouts/application.html.slim
@@ -13,15 +13,10 @@ html lang=I18n.locale
= javascript_pack_tag 'application'
= javascript_include_tag 'application'
-
-
body
= render 'layouts/navigation/main_nav'
-
= render 'layouts/flash_messages', flash: flash
-
= yield
-
#sidebar
= yield :sidebar
diff --git a/app/views/layouts/navigation/_breadcrumb.html.slim b/app/views/layouts/navigation/_breadcrumb.html.slim
index a101098fe..403ed6702 100644
--- a/app/views/layouts/navigation/_breadcrumb.html.slim
+++ b/app/views/layouts/navigation/_breadcrumb.html.slim
@@ -1,2 +1 @@
-- if @breadcrumbs.present?
- = render_breadcrumbs builder: BootstrapBreadcrumbsBuilder, tag: :li, separator: ''
+== breadcrumbs
diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim
index 062c9383c..837b9cb73 100644
--- a/app/views/layouts/navigation/_main_nav_left.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left.html.slim
@@ -31,16 +31,17 @@
#miTwo.panel-collapse.collapse
.list-group
- = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
- span Jeux de données
- = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
- span Import
- = link_to calendars_path, class: 'list-group-item' do
- span Modèles de calendrier
- = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
- span Rapport de contrôle
- = link_to compliance_control_sets_path, class: 'list-group-item' do
- span Jeux de contrôle
+ - if current_user
+ = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
+ span Jeux de données
+ = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
+ span Import
+ = link_to calendars_path, class: 'list-group-item' do
+ span Modèles de calendrier
+ = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
+ span Rapport de contrôle
+ = link_to compliance_control_sets_path, class: 'list-group-item' do
+ span Jeux de contrôle
.menu-item.panel
.panel-heading
diff --git a/app/views/line_footnotes/show.html.slim b/app/views/line_footnotes/show.html.slim
index 8138c1383..0ed1d2958 100644
--- a/app/views/line_footnotes/show.html.slim
+++ b/app/views/line_footnotes/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :line_footnotes, @referential, @line
/ PageHeader
= pageheader 'ligne',
"Notes sur la ligne #{@line.name}",
@@ -22,4 +23,4 @@
- else
= replacement_msg 'Aucune note ne correspond à votre recherche'
-
+
diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim
index d2527f360..b98e9d5bb 100644
--- a/app/views/line_referentials/show.html.slim
+++ b/app/views/line_referentials/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :line_referential, @line_referential
/ PageHeader
= pageheader 'synchro-ilico',
t('.title'),
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index 87c3a69e7..7e3e1cc85 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :lines, @line_referential
/ PageHeader
= pageheader 'ligne',
t('lines.index.title'),
diff --git a/app/views/lines/new.html.slim b/app/views/lines/new.html.slim
index 56da24d7c..f09a4b4aa 100644
--- a/app/views/lines/new.html.slim
+++ b/app/views/lines/new.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :lines, @line_referential
+
= title_tag t('lines.new.title')
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim
index b16b6472a..d8f236ecc 100644
--- a/app/views/lines/show.html.slim
+++ b/app/views/lines/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :line, @line
/ PageHeader
= pageheader 'ligne',
@line.name,
diff --git a/app/views/networks/edit.html.slim b/app/views/networks/edit.html.slim
index d4e088937..2d511e15d 100644
--- a/app/views/networks/edit.html.slim
+++ b/app/views/networks/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :network, @network
= title_tag t('networks.edit.title', network: @network.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/networks/index.html.slim b/app/views/networks/index.html.slim
index 235bdebda..e498ea35f 100644
--- a/app/views/networks/index.html.slim
+++ b/app/views/networks/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :networks, @line_referential
/ PageHeader
= pageheader 'reseau',
t('networks.index.title'),
diff --git a/app/views/networks/new.html.slim b/app/views/networks/new.html.slim
index 7071ded33..cf04ab03f 100644
--- a/app/views/networks/new.html.slim
+++ b/app/views/networks/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :networks, @line_referential
= title_tag t('networks.new.title')
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/networks/show.html.slim b/app/views/networks/show.html.slim
index d237351c4..9b2a0dbf8 100644
--- a/app/views/networks/show.html.slim
+++ b/app/views/networks/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :network, @network
/ PageHeader
= pageheader 'reseau',
@network.name,
diff --git a/app/views/organisations/edit.html.slim b/app/views/organisations/edit.html.slim
index a78d59f3d..0d81b26e3 100644
--- a/app/views/organisations/edit.html.slim
+++ b/app/views/organisations/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :organisation, @organisation
= title_tag t('.title')
= semantic_form_for @organisation, :url => organisation_path do |form|
@@ -7,4 +8,4 @@
= form.actions do
= form.action :submit, as: :button
- = form.action :cancel, as: :link \ No newline at end of file
+ = form.action :cancel, as: :link
diff --git a/app/views/organisations/show.html.slim b/app/views/organisations/show.html.slim
index bf9f464dd..89e3b2870 100644
--- a/app/views/organisations/show.html.slim
+++ b/app/views/organisations/show.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :organisation, @organisation
+
= title_tag @organisation.name
.summary
diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim
index e5b7ce24a..9f5cd5d62 100644
--- a/app/views/referential_companies/index.html.slim
+++ b/app/views/referential_companies/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_companies, @referential
/ PageHeader
= pageheader 'transporteur',
t('companies.index.title'),
diff --git a/app/views/referential_companies/new.html.slim b/app/views/referential_companies/new.html.slim
index 1acb1786f..1c7fc7297 100644
--- a/app/views/referential_companies/new.html.slim
+++ b/app/views/referential_companies/new.html.slim
@@ -1,2 +1,3 @@
+- breadcrumb :referential_companies, @referential
= title_tag t('companies.new.title')
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_companies/show.html.slim b/app/views/referential_companies/show.html.slim
index 1d71c778a..0dbc3cdd0 100644
--- a/app/views/referential_companies/show.html.slim
+++ b/app/views/referential_companies/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_company, @referential, @company
/ PageHeader
= pageheader 'transporteur',
@company.name,
diff --git a/app/views/referential_group_of_lines/index.html.slim b/app/views/referential_group_of_lines/index.html.slim
index 9fa3eb381..e782db090 100644
--- a/app/views/referential_group_of_lines/index.html.slim
+++ b/app/views/referential_group_of_lines/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_group_of_lines, @referential
= title_tag t('group_of_lines.index.title')
= search_form_for @q, :url => referential_group_of_lines_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
diff --git a/app/views/referential_group_of_lines/new.html.slim b/app/views/referential_group_of_lines/new.html.slim
index 36b5d6b4e..8807bc402 100644
--- a/app/views/referential_group_of_lines/new.html.slim
+++ b/app/views/referential_group_of_lines/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_group_of_lines, @referential
= title_tag t('group_of_lines.new.title')
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/referential_group_of_lines/show.html.slim b/app/views/referential_group_of_lines/show.html.slim
index a0635f158..504af0187 100644
--- a/app/views/referential_group_of_lines/show.html.slim
+++ b/app/views/referential_group_of_lines/show.html.slim
@@ -1,8 +1,9 @@
+- breadcrumb :referential_group_of_line, @referential, @group_of_line
= title_tag t('group_of_lines.show.title', :group_of_line => @group_of_line.name )
.group_of_line_show
= @map.to_html
-
+
.summary
p
label = "#{@group_of_line.human_attribute_name('registration_number')} : "
@@ -13,10 +14,10 @@
= @group_of_line.comment
p.after_map
-
+
h3.group_of_line_lines = t('.lines')
.lines_detail
- == render partial: "lines_detail"
+ == render partial: "lines_detail"
- content_for :sidebar do
ul.actions
@@ -28,4 +29,4 @@
= link_to t('group_of_lines.actions.destroy'), referential_group_of_line_path(@referential, @group_of_line), :method => :delete, :data => {:confirm => t('group_of_lines.actions.destroy_confirm')} , class: 'remove'
br
- = creation_tag(@group_of_line) \ No newline at end of file
+ = creation_tag(@group_of_line)
diff --git a/app/views/referential_lines/edit.html.slim b/app/views/referential_lines/edit.html.slim
index 0036d023b..8c51715ba 100644
--- a/app/views/referential_lines/edit.html.slim
+++ b/app/views/referential_lines/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_line, @line, @referential
= title_tag t('lines.edit.title', line: @line.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index df3c285ee..0ef548e89 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_line, @referential, @line
/ PageHeader
= pageheader 'ligne',
t('lines.index.line', line: @line.name),
diff --git a/app/views/referential_networks/edit.html.slim b/app/views/referential_networks/edit.html.slim
index d4e088937..dded4b176 100644
--- a/app/views/referential_networks/edit.html.slim
+++ b/app/views/referential_networks/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_network, @referential, @network
= title_tag t('networks.edit.title', network: @network.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim
index ca67eca8b..57d3e7f1f 100644
--- a/app/views/referential_networks/index.html.slim
+++ b/app/views/referential_networks/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_networks, @referential
/ PageHeader
= pageheader 'reseau',
t('networks.index.title'),
@@ -39,7 +40,7 @@
],
links: [:show],
cls: 'table has-search'
-
+
= new_pagination @networks, 'pull-right'
- unless @networks.any?
diff --git a/app/views/referential_networks/new.html.slim b/app/views/referential_networks/new.html.slim
index 7071ded33..4a737d9f7 100644
--- a/app/views/referential_networks/new.html.slim
+++ b/app/views/referential_networks/new.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :referential_networks, @referential
+
= title_tag t('networks.new.title')
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim
index d7095561e..eab0cd51a 100644
--- a/app/views/referential_networks/show.html.slim
+++ b/app/views/referential_networks/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_network, @referential, @network
/ PageHeader
= pageheader 'reseau',
@network.name,
diff --git a/app/views/referential_stop_areas/edit.html.slim b/app/views/referential_stop_areas/edit.html.slim
index a999ab715..fc7220095 100644
--- a/app/views/referential_stop_areas/edit.html.slim
+++ b/app/views/referential_stop_areas/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_stop_area, @referential, @stop_area
= title_tag t('stop_areas.edit.title', stop_area: @stop_area.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_stop_areas/index.html.slim b/app/views/referential_stop_areas/index.html.slim
index 7bf39eabd..718cbb472 100644
--- a/app/views/referential_stop_areas/index.html.slim
+++ b/app/views/referential_stop_areas/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_stop_areas, @referential
= title_tag t('stop_areas.index.title')
= search_form_for @q, :url => referential_stop_areas_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
diff --git a/app/views/referential_stop_areas/new.html.slim b/app/views/referential_stop_areas/new.html.slim
index 54fd59422..87ba9b657 100644
--- a/app/views/referential_stop_areas/new.html.slim
+++ b/app/views/referential_stop_areas/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_stop_areas, @referential
= title_tag t('stop_areas.new.title')
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim
index fa383c82d..b9a1c9899 100644
--- a/app/views/referential_stop_areas/show.html.slim
+++ b/app/views/referential_stop_areas/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_stop_area, @referential, @stop_area
/ PageHeader
= pageheader 'arret',
@stop_area.name,
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 26ce0acbb..b03fb9f53 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb @referential
/ PageHeader
= pageheader 'jeux-de-donnees',
@referential.name,
diff --git a/app/views/route_sections/index.html.slim b/app/views/route_sections/index.html.slim
index 2d36be67a..c459af73c 100644
--- a/app/views/route_sections/index.html.slim
+++ b/app/views/route_sections/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_route_sections, @referential
= title_tag t('.title')
= form_for search, url: referential_route_sections_path(@referential), method: :get, class: 'form-inline' do |form|
@@ -45,4 +46,4 @@ table.table.table-hover.table-striped
= link_to t('.actions.destroy'), referential_route_section_path(@referential, route_section), method: :delete, data: { confirm: t('route_sections.actions.destroy_confirm') }, class: 'remove'
.pagination
- = will_paginate @route_sections, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer \ No newline at end of file
+ = will_paginate @route_sections, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer
diff --git a/app/views/route_sections/new.html.slim b/app/views/route_sections/new.html.slim
index a41db0254..79f4cda2b 100644
--- a/app/views/route_sections/new.html.slim
+++ b/app/views/route_sections/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_route_sections, @referential
= title_tag t('route_sections.new.title')
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/route_sections/show.html.slim b/app/views/route_sections/show.html.slim
index f02f7de80..afd0ed0d6 100644
--- a/app/views/route_sections/show.html.slim
+++ b/app/views/route_sections/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_route_section, @referential, @route_section
= title_tag t('.title')
.route_section
@@ -23,4 +24,4 @@
li
= link_to t('route_sections.actions.destroy'), referential_route_section_path(@referential, @route_section), :method => :delete, :data => {:confirm => t('route_sections.actions.destroy_confirm')}, class: 'remove'
- = creation_tag(@route_section) \ No newline at end of file
+ = creation_tag(@route_section)
diff --git a/app/views/routes/edit.html.slim b/app/views/routes/edit.html.slim
index 850588aef..a69c5aeff 100644
--- a/app/views/routes/edit.html.slim
+++ b/app/views/routes/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :route, @referential, @route
/ PageHeader
= pageheader 'itineraire',
@route.name,
diff --git a/app/views/routes/new.html.slim b/app/views/routes/new.html.slim
index a68f8ae4e..3a8ceb963 100644
--- a/app/views/routes/new.html.slim
+++ b/app/views/routes/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :referential_line, @referential, @line
/ PageHeader
= pageheader 'itineraire',
t('routes.new.title'),
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index 6bd3451cd..1411a5502 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :route, @referential, @route
/ PageHeader
= pageheader 'itineraire',
t('routes.index.title', route: @route.name),
@@ -78,4 +79,4 @@
= javascript_tag do
| window.route = "#{URI.escape(route_json_for_edit(@route))}"
-= javascript_pack_tag 'routes/show.js' \ No newline at end of file
+= javascript_pack_tag 'routes/show.js'
diff --git a/app/views/routing_constraint_zones/edit.html.slim b/app/views/routing_constraint_zones/edit.html.slim
index 2c23344df..c9b9b0c41 100644
--- a/app/views/routing_constraint_zones/edit.html.slim
+++ b/app/views/routing_constraint_zones/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :routing_constraint_zone, @referential, @line, @routing_constraint_zone
/ PageHeader
= pageheader 'itl',
t('.title', routing_constraint_zone: @routing_constraint_zone.name),
diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim
index 4e2534b6a..ddad7723e 100644
--- a/app/views/routing_constraint_zones/index.html.slim
+++ b/app/views/routing_constraint_zones/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :routing_constraint_zones, @referential, @line
/ PageHeader
= pageheader 'itl',
t('routing_constraint_zones.index.title'),
diff --git a/app/views/routing_constraint_zones/new.html.slim b/app/views/routing_constraint_zones/new.html.slim
index 1ed65335f..d15de13a4 100644
--- a/app/views/routing_constraint_zones/new.html.slim
+++ b/app/views/routing_constraint_zones/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :routing_constraint_zones, @referential, @line
/ PageHeader
= pageheader 'itl',
t('.title')
diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim
index dbd8464a0..d0c0619c3 100644
--- a/app/views/routing_constraint_zones/show.html.slim
+++ b/app/views/routing_constraint_zones/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :routing_constraint_zone, @referential, @line, @routing_constraint_zone
/ PageHeader
= pageheader 'itl',
@routing_constraint_zone.name,
diff --git a/app/views/shared/_breadcrumb.html.slim b/app/views/shared/_breadcrumb.html.slim
index a101098fe..403ed6702 100644
--- a/app/views/shared/_breadcrumb.html.slim
+++ b/app/views/shared/_breadcrumb.html.slim
@@ -1,2 +1 @@
-- if @breadcrumbs.present?
- = render_breadcrumbs builder: BootstrapBreadcrumbsBuilder, tag: :li, separator: ''
+== breadcrumbs
diff --git a/app/views/stif/dashboards/_dashboard.html.slim b/app/views/stif/dashboards/_dashboard.html.slim
index 3142ecd5b..f3cd01f46 100644
--- a/app/views/stif/dashboards/_dashboard.html.slim
+++ b/app/views/stif/dashboards/_dashboard.html.slim
@@ -39,14 +39,14 @@
h3.panel-title.with_actions
div
= t('.referentials')
- span.badge.ml-xs = @referentials.count if @referentials.present?
+ span.badge.ml-xs = @dashboard.referentials.count if @dashboard.referentials.present?
div
= link_to '', workbench_path(@dashboard.workbench), class: ' fa fa-chevron-right pull-right', title: t('.see')
- - if @referentials.present?
+ - if @dashboard.referentials.present?
.list-group
- - @referentials.each_with_index do |referential, i|
+ - @dashboard.referentials.first(5).each_with_index do |referential, i|
= link_to referential.name, referential_path(referential, workbench_id: referential.workbench_id, current_workbench_id: @dashboard.workbench.id), class: 'list-group-item' if i < 6
- else
@@ -65,7 +65,7 @@
- if @dashboard.calendars.present?
.list-group
- - @dashboard.calendars.each_with_index do |calendar, i|
+ - @dashboard.calendars.first(5).each_with_index do |calendar, i|
= link_to calendar.name, calendar_path(calendar), class: 'list-group-item' if i < 6
- else
diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim
index dc90def50..896ce756e 100644
--- a/app/views/stop_area_referentials/show.html.slim
+++ b/app/views/stop_area_referentials/show.html.slim
@@ -1,10 +1,11 @@
+- breadcrumb :stop_area_referential, @stop_area_referential
/ PageHeader
= pageheader 'synchro-icar',
t('.title'),
'Lorem ipsum dolor sit amet',
t('last_update', time: l(@stop_area_referential.updated_at, format: :short)),
link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default') do
-
+
.row.mb-md
.col-lg-12.text-right
= link_to stop_area_referential_stop_areas_path(@stop_area_referential), class: 'btn btn-primary' do
diff --git a/app/views/stop_areas/edit.html.slim b/app/views/stop_areas/edit.html.slim
index 170b6bd20..8005f5a08 100644
--- a/app/views/stop_areas/edit.html.slim
+++ b/app/views/stop_areas/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :stop_area, @stop_area_referential, @stop_area
= title_tag t('stop_areas.edit.title', stop_area: @stop_area.name )
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 95b9b1b0e..4e880f7a3 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :stop_areas, @stop_area_referential
/ PageHeader
= pageheader 'arret',
t('stop_areas.index.title'),
diff --git a/app/views/stop_areas/new.html.slim b/app/views/stop_areas/new.html.slim
index bdbd97571..e0c5b7a61 100644
--- a/app/views/stop_areas/new.html.slim
+++ b/app/views/stop_areas/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :stop_areas, @stop_area_referential
= title_tag t('stop_areas.new.title')
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index dce5bdbad..bc9cc2ac0 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :stop_area, @stop_area_referential, @stop_area
/ PageHeader
= pageheader 'arret',
@stop_area.name,
diff --git a/app/views/time_tables/edit.html.slim b/app/views/time_tables/edit.html.slim
index bf7573c71..a1ebb2c72 100644
--- a/app/views/time_tables/edit.html.slim
+++ b/app/views/time_tables/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :time_table, @referential, @time_table
/ PageHeader
= pageheader 'calendrier-application',
@time_table.comment,
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index c71a214f1..b0f4e84c5 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :time_tables, @referential
/ PageHeader
= pageheader 'calendrier-application',
t('time_tables.index.title'),
diff --git a/app/views/time_tables/new.html.slim b/app/views/time_tables/new.html.slim
index 8a6930b9c..c8c2658ba 100644
--- a/app/views/time_tables/new.html.slim
+++ b/app/views/time_tables/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :time_tables, @referential
/ PageHeader
= pageheader 'calendrier-application',
t("time_tables.#{params[:action]}.title"),
diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim
index 021b55058..85de7f8ec 100644
--- a/app/views/time_tables/show.html.slim
+++ b/app/views/time_tables/show.html.slim
@@ -1,5 +1,5 @@
- require 'calendar_helper'
-
+- breadcrumb :time_table, @referential, @time_table
/ PageHeader
= pageheader 'calendrier-application',
diff --git a/app/views/timebands/edit.html.slim b/app/views/timebands/edit.html.slim
index af62ae8db..c70de82ef 100644
--- a/app/views/timebands/edit.html.slim
+++ b/app/views/timebands/edit.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :timeband, @referential, @timeband
= title_tag t('timebands.edit.title', timeband: @timeband.name)
-= render 'form' \ No newline at end of file
+= render 'form'
diff --git a/app/views/timebands/index.html.slim b/app/views/timebands/index.html.slim
index c81c0a670..6dcf348f9 100644
--- a/app/views/timebands/index.html.slim
+++ b/app/views/timebands/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :timebands, @referential
= title_tag t('timebands.index.title')
- if @timebands.any?
diff --git a/app/views/timebands/new.html.slim b/app/views/timebands/new.html.slim
index 90aa1bd2e..d9fc27823 100644
--- a/app/views/timebands/new.html.slim
+++ b/app/views/timebands/new.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :timebands, @referential
= title_tag t('timebands.new.title')
-== render 'form' \ No newline at end of file
+== render 'form'
diff --git a/app/views/timebands/show.html.slim b/app/views/timebands/show.html.slim
index 100457226..d45611c56 100644
--- a/app/views/timebands/show.html.slim
+++ b/app/views/timebands/show.html.slim
@@ -1,8 +1,9 @@
+- breadcrumb :timeband, @referential, @timeband
= title_tag t( 'timebands.show.title', timeband: @timeband.name )
.summary
p
label = "#{@timeband.name} : "
= "#{l(@timeband.start_time, format: :hour)} - #{l(@timeband.end_time, format: :hour)}"
-
-== render 'sidebar' \ No newline at end of file
+
+== render 'sidebar'
diff --git a/app/views/vehicle_journeys/edit.html.slim b/app/views/vehicle_journeys/edit.html.slim
index 8b3dbcf51..6276b2635 100644
--- a/app/views/vehicle_journeys/edit.html.slim
+++ b/app/views/vehicle_journeys/edit.html.slim
@@ -1,3 +1,3 @@
= title_tag edit_vehicle_title(@vehicle_journey)
-== render 'form', vehicle_journey: @vehicle_journey, form_url: referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey) \ No newline at end of file
+== render 'form', vehicle_journey: @vehicle_journey, form_url: referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey)
diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim
index f88afc398..2046ecca6 100644
--- a/app/views/vehicle_journeys/index.html.slim
+++ b/app/views/vehicle_journeys/index.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :vehicle_journeys, @referential, @route
/ PageHeader
= pageheader 'horaires-des-courses',
t('vehicle_journeys.index.title', route: @route.name ),
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 32a933cc2..66eedb68d 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -1,9 +1,9 @@
+- breadcrumb @workbench
/ PageHeader
= pageheader 'jeux-de-donnees',
t('referentials.index.title'),
'',
'' do
-
/ Below is secundary actions & optional contents (filters, ...)
.row.mb-sm
.col-lg-12.text-right
@@ -78,4 +78,4 @@
= javascript_tag do
| window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe};
-= javascript_pack_tag 'date_filters' \ No newline at end of file
+= javascript_pack_tag 'date_filters'
diff --git a/app/workers/compliance_control_set_copy_worker.rb b/app/workers/compliance_control_set_copy_worker.rb
new file mode 100644
index 000000000..d18bb0c88
--- /dev/null
+++ b/app/workers/compliance_control_set_copy_worker.rb
@@ -0,0 +1,14 @@
+class ComplianceControlSetCopyWorker
+ include Sidekiq::Worker
+
+ def perform(control_set_id, referential_id)
+ check_set = ComplianceControlSetCopier.new.copy(control_set_id, referential_id)
+
+ begin
+ Net::HTTP.get(URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{check_set.id}"))
+ rescue Exception => e
+ logger.error "IEV server error : #{e.message}"
+ logger.error e.backtrace.inspect
+ end
+ end
+end
diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb
index 300fad9e2..de51efded 100644
--- a/app/workers/workbench_import_worker.rb
+++ b/app/workers/workbench_import_worker.rb
@@ -35,7 +35,7 @@ class WorkbenchImportWorker
end
def handle_corrupt_zip_file
- @workbench_import.messages.create(criticity: :error, message_key: 'corrupt_zip_file', message_attributes: {import_name: @workbench_import.name})
+ @workbench_import.messages.create(criticity: :error, message_key: 'corrupt_zip_file', message_attributes: {source_filename: @workbench_import.file.file.file})
end
def upload zip_service
@@ -55,8 +55,8 @@ class WorkbenchImportWorker
criticity: :warning,
message_key: 'inconsistent_zip_file',
message_attributes: {
- 'import_name' => @workbench_import.name,
- 'spurious_dirs' => entry.spurious.join(', ')
+ 'source_filename' => @workbench_import.file.file.file,
+ 'spurious_dirs' => entry.spurious.join(', ')
})
end
end
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
new file mode 100644
index 000000000..a9652fc89
--- /dev/null
+++ b/config/breadcrumbs.rb
@@ -0,0 +1,249 @@
+crumb :root do
+ link I18n.t('layouts.home'), root_path
+end
+
+crumb :workbench do |workbench|
+ link workbench.name, workbench_path(workbench)
+end
+
+crumb :referential do |referential|
+ link referential.name, referential_path(referential)
+ parent :workbench, current_offer_workbench
+end
+
+crumb :referential_companies do |referential|
+ link I18n.t('companies.index.title'), referential_companies_path(referential)
+ parent :referential, referential
+end
+
+crumb :referential_company do |referential, company|
+ link company.name, referential_company_path(referential, company)
+ parent :referential_companies, referential
+end
+
+crumb :referential_networks do |referential|
+ link I18n.t('networks.index.title'), referential_networks_path
+ parent :referential, referential
+end
+
+crumb :referential_network do |referential, network|
+ link network.name, referential_network_path(referential, network)
+ parent :referential_networks, referential
+end
+
+crumb :referential_group_of_lines do |referential|
+ link I18n.t('group_of_lines.index.title'), referential_networks_path(referential)
+ parent :referential, referential
+end
+
+crumb :referential_group_of_line do |referential, group_of_line|
+ link group_of_line.name, referential_group_of_line_path(referential, group_of_line)
+ parent :referential_group_of_lines, referential
+end
+
+crumb :referential_route_sections do |referential|
+ link I18n.t('route_sections.index.title'), referential_route_sections_path(referential)
+ parent :referential, referential
+end
+
+crumb :referential_route_section do |referential, route_section|
+ link route_section.departure.name, referential_route_section_path(referential, route_section)
+ parent :referential_route_sections, referential
+end
+
+
+crumb :time_tables do |referential|
+ link I18n.t('time_tables.index.title'), referential_time_tables_path(referential)
+ parent :referential, referential
+end
+
+crumb :time_table do |referential, time_table|
+ link time_table.comment, referential_time_table_path(referential, time_table)
+ parent :time_tables, referential
+end
+
+crumb :timebands do |referential|
+ link I18n.t('timebands.index.title'), referential_timebands_path(referential)
+ parent :referential, referential
+end
+
+crumb :timeband do |referential, timeband|
+ link timeband.name, referential_timeband_path(referential, timeband)
+ parent :timebands, referential
+end
+
+crumb :compliance_check_sets do |workbench|
+ link I18n.t('compliance_check_sets.index.title'), workbench_compliance_check_sets_path(workbench)
+ parent :workbench, workbench
+end
+
+crumb :compliance_check_set do |workbench, compliance_check_set|
+ link compliance_check_set.name, workbench_compliance_check_set_path(workbench, compliance_check_set)
+ parent :compliance_check_sets, workbench
+end
+
+crumb :imports do |workbench|
+ link I18n.t('imports.index.title'), workbench_imports_path(workbench)
+ parent :workbench, workbench
+end
+
+crumb :import do |workbench, import|
+ link import.name, workbench_import_path(workbench, import)
+ parent :imports, workbench
+end
+
+crumb :organisation do |organisation|
+ link organisation.name, organisation_path(organisation)
+end
+
+crumb :compliance_control_sets do
+ link I18n.t('compliance_control_sets.index.title'), compliance_control_sets_path
+end
+
+crumb :compliance_control_set do |compliance_control_set|
+ link compliance_control_set.name, compliance_control_set_path(compliance_control_set)
+ parent :compliance_control_sets
+end
+
+crumb :compliance_control do |compliance_control|
+ link compliance_control.name, compliance_control_set_compliance_control_path(compliance_control.compliance_control_set, compliance_control)
+ parent :compliance_control_set, compliance_control.compliance_control_set
+end
+
+crumb :stop_area_referential do |stop_area_referential|
+ link I18n.t('stop_area_referentials.show.title'), stop_area_referential_path(stop_area_referential)
+end
+
+crumb :stop_areas do |stop_area_referential|
+ link I18n.t('stop_areas.index.title'), stop_area_referential_stop_areas_path(stop_area_referential)
+ parent :stop_area_referential, stop_area_referential
+end
+
+crumb :stop_area do |stop_area_referential, stop_area|
+ link stop_area.name, stop_area_referential_stop_area_path(stop_area_referential, stop_area)
+ parent :stop_areas, stop_area_referential
+end
+
+crumb :line_referential do |line_referential|
+ link I18n.t('line_referentials.show.title'), line_referential_path(line_referential)
+end
+
+crumb :companies do |line_referential|
+ link I18n.t('companies.index.title'), line_referential_companies_path(line_referential)
+ parent :line_referential, line_referential
+end
+
+crumb :company do |company|
+ link company.name, line_referential_company_path(company.line_referential, company)
+ parent :companies, company.line_referential
+end
+
+crumb :networks do |line_referential|
+ link I18n.t('networks.index.title'), line_referential_networks_path(line_referential)
+ parent :line_referential, line_referential
+end
+
+crumb :network do |network|
+ link network.name, line_referential_network_path(network.line_referential, network)
+ parent :networks, network.line_referential
+end
+
+crumb :group_of_lines do |line_referential|
+ link I18n.t('group_of_lines.index.title'), line_referential_group_of_lines_path(line_referential)
+ parent :line_referential, line_referential
+end
+
+crumb :group_of_line do |group_of_line|
+ link group_of_line.name, line_referential_group_of_line_path(group_of_line.line_referential, group_of_line)
+ parent :group_of_lines, group_of_line.line_referential
+end
+
+crumb :lines do |line_referential|
+ link I18n.t('lines.index.title'), line_referential_lines_path
+ parent :line_referential, line_referential
+end
+
+crumb :line do |line|
+ link line.name, line_referential_line_path(line.line_referential, line)
+ parent :lines, line.line_referential
+end
+
+crumb :calendars do
+ link I18n.t('calendars.index.title'), calendars_path
+end
+
+crumb :calendar do |calendar|
+ link calendar.name, calendar_path(calendar)
+ parent :calendars
+end
+
+crumb :referential_line do |referential, line|
+ link line.name, referential_line_path(referential, line)
+ parent :referential, referential
+end
+
+crumb :line_footnotes do |referential, line|
+ link line.name, referential_line_footnotes_path(referential, line)
+ parent :referential_line, referential, line
+end
+
+crumb :routing_constraint_zones do |referential, line|
+ link I18n.t('routing_constraint_zones.index.title'), referential_line_routing_constraint_zones_path(referential, line)
+ parent :referential_line, referential, line
+end
+
+crumb :routing_constraint_zone do |referential, line, routing_constraint_zone|
+ link routing_constraint_zone.name, referential_line_routing_constraint_zone_path(referential, line, routing_constraint_zone)
+ parent :routing_constraint_zones, referential, line
+end
+
+crumb :route do |referential, route|
+ link I18n.t('routes.index.title', route: route.name), referential_line_route_path(referential, route.line, route)
+ parent :referential_line, referential, route.line
+end
+
+crumb :journey_patterns do |referential, route|
+ link I18n.t('journey_patterns.index.title'), referential_line_route_journey_patterns_collection_path(referential, route.line, route)
+ parent :route, referential, route
+end
+
+crumb :referential_stop_areas do |referential|
+ link I18n.t('stop_areas.index.title'), referential_stop_areas_path(referential)
+ parent :referential, referential
+end
+
+crumb :referential_stop_area do |referential, stop_area|
+ link stop_area.name, referential_stop_area_path(referential, stop_area)
+ parent :referential_stop_areas, referential
+end
+
+crumb :vehicle_journeys do |referential, route|
+ link I18n.t('vehicle_journeys.index.title', route: route.name), referential_line_route_vehicle_journeys_path(referential, route.line, route)
+ parent :route, referential, route
+end
+
+# crumb :compliance_controls do|compliance_control_sets|
+# link
+# parent :compliance_control_sets, compliance_control_sets
+# end
+
+# crumb :project do |project|
+# link project.name, project_path(project)
+# parent :projects
+# end
+
+# crumb :project_issues do |project|
+# link "Issues", project_issues_path(project)
+# parent :project, project
+# end
+
+# crumb :issue do |issue|
+# link issue.title, issue_path(issue)
+# parent :project_issues, issue.project
+# end
+
+# If you want to split your breadcrumbs configuration over multiple files, you
+# can create a folder named `config/breadcrumbs` and put your configuration
+# files there. All *.rb files (e.g. `frontend.rb` or `products.rb`) in that
+# folder are loaded and reloaded automatically when you change them, just like
+# this file (`config/breadcrumbs.rb`).
diff --git a/config/environments/test.rb b/config/environments/test.rb
index b3312be4a..8bf94f5da 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -62,6 +62,9 @@ Rails.application.configure do
# Reflex api url
config.reflex_api_url = "https://195.46.215.128/ws/reflex/V1/service=getData"
+ # IEV url
+ config.iev_url = ENV.fetch('IEV_URL', 'http://localhost:8080')
+
config.rails_host = "http://www.example.com"
# file to data for demo
config.demo_data = "tmp/demo.zip"
diff --git a/config/locales/breadcrumbs.en.yml b/config/locales/breadcrumbs.en.yml
deleted file mode 100644
index 6fec15b85..000000000
--- a/config/locales/breadcrumbs.en.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-en:
- breadcrumbs:
- vehicle_journeys: "Passing times"
- vehicle_journey_frequencies: "Times bands"
- referentials: "Home"
- users: "Users"
- imports: Imports
diff --git a/config/locales/breadcrumbs.fr.yml b/config/locales/breadcrumbs.fr.yml
deleted file mode 100644
index 725549f14..000000000
--- a/config/locales/breadcrumbs.fr.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-fr:
- breadcrumbs:
- vehicle_journeys: "Horaires"
- vehicle_journey_frequencies: "Créneaux horaires"
- root: "Accueil"
- users: "Utilisateurs"
- imports: Imports
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index d8bc6962b..94c7ec529 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -2,12 +2,26 @@ en:
compliance_controls:
clone:
prefix: 'Copy of'
+ filters:
+ criticity: Severity
+ name: "Search by a control's name or code"
+ subclass: Object
+ subclasses:
+ generic: 'Generic'
+ journey_pattern: 'JourneyPattern'
+ line: 'Line'
+ route: 'Route'
+ routing_constraint_zone: 'RoutingConstraint'
+ vehicle_journey: 'VehicleJourney'
min_max_values: "the minimum (%{min}) is not supposed to be greater than the maximum (%{max})"
errors:
incoherent_control_sets: "Impossible to assign a control to a set (id: %{direct_set_name}) differing from the one of its group (id: %{indirect_set_name})"
mandatory_control_type: "A control type must be selected"
show:
title: "Compliance control"
+ metadatas:
+ compliance_control_block: "Control block informations"
+ new:
index:
title: "Compliance control"
new:
@@ -20,6 +34,8 @@ en:
show: Show
destroy: Destroy
destroy_confirm: Are you sure ?
+ metas:
+ no_prerequisite: "None"
route_control/zdl_stop_area:
messages:
3_route_1: "The route with %{source_objectid} objectid connect the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) which belong to the same ZDL"
@@ -31,6 +47,7 @@ en:
"If the route has an opposite route, it must :
- reference the opposite route
- have an opposite route in relation with the tested route"
+ prerequisite: "Présence d'itinéraire référençant un itinéraire inverse"
route_control/journey_pattern:
messages:
3_route_3: "The route with %{source_objectid} objectid doesn't have any journey pattern"
@@ -43,6 +60,7 @@ en:
messages:
3_route_5: "The route with %{source_objectid} objectid has a first stop from the %{target_0_label} ZDL whereas its oppoite route's last stop is from the ZDL %{target_1_label}"
description: "Deux itinéraires en aller/retour doivent desservir les mêmes terminus"
+ prerequisite: "Présence d'itinéraire référençant un itinéraire inverse"
route_control/minimum_length:
messages:
3_route_6: "The route with %{source_objectid} objectid does not connect enough stop points (required 2 stop points)"
@@ -105,6 +123,7 @@ en:
messages:
3_line_1: "On line :%{source_label} (%{source_objectid}), no route has an opposite route"
description: "The routes of a line must have an opposite route"
+ prerequisite: Lign has multiple routes
generic_attribute_control/pattern:
messages:
3_generic_1: "%{source_objectid} : the %{source_label} attribute value (%{error_value}) does not respect the following pattern : %{reference_value}"
@@ -185,4 +204,6 @@ en:
compliance_control_block: "Control Block"
minimum: "Minimum"
maximum: "Maximum"
- target: "Target" \ No newline at end of file
+ target: "Target"
+ prerequisite: "Prerequisite"
+ predicate: "Predicate" \ No newline at end of file
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index 50083bc54..69773f61c 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -2,12 +2,25 @@ fr:
compliance_controls:
clone:
prefix: 'Copie de'
+ filters:
+ criticity: Criticité
+ name: "Chercher le nom ou code d'un contrôl"
+ subclass: Objet
+ subclasses:
+ generic: 'Généric'
+ journey_pattern: 'JourneyPattern'
+ line: 'Ligne'
+ route: 'Itinéraire'
+ routing_constraint_zone: 'ITL'
+ vehicle_journey: 'Course'
min_max_values: "la valeur de minimum (%{min}) ne doit pas être superieur à la valuer du maximum (%{max})"
errors:
incoherent_control_sets: "Le contrôle ne peut pas être associé à un jeu de contrôle (id: %{direct_set_name}) différent de celui de son groupe (id: %{indirect_set_name})"
mandatory_control_type: "Un type de contrôle doit être sélectionné"
show:
title: "Consulter un contrôle"
+ metadatas:
+ compliance_control_block: "Informations sur le groupe de contrôle"
new:
title: "Ajouter un contrôle"
edit:
@@ -20,6 +33,8 @@ fr:
show: Consulter
destroy: Supprimer
destroy_confirm: Etes vous sûr de supprimer ce contrôle ?
+ metas:
+ no_prerequisite: "Aucun"
route_control/zdl_stop_area:
messages:
3_route_1: "L'itinéraire %{source_objectid} dessert successivement les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) de la même zone de lieu"
@@ -31,6 +46,7 @@ fr:
"Si l'itinéraire référence un itinéraire inverse, celui-ci doit :
- référencer l'itinéraire inverse
- avoir un sens opposé à l'itinéraire testé"
+ prerequisite: "Présence d'itinéraire référençant un itinéraire inverse"
route_control/journey_pattern:
messages:
3_route_3: "L'itinéraire %{source_objectid} n'a pas de mission"
@@ -43,6 +59,7 @@ fr:
messages:
3_route_5: "L'itinéraire %{source_objectid} dessert au départ un arrêt de la ZDL %{target_0_label} alors que l'itinéraire inverse dessert à l'arrivée un arrêt de la ZDL %{target_1_label}"
description: "Deux itinéraires en aller/retour doivent desservir les mêmes terminus"
+ prerequisite: "Présence d'itinéraire référençant un itinéraire inverse"
route_control/minimum_length:
messages:
3_route_6: "L'itinéraire %{source_objectid} ne dessert pas assez d'arrêts (minimum 2 requis)"
@@ -105,6 +122,7 @@ fr:
messages:
3_line_1: "Sur la ligne %{source_label} (%{source_objectid}), aucun itinéraire n'a d'itinéraire inverse"
description: "Les itinéraires d'une ligne doivent être associés en aller/retour"
+ prerequisite: Ligne disposant de plusieurs itinéraires
generic_attribute_control/pattern:
messages:
3_generic_1: "%{source_objectid} : l'attribut % à une valeur %{error_value} qui ne respecte pas le motif %{reference_value}"
@@ -125,7 +143,7 @@ fr:
activerecord:
models:
compliance_control:
- one: "controle"
+ one: "contrôle"
other: "contrôles"
route_control/zdl_stop_area:
one: "Deux arrêts d’une même ZDL ne peuvent pas se succéder dans un itinéraire"
@@ -136,7 +154,7 @@ fr:
route_control/duplicates:
one: "Détection de double définition d'itinéraire"
route_control/opposite_route_terminus:
- one: "Vérification des terminus de l'itinéraire inverse"
+ one: "Vérification des terminus de l'itinéraire inverse"
route_control/minimum_length:
one: "Un itinéraire doit contenir au moins 2 arrêts"
route_control/omnibus_journey_pattern:
@@ -144,7 +162,7 @@ fr:
route_control/unactivated_stop_points:
one: "Itinéraire & arrêt désactivé"
route_control/stop_points_in_journey_pattern:
- one: "Un itinéraire doit contenir au moins 2 arrêts"
+ one: "Utilisation des arrêts par les missions"
journey_pattern_control/duplicates:
one: "Doublon de missions dans une ligne"
journey_pattern_control/vehicle_journey:
@@ -185,4 +203,6 @@ fr:
compliance_control_block: "Groupe de contrôle"
minimum: "Minimum"
maximum: "Maximum"
- target: "Cible" \ No newline at end of file
+ target: "Cible"
+ prerequisite: "Prérequis"
+ predicate: "Prédicat" \ No newline at end of file
diff --git a/config/locales/import_messages.en.yml b/config/locales/import_messages.en.yml
index 528ab3477..bf6b45020 100644
--- a/config/locales/import_messages.en.yml
+++ b/config/locales/import_messages.en.yml
@@ -1,8 +1,8 @@
en:
import_messages:
compliance_check_messages:
- corrupt_zip_file: "The zip file of WorkbenchImport %{import_name} is corrupted and cannot be read"
- inconsistent_zip_file: "The zip file of WorkbenchImport %{import_name} contains the following spurious directories %{spurious_dirs}, which are ignored"
+ corrupt_zip_file: "The zip file %{source_filename} is corrupted and cannot be read"
+ inconsistent_zip_file: "The zip file %{source_filename} contains unexpected directories: %{spurious_dirs}, which are ignored"
referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les même périodes et lignes"
1_netexstif_2: "Le fichier %{source_filename} ne respecte pas la syntaxe XML ou la XSD NeTEx : erreur '%{error_value}' rencontré"
1_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
@@ -15,6 +15,7 @@ en:
2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"
2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"
2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{error_value} ne respecte pas la syntaxe %{reference_value}"
+ 2_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{error_value} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'"
2_netexstif_7: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} définit une référence %{reference_value} de syntaxe invalide : %{error_value}"
2_netexstif_8_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} définit une référence %{error_value} de type externe : référence interne attendue"
diff --git a/config/locales/import_messages.fr.yml b/config/locales/import_messages.fr.yml
index 15de6eed8..7d3bbf23b 100644
--- a/config/locales/import_messages.fr.yml
+++ b/config/locales/import_messages.fr.yml
@@ -1,8 +1,8 @@
fr:
import_messages:
compliance_check_messages:
- corrupt_zip_file: "Le fichier zip du WorkbenchImport %{import_name} est corrompu, et ne peut être lu"
- inconsistent_zip_file: "Le fichier zip du WorkbenchImport %{import_name} contient les repertoirs illegeaux %{spurious_dirs} qui seront ignorés"
+ corrupt_zip_file: "Le fichier zip %{source_filename} est corrompu, et ne peut être lu"
+ inconsistent_zip_file: "Le fichier zip %{source_filename} contient des repertoires non prévus : %{spurious_dirs} qui seront ignorés"
referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les même périodes et lignes"
1_netexstif_2: "Le fichier %{source_filename} ne respecte pas la syntaxe XML ou la XSD NeTEx : erreur '%{error_value}' rencontré"
1_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
@@ -15,6 +15,7 @@ fr:
2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"
2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"
2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{error_value} ne respecte pas la syntaxe %{reference_value}"
+ 2_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{error_value} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'"
2_netexstif_7: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} définit une référence %{reference_value} de syntaxe invalide : %{error_value}"
2_netexstif_8_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} définit une référence %{error_value} de type externe : référence interne attendue"
diff --git a/config/locales/imports.en.yml b/config/locales/imports.en.yml
index f3bcad9e9..10434dd19 100644
--- a/config/locales/imports.en.yml
+++ b/config/locales/imports.en.yml
@@ -55,8 +55,10 @@ en:
other: "imports"
errors:
models:
- imports:
- wrong_file_extension: "The imported file must be a zip file"
+ import:
+ attributes:
+ file:
+ wrong_file_extension: "The imported file must be a zip file"
attributes:
import:
resources: "File to import"
diff --git a/config/locales/imports.fr.yml b/config/locales/imports.fr.yml
index 6e74fa33c..099488a6b 100644
--- a/config/locales/imports.fr.yml
+++ b/config/locales/imports.fr.yml
@@ -55,8 +55,10 @@ fr:
other: "imports"
errors:
models:
- imports:
- wrong_file_extension: "Le fichier importé doit être au format zip"
+ import:
+ attributes:
+ file:
+ wrong_file_extension: "Le fichier importé doit être au format zip"
attributes:
import:
resources: "Fichier à importer"
diff --git a/config/locales/referential_suites.en.yml b/config/locales/referential_suites.en.yml
index 1a77d9026..aa6fef0e2 100644
--- a/config/locales/referential_suites.en.yml
+++ b/config/locales/referential_suites.en.yml
@@ -1,2 +1,5 @@
-en:
+fr:
referential_suites:
+ errors:
+ inconsistent_current: "The current referential (%{name}) does not belong to this referential suite"
+ inconsistent_new: "The new referential (%{name}) does not belong to this referential suite"
diff --git a/config/locales/referential_suites.fr.yml b/config/locales/referential_suites.fr.yml
index c87b32fc7..9cb1e33d3 100644
--- a/config/locales/referential_suites.fr.yml
+++ b/config/locales/referential_suites.fr.yml
@@ -1,2 +1,5 @@
-fr:
+en:
referential_suites:
+ errors:
+ inconsistent_current: "Le current referential (%{name}) n'appartient pas à cette referential suite"
+ inconsistent_new: "Le new referential (%{name}) n'appartient pas à cette referential suite"
diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml
index 14b4dbe66..7923ba5f2 100644
--- a/config/locales/referentials.en.yml
+++ b/config/locales/referentials.en.yml
@@ -38,6 +38,7 @@ en:
edit: "Edit this data space"
clone: "Clone this data space"
errors:
+ inconsistent_organisation: "Organisation of asscociated workbench is (%{indirect_name}), while directly associated organisation is (%{direct_name}), they need to be equal"
validity_period: "Invalid validity periode"
pg_excluded: "can't begins with pg_"
public_excluded: "public is a reserved value"
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index b90f6e5b6..6aa81b33d 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -2,7 +2,7 @@ fr:
referentials:
filters:
name_or_number_or_objectid: 'Indiquez un nom de ligne, nom court ou objectid'
- name: 'Indiquez un nom de référentiel...'
+ name: 'Indiquez un nom de jeu de données...'
line: 'Indiquez une ligne...'
search_no_results: 'Aucun jeu de données ne correspond à votre recherche'
error_period_filter: "Le filtre par période doit contenir une date de début et de fin valides"
@@ -38,6 +38,7 @@ fr:
edit: "Editer ce jeu de données"
clone: "Cloner ce jeu de données"
errors:
+ inconsistent_organisation: "L'organisation asscociée par espace de travail est (%{indirect_name}), mais l'organisation associée directement est (%{direct_name}), elles doivent être identiques."
validity_period: "Période de validité invalide"
pg_excluded: "ne peut pas commencer par pg_ (valeurs réservées)"
public_excluded: "public est une valeur réservée"
@@ -102,8 +103,8 @@ fr:
referential:
slug: "caractères autorisés : alphanumériques minuscules et 'souligné' et doit commencer par une lettre"
prefix: "caractères autorisés : alphanumériques et 'souligné'"
- upper_corner: "latitude,longitude dans le référentiel WGS84, le séparateur de décimales est 'point'"
- lower_corner: "latitude,longitude dans le référentiel WGS84, le séparateur de décimales est 'point'"
+ upper_corner: "latitude,longitude dans le jeu de données WGS84, le séparateur de décimales est 'point'"
+ lower_corner: "latitude,longitude dans le jeu de données WGS84, le séparateur de décimales est 'point'"
simple_form:
labels:
diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml
index 83a96732d..31838f1a7 100644
--- a/config/locales/routes.fr.yml
+++ b/config/locales/routes.fr.yml
@@ -81,7 +81,7 @@ fr:
number: "Indice"
comment: "Commentaire"
direction: "Direction"
- wayback: "Direction"
+ wayback: "Sens"
stop_points: "Nb arrêts"
journey_patterns: "Nb missions"
opposite_route: "Itinéraire associé"
diff --git a/config/locales/workbenches.en.yml b/config/locales/workbenches.en.yml
index 051ef1c96..3a2fcd598 100644
--- a/config/locales/workbenches.en.yml
+++ b/config/locales/workbenches.en.yml
@@ -11,9 +11,9 @@ en:
see: "See the list"
no_content: "No content yet."
referential_count:
- zero: "Currently, there is no referential in your workbench"
- one: "Currently, there is one referential in your workbench"
- other: "Currently, there are #{count} referentials in your workbench"
+ zero: "There is no referential in your workbench"
+ one: "There is one referential in your workbench"
+ other: "There are #{count} referentials in your workbench"
activerecord:
models:
workbench:
diff --git a/config/locales/workbenches.fr.yml b/config/locales/workbenches.fr.yml
index 7a614efc5..0f8a516e3 100644
--- a/config/locales/workbenches.fr.yml
+++ b/config/locales/workbenches.fr.yml
@@ -1,9 +1,9 @@
fr:
workbenches:
referential_count:
- zero: "Aucun jeu de données à l'heure actuelle"
- one: "1 jeu de données à l'heure actuelle"
- other: "#{count} jeux de données à l'heure actuelle"
+ zero: "Aucun jeu de données dans cet espace de travail"
+ one: "1 jeu de données dans cet espace de travail"
+ other: "#{count} jeux de données dans cet espace de travail"
activerecord:
models:
workbench:
diff --git a/config/routes.rb b/config/routes.rb
index b105e77d6..27c3c3044 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -74,6 +74,7 @@ ChouetteIhm::Application.routes.draw do
resources :api_keys, :only => [:edit, :update, :new, :create, :destroy]
resources :compliance_control_sets do
+ get :simple, on: :member
get :clone, on: :member
resources :compliance_controls, except: :index do
get :select_type, on: :collection
diff --git a/db/migrate/20171106111448_update_import_message_criticity_type_to_string.rb b/db/migrate/20171106111448_update_import_message_criticity_type_to_string.rb
new file mode 100644
index 000000000..c14450387
--- /dev/null
+++ b/db/migrate/20171106111448_update_import_message_criticity_type_to_string.rb
@@ -0,0 +1,16 @@
+class UpdateImportMessageCriticityTypeToString < ActiveRecord::Migration
+ def change
+ change_column :import_messages, :criticity, :string
+
+ def change_criticity_value criticity
+ case criticity
+ when 0 then "info"
+ when 1 then "warning"
+ when 2 then "error"
+ else
+ "info"
+ end
+ end
+ ImportMessage.all.each { |im| im.update_attribute(:criticity, change_criticity_value(im.criticity)) }
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a64a426de..050e81ad5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20171016074044) do
+ActiveRecord::Schema.define(version: 20171106111448) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -366,7 +366,7 @@ ActiveRecord::Schema.define(version: 20171016074044) do
end
create_table "import_messages", id: :bigserial, force: :cascade do |t|
- t.integer "criticity"
+ t.string "criticity"
t.string "message_key"
t.hstore "message_attributes"
t.integer "import_id", limit: 8
@@ -408,9 +408,9 @@ ActiveRecord::Schema.define(version: 20171016074044) do
t.string "type"
t.integer "parent_id", limit: 8
t.string "parent_type"
- t.datetime "notified_parent_at"
t.integer "current_step", default: 0
t.integer "total_steps", default: 0
+ t.datetime "notified_parent_at"
t.string "creator"
end
diff --git a/lib/bootstrap_breadcrumbs_builder.rb b/lib/bootstrap_breadcrumbs_builder.rb
deleted file mode 100644
index daa154bdf..000000000
--- a/lib/bootstrap_breadcrumbs_builder.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# bootstrap builder for breadcrumbs_on_rails gem
-class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
- def render
- @context.content_tag(:ul, class: 'breadcrumb') do
- @elements.collect do |element|
- render_element(element)
- end.join.html_safe
- end
- end
-
- def render_element(element)
- active = element.path.nil? || @context.current_page?(compute_path(element))
- # Bootstrap use '/' divider by default but you can customize it:
- # divider = @context.content_tag(:span, '/'.html_safe, class: 'divider') unless active
-
- @context.content_tag(:li, :class => ('active' if active)) do
- content = if element.path.nil?
- compute_name(element)
- else
- @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
- end
-
- # content + (divider || '')
- content
- end
- end
-end
-
-
-# Usage:
-# = render_breadcrumbs(builder: BootstrapBreadcrumbsBuilder) \ No newline at end of file
diff --git a/lib/compliance_control_set_cloner.rb b/lib/compliance_control_set_cloner.rb
index 12e1eccb5..17443a07f 100644
--- a/lib/compliance_control_set_cloner.rb
+++ b/lib/compliance_control_set_cloner.rb
@@ -57,7 +57,7 @@ class ComplianceControlSetCloner
comment: compliance_control.comment,
control_attributes: compliance_control.control_attributes,
criticity: compliance_control.criticity,
- name: name_of_copy(:compliance_controls, compliance_control.name),
+ name: compliance_control.name,
origin_code: compliance_control.origin_code,
type: compliance_control.type
).tap do | control |
diff --git a/lib/compliance_control_set_copier.rb b/lib/compliance_control_set_copier.rb
index 20518ee0e..58d40cdbf 100644
--- a/lib/compliance_control_set_copier.rb
+++ b/lib/compliance_control_set_copier.rb
@@ -11,6 +11,8 @@ class ComplianceControlSetCopier
@referential_id = referential_id
check_organisation_coherence!
copy_set
+
+ cck_set
end
diff --git a/lib/stif/dashboard.rb b/lib/stif/dashboard.rb
index fafddec62..b6b6b8284 100644
--- a/lib/stif/dashboard.rb
+++ b/lib/stif/dashboard.rb
@@ -5,7 +5,7 @@ module Stif
end
def referentials
- @referentials ||= @workbench.all_referentials
+ @referentials ||= self.workbench.all_referentials
end
def calendars
diff --git a/package.json b/package.json
index 7e8d695ac..01b1244af 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
},
"license": "MIT",
"engines": {
- "node": "6.11.4"
+ "node": "~6.11.4"
},
"devDependencies": {
"clean-webpack-plugin": "0.1.17",
diff --git a/spec/controllers/api/v1/imports_controller_spec.rb b/spec/controllers/api/v1/imports_controller_spec.rb
index 266b25486..8077dd052 100644
--- a/spec/controllers/api/v1/imports_controller_spec.rb
+++ b/spec/controllers/api/v1/imports_controller_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Api::V1::ImportsController, type: :controller do
it 'should be successful' do
expect {
- post :create, workbench_id: workbench.id, workbench_import: {file: file, creator: 'test'}, format: :json
+ post :create, workbench_id: workbench.id, workbench_import: {name: "test", file: file, creator: 'test'}, format: :json
}.to change{WorkbenchImport.count}.by(1)
expect(response).to be_success
end
diff --git a/spec/factories/referentials.rb b/spec/factories/referentials.rb
index 5348ad96b..a4155d181 100644
--- a/spec/factories/referentials.rb
+++ b/spec/factories/referentials.rb
@@ -3,11 +3,17 @@ FactoryGirl.define do
sequence(:name) { |n| "Test #{n}" }
sequence(:slug) { |n| "test_#{n}" }
sequence(:prefix) { |n| "test_#{n}" }
- association :organisation
- association :workbench
association :line_referential
association :stop_area_referential
+ association :organisation
time_zone "Europe/Paris"
ready { true }
+
+ factory :workbench_referential do
+ association :workbench
+ before :create do | ref |
+ ref.workbench.organisation = ref.organisation
+ end
+ end
end
end
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
new file mode 100644
index 000000000..500d4ce6f
--- /dev/null
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -0,0 +1,82 @@
+RSpec.describe "ComplianceControlSets", type: :feature do
+
+ login_user
+
+ # We setup a control_set with two blocks and one direct control (meaning that it is not attached to a block)
+ # Then we add one control to the first block and two controls to the second block
+ let( :control_set ){ create :compliance_control_set, organisation: organisation }
+ let( :controls ){ control_set.compliance_controls }
+
+ let(:blox){
+ 2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set }
+ }
+
+ before do
+ blox.first.update transport_mode: 'bus', transport_submode: 'bus'
+ blox.second.update transport_mode: 'train', transport_submode: 'train'
+
+ make_control
+ make_control blox.first, severity: :error
+ make_control blox.second, times: 2
+ end
+
+ describe 'show' do
+ before do
+ visit compliance_control_set_path( control_set )
+ end
+
+ it 'we can see the controls inside their blocks' do
+ controls.each do | control |
+ expect( page ).to have_content(control.code)
+ end
+ end
+
+ it 'we can apply a severity filter' do
+ controls.take(2).each do | control |
+ control.update criticity: 'error'
+ end
+ check('error')
+ click_on('Filtrer')
+ controls.each do | control |
+ if control.criticity == 'error'
+ expect( page ).to have_content(control.code)
+ else
+ expect( page ).not_to have_content(control.code)
+ end
+ end
+ end
+
+ it 'we can apply a subclass filter' do
+ controls.first.update(origin_code: 'x-Route-y')
+ controls.second.update(origin_code: 'x-Line-y')
+
+ within('#subclass-filter') do
+ check('Itinéraire')
+ check('Ligne')
+ end
+ click_on('Filtrer')
+ controls.each do | control |
+ if control.origin_code[/-Generic-/]
+ expect( page ).not_to have_content(control.code)
+ else
+ expect( page ).to have_content(control.code)
+ end
+ end
+ end
+
+ end
+
+ def make_control ccblock=nil, times: 1, severity: :warning
+ times.times do
+ make_one_control ccblock, severity
+ end
+ end
+
+ def make_one_control ccblock, severity
+ create( :generic_attribute_control_min_max,
+ code: random_string,
+ compliance_control_block: ccblock,
+ compliance_control_set: control_set)
+ end
+
+end
diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb
index 7272242fe..2f6283dcd 100644
--- a/spec/features/connection_links_spec.rb
+++ b/spec/features/connection_links_spec.rb
@@ -1,4 +1,4 @@
-RSpec.describe "ConnectionLinks", :type => :feature do
+RSpec.describe "ConnectionLinks", type: :feature do
login_user
let!(:connection_links) { Array.new(2) { create(:connection_link) } }
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index e33f8c134..f1151a67b 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -1,6 +1,4 @@
-# coding: utf-8
-
-describe 'Workbenches', type: :feature do
+RSpec.describe 'Workbenches', type: :feature do
login_user
let(:line_ref) { create :line_referential }
@@ -8,7 +6,7 @@ describe 'Workbenches', type: :feature do
let(:ref_metadata) { create(:referential_metadata, lines: [line]) }
let!(:workbench) { create(:workbench, line_referential: line_ref, organisation: @user.organisation) }
- let!(:referential) { create :referential, workbench: workbench, metadatas: [ref_metadata], organisation: @user.organisation }
+ let!(:referential) { create :workbench_referential, workbench: workbench, metadatas: [ref_metadata], organisation: @user.organisation }
describe 'show' do
context 'ready' do
@@ -25,10 +23,10 @@ describe 'Workbenches', type: :feature do
end
context 'filtering' do
- let(:another_organisation) { create :organisation }
+ let!(:another_organisation) { create :organisation }
let(:another_line) { create :line, line_referential: line_ref }
let(:another_ref_metadata) { create(:referential_metadata, lines: [another_line]) }
- let!(:other_referential) { create :referential, workbench: workbench, metadatas: [another_ref_metadata], organisation: another_organisation}
+ let!(:other_referential) { create :workbench_referential, workbench: workbench, metadatas: [another_ref_metadata] }
before(:each) do
visit workbench_path(workbench)
@@ -53,7 +51,7 @@ describe 'Workbenches', type: :feature do
it 'should be possible to filter by multiple organisation' do
find("#q_organisation_name_eq_any_#{@user.organisation.name.parameterize.underscore}").set(true)
- find("#q_organisation_name_eq_any_#{another_organisation.name.parameterize.underscore}").set(true)
+ find("#q_organisation_name_eq_any_#{other_referential.organisation.name.parameterize.underscore}").set(true)
click_button I18n.t('actions.filter')
expect(page).to have_content(referential.name)
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb
index e17196a19..4d9808044 100644
--- a/spec/helpers/table_builder_helper_spec.rb
+++ b/spec/helpers/table_builder_helper_spec.rb
@@ -7,7 +7,7 @@ end
describe TableBuilderHelper, type: :helper do
describe "#table_builder_2" do
it "builds a table" do
- referential = build_stubbed(:referential)
+ referential = build_stubbed(:workbench_referential)
workbench = referential.workbench
user_context = UserContext.new(
diff --git a/spec/lib/compliance_control_set_cloner_spec.rb b/spec/lib/compliance_control_set_cloner_spec.rb
index 4305ec70b..c17f0bb52 100644
--- a/spec/lib/compliance_control_set_cloner_spec.rb
+++ b/spec/lib/compliance_control_set_cloner_spec.rb
@@ -7,7 +7,6 @@ RSpec.describe ComplianceControlSetCloner do
let( :source_set ){ create :compliance_control_set }
let( :set_prefix ){ I18n.t('compliance_control_sets.clone.prefix') }
let( :block_prefix ){ I18n.t('compliance_control_blocks.clone.prefix') }
- let( :control_prefix ){ I18n.t('compliance_controls.clone.prefix') }
context 'Copying empty set' do
@@ -96,7 +95,7 @@ RSpec.describe ComplianceControlSetCloner do
expect( target.compliance_control_set ).to eq( target_set )
expect( target.control_attributes ).to eq(source.control_attributes)
expect( target.criticity ).to eq(source.criticity )
- expect( target.name ).to eq([control_prefix, source.name].join(' '))
+ expect( target.name ).to eq(source.name)
expect( target.origin_code ).to eq(source.origin_code )
expect( target.type ).to eq(source.type)
end
diff --git a/spec/lib/compliance_control_set_copier_spec.rb b/spec/lib/compliance_control_set_copier_spec.rb
index a9e576cf7..0f15d86d0 100644
--- a/spec/lib/compliance_control_set_copier_spec.rb
+++ b/spec/lib/compliance_control_set_copier_spec.rb
@@ -99,6 +99,10 @@ RSpec.describe ComplianceControlSetCopier do
expect( actual ).to eq( expected )
end
+
+ it 'returns the newly-created ComplianceCheckSet' do
+ expect(subject.copy(cc_set.id, ref.id)).to eq(cck_set)
+ end
end
end
diff --git a/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb
new file mode 100644
index 000000000..868eca984
--- /dev/null
+++ b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb
@@ -0,0 +1,17 @@
+RSpec.describe ComplianceControl do
+ let( :subject ){ described_class.subclass_patterns }
+
+ context 'subclass_patterns' do
+ it 'are correctly defined' do
+ expect_it.to eq(
+ generic: 'Generic',
+ journey_pattern: 'JourneyPattern',
+ line: 'Line',
+ route: 'Route',
+ routing_constraint_zone: 'RoutingConstraint',
+ vehicle_journey: 'VehicleJourney'
+ )
+ end
+ end
+
+end
diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb
index db73dab21..4267459ea 100644
--- a/spec/models/compliance_control_spec.rb
+++ b/spec/models/compliance_control_spec.rb
@@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do
let(:compliance_control) { build_stubbed :compliance_control }
- it 'should have a valid factory' do
- expect(compliance_control).to be_valid
- end
-
it { should belong_to :compliance_control_set }
it { should belong_to :compliance_control_block }
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb
index c06d05dab..7be05908a 100644
--- a/spec/models/import_spec.rb
+++ b/spec/models/import_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Import, type: :model do
it { should validate_presence_of(:workbench) }
it { should validate_presence_of(:creator) }
- it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.imports.wrong_file_extension')) }
+ it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')) }
it { should_not allow_values('file.json', 'file.png', 'file.pdf').for(:file) }
let(:workbench_import) { build_stubbed(:workbench_import) }
diff --git a/spec/models/referential/referential_org_through_workbench_spec.rb b/spec/models/referential/referential_org_through_workbench_spec.rb
new file mode 100644
index 000000000..358a9e5e6
--- /dev/null
+++ b/spec/models/referential/referential_org_through_workbench_spec.rb
@@ -0,0 +1,44 @@
+RSpec.describe Referential do
+
+ describe 'Normalisation between Workbench and Organisation' do
+
+ context 'no workbench' do
+ subject{ create( :referential, workbench: nil ) }
+ it do
+ expect_it.to be_valid
+ end
+ end
+ context 'workbench with same organisation' do
+ let( :workbench ){ create :workbench}
+ subject do
+ create( :referential,
+ workbench: workbench,
+ organisation: workbench.organisation )
+ end
+ it do
+ expect_it.to be_valid
+ end
+ end
+
+ context 'workbench with different organisation' do
+ let( :workbench ){ create :workbench}
+ subject do
+ build( :referential, workbench: workbench)
+ end
+ before do
+ subject.organisation = build_stubbed(:organisation)
+ end
+ it 'is not valid' do
+ expect_it.not_to be_valid
+ end
+ it 'has correct error message' do
+ subject.valid?
+ errors = subject.errors.messages[:inconsistent_organisation]
+ expect(errors.grep(%r<#{subject.organisation.name}>)).not_to be_empty
+ expect(errors.grep(%r<#{workbench.organisation.name}>)).not_to be_empty
+ end
+ end
+
+ end
+
+end
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index bb8fabb2e..ad9c43010 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Referential, :type => :model do
- let(:ref) { create :referential, metadatas: [create(:referential_metadata)] }
+ let(:ref) { create :workbench_referential, metadatas: [create(:referential_metadata)] }
# it "create a rule_parameter_set" do
# referential = create(:referential)
diff --git a/spec/models/referential_suite/referential_suite_current_new_spec.rb b/spec/models/referential_suite/referential_suite_current_new_spec.rb
new file mode 100644
index 000000000..a910a12da
--- /dev/null
+++ b/spec/models/referential_suite/referential_suite_current_new_spec.rb
@@ -0,0 +1,64 @@
+RSpec.describe ReferentialSuite do
+
+ describe 'Normalisation of current and new towards a proper Referential' do
+
+ subject { create :referential_suite, new: nil, current: nil }
+
+ describe 'valid' do
+ context 'current and new nil' do
+ it do
+ expect_it.to be_valid
+ end
+ end
+
+ context 'current nil and new pointing correctly back' do
+ let( :child ){ create :referential, referential_suite: subject }
+ it do
+ subject.new_id = child.id
+ expect_it.to be_valid
+ end
+ end
+
+ context 'new nil and current pointing correctly back' do
+ let( :child ){ create :referential, referential_suite: subject }
+ it do
+ subject.current_id = child.id
+ expect_it.to be_valid
+ end
+ end
+
+ context 'new and current pointing correctly back' do
+ let( :child ){ create :referential, referential_suite: subject }
+ let( :sibbling ){ create :referential, referential_suite: subject }
+ it do
+ subject.current_id = child.id
+ subject.new_id = sibbling.id
+ expect_it.to be_valid
+ end
+ end
+ end
+
+ describe 'invalid' do
+ context 'current points to incorrect referential(not a child), new is nil' do
+ let( :current ){ create :referential }
+ it do
+ subject.current_id = current.id
+ expect_it.not_to be_valid
+ expect( subject.errors.messages[:inconsistent_new] ).to be_nil
+ expect( subject.errors.messages[:inconsistent_current].first ).to match(%r<#{current.name}>)
+ end
+ end
+ context 'current points to correct referential, new to incorrect referential(not a child)' do
+ let( :current ){ create :referential, referential_suite: subject }
+ let( :new ){ create :referential, referential_suite: create( :referential_suite ) }
+ it do
+ subject.current_id = current.id
+ subject.new_id = new.id
+ expect_it.not_to be_valid
+ expect( subject.errors.messages[:inconsistent_current] ).to be_nil
+ expect( subject.errors.messages[:inconsistent_new].first ).to match(%r<#{new.name}>)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/referential_suite_spec.rb b/spec/models/referential_suite/referential_suite_spec.rb
index 771187b55..771187b55 100644
--- a/spec/models/referential_suite_spec.rb
+++ b/spec/models/referential_suite/referential_suite_spec.rb
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb
index b6728168e..a90e51e5b 100644
--- a/spec/requests/api/v1/netex_import_spec.rb
+++ b/spec/requests/api/v1/netex_import_spec.rb
@@ -2,7 +2,7 @@ RSpec.describe "NetexImport", type: :request do
describe 'POST netex_imports' do
- let( :referential ){ create :referential }
+ let( :referential ){ create :workbench_referential }
let( :workbench ){ referential.workbench }
let( :workbench_import ){ create :workbench_import }
diff --git a/spec/workers/compliance_control_set_copy_worker_spec.rb b/spec/workers/compliance_control_set_copy_worker_spec.rb
new file mode 100644
index 000000000..0ff721e75
--- /dev/null
+++ b/spec/workers/compliance_control_set_copy_worker_spec.rb
@@ -0,0 +1,35 @@
+RSpec.describe ComplianceControlSetCopyWorker do
+ let(:control_set_id) { 55 }
+ let(:referential_id) { 99 }
+ let(:check_set) { double(ComplianceCheckSet, id: 888) }
+ let(:stub_validation_request) do
+ stub_request(
+ :get,
+ "#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{check_set.id}"
+ )
+ end
+
+ before(:each) do
+ allow_any_instance_of(
+ ComplianceControlSetCopier
+ ).to receive(:copy).and_return(check_set)
+
+ stub_validation_request
+ end
+
+ it "calls ComplianceControlSetCopier" do
+ expect_any_instance_of(
+ ComplianceControlSetCopier
+ ).to receive(:copy)
+ .with(control_set_id, referential_id)
+ .and_return(check_set)
+
+ ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id)
+ end
+
+ it "calls the Java API to launch validation" do
+ ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id)
+
+ expect(stub_validation_request).to have_been_requested
+ end
+end
diff --git a/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb
index 5e34b208a..47626f5a1 100644
--- a/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb
+++ b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb
@@ -1,6 +1,5 @@
RSpec.describe WorkbenchImportWorker do
-
shared_examples_for 'corrupt zipfile data' do
subject { described_class.new }
let( :workbench_import ){ create :workbench_import, status: :pending }
@@ -23,7 +22,7 @@ RSpec.describe WorkbenchImportWorker do
message = workbench_import.messages.last
expect( message.criticity ).to eq('error')
expect( message.message_key ).to eq('corrupt_zip_file')
- expect( message.message_attributes ).to eq( 'import_name' => workbench_import.name )
+ expect( message.message_attributes ).to eq( 'source_filename' => workbench_import.file.file.file )
end
it 'does not change current step' do
diff --git a/spec/workers/workbench_import/workbench_import_worker_spec.rb b/spec/workers/workbench_import/workbench_import_worker_spec.rb
index 9f860a6b3..47ca2b4ff 100644
--- a/spec/workers/workbench_import/workbench_import_worker_spec.rb
+++ b/spec/workers/workbench_import/workbench_import_worker_spec.rb
@@ -115,8 +115,8 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do
let( :spurious ){ [spurious1, spurious2] }
let( :messages ){ double('messages') }
let( :message_attributes ){{criticity: :warning, message_key: 'inconsistent_zip_file'}}
- let( :message1_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious1.inspect}) }
- let( :message2_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious2.inspect}) }
+ let( :message1_attributes ){ message_attributes.merge(message_attributes: {'source_filename' => import.file.file.file, 'spurious_dirs' => spurious1.join(', ')}) }
+ let( :message2_attributes ){ message_attributes.merge(message_attributes: {'source_filename' => import.file.file.file, 'spurious_dirs' => spurious2.join(', ')}) }
before do
allow(import).to receive(:messages).and_return(messages)