default widgets and sidebar.
This commit is contained in:
1 parent
6995bb1622
commit
5f712622ad
28 files changed
+344
-162
No files matched your search
@@ -1,12 +1,32 @@
|
||||
module ContextLinkRenderer
|
||||
include Renderer
|
||||
|
||||
def render(request,params)
|
||||
def render(request,params,module_app,user)
|
||||
@module_app = module_app
|
||||
@request = request
|
||||
@params = params
|
||||
@current_user = user
|
||||
if display?
|
||||
content_tag :li, link_to((I18n.t(@label_i18n) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, eval(@path)), :class => (active? ? 'active' : nil)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def display?
|
||||
@available_for.each do |available_for_in_sym|
|
||||
result = case available_for_in_sym
|
||||
when :all
|
||||
true
|
||||
when :manager
|
||||
@module_app.is_manager? @current_user
|
||||
when :sub_manager
|
||||
@module_app.is_sub_manager? @current_user
|
||||
else
|
||||
(eval(available_for_in_sym).include? @current_user rescue false)
|
||||
end # of case
|
||||
return true if result || @current_user.admin?
|
||||
end # of collect
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,10 +8,15 @@ module Renderer
|
||||
|
||||
protected
|
||||
def active_for_app_auth?
|
||||
@module_app.id.to_s == @params[:module_app_id] ? true : false
|
||||
if @module_app.nil?
|
||||
false
|
||||
else
|
||||
@module_app.id.to_s == @params[:module_app_id] ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
def active_for_ob_auths?
|
||||
|
||||
if @params.has_key? :object_auth_id
|
||||
oa = ObjectAuth.find @params[:object_auth_id]
|
||||
check_controller = @params[:controller] == 'admin/object_auths_new_interface'
|
||||
|
||||
@@ -2,7 +2,8 @@ module SideBarRenderer
|
||||
include Renderer
|
||||
include AdminHelper
|
||||
|
||||
def render(request,params,user)
|
||||
def render(request,params,user,module_app)
|
||||
@module_app = module_app
|
||||
@request = request
|
||||
@params = params
|
||||
@current_user = user
|
||||
@@ -11,7 +12,7 @@ module SideBarRenderer
|
||||
buf = link_to( content_tag(:i, nil, :class => @icon_class ) + content_tag(:span, I18n.t( @head_label )), eval(@head_link))
|
||||
buf << content_tag( :ul, :class => ("nav nav-list active") )do # visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))
|
||||
@context_links.sort_by! {| obj | obj.priority}.collect do |link|
|
||||
link.render(request,params)
|
||||
link.render(request,params,@module_app,@current_user)
|
||||
end.join.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,11 +78,11 @@ module OrbitApp
|
||||
end
|
||||
|
||||
def get_categories
|
||||
eval(@widget_set.categories_query) rescue nil
|
||||
@widget_set.get_categories
|
||||
end
|
||||
|
||||
def get_tags
|
||||
eval(@widget_set.tags_query) rescue nil
|
||||
@widget_set.get_tags
|
||||
end
|
||||
|
||||
def front_end(&block)
|
||||
|
||||
@@ -46,9 +46,9 @@ module OrbitApp
|
||||
@active_for_app_auth = []
|
||||
@head_link = ""
|
||||
@app_base_path = ''
|
||||
@module_app_key = key
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
# setup_module_app(module_app_key)
|
||||
@module_app_key = key
|
||||
finalize!
|
||||
SideBarRegisition.add(self)
|
||||
end
|
||||
@@ -76,6 +76,7 @@ module OrbitApp
|
||||
end
|
||||
|
||||
def context_link(*var)
|
||||
var[1].merge!(:module_app_key=>@module_app_key) unless @module_app_key.nil?
|
||||
new_context_link = ContextLink.new(*var)
|
||||
@context_links << new_context_link
|
||||
end
|
||||
@@ -124,10 +125,14 @@ module OrbitApp
|
||||
@active_for_action = options[:active_for_action] || []
|
||||
@active_for_object_auth = options[:active_for_object_auth] || []
|
||||
@active_for_app_auth = options[:active_for_app_auth] || []
|
||||
@module_app_key = options[:module_app_key]
|
||||
end
|
||||
|
||||
def active?
|
||||
active_for_action? || active_for_app_auth? || active_for_ob_auths?
|
||||
for_action = @active_for_action.blank? ? false : active_for_action?
|
||||
for_app_auth = @active_for_app_auth.blank? ? false : active_for_app_auth?
|
||||
for_ob_auth = @active_for_object_auth.blank? ? false : active_for_ob_auths?
|
||||
for_action || for_app_auth || for_ob_auth
|
||||
end
|
||||
|
||||
def active_for_action?
|
||||
|
||||
@@ -35,11 +35,11 @@ module OrbitApp
|
||||
end
|
||||
|
||||
def get_categories
|
||||
@categories_query
|
||||
eval(@categories_query) rescue nil
|
||||
end
|
||||
|
||||
def get_tags
|
||||
@tags_query
|
||||
eval(@tags_query) rescue nil
|
||||
end
|
||||
|
||||
def default_widget(&block)
|
||||
@@ -53,6 +53,7 @@ module OrbitApp
|
||||
def to_module_app_format
|
||||
hash = {}
|
||||
@widgets.collect{|t| hash[t.name] = t.to_hash}
|
||||
hash["default_widget"]= DefaultWidget.get_interface_args unless @default_widget.blank?
|
||||
hash
|
||||
end
|
||||
|
||||
@@ -63,12 +64,19 @@ module OrbitApp
|
||||
end
|
||||
|
||||
class DefaultWidget
|
||||
STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"]
|
||||
|
||||
def initialize(&block)
|
||||
@query = nil
|
||||
@image = nil
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
end
|
||||
|
||||
def self.get_interface_args
|
||||
#will need to work with design
|
||||
{:name=>"default_widget",:field=>nil,:label=>'label',:style=>STYLE}
|
||||
end
|
||||
|
||||
def to_module_app_format
|
||||
{:query=>@query,:image=>@image} rescue nil
|
||||
end
|
||||
@@ -90,10 +98,11 @@ module OrbitApp
|
||||
@name = name
|
||||
@fields = options[:fields]
|
||||
@label = label
|
||||
@style= options[:style]
|
||||
end
|
||||
|
||||
def to_hash
|
||||
{:name => @name,:fields=>@fields,:label=>@label}
|
||||
{:name => @name,:fields=>@fields,:label=>@label,:style=>@style}
|
||||
end
|
||||
|
||||
def finalize!
|
||||
|
||||
Reference in new issue
Block a user