Sidebar registration working,admin items with corrected translation

This commit is contained in:
Saurabh Bhatia 2014-04-09 18:30:13 +08:00
parent 0ff748acc4
commit 0ee2820cbd
9 changed files with 47 additions and 80 deletions

View File

@ -14,7 +14,7 @@ gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
gem 'announcement', path: '/Users/saurabhbhatia/announcement-test'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

View File

@ -1,3 +0,0 @@
// Place all the styles related to the admin/dashboards controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -1,69 +0,0 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
color: #fff;
background-color: #000;
}
}
div {
&.field, &.actions {
margin-bottom: 10px;
}
}
#notice {
color: green;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}

View File

@ -132,6 +132,14 @@ module ApplicationHelper
data
end
def active_for_controllers(*controller_names)
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? 'active' : nil
end
def visible_for_controllers(*controller_names)
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? '' : 'hide'
end
def active_for_action(controller_name, action_name)
((controller.controller_name.eql?(controller_name) || request.fullpath.eql?(controller_name)) && controller.action_name.eql?(action_name)) ? 'active' : nil
end

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html>
<head>
<title><%= current_site.title || t('site.settings') %></title>
<title><%= current_site.title %> | <%= t('site.settings') %></title>
<%= render 'shared/meta' %>
<%= render 'shared/google_font' %>
<%= stylesheet_link_tag "structure" %>
@ -18,3 +18,4 @@
</section>
</body>
</html>

View File

@ -41,5 +41,7 @@ en:
dashboard_: Dashboard
desktop: Desktop
homepage: Homepage
site:
system_preference: System Preference
site:
system_preference: System Preference
settings: Site Settings

View File

@ -1,6 +1,7 @@
module Renderer
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
include ActionView::RoutingUrlFor
include ActionView::Helpers::TagHelper
include ActionView::Helpers::RenderingHelper
include ActionView::Context

View File

@ -10,9 +10,7 @@ module SideBarRenderer
content_tag :div, class: "sub-nav-block #{@icon_class}" do
concat content_tag :h4, I18n.t(@head_label)
concat (content_tag :ul, class: "nav nav-list" do
@context_links.sort_by {| obj | obj.priority}.map{ |link|
link.render(request, params, @current_module_app, @belong_module_app)
}.join.html_safe
end)
end
end
@ -23,13 +21,24 @@ module SideBarRenderer
@request = request
@params = params
content_tag :li, class: (module_sidebar_active? ? 'active' : nil) do
link_to eval(@head_link) do
link_to Rails.application.routes.url_helpers.send(@head_link) do
content_tag :span do
content_tag(:i, nil, class: @icon_class)
end
end
end
end
protected
def module_sidebar_active?
active_for_controller?
end
def active_for_controller?
@active_for_controllers.include? controller
end
end

View File

@ -45,6 +45,7 @@ module OrbitApp
@head_label = name
@head_link = ""
@app_base_path = ''
@active_for_controllers = []
@module_app_key = key
@get_module_app = get_module_app
@sidebar_order = 0
@ -77,6 +78,23 @@ module OrbitApp
def head_link_path(var)
@head_link = var
end
def active_for_controllers(var)
@active_for_controllers = var
end
protected
def set_controllers_scope
var = @active_for_controllers
@active_for_controllers = []
var[:private].each do |controller|
@active_for_controllers << "admin/"+controller
end unless var[:private].nil?
var[:public].each do |controller|
@active_for_controllers << controller
end unless var[:public].nil?
end
end
end
end