aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-09-22 11:17:33 +0200
committerMichel Etienne2014-09-22 11:17:33 +0200
commit9e25d62af63c460583c05f4c33245a5dd1a5b2b9 (patch)
tree0480062cdcb96c837268cf1a997336bf89ba495c
parentd86f7fe8cad332890f0be146f229cde72dc52eec (diff)
downloadchouette-core-9e25d62af63c460583c05f4c33245a5dd1a5b2b9.tar.bz2
add breadcrumbs on home and user forms
-rw-r--r--app/controllers/breadcrumb_controller.rb41
-rw-r--r--app/controllers/chouette_controller.rb2
-rw-r--r--app/controllers/organisations_controller.rb4
-rw-r--r--app/controllers/referentials_controller.rb7
-rw-r--r--app/controllers/users_controller.rb4
-rw-r--r--app/helpers/breadcrumb_helper.rb44
-rw-r--r--app/views/vehicle_journeys/_sidebar.html.erb10
-rw-r--r--config/locales/breadcrumbs.yml10
-rw-r--r--config/locales/vehicle_journeys.yml2
9 files changed, 89 insertions, 35 deletions
diff --git a/app/controllers/breadcrumb_controller.rb b/app/controllers/breadcrumb_controller.rb
new file mode 100644
index 000000000..022636709
--- /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 :show
+ end
+ end
+
+ def create
+ create! do |success, failure|
+ build_breadcrumb :show
+ end
+ end
+
+end
diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb
index 6e87a4bf6..4aeb2aa09 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
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/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/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 718147ce7..3b1bcca95 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -36,30 +36,32 @@ module BreadcrumbHelper
compliance_breadcrumb action
when "RuleParameterSet"
rule_parameter_breadcrumb action
+ when "User"
+ user_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
@@ -76,19 +78,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 +105,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 +116,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 +143,21 @@ 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)
+ add_breadcrumb I18n.t("breadcrumbs.referentials"), referentials_path
+ add_breadcrumb breadcrumb_label(@referential), referential_path(@referential),:title => breadcrumb_tooltip(@referential) if action != :index && @referential.present?
end
+ def user_breadcrumb (action)
+ referential_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 +170,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/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/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 810c80ddb..8313c12b8 100644
--- a/config/locales/vehicle_journeys.yml
+++ b/config/locales/vehicle_journeys.yml
@@ -141,7 +141,7 @@ fr:
validation: "Cloner"
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"