Breadcrumb for dashboard (tags and categories cannot link to original module index)

This commit is contained in:
chris 2013-07-29 17:34:03 +08:00
parent fe10cc62d9
commit d190a50046
6 changed files with 61 additions and 4 deletions

View File

@ -136,7 +136,7 @@ class Admin::AuthorizationsController < OrbitBackendController
@module_app = ModuleApp.first(conditions: {:key => params[:module]} ) if params[:module] @module_app = ModuleApp.first(conditions: {:key => params[:module]} ) if params[:module]
@type = params[:type].underscore if params[:type] @type = params[:type].underscore if params[:type]
if @type if @type
@klass = @type.classify.constantize @klass = @type.classify.constantize rescue nil
@object = @klass.find(params[:id]) rescue nil @object = @klass.find(params[:id]) rescue nil
end end
end end

View File

@ -345,4 +345,42 @@ module OrbitBackendHelper
end end
end end
# ===============================================================
# Breadcrumbs
# ===============================================================
def back_end_breadcrumb
res = ''
divider = "<span class='divider'>/</span>"
res << "<li><a href='#{admin_dashboards_path}'>#{t(:dashboard_)}</a>#{divider}</li>"
case controller.controller_name
when 'authorizations'
res << "<li><a href='/#{params[:controller]}/#{@module_app.key}'>#{@module_app.title}</a>#{divider}</li>"
case params[:type]
when 'approval'
res << "<li class='active'>#{t(:approval_)}</li>"
when 'category'
res << "<li class='active'>#{t(:category_auth)}</li>"
when nil
res << "<li class='active'>#{t(:module_authorization)}</li>"
else
res << "<li class='active'>#{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}</li>"
end
when 'categories'
res << "<li>#{@module_app.title}#{divider}</li>"
res << "<li class='active'>#{t(:categories)}</li>"
when 'module_tags'
res << "<li>#{@module_app.title}#{divider}</li>"
res << "<li class='active'>#{t(:tags)}</li>"
else
if params[:action].eql?('index')
res << "<li>#{@module_app.title}</li>"
else
res << "<li><a href='/#{params[:controller]}'>#{@module_app.title}</a>#{divider}</li>"
res << "<li class='active'>#{t(params[:action], scope: 'restful_actions')}</li>"
end
end
res.html_safe
end
end end

View File

@ -15,7 +15,7 @@
<div class="mini-layout-body span10"> <div class="mini-layout-body span10">
<%= link_to t(:module_authorization), admin_authorizations_path(@module_app.key) %> <%= link_to t(:module_authorization), admin_authorizations_path(@module_app.key) %>
<% @module_app.authorizable_models.each do |authorizable_model| %> <% @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 %> <% end %>
<%= link_to t(:approval_), admin_authorizations_path(@module_app.key, type: 'approval') if @module_app.is_approvable %> <%= link_to t(:approval_), admin_authorizations_path(@module_app.key, type: 'approval') if @module_app.is_approvable %>
<% if @error %> <% if @error %>

View File

@ -0,0 +1,12 @@
<li><a href="<%= admin_dashboards_path %>"><%= t(:dashboard_) %></a> <span class="divider">/</span></li>
<% case controller.controller_name %>
<% when 'authorizations' %>
<% when 'categories' %>
<% when 'tags' %>
<% else %>
<li><a href="<%= params[:controller] %>"><%= @module_app.title %></li>
<% end %>
<li class="active">All</li>

View File

@ -24,8 +24,7 @@
<div class="wrap-inner"> <div class="wrap-inner">
<div id="filter" class="topnav clearfix"> <div id="filter" class="topnav clearfix">
<ul class="breadcrumb text-info pull-left"> <ul class="breadcrumb text-info pull-left">
<li><a href="/orbit_4.0.1/admin/dashboards/dashboards.shtml">Dashboard</a> <span class="divider">/</span></li> <%= back_end_breadcrumb %>
<li class="active">All</li>
</ul> </ul>
<%= yield :right_nav %> <%= yield :right_nav %>
</div> </div>

View File

@ -40,6 +40,14 @@ en:
previous: Previous previous: Previous
remove: Remove remove: Remove
remove_default: Remove default remove_default: Remove default
restful_actions:
create: Create
delete: Delete
edit: Edit
index: Index
new: New
show: Show
update: Update
search: search:
tags: Search tags tags: Search tags
select_all: Select all select_all: Select all