default widgets and sidebar.

This commit is contained in:
Matthew K. Fu JuYuan committed 2012-12-24 16:38:35 +08:00
1 parent 6995bb1622
commit 5f712622ad
28 files changed
+344 -162

No files matched your search

+2 -2
View File
@@ -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)
+7 -2
View File
@@ -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?
+12 -3
View File
@@ -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!