diff options
| author | Michel Etienne | 2014-09-19 14:56:09 +0200 | 
|---|---|---|
| committer | Michel Etienne | 2014-09-19 14:56:09 +0200 | 
| commit | 4a278cad118f7110cc8304da6288e4e6b6047181 (patch) | |
| tree | 1fd49d6c6d0ef07da6f2cfd60d7304640761e268 | |
| parent | bf6bea71846d2ab079d592086251c6af426c80d9 (diff) | |
| download | chouette-core-4a278cad118f7110cc8304da6288e4e6b6047181.tar.bz2 | |
refactor breadcrumbs
20 files changed, 278 insertions, 196 deletions
| diff --git a/app/controllers/access_links_controller.rb b/app/controllers/access_links_controller.rb index 4509de575..31d183034 100644 --- a/app/controllers/access_links_controller.rb +++ b/app/controllers/access_links_controller.rb @@ -20,10 +20,7 @@ class AccessLinksController < ChouetteController      @access_link = Chouette::AccessLink.find(params[:id])      @stop_area = @access_link.stop_area      show! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -      add_breadcrumb @access_point.name, referential_stop_area_access_point_path(@referential, @stop_area,@access_point) -      add_breadcrumb Chouette::AccessLink.model_name.human(:count => 2), access_links_referential_stop_area_path(@referential, @stop_area) +      build_breadcrumb :show      end    end @@ -43,9 +40,7 @@ class AccessLinksController < ChouetteController      end      @access_link = Chouette::AccessLink.new(data)      new! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -      add_breadcrumb @access_point.name, referential_stop_area_access_point_path(@referential, @stop_area,@access_point) +      build_breadcrumb :new      end    end @@ -63,10 +58,7 @@ class AccessLinksController < ChouetteController      @stop_area = @access_link.stop_area      @orientation = @access_link.link_orientation_type      edit! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -      add_breadcrumb @access_point.name, referential_stop_area_access_point_path(@referential, @stop_area,@access_point) -      add_breadcrumb @access_link.name, referential_access_point_access_link_path(@referential, @access_point, @access_link) +      build_breadcrumb :edit      end    end    protected diff --git a/app/controllers/access_points_controller.rb b/app/controllers/access_points_controller.rb index 0e06bee19..8e1f4664b 100644 --- a/app/controllers/access_points_controller.rb +++ b/app/controllers/access_points_controller.rb @@ -30,25 +30,16 @@ class AccessPointsController < ChouetteController          }        end -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +      build_breadcrumb :show      end    end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -    end -  end    def edit      access_point.position ||= access_point.default_position      map.editable = true      edit! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -      add_breadcrumb @access_point.name, referential_stop_area_access_point_path(@referential, @stop_area,@access_point) +      build_breadcrumb :edit      end    end diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb index 6ef699d5b..6e87a4bf6 100644 --- a/app/controllers/chouette_controller.rb +++ b/app/controllers/chouette_controller.rb @@ -1,6 +1,7 @@  class ChouetteController < InheritedResources::Base    include ApplicationHelper +  include BreadcrumbHelper    before_filter :switch_referential @@ -13,5 +14,41 @@ class ChouetteController < InheritedResources::Base    def referential      @referential ||= current_organisation.referentials.find params[:referential_id]      end  +   +  def show +    show! do  +      build_breadcrumb :show +    end +  end +   +  def index +    index! do  +      build_breadcrumb :index +    end +  end +     +  def edit +    edit! do +      build_breadcrumb :edit +    end +  end + +  def update  +    update! do |success, failure| +      build_breadcrumb :edit +    end +  end + +  def new +    new! do  +      build_breadcrumb :show +    end +  end +   +  def create +    create! do |success, failure| +      build_breadcrumb :show +    end +  end  end diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 20f84e763..025c0fdee 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -14,30 +14,11 @@ class CompaniesController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end -      add_breadcrumb Referential.model_name.human(:count => 2), referentials_path() -      add_breadcrumb @referential.name, referential_path(@referential)        } +      build_breadcrumb :index      end           end -  def show -    show! do -      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential) -    end -  end - -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential) -      add_breadcrumb @company.name, referential_line_path(@referential, @company) -    end -  end    protected    def collection     diff --git a/app/controllers/compliance_check_tasks_controller.rb b/app/controllers/compliance_check_tasks_controller.rb index bf8a670a3..d28ca34ae 100644 --- a/app/controllers/compliance_check_tasks_controller.rb +++ b/app/controllers/compliance_check_tasks_controller.rb @@ -1,18 +1,10 @@  class ComplianceCheckTasksController < ChouetteController +  defaults :resource_class => ComplianceCheckTask +    respond_to :html, :js    belongs_to :referential -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) -    end -  end -  def show -    show! do -      add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) -    end -  end    def references      @references = referential.send(params[:type]).where("name ilike ?", "%#{params[:q]}%")      respond_to do |format| @@ -24,6 +16,7 @@ class ComplianceCheckTasksController < ChouetteController    def rule_parameter_set      @rule_parameter_set = compliance_check_task.rule_parameter_set_archived +    build_breadcrumb :edit      render "rule_parameter_sets/show"    end diff --git a/app/controllers/connection_links_controller.rb b/app/controllers/connection_links_controller.rb index ca34aecdc..9f08babf0 100644 --- a/app/controllers/connection_links_controller.rb +++ b/app/controllers/connection_links_controller.rb @@ -16,6 +16,7 @@ class ConnectionLinksController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end +        build_breadcrumb :index        }      end           end @@ -23,30 +24,15 @@ class ConnectionLinksController < ChouetteController    def show      @map = ConnectionLinkMap.new(resource).with_helpers(self)      show! do -      add_breadcrumb Referential.human_attribute_name("connection_links"), referential_connection_links_path(@referential) +        build_breadcrumb :show      end    end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("connection_links"), referential_connection_links_path(@referential) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("connection_links"), referential_connection_links_path(@referential) -      add_breadcrumb @connection_link.name, referential_connection_link_path(@referential, @connection_link) -    end -  end - -    def select_areas      @connection_link = connection_link      @departure = connection_link.departure      @arrival = connection_link.arrival -    add_breadcrumb Referential.human_attribute_name("connection_links"), referential_connection_links_path(@referential) -    add_breadcrumb @connection_link.name, referential_connection_link_path(@referential, @connection_link) +    build_breadcrumb :show    end    protected diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb index d5723ff78..8de7e4f1f 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -1,5 +1,6 @@  class ExportsController < ChouetteController - +  defaults :resource_class => Export +      respond_to :html, :xml, :json, :js    respond_to :zip, :only => :show @@ -7,7 +8,7 @@ class ExportsController < ChouetteController    def new      new! do -      add_breadcrumb Referential.human_attribute_name("exports"), referential_exports_path(@referential) +      build_breadcrumb :show        available_exports      end    end @@ -20,9 +21,9 @@ class ExportsController < ChouetteController    end    def show -    add_breadcrumb Referential.human_attribute_name("exports"), referential_exports_path(@referential)      show! do |format|        format.zip { send_file @export.file, :type => :zip } +      build_breadcrumb :show      end    end diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb index 7167cc40e..59e933637 100644 --- a/app/controllers/group_of_lines_controller.rb +++ b/app/controllers/group_of_lines_controller.rb @@ -12,7 +12,7 @@ class GroupOfLinesController < ChouetteController      @map = GroupOfLineMap.new(resource).with_helpers(self)      @lines = resource.lines.order(:name).paginate(:page => params[:page])      show! do -      add_breadcrumb Referential.human_attribute_name("group_of_lines"), referential_group_of_lines_path(@referential) +      build_breadcrumb :show      end    end @@ -22,22 +22,11 @@ class GroupOfLinesController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end +        build_breadcrumb :index        }      end           end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("group_of_lines"), referential_group_of_lines_path(@referential) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("group_of_lines"), referential_group_of_lines_path(@referential) -      add_breadcrumb @group_of_line.name, referential_group_of_line_path(@referential, @group_of_line) -    end -  end    def name_filter      respond_to do |format|   diff --git a/app/controllers/import_tasks_controller.rb b/app/controllers/import_tasks_controller.rb index e900c79ce..a0d17d4d7 100644 --- a/app/controllers/import_tasks_controller.rb +++ b/app/controllers/import_tasks_controller.rb @@ -1,18 +1,19 @@  class ImportTasksController < ChouetteController +  defaults :resource_class => ImportTask    respond_to :html, :xml, :json    respond_to :js, :only => [:show, :index]    belongs_to :referential    def new      new! do -      add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) +      build_breadcrumb :show        available_imports      end    end    def show      show! do -      add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) +      build_breadcrumb :show        if import_task.completed?          @files_stats = import_task.result["files"]["stats"]          @files_list = import_task.result["files"]["list"] diff --git a/app/controllers/journey_patterns_controller.rb b/app/controllers/journey_patterns_controller.rb index 084f34b03..26c54e9c6 100644 --- a/app/controllers/journey_patterns_controller.rb +++ b/app/controllers/journey_patterns_controller.rb @@ -28,26 +28,7 @@ class JourneyPatternsController < ChouetteController      @map = JourneyPatternMap.new(journey_pattern).with_helpers(self)      @stop_points = journey_pattern.stop_points.paginate(:page => params[:page])      show! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -      add_breadcrumb @route.name, referential_line_route_path(@referential, @line, @route) -    end -  end - -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -      add_breadcrumb @route.name, referential_line_route_path(@referential, @line, @route) -    end -  end - -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -      add_breadcrumb @route.name, referential_line_route_path(@referential, @line, @route) -      add_breadcrumb @journey_pattern.name, referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern) +      build_breadcrumb :show      end    end diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 2ff732721..8aeddb6cd 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -14,6 +14,7 @@ class LinesController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end +        build_breadcrumb :index        }      end           end @@ -23,22 +24,10 @@ class LinesController < ChouetteController      @routes = @line.routes      @group_of_lines = @line.group_of_lines      show! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) +      build_breadcrumb :show      end    end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -    end -  end    # overwrite inherited resources to use delete instead of destroy     # foreign keys will propagate deletion)    def destroy_resource(object) diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index f99ff494b..25c4caaac 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -11,7 +11,7 @@ class NetworksController < ChouetteController    def show      @map = NetworkMap.new(resource).with_helpers(self)      show! do -      add_breadcrumb Referential.human_attribute_name("networks"), referential_networks_path(@referential) +      build_breadcrumb :show      end    end @@ -22,22 +22,10 @@ class NetworksController < ChouetteController            redirect_to params.merge(:page => 1)          end        } +      build_breadcrumb :index      end           end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("networks"), referential_networks_path(@referential) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("networks"), referential_networks_path(@referential) -      add_breadcrumb @network.name, referential_line_path(@referential, @network) -    end -  end -    protected    def collection     diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 7d51c47ad..391a14d88 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -19,25 +19,10 @@ class RoutesController < ChouetteController      @map = RouteMap.new(route).with_helpers(self)      @stop_points = route.stop_points.paginate(:page => params[:page])      show! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) +      build_breadcrumb :show      end    end -  def new -    new! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -    end -  end -   -  def edit -    edit! do -      add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) -      add_breadcrumb @line.name, referential_line_path(@referential, @line) -      add_breadcrumb @route.name, referential_line_route_path(@referential, @line, @route) -    end -  end    # overwrite inherited resources to use delete instead of destroy     # foreign keys will propagate deletion)    def destroy_resource(object) diff --git a/app/controllers/rule_parameter_sets_controller.rb b/app/controllers/rule_parameter_sets_controller.rb index 9918e0eb5..63265bced 100644 --- a/app/controllers/rule_parameter_sets_controller.rb +++ b/app/controllers/rule_parameter_sets_controller.rb @@ -1,4 +1,5 @@  class RuleParameterSetsController < ChouetteController +  defaults :resource_class => RuleParameterSet    respond_to :html    respond_to :js, :only => [ :mode ] @@ -7,26 +8,10 @@ class RuleParameterSetsController < ChouetteController    def new      @rule_parameter_set = RuleParameterSet.default( @referential)      new! do -      add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) -      add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential)       -      add_breadcrumb Referential.human_attribute_name("rule_parameter_sets"), referential_rule_parameter_sets_path(@referential)       +      build_breadcrumb :show           end    end -  def index -    index! do -      add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) -      add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential)       -    end -  end - -  def show -    show! do -      add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) -      add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential)       -      add_breadcrumb Referential.human_attribute_name("rule_parameter_sets"), referential_rule_parameter_sets_path(@referential)       -    end -  end    def destroy      if @referential.rule_parameter_sets.count == 1 diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index ca72c362b..560b20626 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -19,37 +19,32 @@ class StopAreasController < ChouetteController    def select_parent      @stop_area = stop_area      @parent = stop_area.parent -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +    build_breadcrumb :edit    end    def add_children      @stop_area = stop_area      @children = stop_area.children -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +    build_breadcrumb :edit    end    def add_routing_lines      @stop_area = stop_area      @lines = stop_area.routing_lines -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +    build_breadcrumb :edit    end    def add_routing_stops      @stop_area = stop_area      @stops = stop_area.routing_stops -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +    build_breadcrumb :edit    end    def access_links      @stop_area = stop_area      @generic_access_links = stop_area.generic_access_link_matrix      @detail_access_links = stop_area.detail_access_link_matrix -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) +    build_breadcrumb :edit    end    def index @@ -60,6 +55,7 @@ class StopAreasController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end +        build_breadcrumb :index        }      end    end @@ -68,7 +64,7 @@ class StopAreasController < ChouetteController      @map = StopAreaMap.new( Chouette::StopArea.new).with_helpers(self)      @map.editable = true      new! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) +      build_breadcrumb :show      end    end @@ -82,7 +78,7 @@ class StopAreasController < ChouetteController          }        end -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) +      build_breadcrumb :show      end    end @@ -91,9 +87,8 @@ class StopAreasController < ChouetteController      map.editable = true      edit! do -      add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) -      add_breadcrumb @stop_area.name, referential_stop_area_path(@referential, @stop_area) -    end +      build_breadcrumb :edit +   end    end    def default_geometry diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 78d633581..957603b3b 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -9,25 +9,24 @@ class TimeTablesController < ChouetteController    belongs_to :referential    def show -    add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential)      @year = params[:year] ? params[:year].to_i : Date.today.cwyear      @time_table_combination = TimeTableCombination.new -    show! +    show! do +      build_breadcrumb :show +    end    end    def new -    add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) -      @autocomplete_items = ActsAsTaggableOn::Tag.all -    new! +    new! do +      build_breadcrumb :show       +    end    end    def edit      edit! do -      add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) -      add_breadcrumb @time_table.comment, referential_time_table_path(@referential, @time_table) - +      build_breadcrumb :edit              @autocomplete_items = ActsAsTaggableOn::Tag.all      end    end @@ -47,6 +46,7 @@ class TimeTablesController < ChouetteController          if collection.out_of_bounds?            redirect_to params.merge(:page => 1)          end +        build_breadcrumb :index              }      end    end diff --git a/app/controllers/vehicle_journey_imports_controller.rb b/app/controllers/vehicle_journey_imports_controller.rb index 136fac6d3..ce164c51e 100644 --- a/app/controllers/vehicle_journey_imports_controller.rb +++ b/app/controllers/vehicle_journey_imports_controller.rb @@ -1,4 +1,6 @@  class VehicleJourneyImportsController < ChouetteController +  defaults :resource_class => VehicleJourneyImport +      belongs_to :referential do      belongs_to :line, :parent_class => Chouette::Line do        belongs_to :route, :parent_class => Chouette::Route @@ -10,7 +12,9 @@ class VehicleJourneyImportsController < ChouetteController    def new          @vehicle_journey_import = VehicleJourneyImport.new(:route => route) -    new! +    new! do +      build_breadcrumb :show +    end    end    def create diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 18cd6b96c..8dc425ffc 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -36,6 +36,7 @@ class VehicleJourneysController < ChouetteController        if collection.out_of_bounds?          redirect_to params.merge(:page => 1)        end +      build_breadcrumb :index      end    end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb new file mode 100644 index 000000000..718147ce7 --- /dev/null +++ b/app/helpers/breadcrumb_helper.rb @@ -0,0 +1,188 @@ +module BreadcrumbHelper + +  def build_breadcrumb(action) +    case resource_class.to_s +    when "Chouette::Network" +      network_breadcrumb action +    when "Chouette::Company" +      company_breadcrumb action +    when "Chouette::GroupOfLine" +      group_of_line_breadcrumb action +    when "Chouette::Line" +      line_breadcrumb action +    when "Chouette::Route" +      route_breadcrumb action +    when "Chouette::JourneyPattern" +      journey_pattern_breadcrumb action +    when "Chouette::VehicleJourney" +      vehicle_journey_breadcrumb action +    when "VehicleJourneyImport" +      vehicle_journey_import_breadcrumb action +    when "Chouette::StopArea" +      stop_area_breadcrumb action +    when "Chouette::AccessPoint" +      access_point_breadcrumb action +    when "Chouette::AccessLink" +      access_link_breadcrumb action +    when "Chouette::ConnectionLink" +      connection_link_breadcrumb action +    when "Chouette::TimeTable" +      time_table_breadcrumb action +    when "ImportTask" +      import_breadcrumb action +    when "Export" +      export_breadcrumb action +    when "ComplianceCheckTask" +      compliance_breadcrumb action +    when "RuleParameterSet" +      rule_parameter_breadcrumb action +    else +      Rails.logger.info "---------" +      Rails.logger.info ">>>>>>> "+resource_class.to_s+" unmapped" +      Rails.logger.info "---------" +      referential_breadcrumb +    end +  end +   + +  def network_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("networks"), referential_networks_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@network), referential_line_path(@referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit +  end + +  def group_of_line_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("group_of_lines"), referential_group_of_lines_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@group_of_line), referential_group_of_line_path(@referential, @group_of_line),:title => breadcrumb_tooltip(@group_of_line) if action == :edit +  end + +  def stop_area_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("stop_areas"), referential_stop_areas_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@stop_area), referential_stop_area_path(@referential, @stop_area),:title => breadcrumb_tooltip(@stop_area) if action == :edit +  end + +  def access_point_breadcrumb(action) +    stop_area_breadcrumb :edit +    add_breadcrumb breadcrumb_label(@access_point), referential_stop_area_access_point_path(@referential, @stop_area,@access_point),:title => breadcrumb_tooltip(@access_point) if action == :edit +  end + +  def access_link_breadcrumb(action) +    access_point_breadcrumb :edit +    add_breadcrumb Chouette::AccessLink.model_name.human(:count => 2), access_links_referential_stop_area_path(@referential, @stop_area) +    add_breadcrumb breadcrumb_label(@access_link), referential_access_point_access_link_path(@referential, @access_point,@access_link),:title => breadcrumb_tooltip(@access_link) if action == :edit +  end + +  def connection_link_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("connection_links"), referential_connection_links_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@connection_link), referential_connection_link_path(@referential, @connection_link),:title => breadcrumb_tooltip(@connection_link) if action == :edit +  end + +  def time_table_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@time_table), referential_time_table_path(@referential, @time_table),:title => breadcrumb_tooltip(@time_table) if action == :edit +  end + +  def line_breadcrumb(action) +    referential_breadcrumb +    add_breadcrumb Referential.human_attribute_name("lines"), referential_lines_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@line), referential_line_path(@referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit +  end + +  def route_breadcrumb(action) +    line_breadcrumb :edit +    add_breadcrumb breadcrumb_label(@route), referential_line_route_path(@referential, @line,@route),:title => breadcrumb_tooltip(@route) if action == :edit +  end + +  def journey_pattern_breadcrumb(action) +    route_breadcrumb :edit +    add_breadcrumb breadcrumb_label(@journey_pattern), referential_line_route_journey_pattern_path(@referential, @line,@route,@journey_pattern),:title => breadcrumb_tooltip(@journey_pattern) if action == :edit +  end + +  def vehicle_journey_breadcrumb(action) +    if action == :index  +      route_breadcrumb :edit +    else  +      @journey_pattern = @vehicle_journey.journey_pattern +      journey_pattern_breadcrumb :edit +      add_breadcrumb Referential.human_attribute_name("vehicle_journeys"), referential_line_route_vehicle_journeys_path(@referential, @line,@route) +    end +    add_breadcrumb breadcrumb_label(@vehicle_journey), referential_line_route_vehicle_journey_path(@referential, @line,@route,@vehicle_journey),:title => breadcrumb_tooltip(@vehicle_journey) if action == :edit +  end +   +  def vehicle_journey_import_breadcrumb (action) +    route_breadcrumb :edit +  end + +  def company_breadcrumb (action) +    referential_breadcrumb  +    add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@company), referential_company_path(@referential, @company),:title => breadcrumb_tooltip(@company) if action == :edit +  end +   +  def import_breadcrumb (action) +    referential_breadcrumb  +    add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) unless action == :index +  end +   +  def export_breadcrumb (action) +    referential_breadcrumb  +    add_breadcrumb Referential.human_attribute_name("exports"), referential_exports_path(@referential) unless action == :index +  end + +  def compliance_breadcrumb (action) +    referential_breadcrumb  +    add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) unless action == :index +    add_breadcrumb breadcrumb_label(@compliance_check_task), referential_compliance_check_task_path(@referential, @compliance_check_task),:title => breadcrumb_tooltip(@compliance_check_task) if action == :edit +  end + +  def rule_parameter_breadcrumb (action) +    referential_breadcrumb  +    add_breadcrumb Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential)  +    add_breadcrumb Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) +    add_breadcrumb Referential.human_attribute_name("rule_parameter_sets"), referential_rule_parameter_sets_path(@referential) unless action == :index +  end + +  def referential_breadcrumb +    if @referential.present? +      add_breadcrumb breadcrumb_label(@referential), referential_path(@referential),:title => breadcrumb_tooltip(@referential) +    end +  end +   +  def breadcrumb_label(obj) +    label = breadcrumb_name(obj) +    if label.blank? +      label = obj.id.to_s +    end +     +    if label.length > 12 +      label[0..8]+"..." +    else +      label   +    end +  end +   +  def breadcrumb_tooltip(obj) +    label = breadcrumb_name(obj) +    if label.blank? +      label = obj.class.model_name.human+"("+obj.id.to_s+")" +    else +      label = obj.class.model_name.human+" : "+label +    end +    label +  end + +  def breadcrumb_name(obj) +    label = "" +    if obj.respond_to?('name')  +      label = obj.name +    elsif obj.respond_to?('comment')  +      label = obj.comment +    end +    label     +  end + +end diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb index b50f25027..4ee1881b0 100644 --- a/app/views/vehicle_journeys/index.html.erb +++ b/app/views/vehicle_journeys/index.html.erb @@ -1,8 +1,3 @@ -<ol class="breadcrumb"> -  <li><%= link_to line_formatted_name( @line), [@referential, @line] %></li> -  <li><%= link_to @route.name, [@referential, @line, @route] %></li> -</ol> -  <%= title_tag t('vehicle_journeys.index.title', :route => @route.name ) %>  <%= search_form_for @q, :url => referential_line_route_vehicle_journeys_path(@referential,@line,@route), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> | 
