Commit ea8c0e4103ea710b2ee5443eb09b30a3ac64ce65
1 parent
26f8889c
Exists in
master
and in
11 other branches
proposals_discussion: fix infinite loading bug
Showing
4 changed files
with
14 additions
and
13 deletions
Show diff stats
controllers/public/proposals_discussion_plugin_public_controller.rb
@@ -11,11 +11,7 @@ class ProposalsDiscussionPluginPublicController < ApplicationController | @@ -11,11 +11,7 @@ class ProposalsDiscussionPluginPublicController < ApplicationController | ||
11 | @proposals = order_proposals(@holder.proposals.public, order) | 11 | @proposals = order_proposals(@holder.proposals.public, order) |
12 | @proposals = @proposals.page(page).per_page(4) | 12 | @proposals = @proposals.page(page).per_page(4) |
13 | 13 | ||
14 | - unless @proposals.empty? | ||
15 | - render :partial => 'content_viewer/proposals_list_content', :locals => {:proposals => @proposals, :holder => @holder, :page => page+1, :order => order} | ||
16 | - else | ||
17 | - render :text => '' | ||
18 | - end | 14 | + render :partial => 'content_viewer/proposals_list_content', :locals => {:proposals => @proposals, :holder => @holder, :page => page+1, :order => order} |
19 | end | 15 | end |
20 | 16 | ||
21 | private | 17 | private |
public/proposals_list.js
@@ -10,11 +10,16 @@ jQuery(document).ready(function($) { | @@ -10,11 +10,16 @@ jQuery(document).ready(function($) { | ||
10 | }); | 10 | }); |
11 | 11 | ||
12 | function proposalsScroll() { | 12 | function proposalsScroll() { |
13 | - $('.article-body-proposals-discussion-plugin_topic .topic-content').data('jscroll', null); | ||
14 | - $('.article-body-proposals-discussion-plugin_topic .topic-content').jscroll({ | ||
15 | - loadingHtml: '<img src="/images/loading.gif" alt="Loading" />Loading...', | ||
16 | - nextSelector: 'div.more a' | ||
17 | - }); | 13 | + var scroll = $('.article-body-proposals-discussion-plugin_topic .topic-content .proposals_list'); |
14 | + var nextSelector = 'div.more a'; | ||
15 | + if(scroll.data('jscroll')) scroll.jscroll.destroy(); | ||
16 | + | ||
17 | + if(scroll.find(nextSelector).length > 0) { | ||
18 | + scroll.jscroll({ | ||
19 | + loadingHtml: '<img src="/images/loading.gif" alt="Loading" />Loading...', | ||
20 | + nextSelector: nextSelector | ||
21 | + }); | ||
22 | + } | ||
18 | } | 23 | } |
19 | $('.filters .random').click(); | 24 | $('.filters .random').click(); |
20 | 25 |
test/functional/proposals_discussion_plugin_public_controller_test.rb
@@ -22,9 +22,9 @@ class ProposalsDiscussionPluginPublicControllerTest < ActionController::TestCase | @@ -22,9 +22,9 @@ class ProposalsDiscussionPluginPublicControllerTest < ActionController::TestCase | ||
22 | assert_match /href=.*page=2/, response.body | 22 | assert_match /href=.*page=2/, response.body |
23 | end | 23 | end |
24 | 24 | ||
25 | - should 'render blank text if it is the last page' do | 25 | + should 'not render more link if it was the last page' do |
26 | get :load_proposals, :profile => profile.identifier, :holder_id => topic.id | 26 | get :load_proposals, :profile => profile.identifier, :holder_id => topic.id |
27 | - assert_equal '', response.body | 27 | + assert_select 'div.more a', 0 |
28 | end | 28 | end |
29 | 29 | ||
30 | should 'load proposals with alphabetical order' do | 30 | should 'load proposals with alphabetical order' do |
views/content_viewer/_proposals_list_content.html.erb
@@ -3,5 +3,5 @@ | @@ -3,5 +3,5 @@ | ||
3 | <% extend ProposalsDiscussionPlugin::ProposalsListHelper %> | 3 | <% extend ProposalsDiscussionPlugin::ProposalsListHelper %> |
4 | 4 | ||
5 | <div class="more"> | 5 | <div class="more"> |
6 | - <%= more_proposals(_('More'), holder, order, page) %> | 6 | + <%= more_proposals(_('More'), holder, order, page) unless proposals.empty? %> |
7 | </div> | 7 | </div> |