From 899e050f7eb8cc767df5f173b0b89b821a34004c Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Mon, 28 Oct 2013 15:36:13 -0300 Subject: [PATCH] Add product_tabs hotspot --- app/helpers/application_helper.rb | 2 ++ app/helpers/plugins_helper.rb | 9 +++++++++ app/views/manage_products/show.html.erb | 15 +++++++++++++++ lib/noosfero/plugin.rb | 13 +++++++++++-- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/helpers/plugins_helper.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8dde451..d0c033b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,6 +46,8 @@ module ApplicationHelper include CatalogHelper + include PluginsHelper + def locale (@page && !@page.language.blank?) ? @page.language : FastGettext.locale end diff --git a/app/helpers/plugins_helper.rb b/app/helpers/plugins_helper.rb new file mode 100644 index 0000000..503c791 --- /dev/null +++ b/app/helpers/plugins_helper.rb @@ -0,0 +1,9 @@ +module PluginsHelper + + def plugins_product_tabs + @plugins.dispatch(:product_tabs, @product).map do |tab| + {:title => tab[:title], :id => tab[:id], :content => instance_eval(&tab[:content])} + end + end + +end diff --git a/app/views/manage_products/show.html.erb b/app/views/manage_products/show.html.erb index b6d78b9..f4eefcd 100644 --- a/app/views/manage_products/show.html.erb +++ b/app/views/manage_products/show.html.erb @@ -24,6 +24,8 @@
<% unless !@allowed_user && (@product.description.blank? && @product.inputs.empty? && !@product.price_described? ) %> + <% plugins_tabs = plugins_product_tabs %> +
+
<%= render :partial => 'manage_products/display_description' %>
+
<%= render :partial => 'manage_products/display_inputs' %>
+ <% if @product.price_described? || @allowed_user %>
<%= render :partial => 'manage_products/display_price_details' %> <%= render :partial => 'manage_products/price_details_button' %>
<% end %> + + <% plugins_tabs.each do |tab| %> +
<%= raw tab[:content] %>
+ <% end %> +
<% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 436bf34..1eb4444 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -256,7 +256,16 @@ class Noosfero::Plugin nil end - # -> Adds content to catalog item + # -> Adds tabs to the products + # returns = { :title => title, :id => id, :content => content } + # title = name that will be displayed. + # id = div id. + # content = lambda block that creates html code. + def product_tabs product + nil + end + + # -> Adds content to calalog item # returns = lambda block that creates html code def catalog_item_extras(item) nil @@ -422,7 +431,7 @@ class Noosfero::Plugin def upload_files_extra_fields(article) nil end - + # -> Adds fields to the signup form # returns = proc that creates html code def signup_extra_contents -- libgit2 0.21.2