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!
|
||||
|
||||
+33
-3
@@ -81,7 +81,7 @@ module OrbitCoreLib
|
||||
end
|
||||
|
||||
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
|
||||
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id)
|
||||
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role_ids}).excludes(blocked_user_ids: user.id)
|
||||
result = (query1 + query2).uniq
|
||||
result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
|
||||
end
|
||||
@@ -128,7 +128,7 @@ module OrbitCoreLib
|
||||
end
|
||||
|
||||
end
|
||||
module ObjectTokenUnility
|
||||
module ObjectTokenUtility
|
||||
def self.included(base)
|
||||
base.instance_eval("field :s_token")
|
||||
base.instance_eval("after_create :generate_token")
|
||||
@@ -145,7 +145,7 @@ module OrbitCoreLib
|
||||
end
|
||||
end
|
||||
|
||||
module PermissionUnility
|
||||
module PermissionUtility
|
||||
private
|
||||
def check_permission(type = :use)
|
||||
permission_grant = current_or_guest_user.admin?? true : false
|
||||
@@ -168,4 +168,34 @@ module OrbitCoreLib
|
||||
ModuleApp.first(conditions: {s_token: token})
|
||||
end
|
||||
end
|
||||
|
||||
module AppBackendUtility
|
||||
def setup_vars
|
||||
@app_title ||= controller_path.split('/')[1].singularize
|
||||
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def force_order_for_visitor
|
||||
setup_vars
|
||||
set_current_user
|
||||
end
|
||||
|
||||
|
||||
def force_order_for_user
|
||||
setup_vars
|
||||
set_current_user
|
||||
authenticate_user!
|
||||
check_user_can_use
|
||||
end
|
||||
|
||||
def check_user_can_use
|
||||
unless check_permission
|
||||
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -206,8 +206,14 @@ module ParserCommon
|
||||
when 'text'
|
||||
ret << part.content rescue ''
|
||||
when 'module_widget'
|
||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
||||
url = case part.widget_path
|
||||
when 'default_widget'
|
||||
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
|
||||
else
|
||||
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
end
|
||||
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}"
|
||||
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
|
||||
Reference in new issue
Block a user