From 98159500834167190ed5ccfb7076bc0f96ed60b6 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Wed, 13 Mar 2013 14:09:10 +0800 Subject: [PATCH] now default options can be chosen by developer at init --- .../_default_widget_style_panel.html.erb | 90 ++++++++++--------- lib/orbit_app/module/side_bar.rb | 7 +- lib/orbit_app/module/widget.rb | 8 +- vendor/built_in_modules/announcement/init.rb | 1 + 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/app/views/admin/page_parts/_default_widget_style_panel.html.erb b/app/views/admin/page_parts/_default_widget_style_panel.html.erb index bc6fc89c..f4eb8ed2 100644 --- a/app/views/admin/page_parts/_default_widget_style_panel.html.erb +++ b/app/views/admin/page_parts/_default_widget_style_panel.html.erb @@ -12,47 +12,57 @@
\ No newline at end of file diff --git a/lib/orbit_app/module/side_bar.rb b/lib/orbit_app/module/side_bar.rb index cdd98f96..79019bf0 100644 --- a/lib/orbit_app/module/side_bar.rb +++ b/lib/orbit_app/module/side_bar.rb @@ -40,12 +40,7 @@ module OrbitApp # include ApplicationHelper # include AdminHelper include SideBarRenderer - # def is_admin? - # binding.pry - # end - # def is_manager? - # binding.pry - # end + def initialize(name = '',key,get_module_app,&block) @head_label = name @context_links = [] diff --git a/lib/orbit_app/module/widget.rb b/lib/orbit_app/module/widget.rb index 16e531ae..c932a7f7 100644 --- a/lib/orbit_app/module/widget.rb +++ b/lib/orbit_app/module/widget.rb @@ -101,9 +101,13 @@ module OrbitApp @image = nil @more_link = {} @fields = [] + @enabled_styles = STYLE block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? end + def enable(args) + @enabled_styles = args + end def link_to_more(*args) @more_link[:label_i18n] = (args[1] ? args[1][:title_i18n] : 'default_widget.default_link_to_more' ) @@ -112,11 +116,11 @@ module OrbitApp def self.get_interface_args #will need to work with design - {:name=>"default_widget",:field=>@fields,:style=>STYLE,:i18n=>'default_widget.default_widget'} + {:name=>"default_widget",:field=>@fields,:style=>@enabled_styles,:i18n=>'default_widget.default_widget'} end def to_module_app_format - {"query"=>@query,"image"=>@image,"more_link"=>@more_link} rescue nil + {"query"=>@query,"image"=>@image,"more_link"=>@more_link,"enabled_styles"=>@enabled_styles} rescue nil end def link_field(field_name,setting) diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index 8032bd33..2c4375c8 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -24,6 +24,7 @@ module Announcement widgets do default_widget do query 'Bulletin.any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' + enable ["typeA","typeC"] image :image field :postdate link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}