From 4e706fab0c3e11007924cad6066a6bfb10c8daec Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Thu, 7 Nov 2013 10:59:00 +0800 Subject: [PATCH] Fixed gallery and video widgets --- .../admin/page_parts/_custom_widget.html.erb | 21 +++++++++++++++++++ .../page_parts/_widget_ext_options.html.erb | 18 ++++++++++++++++ vendor/built_in_modules/gallery/init.rb | 2 +- vendor/built_in_modules/video/init.rb | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/page_parts/_widget_ext_options.html.erb diff --git a/app/views/admin/page_parts/_custom_widget.html.erb b/app/views/admin/page_parts/_custom_widget.html.erb index d1c94bd8b..1e898e392 100644 --- a/app/views/admin/page_parts/_custom_widget.html.erb +++ b/app/views/admin/page_parts/_custom_widget.html.erb @@ -3,4 +3,25 @@
<%= select 'page_part', 'widget_style', @frontend_styles, {:selected => (@part && @part[:widget_style])}, class: "input-xlarge" %>
+ + +
+<% @module_app.widget_options.tap { |widget|%> + <% widget.each { |w|%> + <% w.get_options.each do |key, settings| %> + <% options = settings[:opts] %> + <%= label_tag(t(settings[:label_i18n], :class=>"control-label muted"))%> + <% case options%> + <% when Hash%> +
+ <%= select_tag "page_part[widget_options][#{key}]", options_from_collection_for_select(eval(options["query"]), options["value"], options["label"].to_s, :selected => (@part.widget_options[key] rescue nil)), class: "input-xlarge" %> +
+ <% else%> +
+ <%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)), class: "input-xlarge" %> + <% end %> +
+ <% end %> + <% } %> +<% } %>
\ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_ext_options.html.erb b/app/views/admin/page_parts/_widget_ext_options.html.erb new file mode 100644 index 000000000..5e421dc6a --- /dev/null +++ b/app/views/admin/page_parts/_widget_ext_options.html.erb @@ -0,0 +1,18 @@ +<% if (not(@selected[:module_app].widget_options(@selected[:app_frontend_url]).blank?) and @selected[:app_frontend_url]!='default_widget')%> + + + <% @selected[:module_app].widget_options(@selected[:app_frontend_url]).get_options.each do |key,settings| %> + <% options = settings[:opts] %> + <%= label_tag(t(settings[:label_i18n]))%> + <% case options%> + <% when Hash%> + <%= select_tag "page_part[widget_options][#{key}]", options_from_collection_for_select(eval(options["query"]), options["value"], options["label"].to_s, :selected => (@part.widget_options[key] rescue nil)) %> + <% else%> + <%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)) %> + + <% end %> + + + <% end %> + +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/init.rb b/vendor/built_in_modules/gallery/init.rb index 32398a688..15627aa7a 100644 --- a/vendor/built_in_modules/gallery/init.rb +++ b/vendor/built_in_modules/gallery/init.rb @@ -34,7 +34,7 @@ module Gallery customize_widget "widget1" do widget_i18n "gallery.widget.widget1" - style [] + style ["1","2"] options "vertical",:i18n => "gallery.widget_option.vertical",:options_item=>[1, 2] options "horizontal",:i18n => "gallery.widget_option.horizontal",:options_item=>[1, 2,3,4,5,6] options "album_id",:i18n =>"gallery.album",:options_item => {"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name} diff --git a/vendor/built_in_modules/video/init.rb b/vendor/built_in_modules/video/init.rb index eb13bde10..6e0b49365 100644 --- a/vendor/built_in_modules/video/init.rb +++ b/vendor/built_in_modules/video/init.rb @@ -50,6 +50,7 @@ module Videos #* customize_widget_options_fields_i18n({"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal", "album_id"=>"gallery.album"}} ) customize_widget "channel_videos" do widget_i18n "videos.widget.channel_videos" + style ["1","2"] options "channel_videos",:i18n =>"videos.channel_videos",:options_item => {"query"=>"ChannelVideo.all", "value"=>:id, "label"=>:channel_name} end