Commit ac2fca893c1557ba0407b35a48afea52f4b2e746

Authored by Victor Costa
1 parent 2b5e621c

rails3: fix display_content plugin

plugins/display_content/lib/display_content_block.rb
@@ -26,6 +26,8 @@ class DisplayContentBlock < Block @@ -26,6 +26,8 @@ class DisplayContentBlock < Block
26 {:name => _('Tags'), :checked => false}] 26 {:name => _('Tags'), :checked => false}]
27 settings_items :display_folder_children, :type => :boolean, :default => true 27 settings_items :display_folder_children, :type => :boolean, :default => true
28 28
  29 + attr_accessible :sections, :checked_nodes, :display_folder_children
  30 +
29 def self.description 31 def self.description
30 _('Display your contents') 32 _('Display your contents')
31 end 33 end
@@ -66,7 +68,8 @@ class DisplayContentBlock < Block @@ -66,7 +68,8 @@ class DisplayContentBlock < Block
66 holder.articles.find(:all, :conditions => {:type => VALID_CONTENT, :parent_id => (parent.nil? ? nil : parent)}) 68 holder.articles.find(:all, :conditions => {:type => VALID_CONTENT, :parent_id => (parent.nil? ? nil : parent)})
67 end 69 end
68 70
69 - include ActionController::UrlWriter 71 + include ActionView::Helpers
  72 + include Rails.application.routes.url_helpers
70 def content(args={}) 73 def content(args={})
71 extra_condition = display_folder_children ? 'OR articles.parent_id IN(:nodes)':'' 74 extra_condition = display_folder_children ? 'OR articles.parent_id IN(:nodes)':''
72 docs = nodes.blank? ? [] : owner.articles.find(:all, :conditions => ["(articles.id IN(:nodes) #{extra_condition}) AND articles.type IN(:types)", {:nodes => self.nodes, :types => VALID_CONTENT}]) 75 docs = nodes.blank? ? [] : owner.articles.find(:all, :conditions => ["(articles.id IN(:nodes) #{extra_condition}) AND articles.type IN(:types)", {:nodes => self.nodes, :types => VALID_CONTENT}])
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -20,8 +20,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase @@ -20,8 +20,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
20 @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity') 20 @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity')
21 @environment.save! 21 @environment.save!
22 22
23 - box = Box.new(:owner => @environment, :position => 1)  
24 - box.save 23 + box = create(Box, :owner => @environment, :position => 1)
25 24
26 DisplayContentBlock.delete_all 25 DisplayContentBlock.delete_all
27 @block = DisplayContentBlock.new 26 @block = DisplayContentBlock.new
plugins/display_content/views/box_organizer/_display_content_block.html.erb 0 → 100644
@@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
  1 +<div id="display_content_plugin">
  2 +
  3 +<h3> <%= _('Choose which attributes should be displayed and drag to reorder them:') %> </h3>
  4 +
  5 +<table class="sections">
  6 + <tbody id="sortable">
  7 + <% for section in @block.sections do %>
  8 + <tr>
  9 + <td><%= hidden_field_tag 'block[sections][][name]', section[:name] %> <%= check_box_tag 'block[sections][][checked]', section[:name], section[:checked] %></td>
  10 + <td><%= section[:name]%></td>
  11 + </tr>
  12 + <% end %>
  13 + </tbody>
  14 +</table>
  15 +
  16 +<h3> <%= _('Choose which content should be displayed:') %> </h3>
  17 +<div id="display_content">
  18 +</div>
  19 +
  20 +<div class="display_folder_children">
  21 + <%= labelled_form_field check_box(:block, :display_folder_children) + _('Dinamically load children of selected folders'), '' %>
  22 +</div>
  23 +
  24 +<script type="text/javascript" >
  25 +
  26 +jQuery_1_8_3("#display_content").jstree({
  27 + plugins : ["themes","json_data", "checkbox"],
  28 + checkbox : {
  29 + real_checkboxes : true,
  30 + real_checkboxes_names : function (n) { return [("block[checked_nodes[" + n.attr('node_id') + "]]"), 1]; }
  31 + },
  32 + themes : {"theme" : "classic", "icons" : true, "url": "/plugins/display_content/javascripts/jstree/themes/classic/style.css"},
  33 + json_data : {
  34 + ajax : {
  35 + url : '<%= url_for @block.url_params %>',
  36 + async: true,
  37 + data : function (m) {
  38 + return m.attr ? {"id" : m.attr("node_id")} : {};
  39 + }
  40 + }
  41 + }
  42 +});
  43 +
  44 +jQuery( "#sortable" ).sortable();
  45 +
  46 +</script>
  47 +</div>
plugins/display_content/views/box_organizer/_display_content_block.rhtml
@@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
1 -<div id="display_content_plugin">  
2 -  
3 -<h3> <%= _('Choose which attributes should be displayed and drag to reorder them:') %> </h3>  
4 -  
5 -<table class="sections">  
6 - <tbody id="sortable">  
7 - <% for section in @block.sections do %>  
8 - <tr>  
9 - <td><%= hidden_field_tag 'block[sections][][name]', section[:name] %> <%= check_box_tag 'block[sections][][checked]', section[:name], section[:checked] %></td>  
10 - <td><%= section[:name]%></td>  
11 - </tr>  
12 - <% end %>  
13 - </tbody>  
14 -</table>  
15 -  
16 -<h3> <%= _('Choose which content should be displayed:') %> </h3>  
17 -<div id="display_content">  
18 -</div>  
19 -  
20 -<div class="display_folder_children">  
21 - <%= labelled_form_field check_box(:block, :display_folder_children) + _('Dinamically load children of selected folders'), '' %>  
22 -</div>  
23 -  
24 -<script type="text/javascript" >  
25 -  
26 -jQuery_1_8_3("#display_content").jstree({  
27 - plugins : ["themes","json_data", "checkbox"],  
28 - checkbox : {  
29 - real_checkboxes : true,  
30 - real_checkboxes_names : function (n) { return [("block[checked_nodes[" + n.attr('node_id') + "]]"), 1]; }  
31 - },  
32 - themes : {"theme" : "classic", "icons" : true, "url": "/plugins/display_content/javascripts/jstree/themes/classic/style.css"},  
33 - json_data : {  
34 - ajax : {  
35 - url : '<%= url_for @block.url_params %>',  
36 - async: true,  
37 - data : function (m) {  
38 - return m.attr ? {"id" : m.attr("node_id")} : {};  
39 - }  
40 - }  
41 - }  
42 -});  
43 -  
44 -jQuery( "#sortable" ).sortable();  
45 -  
46 -</script>  
47 -</div>