diff options
Diffstat (limited to 'app')
65 files changed, 493 insertions, 358 deletions
| 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 = `<div class="modal fade" id="confirmationDialog" tabindex="1" role="dialog"> +        <div class="modal-container"> +          <div class="modal-dialog"> +            <div class="modal-content"> +              <div class="modal-header"> +                <h4 class="modal-title"> ${I18n.t('warning')} </h4> +              </div> +              <div class="modal-body"> +                <p>${message}</p> +              </div> +              <div class="modal-footer"> +                <a data-dismiss="modal" class="btn">${I18n.t('cancel')}</a> +                <a data-dismiss="modal" class="btn btn-primary" data-method=${link.data('method')} href=${link.attr('href')}>${I18n.t('ok')}</a> +              </div> +            </div> +          </div> +        </div> +      </div> ` +    $(html).modal() +  } +})
\ No newline at end of file diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass index e22507dcf..b230991fb 100644 --- a/app/assets/stylesheets/modules/_vj_collection.sass +++ b/app/assets/stylesheets/modules/_vj_collection.sass @@ -22,7 +22,7 @@            display: block            height: 100% -          > span +          > span:not(.small)              position: absolute              display: block              line-height: 1em @@ -219,9 +219,17 @@          .form-control            border-color: #ccc -  .consolidated-view    $highlighted: #d4ba32 +  .togglable +    &.ready +      transition: all 0.5s +      &:not(.open) +        min-height: 0 !important +        padding: 0 !important +        margin: 0 !important +        border: none +    .line      & > .head        font-size: 2em @@ -257,13 +265,15 @@          .vehicle-journeys            display: block            overflow: hidden -          transition: height 0.5s, margin-bottom 0.5s            margin-bottom: 0px            & > *              display: inline-block +          .t2e-item-list +            overflow: scroll              & > *                overflow: hidden                min-width: 0 +              max-width: none            &.open              margin-bottom: 40px @@ -298,6 +308,11 @@    .table-2entries > .t2e-head > .td > div > span::after      bottom: -6px !important +  .table-2entries > .t2e-head > .td > div > span +    text-overflow: ellipsis +    overflow: hidden +    white-space: nowrap +    .table.table-2entries .t2e-item-list .t2e-item      background-color: #F9F9F9 diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 2c32ed3a5..c359dfd6d 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -44,9 +44,9 @@ class CompaniesController < ChouetteController      ids = @q.result(:distinct => true).pluck(:id)      scope = scope.where(id: ids)      if sort_column && sort_direction -      @companies ||= scope.order(sort_column + ' ' + sort_direction).paginate(:page => params[:page]) +      @companies ||= scope.order("lower(#{sort_column})" + ' ' + sort_direction).paginate(:page => params[:page])      else -      @companies ||= scope.order(:name).paginate(:page => params[:page]) +      @companies ||= scope.order('lower(name)').paginate(:page => params[:page])      end    end diff --git a/app/controllers/compliance_check_messages_controller.rb b/app/controllers/compliance_check_messages_controller.rb index 36745981e..db551cca5 100644 --- a/app/controllers/compliance_check_messages_controller.rb +++ b/app/controllers/compliance_check_messages_controller.rb @@ -7,7 +7,7 @@ class ComplianceCheckMessagesController < ChouetteController    def index      index! do |format|        format.csv { -        send_data ComplianceCheckMessageExport.new(compliance_check_messages: collection).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true, server_url: request.base_url) , :filename => "compliance_check_set_errors_#{line_code}_#{Date.today.to_s}.csv" +        send_data ComplianceCheckMessageExport.new(compliance_check_messages: collection).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true, server_url: request.base_url) , :filename => "#{t('compliance_check_messages.compliance_check_set_errors')}_#{line_code}_#{Time.now.strftime('%d-%m-%Y_%H-%M')}.csv"        }      end    end @@ -22,10 +22,10 @@ class ComplianceCheckMessagesController < ChouetteController    end    def compliance_check_resource -    ComplianceCheckResource.find(params[:compliance_check_resource_id])  +    ComplianceCheckResource.find(params[:compliance_check_resource_id])    end -  private  +  private    def line_code      Chouette::Line.find_by_objectid("#{compliance_check_resource.reference}").get_objectid.local_id diff --git a/app/controllers/import_messages_controller.rb b/app/controllers/import_messages_controller.rb index e9a071177..9f61940a3 100644 --- a/app/controllers/import_messages_controller.rb +++ b/app/controllers/import_messages_controller.rb @@ -9,7 +9,7 @@ class ImportMessagesController < ChouetteController    def index      index! do |format|        format.csv { -        send_data Import::MessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true) , :filename => "import_errors_#{@import_resource.name.gsub('.xml', '')}_#{Date.today.to_s}.csv" +        send_data Import::MessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true) , :filename => "#{t('import_messages.import_errors')}_#{@import_resource.name.gsub('.xml', '')}_#{Time.now.strftime("%d-%m-%Y_%H-%M")}.csv"        }      end    end diff --git a/app/controllers/referential_vehicle_journeys_controller.rb b/app/controllers/referential_vehicle_journeys_controller.rb index 111d39c2b..917326a6d 100644 --- a/app/controllers/referential_vehicle_journeys_controller.rb +++ b/app/controllers/referential_vehicle_journeys_controller.rb @@ -23,7 +23,7 @@ class ReferentialVehicleJourneysController < ChouetteController    private    def collection -    @q ||= end_of_association_chain +    @q ||= end_of_association_chain.select("vehicle_journeys.id", "vehicle_journeys.journey_pattern_id", "vehicle_journeys.route_id", "vehicle_journeys.objectid", "vehicle_journeys.published_journey_name")      @q = @q.with_stop_area_ids(params[:q][:stop_area_ids]) if params[:q] && params[:q][:stop_area_ids]      @q = ransack_period_range(scope: @q, error_message:  t('vehicle_journeys.errors.purchase_window'), query: :in_purchase_window, prefix: :purchase_window)      @q = ransack_period_range(scope: @q, error_message:  t('vehicle_journeys.errors.time_table'), query: :with_matching_timetable, prefix: :time_table) diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 734152c64..38363e8ef 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -120,7 +120,6 @@ class StopAreasController < ChouetteController    def collection      scope = parent.present? ? parent.stop_areas : referential.stop_areas -    scope = ransack_status(scope)      @q = scope.search(params[:q])      if sort_column && sort_direction @@ -206,24 +205,4 @@ class StopAreasController < ChouetteController      ] + permitted_custom_fields_params(Chouette::StopArea.custom_fields(stop_area_referential.workgroup))      params.require(:stop_area).permit(fields)    end - -   # Fake ransack filter -  def ransack_status scope -    return scope unless params[:q].try(:[], :status) -    return scope if params[:q][:status].values.uniq.length == 1 - -    @status = { -      in_creation: params[:q][:status]['in_creation'] == 'true', -      confirmed: params[:q][:status]['confirmed'] == 'true', -      deactivated: params[:q][:status]['deactivated'] == 'true', -    } - -    scope = Chouette::StopArea.where( -      "confirmed_at #{(@status[:confirmed] || @status[:deactivated]) ? "IS NOT NULL" : "IS NULL"} -      AND deleted_at #{@status[:deactivated] ? "IS NOT NULL" : "IS NULL"}" -      ) - -    params[:q].delete :status -    scope -  end  end diff --git a/app/decorators/compliance_control_decorator.rb b/app/decorators/compliance_control_decorator.rb index fd2dbd9ce..7cdb4a890 100644 --- a/app/decorators/compliance_control_decorator.rb +++ b/app/decorators/compliance_control_decorator.rb @@ -5,7 +5,7 @@ class ComplianceControlDecorator < AF83::Decorator    with_instance_decorator do |instance_decorator|      instance_decorator.show_action_link do |l| -      l.content h.t('compliance_control_sets.actions.show') +      l.content t('compliance_control_sets.actions.show')        l.href do          h.compliance_control_set_compliance_control_path(            object.compliance_control_set.id, @@ -17,7 +17,7 @@ class ComplianceControlDecorator < AF83::Decorator      instance_decorator.edit_action_link      instance_decorator.destroy_action_link do |l| -      l.data confirm: h.t('compliance_controls.actions.destroy_confirm') +      l.data confirm: t('compliance_controls.actions.destroy_confirm')      end    end diff --git a/app/decorators/compliance_control_set_decorator.rb b/app/decorators/compliance_control_set_decorator.rb index b16a06886..ad38c492c 100644 --- a/app/decorators/compliance_control_set_decorator.rb +++ b/app/decorators/compliance_control_set_decorator.rb @@ -20,7 +20,7 @@ class ComplianceControlSetDecorator < AF83::Decorator      instance_decorator.destroy_action_link do |l|        l.content h.destroy_link_content        l.href { h.compliance_control_set_path(object.id) } -      l.data confirm: h.t('compliance_control_sets.actions.destroy_confirm') +      l.data confirm: t('compliance_control_sets.actions.destroy_confirm')      end    end  end diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index 077978c36..0fdb7cc0b 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -44,7 +44,7 @@ class LineDecorator < AF83::Decorator        l.content  { h.deactivate_link_content('lines.actions.deactivate') }        l.href     { h.deactivate_line_referential_line_path(context[:line_referential], object) }        l.method   :put -      l.data     confirm: h.t('lines.actions.deactivate_confirm') +      l.data     {{ confirm: h.t('lines.actions.deactivate_confirm') }}        l.add_class "delete-action"      end @@ -52,13 +52,13 @@ class LineDecorator < AF83::Decorator        l.content  { h.activate_link_content('lines.actions.activate') }        l.href     { h.activate_line_referential_line_path(context[:line_referential], object) }        l.method   :put -      l.data     confirm: h.t('lines.actions.activate_confirm') +      l.data     {{ confirm: h.t('lines.actions.activate_confirm') }}        l.add_class "delete-action"      end      instance_decorator.destroy_action_link do |l|        l.content  { h.destroy_link_content('lines.actions.destroy') } -      l.data     confirm: h.t('lines.actions.destroy_confirm') +      l.data     {{ confirm: h.t('lines.actions.destroy_confirm') }}        l.add_class "delete-action"      end    end diff --git a/app/decorators/network_decorator.rb b/app/decorators/network_decorator.rb index ea0f73dc2..55cd37082 100644 --- a/app/decorators/network_decorator.rb +++ b/app/decorators/network_decorator.rb @@ -25,8 +25,8 @@ class NetworkDecorator < AF83::Decorator      end      instance_decorator.destroy_action_link do |l| -      l.content h.destroy_link_content('networks.actions.destroy') -      l.data confirm: h.t('networks.actions.destroy_confirm') +      l.content { h.destroy_link_content('networks.actions.destroy') } +      l.data {{ confirm: h.t('networks.actions.destroy_confirm') }}      end    end  end diff --git a/app/decorators/purchase_window_decorator.rb b/app/decorators/purchase_window_decorator.rb index 9b58577b2..8e6ca9d36 100644 --- a/app/decorators/purchase_window_decorator.rb +++ b/app/decorators/purchase_window_decorator.rb @@ -15,7 +15,7 @@ class PurchaseWindowDecorator < AF83::Decorator      instance_decorator.edit_action_link      instance_decorator.destroy_action_link do |l| -      l.data confirm: h.t('purchase_windows.actions.destroy_confirm') +      l.data confirm: t('purchase_windows.actions.destroy_confirm')      end    end diff --git a/app/decorators/referential_line_decorator.rb b/app/decorators/referential_line_decorator.rb index 3ac846d76..4416e133e 100644 --- a/app/decorators/referential_line_decorator.rb +++ b/app/decorators/referential_line_decorator.rb @@ -13,12 +13,12 @@ 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      instance_decorator.action_link secondary: true do |l| -      l.content h.t('routing_constraint_zones.index.title') +      l.content t('routing_constraint_zones.index.title')        l.href do          h.referential_line_routing_constraint_zones_path(            scope, @@ -36,7 +36,7 @@ class ReferentialLineDecorator < AF83::Decorator        },        secondary: true      ) do |l| -      l.content h.t('routes.actions.new') +      l.content t('routes.actions.new')        l.href { h.new_referential_line_route_path(scope, object) }      end    end diff --git a/app/decorators/referential_network_decorator.rb b/app/decorators/referential_network_decorator.rb index c508452c0..f8c656e7c 100644 --- a/app/decorators/referential_network_decorator.rb +++ b/app/decorators/referential_network_decorator.rb @@ -20,8 +20,8 @@ class ReferentialNetworkDecorator < AF83::Decorator      end      instance_decorator.destroy_action_link do |l| -      l.content h.destroy_link_content('networks.actions.destroy') -      l.data confirm: h.t('networks.actions.destroy_confirm') +      l.content { h.destroy_link_content('networks.actions.destroy') } +      l.data confirm: t('networks.actions.destroy_confirm')      end    end  end diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb index 646bc1620..801e139b0 100644 --- a/app/decorators/route_decorator.rb +++ b/app/decorators/route_decorator.rb @@ -18,7 +18,7 @@ class RouteDecorator < AF83::Decorator        if: ->() { object.stop_points.any? },        secondary: :show      ) do |l| -      l.content h.t('journey_patterns.actions.index') +      l.content t('journey_patterns.actions.index')        l.href do          [            context[:referential], @@ -33,7 +33,7 @@ class RouteDecorator < AF83::Decorator        if: ->() { object.journey_patterns.present? },        secondary: :show      ) do |l| -      l.content h.t('vehicle_journeys.actions.index') +      l.content t('vehicle_journeys.actions.index')        l.href do          [            context[:referential], @@ -45,7 +45,7 @@ class RouteDecorator < AF83::Decorator      end      instance_decorator.action_link secondary: :show do |l| -      l.content h.t('vehicle_journey_exports.new.title') +      l.content t('vehicle_journey_exports.new.title')        l.href do          h.referential_line_route_vehicle_journey_exports_path(            context[:referential], @@ -60,7 +60,7 @@ class RouteDecorator < AF83::Decorator        secondary: :show,        policy: :duplicate      ) do |l| -      l.content h.t('routes.duplicate.title') +      l.content t('routes.duplicate.title')        l.method :post        l.href do          h.duplicate_referential_line_route_path( @@ -76,7 +76,7 @@ class RouteDecorator < AF83::Decorator        policy: :create_opposite,        if: ->{h.has_feature?(:create_opposite_routes)}      ) do |l| -      l.content h.t('routes.create_opposite.title') +      l.content t('routes.create_opposite.title')        l.method :post        l.disabled { object.opposite_route.present? }        l.href do @@ -90,7 +90,7 @@ class RouteDecorator < AF83::Decorator      end      instance_decorator.destroy_action_link do |l| -      l.data confirm: h.t('routes.actions.destroy_confirm') +      l.data confirm: t('routes.actions.destroy_confirm')      end    end  end diff --git a/app/decorators/routing_constraint_zone_decorator.rb b/app/decorators/routing_constraint_zone_decorator.rb index de73068be..3ff286cc1 100644 --- a/app/decorators/routing_constraint_zone_decorator.rb +++ b/app/decorators/routing_constraint_zone_decorator.rb @@ -21,7 +21,7 @@ class RoutingConstraintZoneDecorator < AF83::Decorator      instance_decorator.edit_action_link      instance_decorator.destroy_action_link do |l| -      l.data confirm: h.t('routing_constraint_zones.actions.destroy_confirm') +      l.data confirm: t('routing_constraint_zones.actions.destroy_confirm')      end    end  end diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb index 525681971..c7f10b13b 100644 --- a/app/decorators/stop_area_decorator.rb +++ b/app/decorators/stop_area_decorator.rb @@ -11,11 +11,11 @@ class StopAreaDecorator < AF83::Decorator      instance_decorator.show_action_link      instance_decorator.edit_action_link do |l| -      l.content h.t('stop_areas.actions.edit') +      l.content t('stop_areas.actions.edit')      end      instance_decorator.action_link policy: :deactivate, secondary: true do |l| -      l.content h.deactivate_link_content('stop_areas.actions.deactivate') +      l.content { h.deactivate_link_content('stop_areas.actions.deactivate') }        l.href do          h.deactivate_stop_area_referential_stop_area_path(            object.stop_area_referential, @@ -23,12 +23,12 @@ class StopAreaDecorator < AF83::Decorator          )        end        l.method :put -      l.data confirm: h.t('stop_areas.actions.deactivate_confirm') +      l.data confirm: t('stop_areas.actions.deactivate_confirm')        l.add_class 'delete-action'      end      instance_decorator.action_link policy: :activate, secondary: true do |l| -      l.content h.activate_link_content('stop_areas.actions.activate') +      l.content { h.activate_link_content('stop_areas.actions.activate') }        l.href do          h.activate_stop_area_referential_stop_area_path(            object.stop_area_referential, @@ -36,13 +36,13 @@ class StopAreaDecorator < AF83::Decorator          )        end        l.method :put -      l.data confirm: h.t('stop_areas.actions.activate_confirm') +      l.data confirm: t('stop_areas.actions.activate_confirm')        l.add_class 'delete-action'      end      instance_decorator.destroy_action_link do |l| -      l.content h.destroy_link_content('stop_areas.actions.destroy') -      l.data confirm: h.t('stop_areas.actions.destroy_confirm') +      l.content { h.destroy_link_content('stop_areas.actions.destroy') } +      l.data confirm: t('stop_areas.actions.destroy_confirm')      end    end diff --git a/app/decorators/stop_area_referential_decorator.rb b/app/decorators/stop_area_referential_decorator.rb index d30501ec9..36e45abca 100644 --- a/app/decorators/stop_area_referential_decorator.rb +++ b/app/decorators/stop_area_referential_decorator.rb @@ -5,9 +5,9 @@ class StopAreaReferentialDecorator < AF83::Decorator      instance_decorator.action_link policy: :synchronize, primary: :show do |l|        l.content t('actions.sync') -      l.href { h. sync_stop_area_referential_path(object.id) } +      l.href { h.sync_stop_area_referential_path(object.id) }        l.method :post      end -     +    end  end diff --git a/app/decorators/stop_point_decorator.rb b/app/decorators/stop_point_decorator.rb index 4ff5bce9c..575938fa2 100644 --- a/app/decorators/stop_point_decorator.rb +++ b/app/decorators/stop_point_decorator.rb @@ -4,8 +4,8 @@ class StopPointDecorator < AF83::Decorator    with_instance_decorator do |instance_decorator|      instance_decorator.show_action_link do |l|        l.href do -        h.referential_stop_area_path( -          object.referential, +        h.stop_area_referential_stop_area_path( +          object.stop_area.stop_area_referential,            object.stop_area          )        end diff --git a/app/helpers/menus_helper.rb b/app/helpers/menus_helper.rb new file mode 100644 index 000000000..81d55a944 --- /dev/null +++ b/app/helpers/menus_helper.rb @@ -0,0 +1,20 @@ +module MenusHelper +  def main_nav_menu_item label, &block +    @current_menu_item_count ||= 0 +    @current_menu_item_count += 1 +    content_tag :div, class: "menu-item panel" do +      out = "" +      out += content_tag(:div, class: "panel-heading") do +        content_tag :h4, class: "panel-title" do +          link_to label, "#menu-item-#{@current_menu_item_count}", data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' +        end +      end +      out += content_tag(:div, class: "panel-collapse collapse", id: "menu-item-#{@current_menu_item_count}") do +        content_tag :div, class: "list-group" do +          capture(&block) +        end +      end +      out.html_safe +    end +  end +end diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb index 314154fb7..d3e7dd2a4 100644 --- a/app/helpers/stop_areas_helper.rb +++ b/app/helpers/stop_areas_helper.rb @@ -75,16 +75,17 @@ module StopAreasHelper      t "formtastic.hints.stop_area.registration_number"    end -  def stop_area_status(stop_area) -    if stop_area.activated? -      content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') + -      t('activerecord.attributes.stop_area.confirmed') -    elsif stop_area.deactivated? -      content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') + -      t('activerecord.attributes.stop_area.deactivated') -    else -      content_tag(:span, nil, class: 'fa fa-pencil fa-lg text-info') + -      t('activerecord.attributes.stop_area.in_creation') +  def stop_area_status(status) +    case status +      when :confirmed +        content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') + +        t('activerecord.attributes.stop_area.confirmed') +      when :deactivated +        content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') + +        t('activerecord.attributes.stop_area.deactivated') +      else +        content_tag(:span, nil, class: 'fa fa-pencil fa-lg text-info') + +        t('activerecord.attributes.stop_area.in_creation')      end    end diff --git a/app/javascript/helpers/polyfills.js b/app/javascript/helpers/polyfills.js index 93e3e9846..691fe04af 100644 --- a/app/javascript/helpers/polyfills.js +++ b/app/javascript/helpers/polyfills.js @@ -1,4 +1,5 @@  import 'promise-polyfill/src/polyfill'  import 'es6-symbol/implement'  import 'polyfill-array-includes' +import 'babel-polyfill'  import 'whatwg-fetch' 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/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index cec39ab4e..a0438d7c5 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -58,7 +58,8 @@ export default class BSelect4 extends Component {        this.props.onSelect2JourneyPattern(e)      }      else{ -      let data = JSON.parse(e.currentTarget.selectedOptions[0].dataset.item) +      let option = e.currentTarget.options[e.currentTarget.selectedIndex] +      let data = JSON.parse(option.dataset.item)        this.props.onSelect2JourneyPattern({params:          { diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index ecb58e2ea..4931ab46e 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -66,10 +66,6 @@ const vehicleJourney= (state = {}, action, keep) => {              newVjas.departure_day_offset = 1              newVjas.arrival_day_offset = 1            } -          if(current_time.hour + offsetHours < 0){ -            newVjas.departure_day_offset = -1 -            newVjas.arrival_day_offset = -1 -          }          }          else{            newVjas = { diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 949b18d6f..6a02203ad 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -63,6 +63,9 @@ module Chouette          where(" position between ? and ? ", between_positions.first, between_positions.last)        end      end + +    has_many :vehicle_journey_at_stops, through: :vehicle_journeys +      has_many :stop_areas, -> { order('stop_points.position ASC') }, :through => :stop_points do        def between(departure, arrival)          departure, arrival = [departure, arrival].map do |endpoint| @@ -166,7 +169,8 @@ module Chouette      end      def time_tables -      vehicle_journeys.joins(:time_tables).map(&:"time_tables").flatten.uniq +      ids = vehicle_journeys.joins(:time_tables).pluck('time_tables.id').uniq +      Chouette::TimeTable.where(id: ids)      end      def sorted_vehicle_journeys(journey_category_model) diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index b933e1944..25a0010d8 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -383,6 +383,28 @@ module Chouette        end      end +    def self.ransackable_scopes(auth_object = nil) +      [:by_status] +    end + + +    def self.by_status(*statuses) +      return Chouette::StopArea.all if statuses.reject(&:blank?).length == 3 || statuses.reject(&:blank?).empty? + +      status = { +        in_creation: statuses.include?('in_creation'), +        confirmed: statuses.include?('confirmed'), +        deactivated: statuses.include?('deactivated'), +      } + +      query = [] +      query << "deleted_at IS NOT NULL" if statuses.include?('deactivated') +      query << "(confirmed_at IS NULL AND deleted_at IS NULL)" if statuses.include?('in_creation') +      query << "(confirmed_at IS NOT NULL AND deleted_at IS NULL)" if statuses.include?('confirmed') + +      Chouette::StopArea.where(query.join(' OR ')) +    end +      def activated?        !!(deleted_at.nil? && confirmed_at)      end @@ -410,7 +432,7 @@ module Chouette      end      def status -      return :deleted if deleted_at +      return :deactivated if deleted_at        return :confirmed if confirmed_at        :in_creation @@ -418,7 +440,7 @@ module Chouette      def status=(status)        case status&.to_sym -      when :deleted +      when :deactivated          deactivate        when :confirmed          activate @@ -428,7 +450,7 @@ module Chouette      end      def self.statuses -      %i{in_creation confirmed deleted} +      %i{in_creation confirmed deactivated}      end      def time_zone_offset @@ -441,7 +463,7 @@ module Chouette        return unless ActiveSupport::TimeZone[time_zone].present?        ActiveSupport::TimeZone[time_zone].tzinfo.name      end -     +      def country        return unless country_code        country = ISO3166::Country[country_code] diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb index edb0e81fd..82bedc6ab 100644 --- a/app/models/chouette/stop_point.rb +++ b/app/models/chouette/stop_point.rb @@ -10,6 +10,7 @@ module Chouette      include ObjectidSupport      belongs_to :stop_area +    belongs_to :stop_area_light, -> {select(:name, :city_name, :zip_code, :time_zone)}, class_name: "Chouette::StopArea", foreign_key: :stop_area_id      belongs_to :route, inverse_of: :stop_points      has_many :journey_patterns, through: :route      has_many :vehicle_journey_at_stops, :dependent => :destroy @@ -27,7 +28,7 @@ module Chouette      scope :default_order, -> { order("position") } -    delegate :name, :registration_number, :kind, :area_type, to: :stop_area +    delegate :name, :registration_number, :kind, :area_type, to: :stop_area_light      before_destroy :remove_dependent_journey_pattern_stop_points      def remove_dependent_journey_pattern_stop_points diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index 818287b04..3bbd89f7b 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -21,6 +21,7 @@ module Chouette      belongs_to :company      belongs_to :route      belongs_to :journey_pattern +    belongs_to :journey_pattern_only_objectid, -> {select("journey_patterns.objectid")}, class_name: "Chouette::JourneyPattern", foreign_key: :journey_pattern_id      has_many :stop_areas, through: :journey_pattern      has_and_belongs_to_many :footnotes, :class_name => 'Chouette::Footnote' diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb index 3f5bd5abf..797571070 100644 --- a/app/models/chouette/vehicle_journey_at_stop.rb +++ b/app/models/chouette/vehicle_journey_at_stop.rb @@ -101,8 +101,8 @@ module Chouette      end      def time_zone_offset -      return 0 unless stop_point&.stop_area&.time_zone.present? -      ActiveSupport::TimeZone[stop_point.stop_area.time_zone]&.utc_offset || 0 +      return 0 unless stop_point&.stop_area_light&.time_zone.present? +      ActiveSupport::TimeZone[stop_point.stop_area_light.time_zone]&.utc_offset || 0      end      private diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index 0f73e07b2..9cf2389c9 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -16,6 +16,8 @@ class CleanUp < ApplicationModel      where(referential_id: referential.id)    end +  attr_accessor :methods +    def end_date_must_be_greater_that_begin_date      if self.end_date && self.date_type == 'between' && self.begin_date >= self.end_date        errors.add(:base, I18n.t('activerecord.errors.models.clean_up.invalid_period')) @@ -43,17 +45,22 @@ class CleanUp < ApplicationModel            end          end -        destroy_vehicle_journeys_outside_referential +        destroy_routes_outside_referential          # Disabled for the moment. See #5372          # destroy_time_tables_outside_referential -        destroy_vehicle_journeys -        destroy_journey_patterns -        destroy_routes +        # Run caller-specified cleanup methods +        run_methods        end      end    end +  def run_methods +    return if methods.nil? + +    methods.each { |method| send(method) } +  end +    def destroy_time_tables_between      time_tables = Chouette::TimeTable.where('end_date < ? AND start_date > ?', self.end_date, self.begin_date)      self.destroy_time_tables(time_tables) @@ -100,9 +107,9 @@ class CleanUp < ApplicationModel      destroy_time_tables(time_tables)    end -  def destroy_vehicle_journeys_outside_referential +  def destroy_routes_outside_referential      line_ids = referential.metadatas.pluck(:line_ids).flatten.uniq -    Chouette::VehicleJourney.joins(:route).where(["routes.line_id not in (?)", line_ids]).destroy_all +    Chouette::Route.where(['line_id not in (?)', line_ids]).destroy_all    end    def destroy_vehicle_journeys @@ -117,6 +124,12 @@ class CleanUp < ApplicationModel      Chouette::Route.where("id not in (select distinct route_id from journey_patterns)").destroy_all    end +  def destroy_empty +    destroy_vehicle_journeys +    destroy_journey_patterns +    destroy_routes +  end +    def overlapping_periods      self.end_date = self.begin_date if self.date_type != 'between'      Chouette::TimeTablePeriod.where('(period_start, period_end) OVERLAPS (?, ?)', self.begin_date, self.end_date) diff --git a/app/models/concerns/checksum_support.rb b/app/models/concerns/checksum_support.rb index fe52604bb..86bbd1d00 100644 --- a/app/models/concerns/checksum_support.rb +++ b/app/models/concerns/checksum_support.rb @@ -10,19 +10,24 @@ module ChecksumSupport    end    module ClassMethods +      def has_checksum_children klass, opts={}        parent_class = self        belongs_to = opts[:relation] || self.model_name.singular        has_many = opts[:relation] || self.model_name.plural        Rails.logger.debug "Define callback in #{klass} to update checksums #{self.model_name} (via #{has_many}/#{belongs_to})" -      klass.after_save do + +      child_update_parent = Proc.new do          parents = []          parents << self.send(belongs_to) if klass.reflections[belongs_to].present?          parents += self.send(has_many) if klass.reflections[has_many].present?          Rails.logger.debug "Request from #{klass.name} checksum updates for #{parents.count} #{parent_class} parent(s)"          parents.compact.each &:update_checksum_without_callbacks!        end + +      klass.after_save &child_update_parent +      klass.after_destroy &child_update_parent      end    end diff --git a/app/models/import/netex.rb b/app/models/import/netex.rb index b4422328c..753f9128d 100644 --- a/app/models/import/netex.rb +++ b/app/models/import/netex.rb @@ -100,7 +100,6 @@ class Import::Netex < Import::Base          metadata.periodes = frame.periods          line_objectids = frame.line_refs.map { |ref| "STIF:CODIFLIGNE:Line:#{ref}" } -        create_message criticity: :info, message_key: "referential_creation_lines_found", message_attributes: {line_objectids: line_objectids.to_sentence}          metadata.line_ids = workbench.lines.where(objectid: line_objectids).pluck(:id)        end      end diff --git a/app/models/merge.rb b/app/models/merge.rb index 2824e1f83..aca2f4d4d 100644 --- a/app/models/merge.rb +++ b/app/models/merge.rb @@ -145,12 +145,19 @@ class Merge < ApplicationModel        end      end +    referential_route_opposite_route_ids = referential.switch do +      Hash[referential.routes.where('opposite_route_id is not null').pluck(:id, :opposite_route_id)] +    end +      referential_routing_constraint_zones_new_ids = {}      new.switch do +      route_ids_mapping = {} +        referential_routes.each do |route|          existing_route = new.routes.find_by line_id: route.line_id, checksum: route.checksum          if existing_route +          route_ids_mapping[route.id] = existing_route.id            existing_route.merge_metadata_from route          else            objectid = Chouette::Route.where(objectid: route.objectid).exists? ? nil : route.objectid @@ -159,7 +166,7 @@ class Merge < ApplicationModel              objectid: objectid,              # line_id is the same              # all other primary must be changed -            opposite_route_id: nil #FIXME +            opposite_route_id: nil # merged after            )            new_route = new.routes.build attributes @@ -179,6 +186,8 @@ class Merge < ApplicationModel            # We need to create StopPoints to known new primary keys            new_route.save! +          route_ids_mapping[route.id] = new_route.id +            old_stop_point_ids = route_stop_points.sort_by(&:position).map(&:id)            new_stop_point_ids = new_route.stop_points.sort_by(&:position).map(&:id) @@ -225,6 +234,20 @@ class Merge < ApplicationModel            end          end        end + +      referential_route_opposite_route_ids.each do |route_id, opposite_route_id| +        new_route_id = route_ids_mapping[route_id] +        new_opposite_route_id = route_ids_mapping[opposite_route_id] + +        new_route = nil +        if new_route_id && new_opposite_route_id +          if new_route = new.routes.find_by(id: new_route_id) +            new_route.update_column :opposite_route_id, new_opposite_route_id +          end +        end + +        Rails.logger.warn "Can't merge opposite route for Route #{route_id}" unless new_route +      end      end      # JourneyPatterns diff --git a/app/models/simple_importer.rb b/app/models/simple_importer.rb index 4cfe90cff..d47ff6a92 100644 --- a/app/models/simple_importer.rb +++ b/app/models/simple_importer.rb @@ -42,8 +42,10 @@ class SimpleImporter < SimpleInterface    end    def dump_csv_from_context -    dir = context[:logs_output_dir] || "log/importers" -    filepath = File.join dir, "#{self.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}.csv" +    dir = @output_dir +    FileUtils.mkdir_p dir + +    filepath = File.join dir, "#{self.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}_dump.csv"      # for some reason, context[:csv].to_csv does not work      CSV.open(filepath, 'w') do |csv|        header = true @@ -131,14 +133,16 @@ class SimpleImporter < SimpleInterface            @current_attribute = col[:attribute]            val = col[:value]            if val.nil? || val.is_a?(Proc) -            if row.has_key? col.name -              if val.is_a?(Proc) +            if val.is_a?(Proc) +              if row.has_key? col.name                  val = instance_exec(row[col.name], &val)                else -                val = row[col.name] +                val = instance_exec(&val)                end +            elsif row.has_key? col.name +              val = row[col.name]              else -              push_in_journal({event: :column_not_found, message: "Column not found: #{col.name}", kind: :warning}) +              push_in_journal({event: :column_not_found, message: "Column not found: #{col.name || col.attribute}", kind: :warning})                self.status ||= :success_with_warnings              end            end diff --git a/app/models/simple_interface.rb b/app/models/simple_interface.rb index 7b04a07df..d5feafb07 100644 --- a/app/models/simple_interface.rb +++ b/app/models/simple_interface.rb @@ -97,13 +97,14 @@ class SimpleInterface < ApplicationModel    def write_output_to_csv      cols = %i(line kind event message error) -    if self.journal.size > 0 && self.journal.first[:row].present? +    journal = self.journal && self.journal.map(&:symbolize_keys) +    if journal && journal.size > 0 && journal.first[:row].present?        log "Writing output log"        FileUtils.mkdir_p @output_dir -      keys = self.journal.first[:row].map(&:first) +      keys = journal.first[:row].map(&:first)        CSV.open(output_filepath, "w") do |csv|          csv << cols + keys -        self.journal.each do |j| +        journal.each do |j|            csv << cols.map{|c| j[c]} + j[:row].map(&:last)          end        end diff --git a/app/models/simple_interfaces_group.rb b/app/models/simple_interfaces_group.rb index 808be6570..1e13bd0b5 100644 --- a/app/models/simple_interfaces_group.rb +++ b/app/models/simple_interfaces_group.rb @@ -30,7 +30,9 @@ class SimpleInterfacesGroup      name = "### #{self.name} ###"      centered_name = " " * ([width - name.size, 0].max / 2) + name -    banner = [centered_name, ""] +    banner = [centered_name] +    banner << "Output to: #{shared_options[:output_dir]}" if shared_options && shared_options[:output_dir] +    banner << ""      banner << @interfaces.each_with_index.map do |interface, i|        if interface[:interface].status.present?          SimpleInterface.colorize interface[:name], SimpleInterface.status_color(interface[:interface].status) diff --git a/app/services/referential_consolidated.rb b/app/services/referential_consolidated.rb index 465eab405..832210db3 100644 --- a/app/services/referential_consolidated.rb +++ b/app/services/referential_consolidated.rb @@ -48,11 +48,12 @@ class ReferentialConsolidated      attr_reader :parent      attr_reader :ar_model -    def initialize parent, ar_model, vehicle_journeys, params +    def initialize parent, ar_model, vehicle_journeys, params, opts={}        @parent = parent        @ar_model = ar_model        @all_vehicle_journeys = vehicle_journeys        @params = params +      @opts = opts      end      def should_highlight? @@ -74,9 +75,19 @@ class ReferentialConsolidated    class Route < Base      def_delegators :ar_model, :name, :id, :time_tables, :purchase_windows, :stop_area_ids +    def vehicle_journey_at_stops +      @vehicle_journey_at_stops ||= begin +        out = Hash.new{|h, k| h[k] = {}} +        ar_model.vehicle_journey_at_stops.each do |vjas| +          out[vjas.vehicle_journey_id][vjas.stop_point_id] = vjas +        end +        out +      end +    end +      def vehicle_journeys        @vehicle_journeys ||= begin -        ar_model.vehicle_journeys.map {|vj| VehicleJourney.new(self, vj, @all_vehicle_journeys, params) } +        ar_model.vehicle_journeys.select(:id, :published_journey_name, :route_id, :journey_pattern_id).map {|vj| VehicleJourney.new(self, vj, @all_vehicle_journeys, params, vehicle_journey_at_stops: vehicle_journey_at_stops[vj.id]) }        end      end @@ -85,7 +96,7 @@ class ReferentialConsolidated      end      def highlighted_count -      highlighted_journeys.count +      highlighted_journeys.except(:select).count      end      def highlighted? @@ -93,18 +104,32 @@ class ReferentialConsolidated        (should_highlight? || matching_stop_areas) && highlighted_journeys.exists?      end +    def stop_areas +      @stop_areas ||= begin +        out = {} +        ar_model.stop_areas.select(:id, :name, :city_name, :zip_code, :time_zone).each do |sp| +          out[sp.id] = sp +        end +        out +      end +    end +      def stop_points -      @stop_points ||= ar_model.stop_points.map {|sp| StopPoint.new(self, sp, @all_vehicle_journeys, params) } +      @stop_points ||= ar_model.stop_points.map {|sp| StopPoint.new(self, sp, @all_vehicle_journeys, params, stop_area: stop_areas[sp.stop_area_id]) }      end    end    class VehicleJourney < Base -    def_delegators :ar_model, :id, :published_journey_name, :journey_pattern, :time_tables, :purchase_windows, :vehicle_journey_at_stops, :time_table_ids, :purchase_window_ids, :route +    def_delegators :ar_model, :id, :published_journey_name, :journey_pattern, :time_tables, :purchase_windows, :time_table_ids, :purchase_window_ids, :route, :journey_pattern_only_objectid      def highlighted?        should_highlight? && @all_vehicle_journeys.where(id: self.id).exists?      end +    def vehicle_journey_at_stops +      @opts[:vehicle_journey_at_stops] || {} +    end +      def has_purchase_window? purchase_window        purchase_window_ids.include?(purchase_window.id)      end @@ -115,7 +140,15 @@ class ReferentialConsolidated    end    class StopPoint < Base -    def_delegators :ar_model, :id, :arrival_time, :departure_time, :name, :stop_area, :stop_area_id +    def_delegators :ar_model, :id, :arrival_time, :departure_time, :stop_area_id + +    def stop_area +      @opts[:stop_area] +    end + +    def name +      stop_area.name +    end      def highlighted?        params[:q] && params[:q]["stop_areas"] && params[:q]["stop_areas"].values.any?{|v| v.to_s == stop_area_id.to_s} diff --git a/app/services/route_way_cost_calculator.rb b/app/services/route_way_cost_calculator.rb index d41a2e59a..ca47a6772 100644 --- a/app/services/route_way_cost_calculator.rb +++ b/app/services/route_way_cost_calculator.rb @@ -8,5 +8,7 @@ class RouteWayCostCalculator      way_costs = TomTom.matrix(way_costs)      way_costs = WayCostCollectionJSONSerializer.dump(way_costs)      @route.update(costs: way_costs) +  rescue TomTom::Errors::MatrixRemoteError => e +    Rails.logger.error "TomTom::Matrix server error: #{e}"    end  end diff --git a/app/views/companies/show.html.slim b/app/views/companies/show.html.slim index 8960b92dd..6335d88da 100644 --- a/app/views/companies/show.html.slim +++ b/app/views/companies/show.html.slim @@ -6,7 +6,7 @@    .container-fluid      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12 -        - attributes = { t('id_codif') => @company.try(:objectid).try(:local_id), +        - attributes = { t('id_codif') => @company.get_objectid.try(:short_id),            Chouette::Company.human_attribute_name(:phone) => @company.phone,            Chouette::Company.human_attribute_name(:email) => @company.email,            Chouette::Company.human_attribute_name(:url) => @company.url } diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim index 729c1ce43..48c03d7c8 100644 --- a/app/views/compliance_control_sets/show.html.slim +++ b/app/views/compliance_control_sets/show.html.slim @@ -15,8 +15,9 @@          = render '/compliance_controls/filters'    / compliance controls without block -  = render_compliance_control_block -  = render_compliance_controls(@direct_compliance_controls) +  - unless params[:q].present? && @direct_compliance_controls.nil? +    = render_compliance_control_block +    = render_compliance_controls(@direct_compliance_controls)    / compliance controls with block    - if params[:q] && params[:q][:compliance_control_block_id_eq_any].try(:present?) diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim index ce869ee4a..18105041a 100644 --- a/app/views/dashboards/_dashboard.html.slim +++ b/app/views/dashboards/_dashboard.html.slim @@ -6,6 +6,24 @@            h3.panel-title.with_actions              div                = link_to t('dashboards.workbench.title', organisation: workbench.organisation.name), workbench_path(workbench) +              span.badge.ml-xs = workbench.output.referentials.count if workbench.output.referentials.present? + +            div +              = link_to '', workbench_path(workbench), class: ' fa fa-chevron-right pull-right', title: t('workbenches.index.offers.see') + +        - if workbench.output.referentials.present? +          .list-group +            - workbench.output.referentials.limit(5).each do |referential| +              = link_to referential.name, referential_path(referential), class: 'list-group-item' +        - else +          .panel-body +            em.small.text-muted = t('workbenches.index.offers.no_content') + +      .panel.panel-default +        .panel-heading +          h3.panel-title.with_actions +            div +              = link_to t('dashboards.workbench.title', organisation: workbench.organisation.name), workbench_path(workbench)                span.badge.ml-xs = workbench.all_referentials.uniq.count if workbench.all_referentials.present?              div diff --git a/app/views/devise/invitations/edit.html.slim b/app/views/devise/invitations/edit.html.slim index 7a22146c0..20c2f15c8 100644 --- a/app/views/devise/invitations/edit.html.slim +++ b/app/views/devise/invitations/edit.html.slim @@ -1,6 +1,5 @@  / PageHeader - -- content_for :page_header_title, t('.title') +- content_for :page_header_title, t('devise.registrations.edit.title')  / PageContent  .page_content @@ -16,4 +15,4 @@                  = form.input :password, as: :password                  = form.input :password_confirmation, as: :password -            = form.button :submit, value: t('devise.invitations.edit.submit_button'), class: 'btn-info btn-default formSubmitr', form: 'invitation_form' +            = form.button :submit, value: t('actions.submit'), class: 'btn-info btn-default formSubmitr', form: 'invitation_form' diff --git a/app/views/devise/invitations/new.html.slim b/app/views/devise/invitations/new.html.slim index 87bfbf750..90f086c2b 100644 --- a/app/views/devise/invitations/new.html.slim +++ b/app/views/devise/invitations/new.html.slim @@ -1,10 +1,15 @@ -h2 = t('devise.invitations.new.header') +- content_for :page_header_title, t('devise.registrations.new.title') -= simple_form_for resource, as: resource_name, :url => invitation_path(resource_name), :html => {:method => :post, class: "form-horizontal"} do |form| -  = form.input :organisation_id, :as => :hidden, input_html: { :value => current_organisation.id } +/ PageContent +.page_content +  .container-fluid +    .row +      .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 +        = simple_form_for resource, as: resource_name, :url => invitation_path(resource_name), :html => {:method => :post, class: "form-horizontal", id: "new_user_form"} do |form| +          = form.input :organisation_id, :as => :hidden, input_html: { :value => current_organisation.id } -  - resource.class.invite_key_fields.each do |field| -    = form.input field +          - resource.class.invite_key_fields.each do |field| +            = form.input field -  .form-actions -    = form.button :submit, value: t('devise.invitations.new.submit_button'), class: 'btn-info'
\ No newline at end of file +          .form-actions +            = form.button :submit, value: t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'new_user_form'
\ No newline at end of file diff --git a/app/views/imports/import/_gtf.html.slim b/app/views/imports/import/_gtf.html.slim index 8b92f2e92..e50b45888 100644 --- a/app/views/imports/import/_gtf.html.slim +++ b/app/views/imports/import/_gtf.html.slim @@ -1,7 +1,8 @@ +- breadcrumb :gtfs_import, @workbench, @import +  .row    .col-lg-6.col-md-6.col-sm-12.col-xs-12 -    - metadata = { t('.parent') => link_to(@import.parent.name, [@import.parent.workbench, @import.parent]) } -    - metadata = metadata.update({t('.status') => import_status(@import.status, verbose: true) }) +    - metadata = {t('.status') => import_status(@import.status, verbose: true) }      - metadata = metadata.update({t('.referential') => @import.referential ? link_to(@import.referential.name, [@import.referential]) : "-" })      = definition_list t('metadatas'), metadata @@ -14,7 +15,7 @@      = table_builder_2 @import.resources,        [ \          TableBuilderHelper::Column.new( \ -          name: t('.referential_name'), \ +          name: t('imports.show.referential_name'), \            attribute: 'name', \            sortable: false, \            link_to: lambda do |item| \ diff --git a/app/views/imports/import/_netex.html.slim b/app/views/imports/import/_netex.html.slim index 2f341016a..ab0ed20d7 100644 --- a/app/views/imports/import/_netex.html.slim +++ b/app/views/imports/import/_netex.html.slim @@ -1,8 +1,9 @@ +- breadcrumb :netex_import, @workbench, @import +  .row    .col-lg-6.col-md-6.col-sm-12.col-xs-12 -    - metadata = { t('.parent') => link_to(@import.parent.name, [@import.parent.workbench, @import.parent]) } -    - metadata = metadata.update({t('.status') => import_status(@import.status, verbose: true) }) -    - metadata = metadata.update({t('.referential') => @import.referential ? link_to(@import.referential.name, [@import.referential]) : "-" }) +    - metadata = {Import::Base.tmf(:status) => import_status(@import.status, verbose: true) } +    - metadata = metadata.update({Import::Base.tmf(:referential) => @import.referential ? link_to(@import.referential.name, [@import.referential]) : "-" })      = definition_list t('metadatas'), metadata  .col-lg-12 @@ -11,9 +12,9 @@  - if @import.resources.present?    .col-lg-12 -    h2 = t('.table_title') +    h2 = t('imports.show.netex.table_title')    .col-lg-12 -    = t('.table_explanation') +    = t('imports.show.netex.table_explanation')    .col-lg-12      = table_builder_2 @import.resources.where(resource_type: :file),        [ \ @@ -28,12 +29,12 @@            sortable: false, \          ), \          TableBuilderHelper::Column.new( \ -          name: 'Résultat des tests' , \ +          name: t('imports.show.table.test_results') , \            attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \            sortable: false, \          ), \          TableBuilderHelper::Column.new( \ -          name: 'Téléchargement' , \ +          name: t('imports.show.table.download') , \            attribute: Proc.new { |n| '<i class="fa fa-download" aria-hidden="true"></i>'.html_safe }, \            sortable: false, \            link_to: lambda do |import_resource| \ diff --git a/app/views/imports/import/_workbench.html.slim b/app/views/imports/import/_workbench.html.slim index e41ceb0f0..cbdf604c2 100644 --- a/app/views/imports/import/_workbench.html.slim +++ b/app/views/imports/import/_workbench.html.slim @@ -1,7 +1,9 @@ +- breadcrumb :import, @workbench, @import +  .row    .col-lg-6.col-md-6.col-sm-12.col-xs-12 -    - metadata = { t('.data_recovery') => '-', t('.filename') => @import.try(:file_identifier)} -    - metadata = metadata.update({t('.status') => import_status(@import.status, verbose: true) }) +    - metadata = { t('.data_recovery') => '-', t('imports.show.filename') => @import.try(:file_identifier)} +    - metadata = metadata.update({Import::Base.tmf(:status) => import_status(@import.status, verbose: true) })      = definition_list t('metadatas'), metadata  .col-lg-12 @@ -25,7 +27,7 @@ ruby:      = table_builder_2 @import.resources,        [ \          TableBuilderHelper::Column.new( \ -          name: t('.referential_name'), \ +          name: t('imports.show.referential_name'), \            attribute: 'name', \            sortable: false, \            link_to: lambda do |item| \ diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim index 10552129d..fb83e9a06 100644 --- a/app/views/imports/show.html.slim +++ b/app/views/imports/show.html.slim @@ -1,5 +1,3 @@ -- breadcrumb :import, @workbench, @import -  - page_header_content_for @import  .page_content diff --git a/app/views/layouts/navigation/_main_nav_left_content.html.slim b/app/views/layouts/navigation/_main_nav_left_content.html.slim index 889f8f944..547c6fae7 100644 --- a/app/views/layouts/navigation/_main_nav_left_content.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content.html.slim @@ -2,69 +2,54 @@  - current_organisation.workbenches.each do |workbench|    #menu-items.panel-group      .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.current_offer.other') - -      #miOne.panel-collapse.collapse -        .list-group -          = link_to root_path, class: "list-group-item" do -            span = t('layouts.navbar.dashboard') -          = link_to workbench_output_path(workbench), class: 'list-group-item' do -            span = t('layouts.navbar.workbench_outputs.organisation') -          = link_to '#', class: 'list-group-item disabled' do -            span = t('layouts.navbar.workbench_outputs.workgroup') -          - if policy(workbench.workgroup).edit? -            = link_to [:edit, workbench.workgroup], class: 'list-group-item' do -              span = t('layouts.navbar.workbench_outputs.edit_workgroup') +      = main_nav_menu_item 'layouts.navbar.current_offer.other'.t do +        = link_to root_path, class: "list-group-item" do +          span = 'layouts.navbar.dashboard'.t +        = link_to workbench_output_path(workbench), class: 'list-group-item' do +          span = 'layouts.navbar.workbench_outputs.organisation'.t +        = link_to '#', class: 'list-group-item disabled' do +          span = 'layouts.navbar.workbench_outputs.workgroup'.t +        - if policy(workbench.workgroup).edit? +          = link_to [:edit, workbench.workgroup], class: 'list-group-item' do +            span = 'layouts.navbar.workbench_outputs.edit_workgroup'.t      .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            - t('activerecord.models.workbench.one').capitalize - -      #miTwo.panel-collapse.collapse -        .list-group -          = link_to workbench_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.referential.other').capitalize -          = link_to workbench_imports_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.import.other').capitalize -          = link_to workbench_exports_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.export.other').capitalize -          = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do -            span = t('activerecord.models.calendar.other').capitalize -          = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do -            span = t('activerecord.models.compliance_check_set.other').capitalize -          = link_to compliance_control_sets_path, class: 'list-group-item' do -            span = t('activerecord.models.compliance_control_set.other').capitalize -          - if policy(workbench).edit? -            = link_to [:edit, workbench], class: 'list-group-item' do -              span = t('workbenches.edit.link') +      = main_nav_menu_item 'activerecord.models.workbench.one'.t.capitalize do +        = link_to workbench_path(workbench), class: "list-group-item" do +          span = 'activerecord.models.referential.other'.t.capitalize +        = link_to workbench_imports_path(workbench), class: "list-group-item" do +          span = 'activerecord.models.import.other'.t.capitalize +        = link_to workbench_exports_path(workbench), class: "list-group-item" do +          span = 'activerecord.models.export.other'.t.capitalize +        = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do +          span = 'activerecord.models.calendar.other'.t.capitalize +        = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do +          span = 'activerecord.models.compliance_check_set.other'.t.capitalize +        = link_to compliance_control_sets_path, class: 'list-group-item' do +          span = 'activerecord.models.compliance_control_set.other'.t.capitalize +        - if policy(workbench).edit? +          = link_to [:edit, workbench], class: 'list-group-item' do +            span = 'workbenches.edit.link'.t      .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.line_referential') - -      #miFour.panel-collapse.collapse -        .list-group -          = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Line.t.capitalize -          = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Network.t.capitalize -          = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Company.t.capitalize +      = main_nav_menu_item 'layouts.navbar.line_referential'.t do +        = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do +          span = Chouette::Line.t.capitalize +        = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do +          span = Chouette::Network.t.capitalize +        = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do +          span = Chouette::Company.t.capitalize      .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.stop_area_referential') +      = main_nav_menu_item 'layouts.navbar.stop_area_referential'.t do +        = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do +          span = Chouette::StopArea.t.capitalize -      #miFive.panel-collapse.collapse -        .list-group -          = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do -            span = Chouette::StopArea.t.capitalize +    .menu-item.panel +      = main_nav_menu_item 'layouts.navbar.configuration'.t do +        - if policy(workbench).edit? +          = link_to [:edit, workbench], class: 'list-group-item' do +            span = 'layouts.navbar.workbench_configuration'.t +        - if policy(workbench.workgroup).edit? +          = link_to [:edit, workbench.workgroup], class: 'list-group-item' do +            span = 'layouts.navbar.workgroup_configuration'.t diff --git a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim index a7bb3f511..950c23580 100644 --- a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim @@ -1,101 +1,68 @@  - current_organisation.workbenches.each do |workbench|    #menu-items.panel-group -    .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.current_offer.other') +    = main_nav_menu_item 'layouts.navbar.current_offer.other'.t do +      = link_to root_path, class: "list-group-item" do +        span = t('layouts.navbar.dashboard') +      = link_to workbench_output_path(workbench), class: 'list-group-item' do +        span = t('layouts.navbar.workbench_outputs.organisation') +      = link_to '#', class: 'list-group-item disabled' do +        span = t('layouts.navbar.workbench_outputs.workgroup') -      #miOne.panel-collapse.collapse -        .list-group -          = link_to root_path, class: "list-group-item" do -            span = t('layouts.navbar.dashboard') -          = link_to workbench_output_path(workbench), class: 'list-group-item' do -            span = t('layouts.navbar.workbench_outputs.organisation') -          = link_to '#', class: 'list-group-item disabled' do -            span = t('layouts.navbar.workbench_outputs.workgroup') -          - if policy(workbench.workgroup).edit? -            = link_to [:edit, workbench.workgroup], class: 'list-group-item' do -              span = t('layouts.navbar.workbench_outputs.edit_workgroup') +    = main_nav_menu_item 'activerecord.models.workbench.one'.t.capitalize do +      = link_to workbench_path(workbench), class: "list-group-item" do +        span = t('activerecord.models.referential.other').capitalize +      = link_to workbench_imports_path(workbench), class: "list-group-item" do +        span = t('activerecord.models.import.other').capitalize +      = link_to workbench_exports_path(workbench), class: "list-group-item" do +        span = t('activerecord.models.export.other').capitalize +      = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do +        span = t('activerecord.models.calendar.other').capitalize +      = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do +        span = t('activerecord.models.compliance_check_set.other').capitalize +      = link_to compliance_control_sets_path, class: 'list-group-item' do +        span = t('activerecord.models.compliance_control_set.other').capitalize -    .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            - t('activerecord.models.workbench.one').capitalize +    = main_nav_menu_item 'layouts.navbar.line_referential'.t do +      = link_to line_referential_path(workbench.line_referential), class: "list-group-item" do +        span = t('layouts.navbar.sync_ilico') +      = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do +        span = Chouette::Line.t.capitalize +      = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do +        span = Chouette::Network.t.capitalize +      = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do +        span = Chouette::Company.t.capitalize -      #miTwo.panel-collapse.collapse -        .list-group -          = link_to workbench_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.referential.other').capitalize -          = link_to workbench_imports_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.import.other').capitalize -          = link_to workbench_exports_path(workbench), class: "list-group-item" do -            span = t('activerecord.models.export.other').capitalize -          = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do -            span = t('activerecord.models.calendar.other').capitalize -          = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do -            span = t('activerecord.models.compliance_check_set.other').capitalize -          = link_to compliance_control_sets_path, class: 'list-group-item' do -            span = t('activerecord.models.compliance_control_set.other').capitalize -          - if policy(workbench).edit? -            = link_to [:edit, workbench], class: 'list-group-item' do -              span = t('workbenches.edit.link') +    = main_nav_menu_item 'layouts.navbar.stop_area_referential'.t do +      = link_to stop_area_referential_path(workbench.stop_area_referential), class: "list-group-item" do +        span = t('layouts.navbar.sync_icar') +      = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do +        span = Chouette::StopArea.t.capitalize -    .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.line_referential') +    = main_nav_menu_item 'layouts.navbar.configuration'.t do +      - if policy(workbench).edit? +        = link_to [:edit, workbench], class: 'list-group-item' do +          span = t('layouts.navbar.workbench_configuration') +      - if policy(workbench.workgroup).edit? +        = link_to [:edit, workbench.workgroup], class: 'list-group-item' do +          span = t('layouts.navbar.workgroup_configuration') -      #miFour.panel-collapse.collapse -        .list-group -          = link_to line_referential_path(workbench.line_referential), class: "list-group-item" do -            span = t('layouts.navbar.sync_ilico') -          = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Line.t.capitalize -          = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Network.t.capitalize -          = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do -            span = Chouette::Company.t.capitalize - -    .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.stop_area_referential') - -      #miFive.panel-collapse.collapse -        .list-group -          = link_to stop_area_referential_path(workbench.stop_area_referential), class: "list-group-item" do -            span = t('layouts.navbar.sync_icar') -          = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do -            span = Chouette::StopArea.t.capitalize - -    .menu-item.panel -      .panel-heading -        h4.panel-title -          = link_to '#miSix', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -            = t('layouts.navbar.tools') - -      #miSix.panel-collapse.collapse -        .list-group -          = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do -            span -              span.fa.fa-2x.fa-circle -              = t('layouts.navbar.portal') - -          = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do -            span -              span.fa.fa-2x.fa-circle -              = t('layouts.navbar.ilico') - -          = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do -            span -              span.fa.fa-2x.fa-circle -              = t('layouts.navbar.icar') - -          = link_to '#', target: '_blank', class: 'list-group-item' do -            span -              span.fa.fa-2x.fa-circle -              = t('layouts.navbar.support') +    = main_nav_menu_item 'layouts.navbar.tools'.t do +      = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do +        span +          span.fa.fa-2x.fa-circle +          = t('layouts.navbar.portal') +       +      = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do +        span +          span.fa.fa-2x.fa-circle +          = t('layouts.navbar.ilico') +       +      = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do +        span +          span.fa.fa-2x.fa-circle +          = t('layouts.navbar.icar') +       +      = link_to '#', target: '_blank', class: 'list-group-item' do +        span +          span.fa.fa-2x.fa-circle +        = t('layouts.navbar.support') 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/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index beee0383f..06096bbaa 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -7,7 +7,7 @@        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'),            { t('id_reflex') => @stop_area.try(:user_objectid), -            Chouette::StopArea.tmf(:status) => stop_area_status(@stop_area), +            Chouette::StopArea.tmf(:status) => stop_area_status(@stop_area.status),              Chouette::StopArea.tmf(:comment) => @stop_area.try(:comment),              Chouette::StopArea.tmf(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),              Chouette::StopArea.tmf(:registration_number) => @stop_area.registration_number, diff --git a/app/views/referential_vehicle_journeys/_consolidated.html.slim b/app/views/referential_vehicle_journeys/_consolidated.html.slim index e2de526bc..4a1866e8a 100644 --- a/app/views/referential_vehicle_journeys/_consolidated.html.slim +++ b/app/views/referential_vehicle_journeys/_consolidated.html.slim @@ -8,26 +8,42 @@ coffee:    $('a.toggle-timetables').click (e)->      e.preventDefault()      $(e.target).toggleClass 'active' -    $(e.target).parents('.table').find('.detailed-timetables').toggleClass 'hidden' +    $(e.target).parents('.table').find('.detailed-timetables').customToggle()    $('a.toggle-purchase-windows').click (e)->      e.preventDefault()      $(e.target).toggleClass 'active' -    $(e.target).parents('.table').find('.detailed-purchase-windows').toggleClass 'hidden' +    $(e.target).parents('.table').find('.detailed-purchase-windows').customToggle() -  $('.route').find('.vehicle-journeys').each (i, e)-> +  $('.route').find('.togglable.hidden').each (i, e)->      $e = $(e)      $e.removeClass 'hidden' -    e.setAttribute 'data-original-height', $e.height() -    $e.height 0 +    e.setAttribute 'data-original-height', $e.innerHeight() +    e.setAttribute 'data-original-full-height', $e.outerHeight(true) +    $e.css height: 0 +    $e.addClass 'ready'    $('a.toggle-route').click (e)->      e.preventDefault()      $(e.currentTarget).toggleClass 'active'      tab = $(e.currentTarget).parents('.route').find('.vehicle-journeys') -    if tab.hasClass 'open' -      tab.removeClass 'open' -      tab.height 0 -    else -      tab.addClass 'open' -      tab.height tab.attr('data-original-height') +    tab.customToggle() + +  $.fn.extend +    customToggle: (propagate=true)-> +      height = parseFloat this.attr('data-original-height') +      fullHeight = parseFloat this.attr('data-original-full-height') +      if this.hasClass 'open' +        this.css height: 0 +        this.removeClass 'open' +        this.find('.togglable.open').customToggle(false) +        this.find('a.active').removeClass 'active' +        if propagate +          for parent in this.parents(".togglable.open") +            $(parent).height $(parent).height() - fullHeight +      else +        this.addClass 'open' +        this.height height +        if propagate +          for parent in this.parents(".togglable.open") +            $(parent).height $(parent).height() + fullHeight diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim index d4c756d38..9a27c0ecf 100644 --- a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim +++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim @@ -20,7 +20,7 @@                = Chouette::VehicleJourney.t                |                  span.fa.fa-angle-up -        .table.table-2entries.vehicle-journeys.hidden +        .table.table-2entries.vehicle-journeys.hidden.togglable            .t2e-head.w20              .th                div @@ -31,7 +31,7 @@                  = link_to '#', class: 'toggle-purchase-windows detailed-timetables-bt' do                    span.fa.fa-angle-up                    = Chouette::PurchaseWindow.t -              .detailed-purchase-windows.hidden +              .detailed-purchase-windows.hidden.togglable                  - route.purchase_windows.uniq.each do |tt|                    div                      p @@ -46,7 +46,7 @@                    span.fa.fa-angle-up                    = Chouette::TimeTable.t -              .detailed-timetables.hidden +              .detailed-timetables.hidden.togglable                  - route.time_tables.uniq.each do |tt|                    div                      p @@ -78,7 +78,7 @@                        strong= link_to journey.id, [@referential, journey.route.line, journey.route, :vehicle_journeys]                      div                        = link_to journey.published_journey_name, [@referential, journey.route.line, journey.route, :vehicle_journeys], title: journey.published_journey_name -                    div= journey.journey_pattern.get_objectid.short_id +                    div= journey.journey_pattern_only_objectid.get_objectid.short_id                      div                        - journey.purchase_windows[0..3].each do |tt|                          span.vj_tt @@ -86,7 +86,7 @@                              span.fa.fa-calendar style="color: #{tt.color ? tt.color : '#4B4B4B'}"                        - if journey.purchase_windows.size > 3                          span.vj_tt = "+ #{journey.purchase_windows.size - 3}" -                    .detailed-purchase-windows.hidden +                    .detailed-purchase-windows.hidden.togglable                        - route.purchase_windows.uniq.each do |tt|                          div class=(journey.has_purchase_window?(tt) ? 'active' : 'inactive')                      div @@ -96,7 +96,7 @@                              span.fa.fa-calendar style="color: #{tt.color ? tt.color : '#4B4B4B'}"                        - if journey.time_tables.size > 3                          span.vj_tt = "+ #{journey.time_tables.size - 3}" -                    .detailed-timetables.hidden +                    .detailed-timetables.hidden.togglable                        - route.time_tables.uniq.each do |tt|                          div class=(journey.has_time_table?(tt) ? 'active' : 'inactive') @@ -105,7 +105,7 @@                      ruby:                        headline = vehicle_journey_stop_headline prev_sp, sp                        prev_sp = sp -                      vjas = journey.vehicle_journey_at_stops.where(stop_point_id: sp.id).last +                      vjas = journey.vehicle_journey_at_stops[sp.id]                      .td class="#{vjas && sp.highlighted? ? 'highlighted' : ''} #{vjas.nil? ? 'disabled' : ''} #{headline.present? ? 'headlined' : ''}"                        div title="#{sp.stop_area.city_name ? "#{sp.stop_area.city_name} (#{sp.stop_area.zip_code})" : ''}" data-headline=headline class=(headline.present? ? 'headlined' : '')                          - if vjas.present? diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index aea824a89..615913faa 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -30,13 +30,13 @@                  key: :name, \                  attribute: Proc.new { |s| content_tag :span, s.stop_area&.name, class: s.stop_area&.area_type }, \                  link_to: lambda do |stop_point| \ -                  referential_stop_area_path(@referential, stop_point.stop_area) \ +                  stop_area_referential_stop_area_path(stop_point.stop_area.referential, stop_point.stop_area) \                  end \                ), \                TableBuilderHelper::Column.new( \                  key: :status, \                  name: Chouette::StopArea.tmf('status'), \ -                attribute: Proc.new { |s| stop_area_status(s.try(:stop_area)) } \ +                attribute: Proc.new { |s| stop_area_status(s.try(:stop_area).try(:status) ) } \                ), \                TableBuilderHelper::Column.new( \                  key: :zip_code, \ diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim index 7e9fb12a3..a804de449 100644 --- a/app/views/routing_constraint_zones/index.html.slim +++ b/app/views/routing_constraint_zones/index.html.slim @@ -14,7 +14,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: t('objectid'), \ -                attribute: Proc.new { |n| n.get_objectid.local_id }, \ +                attribute: Proc.new { |n| n.get_objectid.short_id }, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ @@ -39,6 +39,8 @@              ],              links: [:show],              cls: 'table has-filter has-search' +           +          = new_pagination @routing_constraint_zones, 'pull-right'      - unless @routing_constraint_zones.any?        .row.mt-xs 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, diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim index cca48bb17..88ed6a772 100644 --- a/app/views/stop_areas/_filters.html.slim +++ b/app/views/stop_areas/_filters.html.slim @@ -9,38 +9,16 @@            span.fa.fa-search    .ffg-row -    = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.human_attribute_name(:zip_code), required: false, wrapper_html: {class: filter_item_class(params[:q], :zip_code_cont)} -    = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.human_attribute_name(:city_name), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)} +    = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.tmf('zip_code'), required: false, wrapper_html: {class: filter_item_class(params[:q], :zip_code_cont)} +    = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.tmf('city_name'), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)}      .form-group.togglable class=filter_item_class(params[:q], :area_type_eq_any) -      = f.label Chouette::StopArea.human_attribute_name(:area_type), required: false, class: 'control-label' +      = f.label Chouette::StopArea.tmf('area_type'), required: false, class: 'control-label'        = f.input :area_type_eq_any, checked: params[:q] && params[:q][:area_type_eq_any], collection: Chouette::AreaType.options, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + w[0] + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' } -       -    .form-group.togglable class=filter_item_class(params[:q], :status) + +    .form-group.togglable class=filter_item_class(params[:q], :by_status)        = f.label Chouette::StopArea.tmf('status'), required: false, class: 'control-label' -      .form-group.checkbox_list -        = f.simple_fields_for :status do |p| -          = p.input :in_creation, -            label: ("<span>#{t('activerecord.attributes.stop_area.in_creation')}<span class='fa fa-pencil text-info'></span></span>").html_safe, -            as: :boolean, -            wrapper_html: { class: 'checkbox-wrapper' }, -            checked_value: true, -            unchecked_value: false, -            input_html: { checked: @status.try(:[], :in_creation) } -          = p.input :confirmed, -            label: ("<span>#{t('activerecord.attributes.stop_area.confirmed')}<span class='fa fa-check-circle text-success'></span></span>").html_safe, -            as: :boolean, -            wrapper_html: { class: 'checkbox-wrapper' }, -            checked_value: true, -            unchecked_value: false, -            input_html: { checked: @status.try(:[], :confirmed) } -          = p.input :deactivated, -            label: ("<span>#{t('activerecord.attributes.stop_area.deleted')}<span class='fa fa-exclamation-circle text-danger'></span></span>").html_safe, -            as: :boolean, -            wrapper_html: { class: 'checkbox-wrapper' }, -            checked_value: true, -            unchecked_value: false, -            input_html: { checked: @status.try(:[], :deactivated) } +      = f.input :by_status, checked: params[:q] && params[:q][:by_status], collection: [:in_creation, :confirmed, :deactivated], as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + stop_area_status(w) + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }    .actions      = link_to t('actions.erase'), @workbench, class: 'btn btn-link' diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index 62b873c36..e5ca82ee2 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -33,7 +33,7 @@                ), \                TableBuilderHelper::Column.new( \                  key: :status, \ -                attribute: Proc.new { |s| stop_area_status(s) } \ +                attribute: Proc.new { |s| stop_area_status(s.status) } \                ), \                TableBuilderHelper::Column.new( \                  key: :zip_code, \ diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index c10d22bfb..c1965c161 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -21,7 +21,7 @@              Chouette::StopArea.tmf('city_name') => @stop_area.city_name,              Chouette::StopArea.tmf('country_code') => @stop_area.country_code.presence || '-',              Chouette::StopArea.tmf('time_zone') => @stop_area.time_zone.presence || '-', -            Chouette::StopArea.tmf('status') => stop_area_status(@stop_area), +            Chouette::StopArea.tmf('status') => stop_area_status(@stop_area.status),              Chouette::StopArea.tmf('comment') => @stop_area.try(:comment),              })          - @stop_area.custom_fields.each do |code, field| diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim index 819346c35..c7b6fd4f3 100644 --- a/app/views/workbenches/_form.html.slim +++ b/app/views/workbenches/_form.html.slim @@ -1,4 +1,6 @@ -= simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form do |f| += title_tag t('activerecord.models.compliance_control_set.other') + += simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form, title: "prout" do |f|    .row      .col-lg-12        = f.fields_for :compliance_control_set_ids do |ff| diff --git a/app/views/workbenches/edit.html.slim b/app/views/workbenches/edit.html.slim index 893024490..0774610e1 100644 --- a/app/views/workbenches/edit.html.slim +++ b/app/views/workbenches/edit.html.slim @@ -1,4 +1,4 @@ -- breadcrumb @workbench +- breadcrumb :workbench_configure, @workbench  - page_header_content_for @workbench  .page_content diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 213c9e5f2..979e7ff04 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -6,8 +6,8 @@        - if policy(Workbench).update?          = link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary'        - if policy(Referential).create? -        = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary' -        = link_to t('actions.export'), workbench_exports_path(@workbench), class: 'btn btn-primary' +        = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary' unless @workbench.workgroup.import_types.empty? +        = link_to t('actions.export'), workbench_exports_path(@workbench), class: 'btn btn-primary' unless @workbench.workgroup.export_types.empty?          = link_to t('actions.add'), new_workbench_referential_path(@workbench), class: 'btn btn-primary'        = link_to t('workbenches.actions.show_output'), workbench_output_path(@workbench), class: 'btn btn-primary' diff --git a/app/views/workgroups/_form.html.slim b/app/views/workgroups/_form.html.slim index 7245cfc40..52d1faca8 100644 --- a/app/views/workgroups/_form.html.slim +++ b/app/views/workgroups/_form.html.slim @@ -1,3 +1,5 @@ += title_tag t('activerecord.models.compliance_control_set.other') +  = simple_form_for @workgroup, html: { class: 'form-horizontal', id: 'workgroup_form' }, wrapper: :horizontal_form do |f|    table.table      thead diff --git a/app/workers/route_way_cost_worker.rb b/app/workers/route_way_cost_worker.rb index b62416c3d..5d8ed52f9 100644 --- a/app/workers/route_way_cost_worker.rb +++ b/app/workers/route_way_cost_worker.rb @@ -3,7 +3,11 @@ class RouteWayCostWorker    def perform(referential_id, route_id)      Referential.find(referential_id).switch -    route = Chouette::Route.find(route_id) +    route = Chouette::Route.where(id: route_id).last +    unless route.present? +      Rails.logger.warn "RouteWayCost called on missing route ##{route_id}".red +      return +    end      # Prevent recursive worker spawning since this call updates the      # `costs` field of the route. | 
