Commit ac2fca893c1557ba0407b35a48afea52f4b2e746
1 parent
2b5e621c
Exists in
master
and in
29 other branches
rails3: fix display_content plugin
Showing
4 changed files
with
52 additions
and
50 deletions
Show diff stats
plugins/display_content/lib/display_content_block.rb
| ... | ... | @@ -26,6 +26,8 @@ class DisplayContentBlock < Block |
| 26 | 26 | {:name => _('Tags'), :checked => false}] |
| 27 | 27 | settings_items :display_folder_children, :type => :boolean, :default => true |
| 28 | 28 | |
| 29 | + attr_accessible :sections, :checked_nodes, :display_folder_children | |
| 30 | + | |
| 29 | 31 | def self.description |
| 30 | 32 | _('Display your contents') |
| 31 | 33 | end |
| ... | ... | @@ -66,7 +68,8 @@ class DisplayContentBlock < Block |
| 66 | 68 | holder.articles.find(:all, :conditions => {:type => VALID_CONTENT, :parent_id => (parent.nil? ? nil : parent)}) |
| 67 | 69 | end |
| 68 | 70 | |
| 69 | - include ActionController::UrlWriter | |
| 71 | + include ActionView::Helpers | |
| 72 | + include Rails.application.routes.url_helpers | |
| 70 | 73 | def content(args={}) |
| 71 | 74 | extra_condition = display_folder_children ? 'OR articles.parent_id IN(:nodes)':'' |
| 72 | 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 | 20 | @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity') |
| 21 | 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 | 25 | DisplayContentBlock.delete_all |
| 27 | 26 | @block = DisplayContentBlock.new | ... | ... |
plugins/display_content/views/box_organizer/_display_content_block.html.erb
0 → 100644
| ... | ... | @@ -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 | -<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> |