diff options
| author | Luc Donnet | 2014-09-22 15:01:18 +0200 |
|---|---|---|
| committer | Luc Donnet | 2014-09-22 15:01:18 +0200 |
| commit | 57dd015630238ddc3dd5451d56591be3a06b0aee (patch) | |
| tree | 426e7b1b818f09acc156d8abf71ccdffa8127fd0 | |
| parent | d376a110c16f0003b84bf2a6fb6e884ffbdd8ff1 (diff) | |
| parent | 50a9cf10902dd32a84e5074b5d392757f120102e (diff) | |
| download | chouette-core-57dd015630238ddc3dd5451d56591be3a06b0aee.tar.bz2 | |
Merge branch 'sismo' of github.com:afimb/chouette2 into sismo
27 files changed, 108 insertions, 146 deletions
diff --git a/app/controllers/breadcrumb_controller.rb b/app/controllers/breadcrumb_controller.rb new file mode 100644 index 000000000..143651b52 --- /dev/null +++ b/app/controllers/breadcrumb_controller.rb @@ -0,0 +1,41 @@ +class BreadcrumbController < InheritedResources::Base + + include BreadcrumbHelper + + 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 :new + end + end + + def create + create! do |success, failure| + build_breadcrumb :new + end + end + +end diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb index 6e87a4bf6..753fbd2fc 100644 --- a/app/controllers/chouette_controller.rb +++ b/app/controllers/chouette_controller.rb @@ -1,4 +1,4 @@ -class ChouetteController < InheritedResources::Base +class ChouetteController < BreadcrumbController include ApplicationHelper include BreadcrumbHelper @@ -15,40 +15,4 @@ class ChouetteController < InheritedResources::Base @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/exports_controller.rb b/app/controllers/exports_controller.rb index 8de7e4f1f..cb555a3dd 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -8,7 +8,7 @@ class ExportsController < ChouetteController def new new! do - build_breadcrumb :show + build_breadcrumb :new available_exports end end diff --git a/app/controllers/import_tasks_controller.rb b/app/controllers/import_tasks_controller.rb index a0d17d4d7..bee70d196 100644 --- a/app/controllers/import_tasks_controller.rb +++ b/app/controllers/import_tasks_controller.rb @@ -6,7 +6,7 @@ class ImportTasksController < ChouetteController def new new! do - build_breadcrumb :show + build_breadcrumb :new available_imports end end diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 7e2edb220..9faea18a5 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -1,4 +1,6 @@ -class OrganisationsController < InheritedResources::Base +class OrganisationsController < BreadcrumbController + + defaults :resource_class => Organisation respond_to :html def update diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index de0b209ca..bf8a2f1ef 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -1,4 +1,7 @@ -class ReferentialsController < InheritedResources::Base +class ReferentialsController < BreadcrumbController + + defaults :resource_class => Referential + respond_to :html respond_to :json, :only => :show respond_to :js, :only => :show @@ -13,6 +16,8 @@ class ReferentialsController < InheritedResources::Base :time_tables_count => resource.time_tables.count, :referential_id => resource.id} } + format.html { build_breadcrumb :show} + end end diff --git a/app/controllers/rule_parameter_sets_controller.rb b/app/controllers/rule_parameter_sets_controller.rb index 63265bced..a422bed15 100644 --- a/app/controllers/rule_parameter_sets_controller.rb +++ b/app/controllers/rule_parameter_sets_controller.rb @@ -8,7 +8,7 @@ class RuleParameterSetsController < ChouetteController def new @rule_parameter_set = RuleParameterSet.default( @referential) new! do - build_breadcrumb :show + build_breadcrumb :new end end diff --git a/app/controllers/stop_area_copies_controller.rb b/app/controllers/stop_area_copies_controller.rb index 642932acd..7c1fac8d9 100644 --- a/app/controllers/stop_area_copies_controller.rb +++ b/app/controllers/stop_area_copies_controller.rb @@ -1,4 +1,5 @@ class StopAreaCopiesController < ChouetteController + defaults :resource_class => StopAreaCopy belongs_to :referential do belongs_to :stop_area, :parent_class => Chouette::StopArea end @@ -9,8 +10,7 @@ class StopAreaCopiesController < ChouetteController def new @stop_area_copy = StopAreaCopy.new(:hierarchy => params[:hierarchy], :source => parent) 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) + build_breadcrumb :new end end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 2b3b556c8..b80f53b77 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -20,7 +20,7 @@ class TimeTablesController < ChouetteController def new @autocomplete_items = ActsAsTaggableOn::Tag.all new! do - build_breadcrumb :show + build_breadcrumb :new end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b57b9d54a..2b1c2bd14 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,4 +1,6 @@ -class UsersController < InheritedResources::Base +class UsersController < BreadcrumbController + + defaults :resource_class => User def create @user = current_organisation.users.build(params[:user]) diff --git a/app/controllers/vehicle_journey_imports_controller.rb b/app/controllers/vehicle_journey_imports_controller.rb index ce164c51e..7ce0aca23 100644 --- a/app/controllers/vehicle_journey_imports_controller.rb +++ b/app/controllers/vehicle_journey_imports_controller.rb @@ -13,7 +13,7 @@ class VehicleJourneyImportsController < ChouetteController def new @vehicle_journey_import = VehicleJourneyImport.new(:route => route) new! do - build_breadcrumb :show + build_breadcrumb :new end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 718147ce7..23cf6a6f2 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -28,6 +28,8 @@ module BreadcrumbHelper connection_link_breadcrumb action when "Chouette::TimeTable" time_table_breadcrumb action + when "StopAreaCopy" + stop_area_copy_breadcrumb action when "ImportTask" import_breadcrumb action when "Export" @@ -36,33 +38,41 @@ module BreadcrumbHelper compliance_breadcrumb action when "RuleParameterSet" rule_parameter_breadcrumb action + when "User" + user_breadcrumb action + when "Organisation" + organisation_breadcrumb action else Rails.logger.info "---------" Rails.logger.info ">>>>>>> "+resource_class.to_s+" unmapped" Rails.logger.info "---------" - referential_breadcrumb + referential_breadcrumb action end end def network_breadcrumb(action) referential_breadcrumb - add_breadcrumb Referential.human_attribute_name("networks"), referential_networks_path(@referential) unless action == :index + add_breadcrumb Chouette::Network.model_name.human(:count => 2), 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 Chouette::GroupOfLine.model_name.human(:count => 2), 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 Chouette::StopArea.model_name.human(:count => 2), 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 stop_area_copy_breadcrumb(action) + stop_area_breadcrumb :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 @@ -76,19 +86,19 @@ module BreadcrumbHelper 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 Chouette::ConnectionLink.model_name.human(:count => 2), 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 Chouette::TimeTable.model_name.human(:count => 2), 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 Chouette::Line.model_name.human(:count => 2), 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 @@ -103,13 +113,8 @@ module BreadcrumbHelper 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 + route_breadcrumb :edit + add_breadcrumb I18n.t("breadcrumbs.vehicle_journeys"), referential_line_route_vehicle_journeys_path(@referential, @line,@route) unless action == :index 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 @@ -119,7 +124,7 @@ module BreadcrumbHelper def company_breadcrumb (action) referential_breadcrumb - add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential) unless action == :index + add_breadcrumb Chouette::Company.model_name.human(:count => 2), 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 @@ -146,16 +151,25 @@ module BreadcrumbHelper 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 + def referential_breadcrumb (action = :edit) + organisation_breadcrumb + add_breadcrumb breadcrumb_label(@referential), referential_path(@referential),:title => breadcrumb_tooltip(@referential) if action == :edit end + def organisation_breadcrumb (action = :edit) + add_breadcrumb I18n.t("breadcrumbs.referentials"), referentials_path + end + + def user_breadcrumb (action) + organisation_breadcrumb + add_breadcrumb I18n.t("breadcrumbs.users"), organisation_path unless action == :index + add_breadcrumb breadcrumb_label(@user), organisation_user_path(@user),:title => breadcrumb_tooltip(@user) unless action == :index + end + def breadcrumb_label(obj) label = breadcrumb_name(obj) if label.blank? - label = obj.id.to_s + label = obj.class.model_name.human+" "+obj.id.to_s end if label.length > 12 @@ -168,7 +182,7 @@ module BreadcrumbHelper def breadcrumb_tooltip(obj) label = breadcrumb_name(obj) if label.blank? - label = obj.class.model_name.human+"("+obj.id.to_s+")" + label = obj.class.model_name.human+" ("+obj.id.to_s+")" else label = obj.class.model_name.human+" : "+label end diff --git a/app/views/access_links/show.html.erb b/app/views/access_links/show.html.erb index 79294bb38..3999b0287 100644 --- a/app/views/access_links/show.html.erb +++ b/app/views/access_links/show.html.erb @@ -5,18 +5,6 @@ <div class="summary"> <p> - <label><%= @access_link.human_attribute_name(:access_point) %>: </label> - <%= link_to @access_link.access_point.name, [@referential, @access_link.access_point.stop_area, @access_link.access_point] %> - </p> - <p> - <label><%= @access_link.human_attribute_name(:stop_area) %>: </label> - <%= link_to @access_link.stop_area.name, [@referential, @access_link.stop_area] %> - </p> - <p> - <label><%= @access_link.human_attribute_name(:name) %>: </label> - <%= @access_link.name %> - </p> - <p> <label><%= @access_link.human_attribute_name("access_link_type") %>: </label> <%= t("connection_link_types.label.#{@access_link.access_link_type}") %> </p> diff --git a/app/views/access_points/show.html.erb b/app/views/access_points/show.html.erb index 7cd7b4920..925d73ee7 100644 --- a/app/views/access_points/show.html.erb +++ b/app/views/access_points/show.html.erb @@ -5,14 +5,6 @@ <% end %> <div class="summary"> <p> - <label><%= @access_point.human_attribute_name(:stop_area) %>: </label> - <%= link_to @stop_area.name, [@referential, @stop_area] %> - </p> - <p> - <label><%= @access_point.human_attribute_name("name") %>: </label> - <%= @access_point.name %> - </p> - <p> <label><%= @access_point.human_attribute_name("comment") %>: </label> <%= @access_point.comment %> </p> diff --git a/app/views/companies/show.html.erb b/app/views/companies/show.html.erb index 0ac132511..0c8585a6c 100644 --- a/app/views/companies/show.html.erb +++ b/app/views/companies/show.html.erb @@ -4,10 +4,6 @@ <div class="summary"> <p> - <label><%= @company.human_attribute_name(:name) %>: </label> - <%= @company.name %> - </p> - <p> <label><%= Chouette::Company.human_attribute_name("short_name") %>: </label> <%= @company.short_name %> </p> diff --git a/app/views/connection_links/show.html.erb b/app/views/connection_links/show.html.erb index 2414f3dbd..f9689bf55 100644 --- a/app/views/connection_links/show.html.erb +++ b/app/views/connection_links/show.html.erb @@ -21,10 +21,6 @@ <% end %> </p> <p> - <label><%= @connection_link.human_attribute_name(:name) %>: </label> - <%= @connection_link.name %> - </p> - <p> <label><%= @connection_link.human_attribute_name("connection_link_type") %>: </label> <%= t("connection_link_types.label.#{@connection_link.connection_link_type}") %> </p> diff --git a/app/views/group_of_lines/show.html.erb b/app/views/group_of_lines/show.html.erb index e5923d539..7ce5ddc46 100644 --- a/app/views/group_of_lines/show.html.erb +++ b/app/views/group_of_lines/show.html.erb @@ -4,10 +4,6 @@ <%= @map.to_html %> <div class="summary"> <p> - <label><%= @group_of_line.human_attribute_name(:name) %>: </label> - <%= @group_of_line.name %> - </p> - <p> <label><%= @group_of_line.human_attribute_name("comment") %>: </label> <%= @group_of_line.comment %> </p> diff --git a/app/views/journey_patterns/show.html.erb b/app/views/journey_patterns/show.html.erb index a5f75e7c9..4ac057161 100644 --- a/app/views/journey_patterns/show.html.erb +++ b/app/views/journey_patterns/show.html.erb @@ -5,14 +5,6 @@ <div class="summary"> <p> - <label><%= @route.human_attribute_name(:line) %>: </label> - <%= link_to line_formatted_name( @line), [@referential, @line] %> - </p> - <p> - <label><%= @journey_pattern.human_attribute_name(:route) %>: </label> - <%= link_to @route.name, [@referential, @line, @route] %> - </p> - <p> <label><%= @journey_pattern.human_attribute_name(:name) %>: </label> <%= @journey_pattern.name %> </p> diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index d1a13aacf..cec5dc2f0 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -21,10 +21,6 @@ <% end %> </p> <p> - <label><%= @line.human_attribute_name(:name) %>: </label> - <%= @line.name %> - </p> - <p> <label><%= @line.human_attribute_name("published_name") %>: </label> <%= @line.published_name %> </p> diff --git a/app/views/networks/show.html.erb b/app/views/networks/show.html.erb index 1999c9869..e7b103dda 100644 --- a/app/views/networks/show.html.erb +++ b/app/views/networks/show.html.erb @@ -4,10 +4,6 @@ <%= @map.to_html %> <div class="summary"> <p> - <label><%= @network.human_attribute_name(:name) %>: </label> - <%= @network.name %> - </p> - <p> <label><%= Chouette::Network.human_attribute_name("registration_number") %>: </label> <%= @network.registration_number %> </p> diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index b935a6f34..22ef7fff8 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -5,10 +5,6 @@ <div class="summary"> <p> - <label><%= @route.human_attribute_name(:line) %>: </label> - <%= link_to line_formatted_name( @line), [@referential, @line] %> - </p> - <p> <label><%= @route.human_attribute_name(:name) %>: </label> <%= @route.name %> </p> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb index 6659b703f..3cef99be8 100644 --- a/app/views/stop_areas/show.html.erb +++ b/app/views/stop_areas/show.html.erb @@ -6,10 +6,6 @@ <% end %> <div class="summary"> <p> - <label><%= @stop_area.human_attribute_name("name") %>: </label> - <%= @stop_area.name %> - </p> - <p> <label><%= @stop_area.human_attribute_name("comment") %>: </label> <%= @stop_area.comment %> </p> diff --git a/app/views/time_tables/_show_time_table.html.erb b/app/views/time_tables/_show_time_table.html.erb index 5095ac918..71fe973c9 100644 --- a/app/views/time_tables/_show_time_table.html.erb +++ b/app/views/time_tables/_show_time_table.html.erb @@ -13,10 +13,6 @@ </div> <div class="summary"> <p> - <label><%= @time_table.human_attribute_name("comment") %>: </label> - <%= @time_table.comment %> - </p> - <p> <label><%= @time_table.human_attribute_name("version") %>: </label> <%= @time_table.version %> </p> diff --git a/app/views/vehicle_journeys/_sidebar.html.erb b/app/views/vehicle_journeys/_sidebar.html.erb index cb3236c18..80f70d574 100644 --- a/app/views/vehicle_journeys/_sidebar.html.erb +++ b/app/views/vehicle_journeys/_sidebar.html.erb @@ -1,14 +1,6 @@ <ul class="actions"> <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> <li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li> + <li><%= link_to image_tag("icons/file_csv.png") + t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :zip), :class => "with_fa" %></li> </ul> - <div class="btn-group"> - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> - <%= t('vehicle_journey_imports.new.export_vehicle_journeys') %><span class="caret"></span> - </button> - <ul class="dropdown-menu" role="menu"> - <li><%= link_to image_tag("icons/file_csv.png") + " Csv" , referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :csv) %></li> - <li><%= link_to image_tag("icons/file_excel.png") + " Excel", referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :xls) %></li> - </ul> - </div> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index 9bf433c29..f964fc4ea 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -15,14 +15,6 @@ <div class="vehicle_journey"> <div class="summary"> <p> - <label><%= @route.human_attribute_name(:line) %>: </label> - <%= link_to line_formatted_name( @line), [@referential, @line] %> - </p> - <p> - <label><%= @vehicle_journey.human_attribute_name(:route) %>: </label> - <%= link_to @route.name, [@referential, @line, @route] %> - </p> - <p> <label><%= @vehicle_journey.human_attribute_name(:journey_pattern) %>: </label> <%= link_to journey_name(@vehicle_journey.journey_pattern), [@referential, @line, @route, @vehicle_journey.journey_pattern] %> </p> diff --git a/config/locales/breadcrumbs.yml b/config/locales/breadcrumbs.yml new file mode 100644 index 000000000..ccf97c414 --- /dev/null +++ b/config/locales/breadcrumbs.yml @@ -0,0 +1,10 @@ +en: + breadcrumbs: + vehicle_journeys: "Passing times" + referentials: "Home" + users: "Users" +fr: + breadcrumbs: + vehicle_journeys: "Horaires" + referentials: "Accueil" + users: "Utilisateurs" diff --git a/config/locales/vehicle_journeys.yml b/config/locales/vehicle_journeys.yml index d9768048a..8eec6657d 100644 --- a/config/locales/vehicle_journeys.yml +++ b/config/locales/vehicle_journeys.yml @@ -139,7 +139,7 @@ fr: bounding: "De %{start} à %{end}" translation_form: "Cloner la course" index: - title: "Courses de la séquence d'arrêts %{route}" + title: "Horaires de la séquence d'arrêts %{route}" vehicle_journeys: "Horaires de départ aux arrêts" selection: "Filtrer sur" selection_all: "Tous" |
