Merge Request #5
← To merge requests
From
content-manager-hostspot
into
master_rails3
New hostspot - Add custom buttons to content manager
Added new hotspot extra_content_actions(article)
that render new buttons for each article in content manager page.
Was made to a refactor into select_profile_folder()
helper method to show children articles instead only folders.
Commits (1)
Showing
3 changed files
Show diff stats
app/views/cms/_view_items.html.erb
@@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
13 | <%= time_ago_in_words article.updated_at %> | 13 | <%= time_ago_in_words article.updated_at %> |
14 | </td> | 14 | </td> |
15 | <td class="article-controls"> | 15 | <td class="article-controls"> |
16 | + <%= @plugins.dispatch(:extra_content_actions, article).collect { |content| instance_exec(&content) }.join("") %> | ||
16 | <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit, article) %> | 17 | <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit, article) %> |
17 | <%= button_without_text :eyes, _('Public view'), article.view_url %> | 18 | <%= button_without_text :eyes, _('Public view'), article.view_url %> |
18 | <%= display_spread_button(article) unless remove_content_button(:spread, article) %> | 19 | <%= display_spread_button(article) unless remove_content_button(:spread, article) %> |
lib/noosfero/plugin.rb
@@ -213,6 +213,13 @@ class Noosfero::Plugin | @@ -213,6 +213,13 @@ class Noosfero::Plugin | ||
213 | end.select {|const| const.is_a?(Class) && const < Noosfero::Plugin::Macro} | 213 | end.select {|const| const.is_a?(Class) && const < Noosfero::Plugin::Macro} |
214 | end | 214 | end |
215 | 215 | ||
216 | + # New buttons actions with icons in each article on content manager page | ||
217 | + # returns = proc block that creates html code to custom buttons | ||
218 | + # | ||
219 | + def extra_content_actions(article) | ||
220 | + nil | ||
221 | + end | ||
222 | + | ||
216 | # Here the developer may specify the events to which the plugins can | 223 | # Here the developer may specify the events to which the plugins can |
217 | # register and must return true or false. The default value must be false. | 224 | # register and must return true or false. The default value must be false. |
218 | # Must also explicitly define its returning variables. | 225 | # Must also explicitly define its returning variables. |
test/unit/plugin_test.rb
@@ -567,4 +567,16 @@ class PluginTest < ActiveSupport::TestCase | @@ -567,4 +567,16 @@ class PluginTest < ActiveSupport::TestCase | ||
567 | assert_equal [], p.article_extra_toolbar_buttons(nil) | 567 | assert_equal [], p.article_extra_toolbar_buttons(nil) |
568 | end | 568 | end |
569 | 569 | ||
570 | + should 'get extra buttons actions on content manager grid' do | ||
571 | + class Plugin1 < Noosfero::Plugin | ||
572 | + def extra_content_actions | ||
573 | + proc do | ||
574 | + '<a href="#" class="icon">Btn</a>' | ||
575 | + end | ||
576 | + end | ||
577 | + end | ||
578 | + p = Plugin1.new | ||
579 | + assert_tag_in_string p.extra_content_actions.call(), :tag => 'a', :content => 'Btn' | ||
580 | + end | ||
581 | + | ||
570 | end | 582 | end |
-
Added 1 new commit:
- 92a63edb - Added new unit test and remove changes in forms helper
-
Status changed to closed
-
@mfdeveloper você pode enviar o merge request dessa funcionalidade para o repositorio oficial do Noosfero?
started a discussion on commit
cb4e3d39