Fix approval in index

This commit is contained in:
chris committed 2013-07-10 16:42:25 +08:00
1 parent 2c331bf1a5
commit 1c4b66f1cb
9 files changed
+76 -66

No files matched your search

+38 -7
View File
@@ -28,7 +28,7 @@ module OrbitApp
end
class DataSheet
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_tag
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :authorizable_models, :is_approvable, :is_authorizable
def initialize(name, &block)
@name = name
@@ -39,6 +39,8 @@ module OrbitApp
@data_count = 1..15 # as default
@has_category = nil
@has_tag = nil
@authorizable_models = []
@is_approvable = nil
@is_authorizable = nil
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
setup_module_app
@@ -123,7 +125,7 @@ module OrbitApp
end
def side_bar(&block) #setter for side_bar from init
@side_bar = SideBarRegisition::SideBar.new(@name,@key,method(:get_module_app),&block)
@side_bar = SideBarRegisition::SideBar.new(@name,@key,method(:get_module_app), is_approvable_with_link?, is_authorizable_with_link?, &block)
end
def personal_plugin(params) #setter for personal_plugin from init
@@ -143,8 +145,21 @@ module OrbitApp
define_method(field){|var| instance_variable_set( "@" + field, var)}
end
def authorizable
@is_authorizable = true
def approvable(link=true)
@is_approvable = {:with_link => link}
end
def authorizable(link=true, &block)
@is_authorizable = {:with_link => link}
if block
block.call
else
authorizable_on
end
end
def authorizable_on(klass = 'Category')
@authorizable_models << klass
end
def categorizable
@@ -155,16 +170,32 @@ module OrbitApp
@has_tag = true
end
def get_authorizable_models
@authorizable_models
end
def get_has_category
@has_category.nil? ? false : true
@has_category == true
end
def get_has_tags
@has_tag.nil? ? false : true
@has_tag == true
end
def get_is_approvable
!@is_approvable.blank?
end
def get_is_authorizable
@is_authorizable.nil? ? false : true
!@is_authorizable.blank?
end
def is_approvable_with_link?
@is_approvable && @is_approvable[:with_link]
end
def is_authorizable_with_link?
@is_authorizable && @is_authorizable[:with_link]
end
end # of class DataSheet
+16 -1
View File
@@ -41,7 +41,7 @@ module OrbitApp
# include AdminHelper
include SideBarRenderer
def initialize(name = '',key,get_module_app,&block)
def initialize(name = '',key,get_module_app, approvable_with_link, authorizable_with_link, &block)
@head_label = name
@context_links = []
@available_for = []
@@ -54,6 +54,8 @@ module OrbitApp
@module_app_key = key
@get_module_app = get_module_app
@sidebar_order = 0
@approvable_with_link = approvable_with_link
@authorizable_with_link = authorizable_with_link
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
# setup_module_app(module_app_key)
finalize!
@@ -107,6 +109,19 @@ module OrbitApp
def finalize!
set_controllers_scope
# set_default_active_app_auth
current_priority = @context_links.count
if @approvable_with_link
context_link 'approval_setting',
:link_path => "admin_authorizations_path(get_module_app.key, 'approval')",
:priority => current_priority + 1,
:available_for => [:manager]
end
if @authorizable_with_link
context_link 'module_authorization',
:link_path => "admin_authorizations_path(get_module_app.key)",
:priority => current_priority + 2,
:available_for => [:manager]
end
@context_links.each do |t|
# t.set_module_app = @module_app
t.finalize!