From d190a500468175bfc1a900a4dbf23bb80bcc5881 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 29 Jul 2013 17:34:03 +0800 Subject: [PATCH] Breadcrumb for dashboard (tags and categories cannot link to original module index) --- .../admin/authorizations_controller.rb | 2 +- app/helpers/orbit_backend_helper.rb | 38 +++++++++++++++++++ app/views/admin/authorizations/index.html.erb | 2 +- .../layouts/_breadcrumb_back_end.html.erb | 12 ++++++ app/views/layouts/back_end.html.erb | 3 +- config/locales/new_ui.en.yml | 8 ++++ 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 app/views/layouts/_breadcrumb_back_end.html.erb diff --git a/app/controllers/admin/authorizations_controller.rb b/app/controllers/admin/authorizations_controller.rb index 07b0de7f8..046812424 100644 --- a/app/controllers/admin/authorizations_controller.rb +++ b/app/controllers/admin/authorizations_controller.rb @@ -136,7 +136,7 @@ class Admin::AuthorizationsController < OrbitBackendController @module_app = ModuleApp.first(conditions: {:key => params[:module]} ) if params[:module] @type = params[:type].underscore if params[:type] if @type - @klass = @type.classify.constantize + @klass = @type.classify.constantize rescue nil @object = @klass.find(params[:id]) rescue nil end end diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index b5c8eca22..aa8075c40 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -345,4 +345,42 @@ module OrbitBackendHelper end end + # =============================================================== + # Breadcrumbs + # =============================================================== + + def back_end_breadcrumb + res = '' + divider = "/" + res << "
  • #{t(:dashboard_)}#{divider}
  • " + case controller.controller_name + when 'authorizations' + res << "
  • #{@module_app.title}#{divider}
  • " + case params[:type] + when 'approval' + res << "
  • #{t(:approval_)}
  • " + when 'category' + res << "
  • #{t(:category_auth)}
  • " + when nil + res << "
  • #{t(:module_authorization)}
  • " + else + res << "
  • #{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}
  • " + end + when 'categories' + res << "
  • #{@module_app.title}#{divider}
  • " + res << "
  • #{t(:categories)}
  • " + when 'module_tags' + res << "
  • #{@module_app.title}#{divider}
  • " + res << "
  • #{t(:tags)}
  • " + else + if params[:action].eql?('index') + res << "
  • #{@module_app.title}
  • " + else + res << "
  • #{@module_app.title}#{divider}
  • " + res << "
  • #{t(params[:action], scope: 'restful_actions')}
  • " + end + end + res.html_safe + end + end \ No newline at end of file diff --git a/app/views/admin/authorizations/index.html.erb b/app/views/admin/authorizations/index.html.erb index 4d0600ca7..41d6b55da 100644 --- a/app/views/admin/authorizations/index.html.erb +++ b/app/views/admin/authorizations/index.html.erb @@ -15,7 +15,7 @@
    <%= link_to t(:module_authorization), admin_authorizations_path(@module_app.key) %> <% @module_app.authorizable_models.each do |authorizable_model| %> - <%= link_to (authorizable_model.eql?('Category') ? t(:category_auth) : "#{authorizable_model.underscore.humanize} #{t(:authorization_)}"), admin_authorizations_path(@module_app.key, type: authorizable_model) %> + <%= link_to (authorizable_model.eql?('Category') ? t(:category_auth) : "#{authorizable_model.underscore.humanize.capitalize} #{t(:authorization_)}"), admin_authorizations_path(@module_app.key, type: authorizable_model.downcase) %> <% end %> <%= link_to t(:approval_), admin_authorizations_path(@module_app.key, type: 'approval') if @module_app.is_approvable %> <% if @error %> diff --git a/app/views/layouts/_breadcrumb_back_end.html.erb b/app/views/layouts/_breadcrumb_back_end.html.erb new file mode 100644 index 000000000..1bafb6d98 --- /dev/null +++ b/app/views/layouts/_breadcrumb_back_end.html.erb @@ -0,0 +1,12 @@ +
  • <%= t(:dashboard_) %> /
  • +<% case controller.controller_name %> + <% when 'authorizations' %> + + <% when 'categories' %> + + <% when 'tags' %> + + <% else %> +
  • <%= @module_app.title %>
  • +<% end %> +
  • All
  • \ No newline at end of file diff --git a/app/views/layouts/back_end.html.erb b/app/views/layouts/back_end.html.erb index f03e9aec1..b102562af 100644 --- a/app/views/layouts/back_end.html.erb +++ b/app/views/layouts/back_end.html.erb @@ -24,8 +24,7 @@
    <%= yield :right_nav %>
    diff --git a/config/locales/new_ui.en.yml b/config/locales/new_ui.en.yml index e0e0a0bda..b6f072b3c 100644 --- a/config/locales/new_ui.en.yml +++ b/config/locales/new_ui.en.yml @@ -40,6 +40,14 @@ en: previous: Previous remove: Remove remove_default: Remove default + restful_actions: + create: Create + delete: Delete + edit: Edit + index: Index + new: New + show: Show + update: Update search: tags: Search tags select_all: Select all