From 7b03179f4b88f7e4f57508300722dba5db3b007d Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Mon, 14 May 2018 17:41:39 -0700 Subject: Refs #6955 Add new translation + custom delete confirmation modal --- app/assets/javascripts/modal_confirmation.js | 31 +++++++++++++++++++++++ app/decorators/network_decorator.rb | 2 +- app/decorators/referential_line_decorator.rb | 2 +- app/javascript/vehicle_journeys/actions/index.js | 10 ++++---- app/views/lines/_form.html.slim | 2 +- app/views/routing_constraint_zones/show.html.slim | 6 ++--- 6 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/modal_confirmation.js (limited to 'app') diff --git a/app/assets/javascripts/modal_confirmation.js b/app/assets/javascripts/modal_confirmation.js new file mode 100644 index 000000000..e82a8a81b --- /dev/null +++ b/app/assets/javascripts/modal_confirmation.js @@ -0,0 +1,31 @@ +$(document).ready(() => { + $.rails.allowAction = (link) => { + let message = link.data('confirm') + if (!message) return true + showConfirmModal(link) + return false + } + + let showConfirmModal = (link) => { + let message = link.data('confirm') + let html = ` ` + $(html).modal() + } +}) \ No newline at end of file diff --git a/app/decorators/network_decorator.rb b/app/decorators/network_decorator.rb index ea0f73dc2..ab90e4998 100644 --- a/app/decorators/network_decorator.rb +++ b/app/decorators/network_decorator.rb @@ -25,7 +25,7 @@ class NetworkDecorator < AF83::Decorator end instance_decorator.destroy_action_link do |l| - l.content h.destroy_link_content('networks.actions.destroy') + l.content h.t('networks.actions.destroy') l.data confirm: h.t('networks.actions.destroy_confirm') end end diff --git a/app/decorators/referential_line_decorator.rb b/app/decorators/referential_line_decorator.rb index 3ac846d76..a8c210be0 100644 --- a/app/decorators/referential_line_decorator.rb +++ b/app/decorators/referential_line_decorator.rb @@ -13,7 +13,7 @@ class ReferentialLineDecorator < AF83::Decorator instance_decorator.show_action_link instance_decorator.action_link secondary: true do |l| - l.content Chouette::Line.human_attribute_name(:footnotes) + l.content Chouette::Line.tmf(:footnotes) l.href { h.referential_line_footnotes_path(context[:referential], object) } end diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 98594083d..8ac8b5ec5 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -379,11 +379,11 @@ const actions = { vehicle_journey_at_stops: vjasWithDelta, deletable: false, selected: false, - published_journey_name: val.published_journey_name || 'non renseigné', - published_journey_identifier: val.published_journey_identifier || 'non renseigné', - company: val.company || {name: 'non renseigné'}, - transport_mode: val.route.line.transport_mode || 'undefined', - transport_submode: val.route.line.transport_submode || 'undefined' + published_journey_name: val.published_journey_name || '', + published_journey_identifier: val.published_journey_identifier || '', + company: val.company || {name: ''}, + transport_mode: val.route.line.transport_mode || '', + transport_submode: val.route.line.transport_submode || '' }) ) } diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim index 909d6512e..4623abf8a 100644 --- a/app/views/lines/_form.html.slim +++ b/app/views/lines/_form.html.slim @@ -4,7 +4,7 @@ = f.input :name = f.input :network_id, as: :select, :collection => @line_referential.networks, include_blank: false = f.input :company_id, as: :select, :collection => @line_referential.companies, include_blank: true - = f.input :secondary_company_ids, :collection => @line_referential.companies, include_blank: false, input_html: { multiple: true, 'data-select2ed': true }, label: t('activerecord.attributes.line.secondary_company') + = f.input :secondary_company_ids, :collection => @line_referential.companies, include_blank: false, input_html: { multiple: true, 'data-select2ed': true }, label: Chouette::Line.tmf(:secondary_companies) = f.input :published_name = f.input :registration_number = f.input :number diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 8c8e9b17a..55c952ae6 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -16,15 +16,15 @@ = table_builder_2 @routing_constraint_zone.route.stop_points, [ \ TableBuilderHelper::Column.new( \ - name: "Arrêts de l'itinéraire", \ + name: t('.route_stop_points'), \ attribute: 'name', \ link_to: lambda do |stop_point| \ referential_stop_area_path(@referential, stop_point.stop_area) \ end \ ), TableBuilderHelper::Column.new( \ - name: "Arrêts inclus dans l'ITL", \ - attribute: Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? 'Oui' : 'Non' } \ + name: t('.stop_points'), \ + attribute: Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? t('yes') : t('no') } \ ) \ ], sortable: false, -- cgit v1.2.3