diff options
Diffstat (limited to 'app')
141 files changed, 616 insertions, 1435 deletions
| diff --git a/app/assets/images/import_task-completed.png b/app/assets/images/import_task-completed.pngBinary files differ deleted file mode 100644 index cd047c5fc..000000000 --- a/app/assets/images/import_task-completed.png +++ /dev/null diff --git a/app/assets/images/import_task-failed.png b/app/assets/images/import_task-failed.pngBinary files differ deleted file mode 100644 index 5d7b51646..000000000 --- a/app/assets/images/import_task-failed.png +++ /dev/null diff --git a/app/assets/images/import_task-pending.png b/app/assets/images/import_task-pending.pngBinary files differ deleted file mode 100644 index d5af6a807..000000000 --- a/app/assets/images/import_task-pending.png +++ /dev/null diff --git a/app/assets/images/import_task-processing.png b/app/assets/images/import_task-processing.pngBinary files differ deleted file mode 100644 index 88990027b..000000000 --- a/app/assets/images/import_task-processing.png +++ /dev/null diff --git a/app/assets/javascripts/modal_confirmation.coffee b/app/assets/javascripts/modal_confirmation.coffee new file mode 100644 index 000000000..0c80148e3 --- /dev/null +++ b/app/assets/javascripts/modal_confirmation.coffee @@ -0,0 +1,29 @@ +$(document).ready () => +  $.rails.allowAction = (link) => +    message = link.data('confirm') +    if !message +      return true +    showConfirmModal link +    false + +  showConfirmModal = (link) => +    message = link.data('confirm') +    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() 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/assets/stylesheets/partials/base.sass b/app/assets/stylesheets/partials/base.sass deleted file mode 100644 index 50a50457b..000000000 --- a/app/assets/stylesheets/partials/base.sass +++ /dev/null @@ -1,19 +0,0 @@ -.formtastic.timeband -  .time_select -    .fragments -      .fragments-group -        padding-left: 0 - -      legend.label -        position: relative -        width: auto -        display: block -        width: 25% -        float: left -        border: none - -        label -          position: relative -          width: auto -          font-size: 125% -          padding: .2em .6em .3em
\ No newline at end of file diff --git a/app/controllers/api/v1/connection_links_controller.rb b/app/controllers/api/v1/connection_links_controller.rb deleted file mode 100644 index c5cf39812..000000000 --- a/app/controllers/api/v1/connection_links_controller.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Api::V1::ConnectionLinksController < Api::V1::ChouetteController - -  defaults :resource_class => Chouette::ConnectionLink, :finder => :find_by_objectid! - -protected - -  def collection -    @connection_links ||= ( @referential ? @referential.connection_links.search(params[:q]).result(:distinct => true) : []) -  end  - -end - diff --git a/app/controllers/autocomplete_timebands_controller.rb b/app/controllers/autocomplete_timebands_controller.rb deleted file mode 100644 index af041c33e..000000000 --- a/app/controllers/autocomplete_timebands_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AutocompleteTimebandsController < ChouetteController -  respond_to :json, :only => [:index] - -  include ReferentialSupport - -  protected - -  def select_timebands -    if params[:route_id] -      referential.timebands.joins( vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})") -    else -      referential.timebands -    end -  end - -  def referential_timebands -    @referential_timebands ||= select_timebands -  end - -  def collection -    @timebands = referential_timebands.select{ |p| p.fullname =~ /#{params[:q]}/i  } -  end -end 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/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb index 7df922d01..ac6c54a3c 100644 --- a/app/controllers/compliance_controls_controller.rb +++ b/app/controllers/compliance_controls_controller.rb @@ -5,7 +5,7 @@ class ComplianceControlsController < ChouetteController    actions :all, :except => [:index]    def select_type -    @sti_subclasses = ComplianceControl.subclasses.sort_by {|compliance_control| compliance_control.default_code} +    @sti_subclasses ||= ComplianceControl.subclasses_to_hash     end    def show diff --git a/app/controllers/connection_link_areas_controller.rb b/app/controllers/connection_link_areas_controller.rb deleted file mode 100644 index 981a7639e..000000000 --- a/app/controllers/connection_link_areas_controller.rb +++ /dev/null @@ -1,28 +0,0 @@ -class ConnectionLinkAreasController < ChouetteController -  include ReferentialSupport - -  respond_to :json, :only => :index - -  def index -    respond_to do |format| -      format.json { render :json => areas_maps } -    end -  end - -  def areas_maps -    areas.collect do |area| -      { :id => area.id.to_s, -        :name => area.name, -        :country_code =>  area.country_code, -        :zip_code => area.zip_code || "", -        :city_name => area.city_name || "", -        :area_type => t("area_types.label.#{area.area_type.underscore}") -      } -    end -  end - -  def areas -    referential.connection_links.find(params[:connection_link_id]).possible_areas.select{ |p| p.name =~ /#{params[:q]}/i  } -  end - -end diff --git a/app/controllers/connection_links_controller.rb b/app/controllers/connection_links_controller.rb deleted file mode 100644 index a7f9758e8..000000000 --- a/app/controllers/connection_links_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -class ConnectionLinksController < ChouetteController -  include ReferentialSupport -  defaults :resource_class => Chouette::ConnectionLink - -  belongs_to :referential do -    belongs_to :departure, :parent_class => Chouette::StopArea, :optional => true -    belongs_to :arrival, :parent_class => Chouette::StopArea, :optional => true -  end - -  respond_to :html, :xml, :json -  respond_to :kml, :only => :show -  respond_to :js, :only => :index - -  include PolicyChecker - -  def index -    index! do |format| -      format.html { -        if collection.out_of_bounds? -          redirect_to params.merge(:page => 1) -        end -      } -    end -  end - -  def show -    show! -  end - -  def select_areas -    @connection_link = connection_link -    @departure = connection_link.departure -    @arrival = connection_link.arrival -  end - -  protected - -  alias_method :connection_link, :resource - -  def collection -    @q = referential.connection_links.search(params[:q]) -    @connection_links ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) -  end - -  def resource_url(connection_link = nil) -    referential_connection_link_path(referential, connection_link || resource) -  end - -  def collection_url -    referential_connection_links_path(referential) -  end - -  private - -  def connection_link_params -    params.require(:connection_link).permit( :connection_link_type,:departure_id, :arrival_id, :objectid, :object_version, :name, :comment, :link_distance, :link_type, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration, :mobility_restricted_traveller_duration, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs ) -  end - -end 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_stop_areas_controller.rb b/app/controllers/referential_stop_areas_controller.rb index fa09bb773..a5fd15fcb 100644 --- a/app/controllers/referential_stop_areas_controller.rb +++ b/app/controllers/referential_stop_areas_controller.rb @@ -6,7 +6,6 @@ class ReferentialStopAreasController  < ChouetteController    belongs_to :referential do      belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true      belongs_to :network, :parent_class => Chouette::Network, :optional => true, :polymorphic => true -    belongs_to :connection_link, :parent_class => Chouette::ConnectionLink, :optional => true, :polymorphic => true    end    respond_to :html, :kml, :xml, :json 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_area_copies_controller.rb b/app/controllers/stop_area_copies_controller.rb deleted file mode 100644 index 992a2bb08..000000000 --- a/app/controllers/stop_area_copies_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class StopAreaCopiesController < ChouetteController -  include ReferentialSupport -  defaults :resource_class => StopAreaCopy -  belongs_to :referential do -    belongs_to :stop_area, :parent_class => Chouette::StopArea -  end - -  actions :new, :create -  respond_to :html, :only => :new - -  def new -    @stop_area_copy = StopAreaCopy.new(:hierarchy => params[:hierarchy], :source => parent) -    new! do -      build_breadcrumb :new -    end -  end - -  def create -    @stop_area_copy = StopAreaCopy.new(params[:stop_area_copy]) -    @stop_area = parent -    if @stop_area_copy.save -      redirect_to referential_stop_area_path( @referential,@stop_area_copy.copy ), notice: I18n.t("stop_area_copies.new.success") -    else -      flash[:error] = I18n.t("stop_area_copies.errors.copy_aborted") + "<br>" + @stop_area_copy.errors.full_messages.join("<br>") -      render :action => :new -    end -  end - -  protected - -end 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/controllers/timebands_controller.rb b/app/controllers/timebands_controller.rb deleted file mode 100644 index 937283b0e..000000000 --- a/app/controllers/timebands_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class TimebandsController < ChouetteController -  include ReferentialSupport - -  defaults :resource_class => Chouette::Timeband - -  respond_to :html - -  belongs_to :referential - -  private -  def timeband_params -    params.require(:timeband).permit( :name, :start_time, :end_time ) -  end -end diff --git a/app/controllers/vehicle_journey_frequencies_controller.rb b/app/controllers/vehicle_journey_frequencies_controller.rb deleted file mode 100644 index 6e12c0247..000000000 --- a/app/controllers/vehicle_journey_frequencies_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class VehicleJourneyFrequenciesController < VehicleJourneysController - -  defaults resource_class: Chouette::VehicleJourneyFrequency - -  def new -    new! do -      vehicle_journey.journey_frequencies.build -    end -  end - -  private - -  def vehicle_journey_frequency_params -    params.require(:vehicle_journey_frequency).permit( { footnote_ids: [] } , :journey_pattern_id, :number, :published_journey_name, -                                             :published_journey_identifier, :comment, :transport_mode, -                                             :mobility_restricted_suitability, :flexible_service, -                                             :facility, :vehicle_type_identifier, :objectid, :time_table_tokens, -                                             { date: [ :hour, :minute ] }, :button, :referential_id, :line_id, -                                             :route_id, :id, { vehicle_journey_at_stops_attributes: [ :arrival_time, -                                                                                                      :id, :_destroy, -                                                                                                      :stop_point_id, -                                                                                                      :departure_time] }, -                                             { journey_frequencies_attributes: [ :id, :_destroy, :scheduled_headway_interval, :first_departure_time, -                                                                                 :last_departure_time, :exact_time, :timeband_id ] } ) -  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/application_helper.rb b/app/helpers/application_helper.rb index 7a3f7e719..7be2b9041 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -115,14 +115,8 @@ module ApplicationHelper        "access_points_links"      when path.include?("/stop_areas")        "stop_areas" -    when path.include?("/connection_links") -      "connection_links"      when path.include?("/time_tables")        "time_tables" -    when path.include?("/timebands") -      "timebands" -    when path.include?("/import_tasks") -      "imports"      when path.include?("/exports")        "exports"      when path.include?("/compliance_check_tasks") diff --git a/app/helpers/compliance_control_sets_helper.rb b/app/helpers/compliance_control_sets_helper.rb index 0c63cb139..a62b27858 100644 --- a/app/helpers/compliance_control_sets_helper.rb +++ b/app/helpers/compliance_control_sets_helper.rb @@ -83,6 +83,10 @@ module ComplianceControlSetsHelper              attribute: 'code'            ),            TableBuilderHelper::Column.new( +            key: :subclass, +            attribute: Proc.new { |compliance_control| compliance_control.object.class.translated_subclass } +          ), +          TableBuilderHelper::Column.new(              key: :name,              attribute: 'name',              link_to: lambda do |compliance_control| @@ -98,7 +102,7 @@ module ComplianceControlSetsHelper              attribute: 'comment'            ),        ], -      sortable: true, +      sortable: false,        cls: 'table has-filter has-search',        model: ComplianceControl,        action: :index diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb index abf909929..78d0ba0c2 100644 --- a/app/helpers/compliance_controls_helper.rb +++ b/app/helpers/compliance_controls_helper.rb @@ -9,13 +9,24 @@ module ComplianceControlsHelper      [t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"]    end +  def display_control_attribute(key, value) +    if key == "target" +      parts = value.match(%r((?'object_type'\w+)#(?'attribute'\w+))) +      object_type = ComplianceControl.tmf("subclasses.#{parts[:object_type]}") +      target = I18n.t("activerecord.attributes.#{parts[:object_type]}.#{parts[:attribute]}") +      "#{object_type} - #{target}" +    else +      value +    end  +  end +    def compliance_control_metadatas(compliance_control)      attributes = resource.class.dynamic_attributes      attributes.push(*resource.control_attributes.keys) if resource&.control_attributes&.keys      {}.tap do |hash|        attributes.each do |attribute| -        hash[ComplianceControl.human_attribute_name(attribute)] = resource.send(attribute) +        hash[ComplianceControl.human_attribute_name(attribute)] = display_control_attribute(attribute, resource.send(attribute))        end      end    end diff --git a/app/helpers/connection_links_helper.rb b/app/helpers/connection_links_helper.rb deleted file mode 100644 index d9c201028..000000000 --- a/app/helpers/connection_links_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module ConnectionLinksHelper - -  def connection_link_type_label_pairs -    Chouette::ConnectionLink -      .connection_link_types -      .zip_map { |type| t("connection_link_types.label.#{type}") } -  end -end diff --git a/app/helpers/exports_helper.rb b/app/helpers/exports_helper.rb index f30a80ed9..cc6fc3046 100644 --- a/app/helpers/exports_helper.rb +++ b/app/helpers/exports_helper.rb @@ -4,12 +4,37 @@ module ExportsHelper      import_status status    end -  def export_option_input form, export, attr, option_def, type -    opts = { required: option_def[:required], input_html: {value: export.try(attr) || option_def[:default_value]}, as: option_def[:type], selected:  export.try(attr) || option_def[:default_value]} -    opts[:collection] = option_def[:collection] if option_def.has_key?(:collection) -    opts[:collection] = export.instance_exec(&option_def[:collection]) if option_def[:collection].is_a?(Proc) -    opts[:label] = t "activerecord.attributes.export.#{type.name.demodulize.underscore}.#{attr}" -    form.input attr, opts +  def export_option_input form, export, attr, option_def, type, referentials +    if !!option_def[:depends_on_referential] +      out = "" +      referentials.each do |referential| +        out += content_tag :div, class: "slave", data: {master: "[name='export[referential_id]']", value: referential.id} do +          _opts = {depends_on_referential: false, collection: option_def[:collection].call(referential)}.reverse_update(option_def) +          export_option_input form, export, attr, _opts, type, referentials +        end +      end +      out.html_safe +    else +      opts = { required: option_def[:required], input_html: {value: export.try(attr) || option_def[:default_value]}, as: option_def[:type], selected:  export.try(attr) || option_def[:default_value]} + +      if option_def.has_key?(:collection) +        if option_def[:collection].is_a?(Array) && !option_def[:collection].first.is_a?(Array) +          opts[:collection] = option_def[:collection].map{|k| [export.class.tmf("#{type.name.demodulize.underscore}.#{attr}_collection.#{k}"), k]} +        else +          opts[:collection] = option_def[:collection] +        end +        opts[:collection] = export.instance_exec(&option_def[:collection]) if option_def[:collection].is_a?(Proc) +      end +      opts[:label] =  export.class.tmf("#{type.name.demodulize.underscore}.#{attr}") +      opts[:input_html]['data-select2ed'] = true if opts[:collection] +      out = form.input attr, opts +      if option_def[:depends] +        out = content_tag :div, class: "slave", data: {master: "[name='export[#{option_def[:depends][:option]}]']", value: option_def[:depends][:value]} do +          out +        end.html_safe +      end +      out +    end    end    def export_message_content message @@ -20,39 +45,6 @@ module ExportsHelper      end.html_safe    end -  def fields_for_export_task_format(form) -    begin -      render :partial => export_partial_name(form), :locals => { :form => form } -    rescue ActionView::MissingTemplate -      "" -    end -  end - -  def export_partial_name(form) -    "fields_#{form.object.format.underscore}_export" -  end - -  def export_attributes_tag(export) -    content_tag :div, class: "export-attributes" do -      [].tap do |parts| -        if export.format.present? -          parts << bh_label(t("enumerize.data_format.#{export.format}")) -        end -      end.join.html_safe -    end -  end - -  def compliance_icon( export_task) -    return nil unless export_task.compliance_check_task -    export_task.compliance_check_task.tap do |cct| -      if cct.failed? || cct.any_error_severity_failure? -        return 'icons/link_page_alert.png' -      else -        return 'icons/link_page.png' -      end -    end -  end -    def workgroup_exports workgroup      Export::Base.user_visible_descendants.select{|e| workgroup.has_export? e.name}    end diff --git a/app/helpers/imports_helper.rb b/app/helpers/imports_helper.rb index f06d77eca..62a09b216 100644 --- a/app/helpers/imports_helper.rb +++ b/app/helpers/imports_helper.rb @@ -44,51 +44,4 @@ module ImportsHelper    def import_message_content message      export_message_content message    end - -  ############################## -  #      TO CLEAN!!! -  ############################## - -  def fields_for_import_task_format(form) -    begin -      render :partial => import_partial_name(form), :locals => { :form => form } -    rescue ActionView::MissingTemplate -      "" -    end -  end - -  def import_partial_name(form) -    "fields_#{form.object.format.underscore}_import" -  end - -  def compliance_icon( import_task) -    return nil unless import_task.compliance_check_task -    import_task.compliance_check_task.tap do |cct| -      if cct.failed? || cct.any_error_severity_failure? -        return 'icons/link_page_alert.png' -      else -        return 'icons/link_page.png' -      end -    end -  end - -  def import_attributes_tag(import) -    content_tag :div, class: "import-attributes" do -      [].tap do |parts| -        if import.format.present? -          parts << bh_label(t("enumerize.data_format.#{import.format}")) -        end -        parts << content_tag(:div, import_save_mode_icon_tag(import), class: "save-mode") -      end.join.html_safe -    end -  end - -  def import_save_mode_icon_tag(import) -    if import.no_save? -      fa_stacked_icon "database", base: "ban" -    else -      fa_icon "database" -    end -  end -  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_area_copies_helper.rb b/app/helpers/stop_area_copies_helper.rb deleted file mode 100644 index 023a9d750..000000000 --- a/app/helpers/stop_area_copies_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module StopAreaCopiesHelper -   -  def label_stop_area_types(*stop_area_types) -    stop_area_types -      .flatten -      .zip_map { |stop_area_type| t("area_types.label.#{stop_area_type}") } -  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/helpers/timebands_helper.rb b/app/helpers/timebands_helper.rb deleted file mode 100644 index 51251e46f..000000000 --- a/app/helpers/timebands_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TimebandsHelper -end diff --git a/app/inputs/search_timeband_input.rb b/app/inputs/search_timeband_input.rb deleted file mode 100644 index bad262ef2..000000000 --- a/app/inputs/search_timeband_input.rb +++ /dev/null @@ -1,44 +0,0 @@ -class SearchTimebandInput < Formtastic::Inputs::SearchInput - -  def search -    if options[:json] -      template.content_tag( :script, -                            ("$(document).ready(function() { -          var timeband_formatter = function(item){ -            return '<li>' + item.name + '</li>'; -          }; -           $('##{dom_id}').tokenInput('#{options[:json]}', { -             zindex: 1061, -             crossDomain: false, -             tokenLimit: 1, -             minChars: 2, -             propertyToSearch: 'name', -             preventDuplicates: true, -             hintText: '#{options[:hint_text]}', -             noResultsText: '#{options[:no_result_text]}', -             searchingText: '#{options[:searching_text]}', -             resultsFormatter: timeband_formatter, -             tokenFormatter: timeband_formatter, -           }); -        });").html_safe) -    end -  end - -  def to_html -    input_wrapping do -      label_html << -          builder.search_field(method, input_html_options) << -          search -    end -  end - -  def input_html_options -    super.merge({ -                    required:             nil, -                    autofocus:            nil, -                    class:                'token-input', -                    :'data-model-name' => object.class.model_name.human -                }) -  end - -end diff --git a/app/javascript/helpers/master_slave.coffee b/app/javascript/helpers/master_slave.coffee index 81bebe36a..e1bd46281 100644 --- a/app/javascript/helpers/master_slave.coffee +++ b/app/javascript/helpers/master_slave.coffee @@ -3,14 +3,21 @@ class MasterSlave      $(selector).find('[data-master]').each (i, slave)->        $slave = $(slave)        master = $($slave.data().master) -      $slave.find("input:disabled, select:disabled").attr "data-slave-force-disabled", "true" -      toggle = -> +      if $slave.find('[data-master]').length == 0 +        $slave.find("input:disabled, select:disabled").attr "data-slave-force-disabled", "true" +      toggle = (disableInputs=true)->          val = master.filter(":checked").val() if master.filter("[type=radio]").length > 0          val ||= master.val() -        selected = val == $slave.data().value +        selected = "#{val}" == "#{$slave.data().value}"          $slave.toggle selected -        $slave.find("input, select").filter(":not([data-slave-force-disabled])").attr "disabled", !selected +        $slave.toggleClass "active", selected +        if disableInputs +          disabled = !selected +          disabled = disabled || $slave.parents("[data-master]:not(.active)").length > 0 +          $slave.find("input, select").filter(":not([data-slave-force-disabled])").attr "disabled", disabled +        if selected +          $("[data-select2ed='true']").select2()        master.change toggle -      toggle() +      toggle($slave.find('[data-master]').length == 0)  export default MasterSlave 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/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/journey_frequency.rb b/app/models/chouette/journey_frequency.rb deleted file mode 100644 index 1b4efe96e..000000000 --- a/app/models/chouette/journey_frequency.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Chouette -  class JourneyFrequencyValidator < ActiveModel::Validator -    def validate(record) -      timeband = record.timeband -      if timeband -        first_departure_time = record.first_departure_time.utc.strftime( "%H%M%S%N" ) -        last_departure_time  = record.last_departure_time.utc.strftime( "%H%M%S%N" ) -        timeband_start_time  = timeband.start_time.utc.strftime( "%H%M%S%N" ) -        timeband_end_time    = timeband.end_time.utc.strftime( "%H%M%S%N" ) - -        unless first_departure_time.between? timeband_start_time, timeband_end_time -          record.errors[:first_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.start_must_be_after_timeband') -        end -        unless last_departure_time.between? timeband_start_time, timeband_end_time -          record.errors[:last_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.end_must_be_before_timeband') -        end -      end -      if record.first_departure_time == record.last_departure_time -        record.errors[:last_departure_time] << I18n.t('activerecord.errors.models.journey_frequency.end_must_be_different_from_first') -      end -      if record.scheduled_headway_interval.blank? || (record.scheduled_headway_interval.strftime( "%H%M%S%N" ) == Time.current.midnight.strftime( "%H%M%S%N" )) -        record.errors[:scheduled_headway_interval] << I18n.t('activerecord.errors.models.journey_frequency.scheduled_headway_interval_greater_than_zero') -      end -    end -  end - -  class JourneyFrequency < ActiveRecord -    belongs_to :vehicle_journey_frequency, foreign_key: 'vehicle_journey_id' -    belongs_to :timeband -    validates :first_departure_time, presence: true -    validates :last_departure_time,  presence: true -    validates :scheduled_headway_interval, presence: true -    validates_with Chouette::JourneyFrequencyValidator -  end -end
\ No newline at end of file diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 949b18d6f..00e5d27fa 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -34,6 +34,7 @@ module Chouette          Chouette::Route.vehicle_journeys_timeless(proxy_association.owner.journey_patterns.pluck( :departure_stop_point_id))        end      end +    has_many :vehicle_journey_at_stops, through: :vehicle_journeys      has_many :vehicle_journey_frequencies, :dependent => :destroy do        # Todo : I think there is a better way to do this.        def timeless @@ -63,6 +64,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| @@ -89,6 +93,18 @@ module Chouette            TomTom.enabled?        } +    def clean! +      vehicle_journeys.find_each do |vj| +        vj.vehicle_journey_at_stops.delete_all +      end +      vehicle_journeys.delete_all +      journey_patterns.delete_all +      stop_points.delete_all +      routing_constraint_zones.delete_all +      Chouette::Route.where(opposite_route_id: self.id).update_all(opposite_route_id: nil) +      self.delete +    end +      def duplicate opposite=false        overrides = {          'opposite_route_id' => nil, @@ -166,7 +182,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..91dfab705 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, :registration_number, :kind, :area_type, :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/timeband.rb b/app/models/chouette/timeband.rb deleted file mode 100644 index 38260b755..000000000 --- a/app/models/chouette/timeband.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Chouette -  class TimebandValidator < ActiveModel::Validator -    def validate(record) -      if record.end_time <= record.start_time -        record.errors[:end_time] << I18n.t('activerecord.errors.models.timeband.start_must_be_before_end') -      end -    end -  end - -  class Timeband < Chouette::TridentActiveRecord -    include ObjectidSupport -    has_metadata - -    validates :start_time, :end_time, presence: true -    validates_with Chouette::TimebandValidator - -    default_scope { order(:start_time) } - -    def self.object_id_key -      "Timeband" -    end - -    def fullname -      fullname = "#{I18n.l(self.start_time, format: :hour)}-#{I18n.l(self.end_time, format: :hour)}" -      "#{self.name} (#{fullname})" if self.name -    end -  end -end 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..c9dc269ac 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]).find_each &:clean!    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/compliance_control.rb b/app/models/compliance_control.rb index 672fb128c..4a2a6e91c 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -20,6 +20,21 @@ class ComplianceControl < ApplicationModel        }      end +    def subclasses_to_hash +      ComplianceControl.subclasses.inject(Hash.new{ |h, k| h[k] = [] } ) do |h, klass| +        h[ComplianceControl.subclass_patterns.key(klass.object_type)] << klass +        h  +      end +    end + +    def translated_subclass +      I18n.t("compliance_controls.filters.subclasses.#{subclass_patterns.key(self.object_type)}") +    end + +    def object_type +      self.default_code.match(/^\d+-(?'object_type'\w+)-\d+$/)[:object_type] +    end +      def inherited(child)        child.instance_eval do          def model_name 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/concerns/custom_fields_support.rb b/app/models/concerns/custom_fields_support.rb index f5a76f324..f55ff923b 100644 --- a/app/models/concerns/custom_fields_support.rb +++ b/app/models/concerns/custom_fields_support.rb @@ -31,7 +31,7 @@ module CustomFieldsSupport      end      def custom_fields_checksum -      custom_fields.values.map(&:checksum) +      custom_fields.values.sort_by(&:code).map(&:checksum)      end      def custom_field_values= vals diff --git a/app/models/concerns/iev_interfaces/task.rb b/app/models/concerns/iev_interfaces/task.rb index e40808009..b8ae12be9 100644 --- a/app/models/concerns/iev_interfaces/task.rb +++ b/app/models/concerns/iev_interfaces/task.rb @@ -7,6 +7,7 @@ module IevInterfaces::Task      belongs_to :referential      mount_uploader :file, ImportUploader +    validates_integrity_of :file      has_many :children, foreign_key: :parent_id, class_name: self.name, dependent: :destroy diff --git a/app/models/export/base.rb b/app/models/export/base.rb index c65539635..6afa6b8e0 100644 --- a/app/models/export/base.rb +++ b/app/models/export/base.rb @@ -52,7 +52,7 @@ class Export::Base < ActiveRecord::Base            begin              klass_name.constantize            rescue => e -            Rails.logger.info "Failed: #{e.message}" +            Rails.logger.info "Failed: #{e.message}".red              nil            end          end @@ -83,10 +83,18 @@ class Export::Base < ActiveRecord::Base      end      if !!opts[:required] -      validates name, presence: true +      if opts[:depends] +        validates name, presence: true, if: ->(record){ record.send(opts[:depends][:option]) == opts[:depends][:value]} +      else +        validates name, presence: true +      end      end      @options ||= {}      @options[name] = opts + +    if block_given? +      yield Export::OptionProxy.new(self, opts.update(name: name)) +    end    end    def self.options diff --git a/app/models/export/netex.rb b/app/models/export/netex.rb index 069ec2209..d471682b0 100644 --- a/app/models/export/netex.rb +++ b/app/models/export/netex.rb @@ -1,8 +1,13 @@  class Export::Netex < Export::Base    after_commit :call_iev_callback, on: :create -  option :export_type, collection: %w(line full), required: true -  option :duration, type: :integer, default_value: 90, required: true -  option :line_code +  option :export_type, collection: %w(line full), required: true do |val| +    val.full do +      option :duration, type: :integer, default_value: 90, required: true +    end +    val.line do +      option :line_code, collection: ->(referential){referential.lines.map{|l| [l.display_name, l.id]}}, depends_on_referential: true +    end +  end    private @@ -10,10 +15,6 @@ class Export::Netex < Export::Base      URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/exporter/new?id=#{id}")    end -  # def self.user_visible? -  #   false -  # end -    def destroy_non_ready_referential      if referential && !referential.ready        referential.destroy diff --git a/app/models/export/option_proxy.rb b/app/models/export/option_proxy.rb new file mode 100644 index 000000000..8141f3b54 --- /dev/null +++ b/app/models/export/option_proxy.rb @@ -0,0 +1,21 @@ +class Export::OptionProxy +  def initialize export, parent_option +    @export = export +    @parent_option = parent_option + +    if parent_option[:collection].is_a?(Array) +      parent_option[:collection].each do |val| +        define_singleton_method val do |&block| +          @_collection_value = val +          instance_exec &block +          @_collection_value = nil +        end +      end +    end +  end + +  def option name, opts={} +    opts.update depends: {option: @parent_option[:name], value: @_collection_value} +    @export.option name, opts +  end +end diff --git a/app/models/import/base.rb b/app/models/import/base.rb index dcd710e58..ea7304d70 100644 --- a/app/models/import/base.rb +++ b/app/models/import/base.rb @@ -1,6 +1,5 @@  class Import::Base < ApplicationModel    self.table_name = "imports" -  validates :file, presence: true    def self.messages_class_name      "Import::Message" @@ -15,6 +14,7 @@ class Import::Base < ApplicationModel    end    include IevInterfaces::Task +  validates_presence_of :file, unless: Proc.new {|import| import.errors[:file].present? }    def self.model_name      ActiveModel::Name.new Import::Base, Import::Base, "Import" 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..f4111c3fa 100644 --- a/app/models/merge.rb +++ b/app/models/merge.rb @@ -35,6 +35,8 @@ class Merge < ApplicationModel        merge_referential referential      end +    clean_new +      save_current    rescue => e      Rails.logger.error "Merge failed: #{e} #{e.backtrace.join("\n")}" @@ -83,6 +85,10 @@ class Merge < ApplicationModel      @new = new    end +  def clean_new +    CleanUp.new(referential: new, methods: [:destroy_empty]).clean +  end +    def merge_referential(referential)      Rails.logger.debug "Merge #{referential.slug}" @@ -145,12 +151,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 +172,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 +192,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 +240,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/referential.rb b/app/models/referential.rb index 0c6e71d47..ea75274d0 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -192,9 +192,6 @@ class Referential < ApplicationModel      Chouette::TimeTableDate.all    end -  def timebands -    Chouette::Timeband.all -  end    def connection_links      Chouette::ConnectionLink.all 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..4da103c38 100644 --- a/app/models/simple_interface.rb +++ b/app/models/simple_interface.rb @@ -97,14 +97,16 @@ 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) +    first_row = journal.find{|r| r[:row].present? } +    if first_row.present?        log "Writing output log"        FileUtils.mkdir_p @output_dir -      keys = self.journal.first[:row].map(&:first) +      keys = first_row[:row].map(&:first)        CSV.open(output_filepath, "w") do |csv|          csv << cols + keys -        self.journal.each do |j| -          csv << cols.map{|c| j[c]} + j[:row].map(&:last) +        journal.each do |j| +          csv << cols.map{|c| j[c]} + (j[:row] || {}).map(&:last)          end        end        log "Output written in #{output_filepath}", replace: true 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/models/stop_area_copy.rb b/app/models/stop_area_copy.rb deleted file mode 100644 index d3eb78557..000000000 --- a/app/models/stop_area_copy.rb +++ /dev/null @@ -1,95 +0,0 @@ -class StopAreaCopy -  include ActiveModel::Validations -  include ActiveModel::Conversion -  extend  ActiveModel::Naming - -  attr_accessor :source_id, :hierarchy, :area_type, :source, :copy - -  validates_presence_of :source_id, :hierarchy, :area_type - -  validates :hierarchy, inclusion: { in: %w(child parent) } - - -  def initialize(attributes = {}) -    attributes.each { |name, value| send("#{name}=", value) } if attributes -    if self.area_type.blank? && self.source != nil -      self.source_id = self.source.id -      if self.hierarchy == "child" -        if self.source.area_type.underscore == "stop_place" -          self.area_type="commercial_stop_point" -        else -          self.area_type="boarding_position" -        end -      else -        if self.source.area_type.underscore == "stop_place" || self.source.area_type.underscore == "commercial_stop_point" -          self.area_type="stop_place" -        else -          self.area_type="commercial_stop_point" -        end -      end -    end -  end - -  def persisted? -    false -  end -   -  def source -    @source ||= Chouette::StopArea.find self.source_id -  end - -  def copy -    @copy ||= self.source.duplicate -  end - -  def copy_is_source_parent? -    self.hierarchy == "parent" -  end - -  def copy_is_source_child? -    self.hierarchy == "child" -  end - -  def copy_modfied_attributes -    { :name => self.source.name, # TODO: change ninoxe to avoid that !!! -      :area_type => self.area_type.camelcase, -      :registration_number => nil, -      :parent_id => copy_is_source_child? ? self.source_id : nil -    } -  end - -  def source_modified_attributes -    return {} unless copy_is_source_parent? -    { :parent_id => self.copy.id -    } -  end - -  def save -    begin -      if self.valid? -        Chouette::StopArea.transaction do -          copy.update_attributes copy_modfied_attributes -          if copy.valid? -            unless source_modified_attributes.empty? -              source.update_attributes source_modified_attributes -            end -            true -          else -            copy.errors.full_messages.each do |m|  -              errors.add :base, m -            end -            false -          end   -        end -      else -        false -      end -    rescue Exception => exception -      Rails.logger.error(exception.message) -      Rails.logger.error(exception.backtrace.join("\n")) -      errors.add :base, I18n.t("stop_area_copies.errors.exception") -      false -    end -  end -   -end diff --git a/app/services/referential_consolidated.rb b/app/services/referential_consolidated.rb index 465eab405..1b07a758e 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, :country_code).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/autocomplete_timebands/index.rabl b/app/views/autocomplete_timebands/index.rabl deleted file mode 100644 index 663b09285..000000000 --- a/app/views/autocomplete_timebands/index.rabl +++ /dev/null @@ -1,8 +0,0 @@ -collection @timebands - -node do |timeband| -  { -    id: timeband.id, -    name: timeband.fullname -  } -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/compliance_controls/select_type.html.slim b/app/views/compliance_controls/select_type.html.slim index d1c518ecf..4be53362b 100644 --- a/app/views/compliance_controls/select_type.html.slim +++ b/app/views/compliance_controls/select_type.html.slim @@ -4,9 +4,11 @@      .row        .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1          = form_tag(new_compliance_control_set_compliance_control_path, method: :get) do -          - @sti_subclasses.each do |klass| -            .radio -              = radio_button_tag(:sti_class, klass, @sti_subclasses.first) -              = "#{klass.default_code} - #{I18n.t("activerecord.models.#{klass.name.underscore}.one")}" +          - ComplianceControl.subclass_patterns.each do |key, value| +            h3 = t("compliance_controls.filters.subclasses.#{key}") +            - @sti_subclasses[key].each do |klass| +              .radio +                = radio_button_tag(:sti_class, klass, @sti_subclasses.first) +                = "#{I18n.t("activerecord.models.#{klass.name.underscore}.one")}"            .text-right              = submit_tag t('compliance_control_sets.actions.loaded'), class: "btn btn-outline-primary" diff --git a/app/views/connection_links/_connection_link.slim b/app/views/connection_links/_connection_link.slim index 44ed5093f..9de04ba12 100644 --- a/app/views/connection_links/_connection_link.slim +++ b/app/views/connection_links/_connection_link.slim @@ -20,14 +20,14 @@        = t('.from')        - if connection_link.departure.present? -        = link_to_if connection_link.departure, truncate(connection_link.departure.name, :length => 15) , referential_stop_area_path(@referential, connection_link.departure), :title => "#{connection_link.human_attribute_name('departure')} #{connection_link.departure.name}" +        = link_to_if connection_link.departure, truncate(connection_link.departure.name, :length => 15) , stop_area_referential_stop_area_path(connection_link.departure.stop_area_referential, connection_link.departure), :title => "#{connection_link.human_attribute_name('departure')} #{connection_link.departure.name}"        - else      	 = connection_link.human_attribute_name('undefined')        = t('.to')        - if connection_link.arrival.present? -        = link_to_if( connection_link.arrival, truncate(connection_link.arrival.name, :length => 15), referential_stop_area_path(@referential, connection_link.arrival), :title => "#{connection_link.human_attribute_name('arrival')} #{connection_link.arrival.name}" ) +        = link_to_if( connection_link.arrival, truncate(connection_link.arrival.name, :length => 15), stop_area_referential_stop_area_path(connection_link.arrival.stop_area_referential, connection_link.arrival), :title => "#{connection_link.human_attribute_name('arrival')} #{connection_link.arrival.name}" )        - else          = connection_link.human_attribute_name("undefined")      p diff --git a/app/views/connection_links/_connection_links.html.slim b/app/views/connection_links/_connection_links.html.slim deleted file mode 100644 index 8cf41a6c1..000000000 --- a/app/views/connection_links/_connection_links.html.slim +++ /dev/null @@ -1,10 +0,0 @@ -.page_info -  span.search -    = t("will_paginate.page_entries_info.search") -  = page_entries_info @connection_links - -.connection_links.paginated_content -  = paginated_content(@connection_links) - -.pagination -  = will_paginate @connection_links, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer diff --git a/app/views/connection_links/_form.html.slim b/app/views/connection_links/_form.html.slim deleted file mode 100644 index a3774ec88..000000000 --- a/app/views/connection_links/_form.html.slim +++ /dev/null @@ -1,21 +0,0 @@ -= semantic_form_for [@referential, @connection_link] do |form| -  = form.inputs do -    = form.input :name -    = form.input :connection_link_type, as: :select, collection: connection_link_type_label_pairs, include_blank: true -    = form.input :comment -    = form.input :link_distance, input_html: { title: t("formtastic.titles#{format_restriction_for_locales(@referential)}.connection_link.link_distance") } -    = form.input :mobility_restricted_suitability, as: :select, :collection => [[t("true"), true], [t("false"), false]], include_blank: true -    = form.input :stairs_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], include_blank: true -    = form.input :lift_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], include_blank: true - -    = form.input :objectid, :required => !@connection_link.new_record?, :input_html => { :title => t("formtastic.titles.connection_link.objectid")} - -  = form.inputs :name => t('connection_links.show.durations') do -    = form.input :default_duration, :as => :extended_time_picker, :size => 8, :step => :seconds, :label => @connection_link.human_attribute_name("default_duration"), :input_html => { :class => "form-control input-sm timepicker_seconds", :step => 1}, :wrapper_html => { :class => "input-append bootstrap-timepicker" } -    = form.input :frequent_traveller_duration, :as => :extended_time_picker, :size => 8, :step => :seconds, :include_seconds => true, :label => @connection_link.human_attribute_name("frequent_traveller_duration"), :input_html => { :class => "form-control input-sm timepicker_seconds", :step => 1}, :wrapper_html => { :class => "input-append bootstrap-timepicker" } -    = form.input :occasional_traveller_duration, :as => :extended_time_picker, :size => 8, :include_seconds => true, :label => @connection_link.human_attribute_name("occasional_traveller_duration"), :input_html => { :class => "form-control input-sm timepicker_seconds", :step => 1}, :wrapper_html => { :class => "input-append bootstrap-timepicker" } -    = form.input :mobility_restricted_traveller_duration, :as => :extended_time_picker,:size => 8, :include_seconds => true, :label => @connection_link.human_attribute_name("mobility_restricted_traveller_duration"), :input_html => { :class => "form-control input-sm timepicker_seconds", :step => 1}, :wrapper_html => { :class => "input-append bootstrap-timepicker" } - -  = form.actions do -    = form.action :submit, as: :button -    = form.action :cancel, as: :link diff --git a/app/views/connection_links/edit.html.slim b/app/views/connection_links/edit.html.slim deleted file mode 100644 index 08a6ddd36..000000000 --- a/app/views/connection_links/edit.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -= title_tag t('connection_links.edit.title', :connection_link => @connection_link.name ) - -= render 'form'
\ No newline at end of file diff --git a/app/views/connection_links/index.html.slim b/app/views/connection_links/index.html.slim deleted file mode 100644 index 7651ae340..000000000 --- a/app/views/connection_links/index.html.slim +++ /dev/null @@ -1,24 +0,0 @@ -= title_tag t('connection_links.index.title') - -= search_form_for @q, :url => referential_connection_links_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| -  .panel.panel-default -    .panel-heading -      .input-group.col-md-12 -        = f.text_field :name_cont, :placeholder => "#{t('.name')}", class: 'form-control' -        .input-group-btn -          button.btn.btn-default type="submit" -            i.fa.fa-search - -      / <!-- /input-group --> -      / <!-- <a data-toggle="collapse" data-parent="#search" href="#advanced_search"> --> -      / <!--   <i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %> --> -      / <!-- </a> --> - -#connection_links -  = render 'connection_links' - -- content_for :sidebar do -  ul.actions -    li -      - if policy(Chouette::ConnectionLink).create? && @referential.organisation == current_organisation -        = link_to t('connection_links.actions.new'), new_referential_connection_link_path(@referential), class: 'add' diff --git a/app/views/connection_links/index.js.slim b/app/views/connection_links/index.js.slim deleted file mode 100644 index 2be61610e..000000000 --- a/app/views/connection_links/index.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('#connection_links').html("#{escape_javascript(render('connection_links'))}");
\ No newline at end of file diff --git a/app/views/connection_links/new.html.slim b/app/views/connection_links/new.html.slim deleted file mode 100644 index c4acdf622..000000000 --- a/app/views/connection_links/new.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -= title_tag t('connection_links.new.title') - -= render 'form'
\ No newline at end of file diff --git a/app/views/connection_links/select_areas.html.slim b/app/views/connection_links/select_areas.html.slim deleted file mode 100644 index 85da40eb7..000000000 --- a/app/views/connection_links/select_areas.html.slim +++ /dev/null @@ -1,11 +0,0 @@ -= title_tag t('connection_links.select_areas.title', connection_link: @connection_link.name) - -= semantic_form_for [@referential, @connection_link] do |form| -  div -    = form.inputs do -      = form.input :departure_id, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=itl_excluded", :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/show', [@departure].compact, :view_path => 'app/views', :format => :json, :scope => self).render  } -      = form.input :arrival_id, :as => :search_stop_area, :json =>  referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=itl_excluded", :tokenLimit => 1, :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/show', [@arrival].compact, :view_path => 'app/views', :format => :json, :scope => self).render } - -     = form.actions do -       = form.action :submit, as: :button -       = form.action :cancel, as: :link
\ No newline at end of file diff --git a/app/views/connection_links/show.html.slim b/app/views/connection_links/show.html.slim deleted file mode 100644 index ca6593131..000000000 --- a/app/views/connection_links/show.html.slim +++ /dev/null @@ -1,94 +0,0 @@ -= title_tag t('connection_links.show.title', :connection_link => @connection_link.name) - -.connection_link_show -  .summary -    p -      label = "#{@connection_link.human_attribute_name(:departure)} : " -      - if @connection_link.departure.present? -        = link_to @connection_link.departure.name, [@referential, @connection_link.departure] -      - else -        = @connection_link.human_attribute_name("undefined") - -    p -      label = "#{@connection_link.human_attribute_name(:arrival)} : " -      - if @connection_link.arrival.present? -        = link_to @connection_link.arrival.name, [@referential, @connection_link.arrival] -      - else -        = @connection_link.human_attribute_name("undefined") - -    p -      label = "#{@connection_link.human_attribute_name('connection_link_type')} : " -      - if @connection_link.connection_link_type.blank? -        = t("unknown") -      - else -        = t("connection_link_types.label.#{@connection_link.connection_link_type}") - -    p -      label = "#{@connection_link.human_attribute_name('comment')} : " -      = @connection_link.comment - -    p -      label = "#{@connection_link.human_attribute_name('link_distance')} : " -      = @connection_link.link_distance - -    p -      label = t('connection_links.show.durations') - -    p -      label.duration = "#{@connection_link.human_attribute_name('default_duration')} : " -      - if @connection_link.default_duration.present? -        = @connection_link.default_duration.strftime('%Hh %Mm %Ss') - -    p -      label.duration = "#{@connection_link.human_attribute_name('frequent_traveller_duration')} : " -      - if @connection_link.frequent_traveller_duration.present? -        = @connection_link.frequent_traveller_duration.strftime('%Hh %Mm %Ss') - -    p -      label.duration = "#{@connection_link.human_attribute_name('occasional_traveller_duration')} : " -      - if @connection_link.occasional_traveller_duration.present? -        = @connection_link.occasional_traveller_duration.strftime('%Hh %Mm %Ss') - -    p -      label.duration = "#{@connection_link.human_attribute_name('mobility_restricted_traveller_duration')} : " -      -if @connection_link.mobility_restricted_traveller_duration.present? -        = @connection_link.mobility_restricted_traveller_duration.strftime('%Hh %Mm %Ss') - -    p -      label = "#{@connection_link.human_attribute_name('mobility_restricted_suitability')} : " -      - if !@connection_link.mobility_restricted_suitability.nil? -        = t((@connection_link.mobility_restricted_suitability == true).to_s) -      - else -        = t("unknown") - -    p -      label = "#{@connection_link.human_attribute_name('stairs_availability')} : " -      - if !@connection_link.stairs_availability.nil? -        = t((@connection_link.stairs_availability == true).to_s) -      - else -        = t("unknown") - -    p -      label = "#{@connection_link.human_attribute_name('lift_availability')} : " -      - if !@connection_link.lift_availability.nil? -        = t((@connection_link.lift_availability == true).to_s) -      - else -        = t("unknown") - -- content_for :sidebar do -  ul.actions -    - if policy(Chouette::ConnectionLink).create? && @referential.organisation == current_organisation -      li -        = link_to t('connection_links.actions.new'), new_referential_connection_link_path(@referential), class: 'add' -    - if policy(@connection_link).edit? -      li -        = link_to t('connection_links.actions.edit'), edit_referential_connection_link_path(@referential, @connection_link), class: 'edit' -    - if policy(@connection_link).destroy? -      li -        = link_to t('connection_links.actions.destroy'), referential_connection_link_path(@referential, @connection_link), :method => :delete,  :data => {:confirm =>  t('connection_links.actions.destroy_confirm')}, class: 'remove' -    - if policy(@connection_link).edit? -      li -        = link_to t('connection_links.actions.select_areas'), select_areas_referential_connection_link_path(@referential, @connection_link), class: 'select' -    br - -  = creation_tag(@connection_link) diff --git a/app/views/connection_links/show.kml.slim b/app/views/connection_links/show.kml.slim deleted file mode 100644 index 59169dba3..000000000 --- a/app/views/connection_links/show.kml.slim +++ /dev/null @@ -1,16 +0,0 @@ -doctype XML - -kml xmlns="http://www.opengis.net/kml/2.2"  -  document -    - if @connection_link.geometry -      placemark id="route_#{@connection_link.id}"  -        name = @connection_link.name -        = @connection_link.geometry.kml_representation.html_safe - -      placemark id="#{@connection_link.departure.id}"  -        departure true -        = @connection_link.departure.geometry.kml_representation.html_safe -         -      placemark id="#{@connection_link.arrival.id}"  -        arrival true -        = @connection_link.arrival.geometry.kml_representation.html_safe 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/export_tasks/_fields_gtfs_export.html.slim b/app/views/export_tasks/_fields_gtfs_export.html.slim deleted file mode 100644 index e95e86230..000000000 --- a/app/views/export_tasks/_fields_gtfs_export.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -= form.input :time_zone, as: :time_zone, :input_html => { :value => @referential.time_zone ,:title => t("formtastic.titles.export_task.time_zone")} - -= form.input :object_id_prefix, :input_html => { :value => @referential.prefix ,:title => t("formtastic.titles.export_task.object_id_prefix")}
\ No newline at end of file diff --git a/app/views/export_tasks/_fields_hub_export.html.slim b/app/views/export_tasks/_fields_hub_export.html.slim deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/export_tasks/_fields_hub_export.html.slim +++ /dev/null diff --git a/app/views/export_tasks/_fields_kml_export.html.slim b/app/views/export_tasks/_fields_kml_export.html.slim deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/export_tasks/_fields_kml_export.html.slim +++ /dev/null diff --git a/app/views/export_tasks/_fields_neptune_export.html.slim b/app/views/export_tasks/_fields_neptune_export.html.slim deleted file mode 100644 index 43749c87e..000000000 --- a/app/views/export_tasks/_fields_neptune_export.html.slim +++ /dev/null @@ -1,2 +0,0 @@ -= form.input :projection_type, as: :hidden, :input_html => { :value => @referential.projection_type || "" } -= form.input :extensions , as: :boolean
\ No newline at end of file diff --git a/app/views/export_tasks/_fields_netex_export.html.slim b/app/views/export_tasks/_fields_netex_export.html.slim deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/export_tasks/_fields_netex_export.html.slim +++ /dev/null diff --git a/app/views/export_tasks/new.html.slim b/app/views/export_tasks/new.html.slim deleted file mode 100644 index 5f89f5865..000000000 --- a/app/views/export_tasks/new.html.slim +++ /dev/null @@ -1,32 +0,0 @@ -= title_tag t(".title") - -ul.nav.nav-pills -  - ExportTask.data_formats.each do |format| -    li role="presentation" -      a href="##{format}" class=("#{@export_task.data_format == format ? "#{format} active" : "#{format}"}") title="#{t(:"enumerize.data_format_detail.#{format}")}" data-toggle="tab" -        = t(:"enumerize.data_format.#{format}") - -.tab-content -  - @available_exports.each do |export_task| -    = semantic_form_for [@referential, export_task], :as => :export_task, :url => referential_export_tasks_path(@referential), :namespace => export_task.data_format ,:html => { :id => "#{export_task.data_format}", :class => "tab-pane highlight"} do |form| -      = form.inputs do -    	  = form.input :user_name, as: :hidden, :input_html => { :value => current_user.name } -    	  = form.input :user_id, as: :hidden, :input_html => { :value => current_user.id } -    	  = form.input :data_format, as: :hidden -    	  = form.input :referential_id, as: :hidden, :input_html => { :value => @referential.id } -        = form.input :name -        = form.input :references_type, as: :select, include_blank: t(".all"), collection: export_task.class.references_type.options.map { |o| o << {data:{"hidden-attributes" => export_task.class.optional_attributes(o.second).join(',') }} } -    	   -        - export_task.class.references_types.each do |type| -    	    = form.input :reference_ids, as: :reference_ids, :json => references_referential_export_tasks_path(@referential, :format => :json) + "?filter=#{type}", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :id => "#{export_task.data_format}_#{type}_reference_ids", :input_html => { :id => "#{export_task.data_format}_#{type}_reference_ids" }, :wrapper_html => { style: "display:none;", "data-type" => type.to_s } - -      = form.input :start_date, as: :date_picker, :input_html => { :title => t("formtastic.titles.export_task.start_date")} -      = form.input :end_date, as: :date_picker, :input_html => { :title => t("formtastic.titles.export_task.end_date")} - -      = render partial: "fields_#{export_task.data_format}_export", :locals => { :form => form } - -    	= form.actions do -    	  = form.action :submit, as: :button , :label => t('formtastic.export') -    	  = form.action :cancel, as: :link - -= javascript_include_tag new_referential_export_task_path(@referential, :format => :js) diff --git a/app/views/export_tasks/new.js.coffee b/app/views/export_tasks/new.js.coffee deleted file mode 100644 index dd0e284a5..000000000 --- a/app/views/export_tasks/new.js.coffee +++ /dev/null @@ -1,2 +0,0 @@ -jQuery -> -  $('#workspace.export_tasks .nav a.active').tab('show')  diff --git a/app/views/exports/_form.html.slim b/app/views/exports/_form.html.slim index 999e33e34..1ce0bfffa 100644 --- a/app/views/exports/_form.html.slim +++ b/app/views/exports/_form.html.slim @@ -4,13 +4,13 @@      .col-lg-12        = form.input :name      .col-lg-12 -      = form.input :type, as: :select, collection: workgroup_exports(workbench.workgroup), label_method: :human_name -      = form.input :referential_id, as: :select, collection: workbench.referentials, label_method: :name +      = form.input :type, as: :select, collection: workgroup_exports(workbench.workgroup), label_method: :human_name, input_html: {"data-select2ed" => true} +      = form.input :referential_id, as: :select, collection: workbench.referentials, label_method: :name, input_html: {"data-select2ed" => true} -      - Export::Base.user_visible_descendants.each do |child| +      - workgroup_exports(workbench.workgroup).each do |child|          .slave data-master="[name='export[type]']" data-value=child.name            - child.options.each do |attr, option_def| -            = export_option_input form, export, attr, option_def, child +            = export_option_input form, export, attr, option_def, child, workbench.referentials    = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'wb_export_form' diff --git a/app/views/help/toc.textile b/app/views/help/toc.textile index 9772ca1b6..754a6ebb5 100644 --- a/app/views/help/toc.textile +++ b/app/views/help/toc.textile @@ -27,8 +27,6 @@ h3. Sommaire  ## "SĂ©quences d'arrĂȘts":routes
  ## "Missions":journey_patterns
  ## "Courses et horaires":vehicle_journeys
 -## "Courses en fréquence":timebands.textile
 -## "Correspondances":connection_links
  ## "Calendrier":time_tables
  # Imports
  ## "Imports":imports
 diff --git a/app/views/import_tasks/_fields_gtfs_import.html.slim b/app/views/import_tasks/_fields_gtfs_import.html.slim deleted file mode 100644 index 8c2ef8ed8..000000000 --- a/app/views/import_tasks/_fields_gtfs_import.html.slim +++ /dev/null @@ -1,6 +0,0 @@ -= form.input :references_type, as: :select, :include_blank => t("import_tasks.new.all"), :input_html => { :title => t("formtastic.titles.import_task.references_type") } -= form.input :object_id_prefix, :input_html => { :value => @referential.prefix } -= form.input :max_distance_for_commercial , as: :number , :input_html => { :title => t("formtastic.titles.import_task.max_distance_for_commercial"), :value => 0 } -= form.input :ignore_last_word , as: :boolean , :input_html => { :title => t("formtastic.titles.import_task.ignore_last_word"), :value => false } -= form.input :ignore_end_chars  , as: :number , :input_html => { :title => t("formtastic.titles.import_task.ignore_end_chars"), :value => 0 } -= form.input :max_distance_for_connection_link  , as: :number , :input_html => { :title => t("formtastic.titles.import_task.max_distance_for_connection_link"), :value => 0 }
\ No newline at end of file diff --git a/app/views/import_tasks/_fields_neptune_import.html.slim b/app/views/import_tasks/_fields_neptune_import.html.slim deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/import_tasks/_fields_neptune_import.html.slim +++ /dev/null diff --git a/app/views/import_tasks/_fields_netex_import.slim b/app/views/import_tasks/_fields_netex_import.slim deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/import_tasks/_fields_netex_import.slim +++ /dev/null diff --git a/app/views/import_tasks/new.html.slim b/app/views/import_tasks/new.html.slim deleted file mode 100644 index dad004759..000000000 --- a/app/views/import_tasks/new.html.slim +++ /dev/null @@ -1,27 +0,0 @@ -= title_tag t(".title") - -ul.nav.nav-pills -  - ImportTask.data_formats.each do |format| -    li role="presentation" -      a href="##{format}" class="#{@import_task.data_format == format ? "#{format} active" : "#{format}" }" title="#{t(:"enumerize.data_format_detail.#{format}")}" data-toggle="tab" -        = t(:"enumerize.data_format.#{format}") - -.tab-content -  - @available_imports.each do |import_task| -    = semantic_form_for [@referential, import_task], as: :import_task, :url => referential_import_tasks_path(@referential), :namespace => import_task.data_format, :html => { :id => "#{import_task.data_format}", class: 'tab-pane highlight' } do |form| -      = form.inputs do -        = form.input :user_name, as: :hidden, :input_html => { :value => current_user.name } -        = form.input :user_id, as: :hidden, :input_html => { :value => current_user.id } -        = form.input :data_format, as: :hidden -        = form.input :referential_id, as: :hidden, :input_html => { :value => @referential.id } -        = form.input :name -        = form.input :no_save, as: :boolean -        = form.input :resources, as: :file - -      = render partial: "fields_#{import_task.data_format}_import", :locals => { :form => form } - -      = form.actions do -        = form.action :submit, as: :button , :label => t( 'formtastic.import' ) -        = form.action :cancel, as: :link - -= javascript_include_tag new_referential_import_task_path(@referential, :format => :js) diff --git a/app/views/import_tasks/new.js.coffee b/app/views/import_tasks/new.js.coffee deleted file mode 100644 index 57dbe9e72..000000000 --- a/app/views/import_tasks/new.js.coffee +++ /dev/null @@ -1,2 +0,0 @@ -jQuery -> -  $('#workspace.import_tasks .nav a.active').tab('show')  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/index.html.slim b/app/views/lines/index.html.slim index 02bb5ec6e..a127a8a29 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -29,7 +29,8 @@                  end \                ), \                TableBuilderHelper::Column.new( \ -                key: :status, \ +                key: :deactivated, \ +                name: Chouette::Line.tmf(:status), \                  class: :state, \                  attribute: Proc.new { |n| line_status(n.status) } \                ), \ diff --git a/app/views/referential_stop_areas/_stop_area.html.slim b/app/views/referential_stop_areas/_stop_area.html.slim index bb9ed7ce3..e4dfe63fa 100644 --- a/app/views/referential_stop_areas/_stop_area.html.slim +++ b/app/views/referential_stop_areas/_stop_area.html.slim @@ -3,11 +3,11 @@      .panel-title.clearfix        span.pull-right          - if policy(stop_area).update? -          = link_to edit_referential_stop_area_path(@referential, stop_area), class: 'btn btn-default btn-sm' do +          = link_to edit_stop_area_referential_stop_area_path(stop_area.stop_area_referential, stop_area), class: 'btn btn-default btn-sm' do              span.fa.fa-pencil          - if policy(stop_area).destroy? -          = link_to referential_stop_area_path(@referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do +          = link_to stop_area_referential_stop_area_path(stop_area.stop_area_referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do              span.fa.fa-trash-o        h5 diff --git a/app/views/referential_stop_areas/edit.html.slim b/app/views/referential_stop_areas/edit.html.slim index d88230b58..4641cf0be 100644 --- a/app/views/referential_stop_areas/edit.html.slim +++ b/app/views/referential_stop_areas/edit.html.slim @@ -1,3 +1,3 @@ -- breadcrumb :referential_stop_area, @referential, @stop_area +- breadcrumb :stop_area, @stop_area.stop_area_referential, @stop_area  - page_header_content_for @stop_area  = render 'form' diff --git a/app/views/referential_stop_areas/index.html.slim b/app/views/referential_stop_areas/index.html.slim index ad04fb02e..39073540d 100644 --- a/app/views/referential_stop_areas/index.html.slim +++ b/app/views/referential_stop_areas/index.html.slim @@ -1,6 +1,6 @@ -- breadcrumb :referential_stop_areas, @referential +- breadcrumb :stop_areas, @referential.workbench.stop_area_referential -= search_form_for @q, :url => referential_stop_areas_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| += search_form_for @q, :url => stop_area_referential_stop_areas_path(@referential.workbench.stop_area_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|    .panel.panel-default      .panel-heading        .input-group.col-md-9.col-sm-9 @@ -29,6 +29,6 @@    ul.actions      - if policy(Chouette::StopArea).create?        li -        = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' +        = link_to t('stop_areas.actions.new'), new_stop_area_referential_stop_area_path(@referential.workbench.stop_area_referential), class: 'add'      li        / = link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator" diff --git a/app/views/referential_stop_areas/new.html.slim b/app/views/referential_stop_areas/new.html.slim index 9342b673b..8fbef33de 100644 --- a/app/views/referential_stop_areas/new.html.slim +++ b/app/views/referential_stop_areas/new.html.slim @@ -1,2 +1,2 @@ -- breadcrumb :referential_stop_areas, @referential +- breadcrumb :stop_areas, @referential.workbench.stop_area_referential  = render 'form' diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index beee0383f..d464eb438 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -1,4 +1,4 @@ -- breadcrumb :referential_stop_area, @referential, @stop_area +- breadcrumb :stop_area, @stop_area.stop_area_referential, @stop_area  - page_header_content_for @stop_area  .page_content @@ -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/_stop_points.html.slim b/app/views/routing_constraint_zones/_stop_points.html.slim index 4e85ba8b2..c2da4bb2d 100644 --- a/app/views/routing_constraint_zones/_stop_points.html.slim +++ b/app/views/routing_constraint_zones/_stop_points.html.slim @@ -1,7 +1,7 @@  - stop_points.each do |stop_point|    .wrapper        div -        = link_to referential_stop_area_path(@referential, stop_point.stop_area.id), class: 'navlink', title: "Voir l'arrĂȘt" do +        = link_to stop_area_referential_stop_area_path(stop_point.stop_area.stop_are_referential, stop_point.stop_area.id), class: 'navlink', title: "Voir l'arrĂȘt" do            span = stop_point.stop_area.name        div 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 55c952ae6..2d444fe90 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -19,7 +19,7 @@                name: t('.route_stop_points'), \                attribute: 'name', \                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.stop_area_referential, stop_point.stop_area) \                end \              ),              TableBuilderHelper::Column.new( \ diff --git a/app/views/shared/_header.html.slim b/app/views/shared/_header.html.slim index afe802b49..a653e5cdf 100644 --- a/app/views/shared/_header.html.slim +++ b/app/views/shared/_header.html.slim @@ -67,7 +67,7 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"                    = Referential.human_attribute_name("lines")                li -                = link_to referential_stop_areas_path(@referential) do +                = link_to stop_area_referential_stop_areas_path(@referential.workbench.stop_area_referential) do                    span.badge.pull-right = @referential.stop_areas.size                    = Referential.human_attribute_name("stop_areas") @@ -81,10 +81,6 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"                    span.badge.pull-right = @referential.time_tables.size                    = Referential.human_attribute_name("time_tables") -              li -                = link_to referential_timebands_path(@referential) do -                  span.badge.pull-right = @referential.timebands.size -                  = Referential.human_attribute_name("timebands")            li              = link_to Referential.human_attribute_name("exports"), referential_exports_path(@referential)            li diff --git a/app/views/stop_area_copies/new.html.slim b/app/views/stop_area_copies/new.html.slim deleted file mode 100644 index b506d35f4..000000000 --- a/app/views/stop_area_copies/new.html.slim +++ /dev/null @@ -1,28 +0,0 @@ -= title_tag t("stop_area_copies.new.title.#{@stop_area_copy.hierarchy}") - -= semantic_form_for [@referential, @stop_area, @stop_area_copy] do |form| -  br -  = form.inputs do -    = form.input :source_id, as: :hidden -    = form.input :hierarchy, as: :hidden -     -    - if @stop_area_copy.hierarchy == "child" -      - if @stop_area.area_type.underscore == "stop_place" -        = form.input :area_type, -          as: :select, -          collection: label_stop_area_types( "stop_place","commercial_stop_point" ), -          include_blank: false -      - else -        = form.input :area_type, -          as: :select, -          collection: label_stop_area_types( "boarding_position","quay" ), -          include_blank: false -    - else -      = form.input :area_type, -        as: :select, -        collection: label_stop_area_types(@stop_area_copy.area_type), -        include_blank: false - -  = form.actions do -    = form.action :submit, as: :button , label: t('formtastic.duplicate') -    = form.action :cancel, as: :link 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/timebands/_form.html.slim b/app/views/timebands/_form.html.slim deleted file mode 100644 index 433d777dc..000000000 --- a/app/views/timebands/_form.html.slim +++ /dev/null @@ -1,9 +0,0 @@ -= semantic_form_for [@referential, @timeband] do |form| -  = form.inputs do -    = form.input :name -    = form.input :start_time -    = form.input :end_time - -  = form.actions do -    = form.action :submit, as: :button -    = form.action :cancel, as: :link
\ No newline at end of file diff --git a/app/views/timebands/_sidebar.html.slim b/app/views/timebands/_sidebar.html.slim deleted file mode 100644 index 07dcebdad..000000000 --- a/app/views/timebands/_sidebar.html.slim +++ /dev/null @@ -1,9 +0,0 @@ -- content_for :sidebar do -  ul.actions -    li = link_to t('timebands.actions.new'), new_referential_timeband_path(@referential), class: "add" - -    - if @timeband -      li -        = link_to t('timebands.actions.edit'), edit_referential_timeband_path(@referential, @timeband), class: "edit" -      li -        = link_to t('timebands.actions.destroy'), referential_timeband_path(@referential, @timeband), :method => :delete, :data => {:confirm =>  t('timebands.actions.destroy_confirm')}, class: "remove"
\ No newline at end of file diff --git a/app/views/timebands/edit.html.slim b/app/views/timebands/edit.html.slim deleted file mode 100644 index c70de82ef..000000000 --- a/app/views/timebands/edit.html.slim +++ /dev/null @@ -1,4 +0,0 @@ -- breadcrumb :timeband, @referential, @timeband -= title_tag t('timebands.edit.title', timeband: @timeband.name) - -= render 'form' diff --git a/app/views/timebands/index.html.slim b/app/views/timebands/index.html.slim deleted file mode 100644 index 6dcf348f9..000000000 --- a/app/views/timebands/index.html.slim +++ /dev/null @@ -1,23 +0,0 @@ -- breadcrumb :timebands, @referential -= title_tag t('timebands.index.title') - -- if @timebands.any? -  table.table.table-striped.table-condensed -    thead -      tr -        th = t('activerecord.attributes.timeband.name') -        th = t('activerecord.attributes.timeband.start_time') -        th = t('activerecord.attributes.timeband.end_time') -        th - -    tbody -      - @timebands.each do |timeband| -        tr -          td = link_to timeband.name, referential_timeband_path(@referential, timeband) -          td = l(timeband.start_time, format: :hour) -          td = l(timeband.end_time, format: :hour) -          td -            = link_to '', edit_referential_timeband_path(@referential, timeband), class: "edit" -            = link_to '', referential_timeband_path(@referential, timeband), :method => :delete, :data => {:confirm =>  t('timebands.actions.destroy_confirm')}, class: "remove" - -== render 'sidebar' diff --git a/app/views/timebands/new.html.slim b/app/views/timebands/new.html.slim deleted file mode 100644 index d9fc27823..000000000 --- a/app/views/timebands/new.html.slim +++ /dev/null @@ -1,4 +0,0 @@ -- breadcrumb :timebands, @referential -= title_tag t('timebands.new.title') - -== render 'form' diff --git a/app/views/timebands/show.html.slim b/app/views/timebands/show.html.slim deleted file mode 100644 index d45611c56..000000000 --- a/app/views/timebands/show.html.slim +++ /dev/null @@ -1,9 +0,0 @@ -- breadcrumb :timeband, @referential, @timeband -= title_tag t( 'timebands.show.title', timeband: @timeband.name ) - -.summary -  p -    label = "#{@timeband.name} : " -    = "#{l(@timeband.start_time, format: :hour)} - #{l(@timeband.end_time, format: :hour)}" - -== render 'sidebar' diff --git a/app/views/vehicle_journey_frequencies/_form_footer.html.slim b/app/views/vehicle_journey_frequencies/_form_footer.html.slim deleted file mode 100644 index 922e867a8..000000000 --- a/app/views/vehicle_journey_frequencies/_form_footer.html.slim +++ /dev/null @@ -1,4 +0,0 @@ -- if vehicle_journey.new_record? -  = javascript_include_tag new_referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route, format: :js) -- else -  = javascript_include_tag edit_referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route, vehicle_journey, format: :js)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_form_vehicle_journey_at_stops.html.slim b/app/views/vehicle_journey_frequencies/_form_vehicle_journey_at_stops.html.slim deleted file mode 100644 index 45b37dee9..000000000 --- a/app/views/vehicle_journey_frequencies/_form_vehicle_journey_at_stops.html.slim +++ /dev/null @@ -1,44 +0,0 @@ -li.input -  = form.label vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), class: 'label' -   -  table.table-striped.ce-TimeBandFormTable -    thead -      tr -        th = t('vehicle_journeys.form.stop_title') -        th -        th = t('vehicle_journeys.form.arrival') -        th = t('vehicle_journeys.form.departure') - -    tbody.journey_pattern_dependent_list -      == render partial: 'vehicle_journey_at_stop_fields', collection: vehicle_journey.vehicle_journey_at_stops, as: :vehicle_journey_at_stop, locals: { vehicle_journey_at_stops_size: vehicle_journey.vehicle_journey_at_stops.size } - -    tfoot -      tr -        td -        td -        td -          = button_tag 'data-ce-action' => 'to_departures', class: 'ce-hide btn btn-primary' do -            = t('vehicle_journeys.form.to_departures').html_safe -            i.fa.fa-angle-double-right -        td -          = button_tag 'data-ce-action' => 'to_arrivals', class: 'ce-hide btn btn-primary' do -            i.fa.fa-angle-double-left -            = t('vehicle_journeys.form.to_arrivals').html_safe - -li.input -  = form.label vehicle_journey.human_attribute_name(:journey_frequency_ids), class: 'label' -   -  ul.ce-FrequencyFormFields -    li = t('activerecord.attributes.journey_frequency.timeband') -    li = t('activerecord.attributes.journey_frequency.first_departure_time') -    li = t('activerecord.attributes.journey_frequency.last_departure_time') -    li = t('activerecord.attributes.journey_frequency.scheduled_headway_interval') -    li -    li -   -  - i = 0 -  = form.semantic_fields_for :journey_frequencies do |journey_frequency| -    == render 'journey_frequency_fields', f: journey_frequency, no_destroy: ((i += 1) == 1 ? true : false) - -  .actions-add-fields -    = link_to_add_association t('journey_frequencies.form.add_line'), form, :journey_frequencies, class: 'btn btn-primary'
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_journey_frequency_fields.html.slim b/app/views/vehicle_journey_frequencies/_journey_frequency_fields.html.slim deleted file mode 100644 index c649abd9b..000000000 --- a/app/views/vehicle_journey_frequencies/_journey_frequency_fields.html.slim +++ /dev/null @@ -1,16 +0,0 @@ -- no_destroy = false unless local_assigns[:no_destroy] - -.nested-fields -  ul.ce-FrequencyFormFields -    = f.input :timeband_id, as: :search_timeband, json: referential_autocomplete_timebands_path(@referential, format: :json), hint_text: t('search_hint'), no_result_text: t('no_result_text'), searching_text: t('searching_term'), label: false, input_html: { :"data-pre" => Rabl::Renderer.new( 'autocomplete_timebands/index', Chouette::Timeband.where(id: f.object.timeband_id), view_path: 'app/views', format: :json, scope: :self ).render } -    = f.input :first_departure_time, label: false -    = f.input :last_departure_time, label: false -    = f.input :scheduled_headway_interval, label: false -    = f.input :exact_time, label: t('activerecord.attributes.journey_frequency.exact_time') -     -    li -      label.label -       -      - unless no_destroy -        = link_to_remove_association f do -          i.fa.fa-trash
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_show_journey_frequencies.html.slim b/app/views/vehicle_journey_frequencies/_show_journey_frequencies.html.slim deleted file mode 100644 index 4510f26f0..000000000 --- a/app/views/vehicle_journey_frequencies/_show_journey_frequencies.html.slim +++ /dev/null @@ -1,21 +0,0 @@ -h3 = t('vehicle_journeys.show.journey_frequencies') - -.journey_frequencies.content -  table.table.table-hover.table-striped -    thead -      tr -        th = t('activerecord.attributes.journey_frequency.timeband') -        th = t('activerecord.attributes.journey_frequency.first_departure_time') -        th = t('activerecord.attributes.journey_frequency.last_departure_time') -        th = t('activerecord.attributes.journey_frequency.scheduled_headway_interval') -        th = t('activerecord.attributes.journey_frequency.exact_time') - -    tbody -      - @vehicle_journey_frequency.journey_frequencies.each do |journey_frequency| -        tr class="#{cycle :odd, :even}"" -          td -            = link_to journey_frequency.timeband.fullname, referential_timeband_path(@referential, journey_frequency.timeband) if journey_frequency.timeband -          td = l(journey_frequency.first_departure_time, format: :hour) -          td = l(journey_frequency.last_departure_time, format: :hour) -          td = l(journey_frequency.scheduled_headway_interval, format: :hour) -          td = '<i class="fa fa-check"></i>'.html_safe if journey_frequency.exact_time
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_show_sidebar.html.slim b/app/views/vehicle_journey_frequencies/_show_sidebar.html.slim deleted file mode 100644 index 61695ef86..000000000 --- a/app/views/vehicle_journey_frequencies/_show_sidebar.html.slim +++ /dev/null @@ -1,15 +0,0 @@ -- content_for :sidebar do -  ul.actions -    li -      = link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), class: "add" - -    li -      = link_to t('vehicle_journeys.actions.new_frequency'), new_referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route), class: "add" - -    li -      = link_to t('vehicle_journeys.actions.edit_frequency'), edit_referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route, @vehicle_journey_frequency), class: "edit" - -    li -      = link_to t('vehicle_journeys.actions.destroy'), referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route, @vehicle_journey_frequency), method: :delete, data: { confirm: t('vehicle_journeys.actions.destroy_confirm') }, class: "remove" - -  = creation_tag(@vehicle_journey_frequency)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_show_vehicle_journey_at_stops.html.slim b/app/views/vehicle_journey_frequencies/_show_vehicle_journey_at_stops.html.slim deleted file mode 100644 index 24517309c..000000000 --- a/app/views/vehicle_journey_frequencies/_show_vehicle_journey_at_stops.html.slim +++ /dev/null @@ -1,22 +0,0 @@ -.vehicle_journey_at_stops.content -  table.table-striped.ce-TimeBandFormTable -    thead -      tr -        th.stop.title = t('vehicle_journeys.show.stop_title') -        th -        th.hour.title = t('vehicle_journeys.show.arrival') -        th.hour.title = t('vehicle_journeys.show.departure') - -    tbody -      - @vehicle_journey_frequency.vehicle_journey_at_stops.each do |vjas| -        tr class="#{cycle :odd, :even}" -          td = link_to vjas.stop_point.stop_area.name, [@referential, vjas.stop_point.stop_area] -          td.ce-TimeBandFormTable-circleLine -            span.ce-TimeBandFormTable-circle -            span.ce-TimeBandFormTable-line - -          td class="hour #{'missing' if vjas.arrival_time.nil?}" -            = l(vjas.arrival_time, format: :hour) if vjas.arrival_time -           -          td class="hour #{'missing' if vjas.departure_time.nil?}" -            = l(vjas.departure_time, format: :hour) if vjas.departure_time
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_vehicle_journey_at_stop_fields.html.slim b/app/views/vehicle_journey_frequencies/_vehicle_journey_at_stop_fields.html.slim deleted file mode 100644 index 6352cebdf..000000000 --- a/app/views/vehicle_journey_frequencies/_vehicle_journey_at_stop_fields.html.slim +++ /dev/null @@ -1,23 +0,0 @@ -- vjas = vehicle_journey_at_stop -- tab_counter_arrival = 2 * vehicle_journey_at_stop_counter + 100 -- tab_counter_departure = (vehicle_journey_at_stops_size * 2) + 2 * vehicle_journey_at_stop_counter + 100 - -tr class="time input optional #{'no_stop' if vjas._destroy} #{cycle :odd, :even}" -  td -    = {id: vjas.id, _destroy: (vjas._destroy ? 1 : 0), stop_point_id: vjas.stop_point_id, :'departure_time(3i)' => 1, :'departure_time(2i)' => 1, :'departure_time(1i)' => 1, :'arrival_time(3i)' => 1, :'arrival_time(2i)' => 1, :'arrival_time(1i)' => 2000}.map{ |k, v| "<input name=\"vehicle_journey_frequency[vehicle_journey_at_stops_attributes][#{vehicle_journey_at_stop_counter}][#{k}]\" type=\"hidden\" value=\"#{v}\">" }.join("\n").html_safe - -    = vjas.stop_point.stop_area.name - -  td.ce-TimeBandFormTable-circleLine -    span.ce-TimeBandFormTable-circle -    span.ce-TimeBandFormTable-line - -  td class="arrival_time #{'missing' unless vjas.arrival_time} #{'invalid_position' if vjas.errors[:arrival_time].present?}" -    = select_hour(vjas.arrival_time ? vjas.arrival_time.hour : 0, { prefix: 'vehicle_journey_frequency', field_name: "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][arrival_time(4i)]" }, class: 'hour', tabindex: tab_counter_arrival + 1) -     -    = select_minute(vjas.arrival_time ? vjas.arrival_time.min : 0, { prefix: 'vehicle_journey_frequency', field_name: "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][arrival_time(5i)]" }, class: 'minute', tabindex: tab_counter_arrival + 2) -   -  td class="departure_time #{'missing' unless vjas.departure_time} #{'invalid_position' if vjas.errors[:departure_time].present?}" -    = select_hour(vjas.departure_time ? vjas.departure_time.hour : 0, { prefix: 'vehicle_journey_frequency', field_name: "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][departure_time(4i)]" }, class: 'hour', tabindex: tab_counter_departure + 1) -     -    = select_minute(vjas.departure_time ? vjas.departure_time.min : 0, { prefix: 'vehicle_journey_frequency', field_name: "vehicle_journey_at_stops_attributes[#{vehicle_journey_at_stop_counter}][departure_time(5i)]" }, class: 'minute', tabindex: tab_counter_departure + 2)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/_vehicle_journeys_matrix.html.slim b/app/views/vehicle_journey_frequencies/_vehicle_journeys_matrix.html.slim deleted file mode 100644 index be6e76e08..000000000 --- a/app/views/vehicle_journey_frequencies/_vehicle_journeys_matrix.html.slim +++ /dev/null @@ -1,11 +0,0 @@ -ul.ce-VehicleJourneyFrequenciesMatrix -  - @vehicle_journeys.each do |vj| -    li -      ul -        - vj.journey_frequencies.each do |jf| -          - left, width = journey_frequency_percent(jf) -           -          li style="left:#{left};width:#{width};" data-style="primary" data-container="body" rel="popover" data-toggle="popover" data-title="#{link_to(vehicle_title(vj, jf), [@referential, @line, @route, vj] )} #{link_to('<span class="fa fa-pencil"></span>'.html_safe, send("edit_referential_line_route_vehicle_journey#{'_frequency' if vj.frequency?}_path", @referential, @line, @route, vj), class: "btn btn-default btn-sm" )}" data-placement= "top" data-content="#{render 'vehicle_journeys/show_popover', { vehicle_journey: vj }}" -             -            span.ce-VehicleJourneyFrequenciesMatrix-firstDepartureTime = l(jf.first_departure_time, format: :hour) -            span.ce-VehicleJourneyFrequenciesMatrix-lastDepartureTime = l(jf.last_departure_time, format: :hour)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/edit.html.slim b/app/views/vehicle_journey_frequencies/edit.html.slim deleted file mode 100644 index af5f1d88e..000000000 --- a/app/views/vehicle_journey_frequencies/edit.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -= title_tag edit_vehicle_title(@vehicle_journey_frequency) - -== render 'vehicle_journeys/form', vehicle_journey: @vehicle_journey_frequency, form_url: referential_line_route_vehicle_journey_frequency_path(@referential, @line, @route, id: @vehicle_journey_frequency)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/edit.js.slim b/app/views/vehicle_journey_frequencies/edit.js.slim deleted file mode 100644 index de74b80c7..000000000 --- a/app/views/vehicle_journey_frequencies/edit.js.slim +++ /dev/null @@ -1,10 +0,0 @@ -|  $(document).ready(function() { -|    $("#vehicle_journey_frequency_journey_pattern_id").change( -|      function(){ -|        var url = "#{select_journey_pattern_referential_line_route_vehicle_journey_path( @referential, @line, @route, @vehicle_journey_frequency)}?journey_pattern_id="+ -|            $("#vehicle_journey_frequency_journey_pattern_input select option:selected").attr("value"); -|        url += "&journey_category=frequency"; -|        $.get(url); -|      } -|    ); -|  });
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/new.html.slim b/app/views/vehicle_journey_frequencies/new.html.slim deleted file mode 100644 index 86a9d144c..000000000 --- a/app/views/vehicle_journey_frequencies/new.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -= title_tag t('vehicle_journeys.new.title_frequency') - -== render 'vehicle_journeys/form', vehicle_journey: @vehicle_journey_frequency, form_url: referential_line_route_vehicle_journey_frequencies_path(@referential, @line, @route)
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/new.js.slim b/app/views/vehicle_journey_frequencies/new.js.slim deleted file mode 100644 index f4d742f72..000000000 --- a/app/views/vehicle_journey_frequencies/new.js.slim +++ /dev/null @@ -1,13 +0,0 @@ -| $(document).ready(function() { -|   $("#vehicle_journey_frequency_journey_pattern_id").change( -|     function(){ -|       var vehicle_journey_journey_pattern_id = $("#vehicle_journey_frequency_journey_pattern_input select option:selected").attr("value"); -|       if (vehicle_journey_journey_pattern_id > 0) { -|         var url = "#{referential_line_route_journey_patterns_path(@referential.id,@line.id,@route.id)}"; -|         url = url + "/" + vehicle_journey_journey_pattern_id + -|             "/new_vehicle_journey?journey_category=frequency"; -|         $.get(url); -|       } -|     } -|   ); -| });
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/select_journey_pattern.js.slim b/app/views/vehicle_journey_frequencies/select_journey_pattern.js.slim deleted file mode 100644 index 205fee59e..000000000 --- a/app/views/vehicle_journey_frequencies/select_journey_pattern.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('.journey_pattern_dependent_list').html("#{escape_javascript(render(partial: 'vehicle_journey_frequencies/vehicle_journey_at_stop_fields', collection: @vehicle_journey.vehicle_journey_at_stops, as: :vehicle_journey_at_stop, locals: { vehicle_journey_at_stops_size: @vehicle_journey.vehicle_journey_at_stops.size })).html_safe}");
\ No newline at end of file diff --git a/app/views/vehicle_journey_frequencies/show.html.slim b/app/views/vehicle_journey_frequencies/show.html.slim deleted file mode 100644 index 9701dbba9..000000000 --- a/app/views/vehicle_journey_frequencies/show.html.slim +++ /dev/null @@ -1,3 +0,0 @@ -== render 'vehicle_journeys/show_details', vehicle_journey: @vehicle_journey_frequency -== render 'show_journey_frequencies' -== render 'show_sidebar' 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. | 
