diff options
24 files changed, 203 insertions, 125 deletions
diff --git a/app/assets/stylesheets/typography/_sboiv.sass b/app/assets/stylesheets/typography/_sboiv.sass index 6c82a5739..f694306c4 100644 --- a/app/assets/stylesheets/typography/_sboiv.sass +++ b/app/assets/stylesheets/typography/_sboiv.sass @@ -80,7 +80,7 @@ .sb-network:before content: '\e90c' -.sb-compliance-check-set:before +.sb-compliance_check_set:before, .sb-import_resource:before content: '\e90d' .sb-OAT:before @@ -104,7 +104,7 @@ .sb-LDA:before content: '\e914' -.sb-referential:before +.sb-referential:before, .sb-workbench:before content: '\e915' .sb-compliance_control_set:before diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb index 510c941a3..ec7f0d6aa 100644 --- a/app/decorators/route_decorator.rb +++ b/app/decorators/route_decorator.rb @@ -13,7 +13,7 @@ class RouteDecorator < Draper::Decorator if object.stop_points.any? links << Link.new( - content: h.t('journey_patterns.index.title'), + content: h.t('journey_patterns.actions.index'), href: [ context[:referential], context[:line], diff --git a/app/helpers/compliance_control_sets_helper.rb b/app/helpers/compliance_control_sets_helper.rb index bb2a72623..57e6d9608 100644 --- a/app/helpers/compliance_control_sets_helper.rb +++ b/app/helpers/compliance_control_sets_helper.rb @@ -4,12 +4,12 @@ module ComplianceControlSetsHelper [current_organisation, Organisation.find_by_name("STIF")].uniq end - def flotted_links ccs_id = @compliance_control_set + def floating_links ccs_id links = [new_control(ccs_id), new_block(ccs_id)] - unless links.all? &:nil? - content_tag :div, class: 'select_toolbox' do + if links.any? + content_tag :div, class: 'select_toolbox', id: 'floating-links' do content_tag :ul do - links.collect {|link| concat content_tag(:li, link, class: 'st_action with_text') unless link.nil?} + links.collect {|link| concat content_tag(:li, link, class: 'st_action with_text') if link} end end end @@ -21,8 +21,6 @@ module ComplianceControlSetsHelper concat content_tag :span, nil, class: 'fa fa-plus' concat content_tag :span, t('compliance_control_sets.actions.add_compliance_control') end - else - nil end end @@ -32,8 +30,83 @@ module ComplianceControlSetsHelper concat content_tag :span, nil, class: 'fa fa-plus' concat content_tag :span,t('compliance_control_sets.actions.add_compliance_control_block') end - else - nil end end -end
\ No newline at end of file + + def render_compliance_control_block(block=nil) + content_tag :div, class: 'row' do + content_tag :div, class: 'col-lg-12' do + content_tag :h2 do + concat transport_mode_text(block) + concat dropdown(block) if block + end + end + end + end + + def dropdown(block) + dropdown_button = content_tag :div, class: 'btn dropdown-toggle', "data-toggle": "dropdown" do + content_tag :div, nil, class: 'span fa fa-cog' + end + + dropdown_menu = content_tag :ul, class: 'dropdown-menu' do + link_1 = content_tag :li do + link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) + end + link_2 = content_tag :li do + 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')} + end + link_1 + link_2 + end + + content_tag :div, class: 'btn-group' do + dropdown_button + dropdown_menu + end + + end + + def render_compliance_controls(compliance_controls) + content_tag :div, class: 'row' do + content_tag :div, class: 'col-lg-12' do + compliance_controls.try(:any?) ? render_table_builder(compliance_controls) : render_no_controls + end + end + + end + + def render_table_builder(compliance_controls) + table = content_tag :div, class: 'select_table' do + 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 + end + metas = content_tag :div, I18n.t('compliance_control_blocks.metas.control', count: compliance_controls.count), class: 'pull-right' + table + metas + end + + def render_no_controls + content_tag :div, I18n.t('compliance_control_blocks.metas.control.zero'), class: 'alert alert-warning' + end +end diff --git a/app/helpers/multiple_selection_toolbox_helper.rb b/app/helpers/multiple_selection_toolbox_helper.rb index 85294af6d..e0a1d2dd4 100644 --- a/app/helpers/multiple_selection_toolbox_helper.rb +++ b/app/helpers/multiple_selection_toolbox_helper.rb @@ -1,7 +1,11 @@ module MultipleSelectionToolboxHelper # Box of links that floats at the bottom right of the page - def multiple_selection_toolbox(actions) + # c.f. https://projects.af83.io/issues/5206 + # #5206 method too long + def multiple_selection_toolbox(actions, collection_name:) links = content_tag :ul do + + # #5206 `if params[:controller]` mieux passer comme parametre si besoin delete_path = nil if params[:controller] = 'workbenches' @@ -15,6 +19,7 @@ module MultipleSelectionToolboxHelper method: :delete, data: { path: delete_path, + # #5206 Missing Translations confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' }, title: t("actions.#{action}") @@ -33,7 +38,9 @@ module MultipleSelectionToolboxHelper class: 'info-msg' ) - content_tag :div, '', class: 'select_toolbox noselect' do + content_tag :div, '', + class: 'select_toolbox noselect', + id: "selected-#{collection_name}-action-box" do links + label end end diff --git a/app/models/referential.rb b/app/models/referential.rb index 29efaa609..851a33653 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,3 +1,4 @@ +# coding: utf-8 class Referential < ActiveRecord::Base include DataFormatEnumerations include ObjectidFormatterSupport @@ -34,7 +35,7 @@ class Referential < ActiveRecord::Base I18n.t('referentials.errors.inconsistent_organisation', indirect_name: workbench.organisation.name, direct_name: organisation.name)) - end + end, if: :organisation belongs_to :line_referential validates_presence_of :line_referential @@ -293,11 +294,11 @@ class Referential < ActiveRecord::Base end def assign_slug - self.slug ||= "#{self.name.parameterize.gsub('-', '_')}_#{Time.now.to_i}" + self.slug ||= "#{name.parameterize.gsub('-', '_')}_#{Time.now.to_i}" if name end def assign_prefix - self.prefix = organisation.name.parameterize.gsub('-', '_') + self.prefix = organisation.name.parameterize.gsub('-', '_') if organisation end def assign_line_and_stop_area_referential diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim index c9d0583a5..5d8e3fa15 100644 --- a/app/views/compliance_check_sets/show.html.slim +++ b/app/views/compliance_check_sets/show.html.slim @@ -1,11 +1,6 @@ - breadcrumb :compliance_check_sets, @workbench, @compliance_check_set / PageHeader -= pageheader 'jeux-de-donnees', - @compliance_check_set.name, - '', - t('last_update', time: l(@compliance_check_set.updated_at, format: :short)) do - - / Below is secundary actions & optional contents (filters, ...) +- content_for :page_header_content do .row .col-lg-12.text-right.mb-sm - @compliance_check_set.action_links.each do |link| @@ -13,7 +8,23 @@ method: link.method, data: link.data, class: 'btn btn-primary' do - = link.content + = link.content + +- page_header_content_for @compliance_check_set +/ = pageheader 'jeux-de-donnees', +/ @compliance_check_set.name, +/ '', +/ t('last_update', time: l(@compliance_check_set.updated_at, format: :short)) do + + / Below is secundary actions & optional contents (filters, ...) + / .row + / .col-lg-12.text-right.mb-sm + / - @compliance_check_set.action_links.each do |link| + / = link_to link.href, + / method: link.method, + / data: link.data, + / class: 'btn btn-primary' do + / = link.content / PageContent .page_content.import_messages diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim index e6416fda4..851a4a41a 100644 --- a/app/views/compliance_control_sets/show.html.slim +++ b/app/views/compliance_control_sets/show.html.slim @@ -26,82 +26,24 @@ .col-lg-12 = render '/compliance_controls/filters' + / compliance controls without block + - if @direct_compliance_controls.try(:any?) + = render_compliance_control_block + = render_compliance_controls(@direct_compliance_controls) - - if @direct_compliance_controls.try(:any?) - .row - .col-lg-12 - h2 - = transport_mode_text() - .row - .col-lg-12 - .select_table - = table_builder_2 @direct_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 - + / compliance controls with block + - if params[:q] && params[:q][:compliance_control_block_id_eq_any].try(:present?) - @blocks_to_compliance_controls_map.each do |block, compliance_controls| + = render_compliance_control_block(block) + = render_compliance_controls(compliance_controls) + - else + - @compliance_control_set.compliance_control_blocks.each do |block| + = render_compliance_control_block(block) + = render_compliance_controls(@blocks_to_compliance_controls_map[block]) - - if compliance_controls.try(:any?) - .row - .col-lg-12 - h2 - = transport_mode_text(block) - .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 + - if params[:q].present? && !@blocks_to_compliance_controls_map.try(:any?) && @direct_compliance_controls.nil? + .row.mt-xs + .col-lg-12 + = replacement_msg t('compliance_controls.search_no_results') - = flotted_links @compliance_control_set.id + = floating_links @compliance_control_set.id diff --git a/app/views/import_resources/index.html.slim b/app/views/import_resources/index.html.slim index 1c4a5a765..728d9f4a8 100644 --- a/app/views/import_resources/index.html.slim +++ b/app/views/import_resources/index.html.slim @@ -1,4 +1,4 @@ - +- breadcrumb :import_resources, @import, @import_resources .page_content.import_messages .container-fluid .row diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 22869b2d7..af312fc08 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -61,7 +61,7 @@ links: [:show, :edit], cls: 'table has-filter has-search' - = multiple_selection_toolbox([:delete]) + = multiple_selection_toolbox([:delete], collection_name: 'referentials') = new_pagination @wbench_refs, 'pull-right' diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index 49323c91f..1081b1d66 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -19,6 +19,7 @@ en: executed: title: Executed control report %{name} show: + title: Compliance check set report table_state: "%{lines_status} lines imported on %{lines_in_compliance_check_set} in the archive" table_explanation: "These controls apply to all imported data and condition the construction of your organization's offer." metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index 0382f2937..8f1c066e7 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -10,11 +10,12 @@ fr: name_compliance_control_set: Indiquez le nom d'un jeu de contrôle error_period_filter: La date de fin doit être supérieure ou égale à la date de début0 index: - title: "Liste des jeux de contrôles" + title: "Liste des jeux de contrôles" search_no_results: Aucun rapport de contrôle ne correspond à votre recherche executed: title: Jeu de contrôles exécutés %{name} show: + title: Rapport de contrôle table_state: "%{lines_status} lignes importées sur %{lines_in_compliance_check_set} présentes dans l'archive" table_explanation: Ces contrôles s’appliquent pour toutes les données importées et conditionnent la construction de l’offre de votre organisation metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" diff --git a/config/locales/compliance_control_blocks.en.yml b/config/locales/compliance_control_blocks.en.yml index fbface6b2..150157ff3 100644 --- a/config/locales/compliance_control_blocks.en.yml +++ b/config/locales/compliance_control_blocks.en.yml @@ -18,3 +18,8 @@ fr: title: Create a control block edit: title: "Edit the control block : %{compliance_control_block}" + metas: + control: + zero: "No controls" + one: "1 control" + other: "%{count} controls" diff --git a/config/locales/compliance_control_blocks.fr.yml b/config/locales/compliance_control_blocks.fr.yml index 66df008be..1222b5c1a 100644 --- a/config/locales/compliance_control_blocks.fr.yml +++ b/config/locales/compliance_control_blocks.fr.yml @@ -18,3 +18,8 @@ fr: title: Créer un groupe de contrôle(s) edit: title: "Editer le groupe de contrôle : %{compliance_control_block}" + metas: + control: + zero: "Aucun contrôle" + one: "1 contrôle" + other: "%{count} contrôles"
\ No newline at end of file diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml index 0c476a46d..f9d7d23d2 100644 --- a/config/locales/compliance_controls.en.yml +++ b/config/locales/compliance_controls.en.yml @@ -13,6 +13,7 @@ en: route: 'Route' routing_constraint_zone: 'RoutingConstraint' vehicle_journey: 'VehicleJourney' + search_no_results: 'No compliance controls matching your query' 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})" diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml index 70227b01f..b77b4e6d4 100644 --- a/config/locales/compliance_controls.fr.yml +++ b/config/locales/compliance_controls.fr.yml @@ -4,7 +4,7 @@ fr: prefix: 'Copie de' filters: criticity: Criticité - name: "Chercher le nom ou code d'un contrôl" + name: "Chercher le nom ou code d'un contrôle" subclass: Objet subclasses: generic: 'Généric' @@ -13,6 +13,7 @@ fr: route: 'Itinéraire' routing_constraint_zone: 'ITL' vehicle_journey: 'Course' + search_no_results: 'Aucun contrôle ne correspond à votre recherche' 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})" diff --git a/config/locales/imports.en.yml b/config/locales/imports.en.yml index 926201150..0bb54d90d 100644 --- a/config/locales/imports.en.yml +++ b/config/locales/imports.en.yml @@ -63,8 +63,8 @@ en: import: resources: "File to import" created_at: "Created on" - started_at: Started at - name: Name + started_at: "Started at" + name: "Name" status: "Status" creator: "Creator" references_type: "Data to be imported" diff --git a/config/locales/journey_patterns.fr.yml b/config/locales/journey_patterns.fr.yml index e989d5820..fb69f4190 100644 --- a/config/locales/journey_patterns.fr.yml +++ b/config/locales/journey_patterns.fr.yml @@ -6,6 +6,7 @@ fr: vehicle_journeys_count: "Courses: %{count}" vehicle_journey_at_stops: "Horaires des courses" actions: + index: "Missions" new: "Ajouter une mission" edit: "Editer cette mission" destroy: "Supprimer cette mission" diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb index bcb989cdc..36dc5c2a9 100644 --- a/spec/features/compliance_control_sets_spec.rb +++ b/spec/features/compliance_control_sets_spec.rb @@ -1,4 +1,5 @@ RSpec.describe "ComplianceControlSets", type: :feature do + include TransportModeHelper login_user @@ -12,7 +13,7 @@ RSpec.describe "ComplianceControlSets", type: :feature do } before do - blox.first.update transport_mode: 'bus', transport_submode: 'bus' + blox.first.update transport_mode: 'bus', transport_submode: 'nightBus' blox.second.update transport_mode: 'train', transport_submode: 'train' make_control @@ -21,6 +22,9 @@ RSpec.describe "ComplianceControlSets", type: :feature do end describe 'show' do + let( :control_button_href ){ select_type_compliance_control_set_compliance_controls_path(control_set) } + let( :new_group_button_href ) { new_compliance_control_set_compliance_control_block_path(control_set) } + before do visit compliance_control_set_path( control_set ) end @@ -40,6 +44,13 @@ RSpec.describe "ComplianceControlSets", type: :feature do controls.each do | control | expect( page ).to have_content(control.code) end + + # Floating Buttons + within '.select_toolbox#floating-links' do + expect( page ).to have_link("Contrôle", href: control_button_href) + expect( page ).to have_link("Groupe de contrôles", href: new_group_button_href) + end + end it 'we can apply a severity filter' do @@ -75,6 +86,13 @@ RSpec.describe "ComplianceControlSets", type: :feature do end end + context "wthout filter on compliance control block applied" do + it "we can see empty blocks" do + blox.first.compliance_controls.destroy_all + expect(page).to have_content (transport_mode_text(blox.first) ) + end + end + end def make_control ccblock=nil, times: 1, severity: :warning diff --git a/spec/features/routes_permissions_spec.rb b/spec/features/routes_permissions_spec.rb index 36c13b24a..6d3db9d55 100644 --- a/spec/features/routes_permissions_spec.rb +++ b/spec/features/routes_permissions_spec.rb @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -require 'spec_helper' - describe "Routes", :type => :feature do login_user diff --git a/spec/features/workbenches_permissions_spec.rb b/spec/features/workbenches/workbenches_permissions_spec.rb index d58293538..d58293538 100644 --- a/spec/features/workbenches_permissions_spec.rb +++ b/spec/features/workbenches/workbenches_permissions_spec.rb diff --git a/spec/features/workbenches/workbenches_show_modal_actions_spec.rb b/spec/features/workbenches/workbenches_show_modal_actions_spec.rb new file mode 100644 index 000000000..ebc48b485 --- /dev/null +++ b/spec/features/workbenches/workbenches_show_modal_actions_spec.rb @@ -0,0 +1,29 @@ +RSpec.describe 'Workbenches', type: :feature do + login_user + + let(:line_ref) { create :line_referential } + let(:line) { create :line, line_referential: line_ref } + let(:ref_metadata) { create(:referential_metadata, lines: [line]) } + + let(:workbench) { create :workbench, line_referential: line_ref, organisation: @user.organisation } + let!(:referential) { create :workbench_referential, + workbench: workbench, + metadatas: [ref_metadata], + organisation: @user.organisation } + + + describe 'show' do + context 'modal action' do + it 'expected behavior' do + visit workbench_path(workbench) + + # Modal Action Box: is present + within( :css, ".select_toolbox#selected-referentials-action-box span.info-msg > span") do + expect( page ).to have_content("0") + end + + end + end + end + +end diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches/workbenches_show_spec.rb index f1151a67b..f1151a67b 100644 --- a/spec/features/workbenches_spec.rb +++ b/spec/features/workbenches/workbenches_show_spec.rb diff --git a/spec/helpers/compliance_control_sets_helper_spec.rb b/spec/helpers/compliance_control_sets_helper_spec.rb deleted file mode 100644 index 981368561..000000000 --- a/spec/helpers/compliance_control_sets_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the ComplianceControlSetsHelper. For example: -# -# describe ComplianceControlSetsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe ComplianceControlSetsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/chouette/journey_frequency_spec.rb b/spec/models/chouette/journey_frequency_spec.rb index 2e2088a0c..549439d90 100644 --- a/spec/models/chouette/journey_frequency_spec.rb +++ b/spec/models/chouette/journey_frequency_spec.rb @@ -5,7 +5,7 @@ describe Chouette::JourneyFrequency, type: :model do describe '#create' do context 'when valid' do - it 'should be created' do + xit 'should be created', '#5209 probably to be removed with Dead Code Elimination' do journey_frequency = build(:journey_frequency) journey_frequency.vehicle_journey_id = vehicle_journey.id expect(journey_frequency.save!).to be |
