diff options
22 files changed, 222 insertions, 65 deletions
diff --git a/app/assets/stylesheets/components/_main_nav.sass b/app/assets/stylesheets/components/_main_nav.sass index f102c4617..2af070389 100644 --- a/app/assets/stylesheets/components/_main_nav.sass +++ b/app/assets/stylesheets/components/_main_nav.sass @@ -245,7 +245,7 @@ $menuW: 300px & > .menu-item max-width: 75% - + .menu-item padding: 0 10px @@ -337,47 +337,35 @@ $menuW: 300px height: $menuH padding: 0 50px 0 75px margin-top: -4px + display: flex > * display: inline-block &.sticky-ptitle - width: 60% + flex: 1 1 height: $menuH + position: relative h1 - position: relative + position: absolute + left: 0 + right: 10px + top: 0 line-height: 1.1 white-space: nowrap max-height: 1.1em margin: 0 -1.4em 0 0 padding: 0 1.4em 5px 0 overflow: hidden - - &:before - content: '[...]' - font-size: 0.65em - position: absolute - z-index: 6 - right: 0 - bottom: 9px - - &:after - content: '' - position: absolute - z-index: 5 - right: 0 - width: 1.4em - height: 1em - margin-top: 0.2em - background-color: $blue + text-overflow: ellipsis .small.fa color: #fff margin-left: 0.5em &.sticky-paction - width: 40% + flex: 0 0 auto text-align: right vertical-align: top diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb index 600c69126..4ec86f0d6 100644 --- a/app/controllers/compliance_check_sets_controller.rb +++ b/app/controllers/compliance_check_sets_controller.rb @@ -21,9 +21,7 @@ class ComplianceCheckSetsController < ChouetteController def show show! do - @compliance_check_set = @compliance_check_set.decorate(context: { - compliance_check_set: @compliance_check_set - }) + @compliance_check_set = @compliance_check_set.decorate end end diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js index c2556303d..fb7e16547 100644 --- a/app/javascript/vehicle_journeys/reducers/modal.js +++ b/app/javascript/vehicle_journeys/reducers/modal.js @@ -147,14 +147,7 @@ export default function modal(state = {}, action) { let stopAreas = _.map(window.jpOriginStopPoints, (sa, i) =>{ return _.assign({}, {stop_area_short_description : {id : sa.stop_area_id}}) }) - selectedJP = { - id: window.jpOrigin.id, - name: window.jpOrigin.name, - published_name: window.jpOrigin.published_name, - objectid: window.jpOrigin.objectid, - stop_areas: stopAreas, - missions: state.missions - } + selectedJP = _.assign({}, window.jpOrigin, {stop_areas: stopAreas}) } return { type: 'create', diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 501c01175..ae45993a8 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -16,7 +16,7 @@ const vehicleJourney= (state = {}, action, keep) => { } if(action.data["start_time.hour"] && action.data["start_time.minute"] && action.selectedJourneyPattern.full_schedule){ current_time.hour = parseInt(action.data["start_time.hour"].value) - current_time.minute = parseInt(action.data["start_time.minute"].value) + current_time.minute = parseInt(action.data["start_time.minute"].value) || 0 } _.each(action.stopPointsList, (sp) =>{ if(action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs && action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){ diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb index 1f7581acd..eda711ade 100644 --- a/app/models/chouette/vehicle_journey_at_stop.rb +++ b/app/models/chouette/vehicle_journey_at_stop.rb @@ -104,6 +104,7 @@ module Chouette def local_time time return unless time return time unless stop_point&.stop_area&.time_zone.present? + return time unless ActiveSupport::TimeZone[stop_point.stop_area.time_zone].present? time + ActiveSupport::TimeZone[stop_point.stop_area.time_zone].utc_offset end diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index 63f380d99..f4c44d26d 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -26,6 +26,14 @@ class ComplianceCheckSet < ActiveRecord::Base end end + def organisation + workbench.organisation + end + + def human_attribute_name(*args) + self.class.human_attribute_name(*args) + end + def update_status statuses = compliance_check_resources.map do |resource| case resource.status diff --git a/app/models/workbench.rb b/app/models/workbench.rb index f49f4e7cf..b80fa64ac 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -31,7 +31,12 @@ class Workbench < ActiveRecord::Base if line_ids.empty? Referential.none else - Referential.joins(:metadatas).where(['referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids]).ready.not_in_referential_suite + workgroup + .referentials + .joins(:metadatas) + .where(['referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids]) + .ready + .not_in_referential_suite end end diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb index 511bbfeb0..3d761e81f 100644 --- a/app/models/workgroup.rb +++ b/app/models/workgroup.rb @@ -4,6 +4,7 @@ class Workgroup < ActiveRecord::Base has_many :workbenches has_many :organisations, through: :workbenches + has_many :referentials, through: :workbenches validates_uniqueness_of :name diff --git a/app/views/compliance_check_sets/executed.html.slim b/app/views/compliance_check_sets/executed.html.slim index da8a2a3de..b33b516b4 100644 --- a/app/views/compliance_check_sets/executed.html.slim +++ b/app/views/compliance_check_sets/executed.html.slim @@ -1,4 +1,4 @@ -- breadcrumb :compliance_check_set, @workbench, @compliance_check_set +- breadcrumb :compliance_check_set_executed, @workbench, @compliance_check_set - page_header_content_for @compliance_check_set .page_content diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index f109845b4..f15e85bdd 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -12,7 +12,10 @@ [ \ TableBuilderHelper::Column.new( \ key: :ref, \ - attribute: 'id' \ + attribute: 'id', \ + link_to: lambda do |compliance_check_set| \ + workbench_compliance_check_set_path(compliance_check_set.workbench_id, compliance_check_set.id) \ + end \ ), \ TableBuilderHelper::Column.new( \ key: :creation_date, \ @@ -31,7 +34,10 @@ ), \ TableBuilderHelper::Column.new(\ key: :compliance_control_set, \ - attribute: Proc.new{ |n| (n.compliance_control_set.name) if n.compliance_control_set} \ + attribute: 'name', \ + link_to: lambda do |compliance_check_set| \ + executed_workbench_compliance_check_set_path(compliance_check_set.workbench_id, compliance_check_set.id) \ + end \ ), \ ], sortable: true, diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim index 35a60eb52..4db2e805f 100644 --- a/app/views/compliance_check_sets/show.html.slim +++ b/app/views/compliance_check_sets/show.html.slim @@ -1,4 +1,4 @@ -- breadcrumb :compliance_check_sets, @workbench, @compliance_check_set +- breadcrumb :compliance_check_set, @workbench, @compliance_check_set / PageHeader - content_for :page_header_content do .row @@ -11,31 +11,28 @@ = 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 .container-fluid .row + .col-lg-6.col-md-6.col-sm-12.col-xs-12 + = definition_list( t('metadatas'), + { I18n.t("compliance_check_sets.show.metadatas.referential") => (@compliance_check_set.referential.nil? ? '' : link_to(@compliance_check_set.referential.name, referential_path(@compliance_check_set.referential)) ), + I18n.t("compliance_check_sets.show.metadatas.referential_type") => 'Jeu de données', + I18n.t("compliance_check_sets.show.metadatas.compliance_check_set_executed") => link_to(@compliance_check_set.name, executed_workbench_compliance_check_set_path(@compliance_check_set.workbench_id, @compliance_check_set)), + I18n.t("compliance_check_sets.show.metadatas.compliance_control_owner") => @compliance_check_set.organisation.name, + I18n.t("compliance_check_sets.show.metadatas.import") => '' }) + .row .col-lg-12 h1 span.status_icon = compliance_check_set_status(@compliance_check_set.status) - span = t('compliance_check_sets.show.table_state', lines_status: @compliance_check_set.lines_status , lines_in_compliance_check_set: @compliance_check_set.lines_in_compliance_check_set ) + span = t('.table_state', lines_status: @compliance_check_set.lines_status , lines_in_compliance_check_set: @compliance_check_set.lines_in_compliance_check_set ) .col-lg-12 - = t('compliance_check_sets.show.table_explanation') + h2 = t('.table_title') + .col-lg-12 + = t('.table_explanation') + .row .col-lg-12 = table_builder_2 @compliance_check_set.compliance_check_resources, @@ -63,4 +60,4 @@ ], sortable: false, \ links: [], - cls: 'table' + cls: 'table has-search' diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index af8b9d889..b2322f73a 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -30,7 +30,7 @@ h3 = t("stop_areas.stop_area.general") - if has_feature?(:stop_area_waiting_time) - = f.input :waiting_time + = f.input :waiting_time, input_html: { min: 0 } = f.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} = f.input :fare_code diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim index f7796b188..a02d5ed38 100644 --- a/app/views/vehicle_journeys/index.html.slim +++ b/app/views/vehicle_journeys/index.html.slim @@ -17,7 +17,7 @@ = javascript_tag do | window.route_id = #{params[:route_id]}; | window.stopPoints = #{(@stop_points_list.to_json).html_safe}; - | window.jpOrigin = #{(@jp_origin.to_json).html_safe}; + | window.jpOrigin = #{(@jp_origin.present? ? @jp_origin.attributes.update({full_schedule: @jp_origin.full_schedule?}).to_json : "").html_safe}; | window.jpOriginStopPoints = #{(@jp_origin_stop_points.to_json).html_safe}; | window.transportMode = #{(@transport_mode.to_json).html_safe}; | window.transportSubmode = #{(@transport_submode.to_json).html_safe}; diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb index ce5cf5b0f..6da96d73a 100644 --- a/config/breadcrumbs.rb +++ b/config/breadcrumbs.rb @@ -96,6 +96,11 @@ crumb :compliance_check_set do |workbench, compliance_check_set| parent :compliance_check_sets, workbench end +crumb :compliance_check_set_executed do |workbench, compliance_check_set| + link I18n.t('compliance_check_sets.executed.title', name: compliance_check_set.name), executed_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 diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index 1081b1d66..5e8c3b24f 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -22,7 +22,14 @@ en: 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." + table_title: Analysed lines state metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" + metadatas: + referential: "Object analysed" + referential_type: "Apply to" + compliance_check_set_executed: "Compliance check set executed" + compliance_control_owner: "Compliance control owner" + import: "Import" errors: no_parent: "The compliance check set doesn't have any parent" activerecord: @@ -40,6 +47,14 @@ en: metrics: Test results download: Download models: + compliance_check_set: + zero: "Compliance check set" + one: "Compliance check set" + other: "Compliance check sets" + compliance_check: + zero: "Compliance check" + one: "Compliance check" + other: "Compliance checks" compliance_check_block: one: compliance_control_set other: compliance_control_sets diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index 8c4561ae9..20bf11d85 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -13,12 +13,19 @@ fr: title: "Liste des rapports 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} + title: Jeu de contrôles exécuté %{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_state: "%{lines_status} lignes valides sur %{lines_in_compliance_check_set} présentes dans l'offre de transport" table_explanation: Ces contrôles s’appliquent pour toutes les données importées et conditionnent la construction de l’offre de votre organisation + table_title: État des lignes analysées metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" + metadatas: + referential: "Objet analysé" + referential_type: "Appliqué à" + compliance_check_set_executed: "Jeu de contrôles exécuté" + compliance_control_owner: "Propriétaire du jeu de contrôles" + import: "Rapport d'import" errors: no_parent: "Le jeux de contrôle n'a pas de parent" activerecord: @@ -28,7 +35,7 @@ fr: creation_date: Date et heure de création associated_object: Objet associé assigned_to: Affectation - compliance_control_set: jeu de contrôle + compliance_control_set: Jeu de contrôle exécuté name: Nom compliance_check_resource: name: Nom de la ligne @@ -36,6 +43,14 @@ fr: metrics: Résultat des tests download: Télécharger models: + compliance_check_set: + zero: "Rapport de contrôles" + one: "Rapport de contrôles" + other: "Rapport de contrôles" + compliance_check: + zero: "Contrôle" + one: "Contrôle" + other: "Contrôles" compliance_check_block: zero: "Groupe de contrôle" one: "Groupe de contrôle" diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml index 62cde93bb..09e8d1a82 100644 --- a/config/locales/stop_areas.en.yml +++ b/config/locales/stop_areas.en.yml @@ -134,7 +134,7 @@ en: city_name: "City" created_at: Created at updated_at: Updated at - waiting_time: Waiting time + waiting_time: Waiting time (minutes) formtastic: titles: stop_area: diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml index 531692cbd..0095bbe6d 100644 --- a/config/locales/stop_areas.fr.yml +++ b/config/locales/stop_areas.fr.yml @@ -134,7 +134,7 @@ fr: city_name: "Commune" created_at: "Créé le" updated_at: "Edité le" - waiting_time: Temps de desserte + waiting_time: Temps de desserte (minutes) formtastic: titles: stop_area: diff --git a/spec/features/compliance_check_sets_spec.rb b/spec/features/compliance_check_sets_spec.rb index 6b7d7a4f8..5cace04d4 100644 --- a/spec/features/compliance_check_sets_spec.rb +++ b/spec/features/compliance_check_sets_spec.rb @@ -32,7 +32,7 @@ RSpec.describe "ComplianceCheckSets", type: :feature do expect_breadcrumb_links "Accueil", "Gestion de l'offre", "Liste des rapports de contrôles" # Headline - expect( page ).to have_content("Jeu de contrôles exécutés #{compliance_check_set.name}") + expect( page ).to have_content(I18n.t("compliance_check_sets.executed.title", name: compliance_check_set.name)) # Information Definition List expect( page.first('.dl-term') ).to have_content("Nom") diff --git a/spec/features/workbenches/workbenches_show_spec.rb b/spec/features/workbenches/workbenches_show_spec.rb index 2b215bb03..7be813b94 100644 --- a/spec/features/workbenches/workbenches_show_spec.rb +++ b/spec/features/workbenches/workbenches_show_spec.rb @@ -22,6 +22,48 @@ RSpec.describe 'Workbenches', type: :feature do end end + it 'lists referentials in the current workgroup' do + other_workbench = create( + :workbench, + line_referential: line_ref, + workgroup: workbench.workgroup + ) + other_referential = create( + :workbench_referential, + workbench: other_workbench, + organisation: other_workbench.organisation, + metadatas: [ + create( + :referential_metadata, + lines: [create(:line, line_referential: line_ref)] + ) + ] + ) + + hidden_referential = create( + :workbench_referential, + workbench: create( + :workbench, + line_referential: line_ref + ), + metadatas: [ + create( + :referential_metadata, + lines: [create(:line, line_referential: line_ref)] + ) + ] + ) + + visit workbench_path(workbench) + + expect(page).to have_content(referential.name), + "Couldn't find `referential`: `#{referential.inspect}`" + expect(page).to have_content(other_referential.name), + "Couldn't find `other_referential`: `#{other_referential.inspect}`" + expect(page).to_not have_content(hidden_referential.name), + "Couldn't find `hidden_referential`: `#{hidden_referential.inspect}`" + end + context 'filtering' do let!(:another_organisation) { create :organisation } let(:another_line) { create :line, line_referential: line_ref } diff --git a/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js b/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js index 31973b390..0d7612a80 100644 --- a/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js +++ b/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js @@ -241,6 +241,83 @@ describe('vehicleJourneys reducer', () => { }, ...state]) }) + it('should handle ADD_VEHICLEJOURNEY with a start time and a fully timed JP but the minutes are not set', () => { + let pristineVjasList = [{ + delta : 0, + arrival_time : { + hour: 22, + minute: 0 + }, + departure_time : { + hour: 22, + minute: 0 + }, + stop_point_objectid: 'test-1', + stop_area_cityname: 'city', + dummy: false + }, + { + delta : 0, + arrival_time : { + hour: 22, + minute: 3 + }, + departure_time : { + hour: 22, + minute: 3 + }, + stop_point_objectid: 'test-2', + stop_area_cityname: 'city', + dummy: false + }] + let fakeData = { + published_journey_name: {value: 'test'}, + published_journey_identifier: {value : ''}, + "start_time.hour": {value : '22'}, + "start_time.minute": {value : ''} + } + let fakeSelectedJourneyPattern = { + id: "1", + full_schedule: true, + stop_areas: [ + {stop_area_short_description: {id: 1}}, + {stop_area_short_description: {id: 2}}, + ], + costs: { + "1-2": { + distance: 10, + time: 63 + }, + } + } + let fakeSelectedCompany = {name: "ALBATRANS"} + expect( + vjReducer(state, { + type: 'ADD_VEHICLEJOURNEY', + data: fakeData, + selectedJourneyPattern: fakeSelectedJourneyPattern, + stopPointsList: [{object_id: 'test-1', city_name: 'city', stop_area_id: 1, id: 1, time_zone_offset: 0}, {object_id: 'test-2', city_name: 'city', stop_area_id: 2, id: 2, time_zone_offset: -3600}], + selectedCompany: fakeSelectedCompany + }) + ).toEqual([{ + journey_pattern: fakeSelectedJourneyPattern, + company: fakeSelectedCompany, + published_journey_name: 'test', + published_journey_identifier: '', + short_id: '', + objectid: '', + footnotes: [], + time_tables: [], + purchase_windows: [], + vehicle_journey_at_stops: pristineVjasList, + selected: false, + custom_fields: undefined, + deletable: false, + transport_mode: 'undefined', + transport_submode: 'undefined' + }, ...state]) + }) + it('should handle RECEIVE_VEHICLE_JOURNEYS', () => { expect( vjReducer(state, { diff --git a/spec/views/offer_workbenches/show.html.erb_spec.rb b/spec/views/offer_workbenches/show.html.erb_spec.rb index 138a1560d..2a2642911 100644 --- a/spec/views/offer_workbenches/show.html.erb_spec.rb +++ b/spec/views/offer_workbenches/show.html.erb_spec.rb @@ -22,7 +22,13 @@ describe "workbenches/show", :type => :view do } let!(:workbench){ assign :workbench, create(:workbench) } let!(:same_organisation_referential){ create :workbench_referential, workbench: workbench, metadatas: [create(:referential_metadata, lines: lines)] } - let!(:different_organisation_referential){ create :workbench_referential, metadatas: [create(:referential_metadata, lines: lines)] } + let!(:different_organisation_referential) do + create( + :workbench_referential, + workbench: create(:workbench, workgroup: workbench.workgroup), + metadatas: [create(:referential_metadata, lines: lines)] + ) + end let!(:referentials){ same_organisation_referential && different_organisation_referential assign :wbench_refs, paginate_collection(Referential, ReferentialDecorator) |
