noosfero | 2 new commits pushed to repository

Bráulio Bhavamitra gitlab at gitlab.com
Tue Feb 10 17:04:10 BRST 2015


Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/899e050f7eb8cc767df5f173b0b89b821a34004c">899e050f</a> by Braulio Bhavamitra
Add product_tabs hotspot

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/4bee61eea82e2060b01e8b18f26938f987cc66d5">4bee61ee</a> by Bráulio Bhavamitra
Merge branch 'product-tabs-for-plugins' into 'master'

Product's tabs for plugins

Reopened from !21

See merge request !442

- - - - -


Changes:

=====================================
app/helpers/application_helper.rb
=====================================
--- 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

=====================================
app/helpers/plugins_helper.rb
=====================================
--- /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

=====================================
app/views/manage_products/show.html.erb
=====================================
--- a/app/views/manage_products/show.html.erb
+++ b/app/views/manage_products/show.html.erb
@@ -24,6 +24,8 @@
   <br style='clear: both'/>
 
   <% unless !@allowed_user && (@product.description.blank? && @product.inputs.empty? && !@product.price_described? ) %>
+    <% plugins_tabs = plugins_product_tabs %>
+
     <div class='ui-tabs' id='product-<%= @product.id %>-tabs'>
       <ul>
         <% if !@product.description.blank? || @allowed_user %>
@@ -35,19 +37,32 @@
         <% if @product.price_described? || @allowed_user %>
           <li class='tab'><a href='#product-price-details'><%= _('Price composition') %></a></li>
         <% end %>
+
+        <% plugins_tabs.each do |tab| %>
+          <li class='tab'><a href='#<%=tab[:id]%>'><%= tab[:title] %></a></li>
+        <% end %>
+
       </ul>
+
       <div id='product-description'>
         <%= render :partial => 'manage_products/display_description' %>
       </div>
+
       <div id='product-inputs'>
         <%= render :partial => 'manage_products/display_inputs' %>
       </div>
+
       <% if @product.price_described? || @allowed_user %>
         <div id='product-price-details'>
           <%= render :partial => 'manage_products/display_price_details' %>
           <%= render :partial => 'manage_products/price_details_button' %>
         </div>
       <% end %>
+
+      <% plugins_tabs.each do |tab| %>
+        <div id='<%=tab[:id]%>'><%= raw tab[:content] %></div>
+      <% end %>
+
     </div>
   <% end %>
 

=====================================
lib/noosfero/plugin.rb
=====================================
--- 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150210/6608f927/attachment.html>


More information about the Noosfero-dev mailing list