Merge pull request #97 from Retrospring/fix-layout-for-js-views

Fix pagination for ajax views
This commit is contained in:
Georg Gadinger 2020-05-09 04:44:49 +02:00 committed by GitHub
commit 7a7174c163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 16 deletions

View File

@ -9,7 +9,7 @@ class GroupController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end
end

View File

@ -49,7 +49,7 @@ class InboxController < ApplicationController
@disabled = true if @inbox.empty?
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end
end

View File

@ -9,7 +9,7 @@ class NotificationsController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end

View File

@ -8,7 +8,7 @@ class PublicController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end
end

View File

@ -7,7 +7,7 @@ class QuestionController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end
end

View File

@ -9,7 +9,7 @@ class StaticController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
else
return render 'static/front'

View File

@ -19,7 +19,7 @@ class UserController < ApplicationController
respond_to do |format|
format.html
format.js
format.js { render layout: false }
end
end
@ -78,7 +78,11 @@ class UserController < ApplicationController
@users_last_id = @users.map(&:id).min
@more_data_available = !@user.cursored_followers(last_id: @users_last_id, size: 1).count.zero?
@type = :friend
render 'show_follow'
respond_to do |format|
format.html { render "show_follow" }
format.js { render "show_follow", layout: false }
end
end
def friends
@ -88,7 +92,11 @@ class UserController < ApplicationController
@users_last_id = @users.map(&:id).min
@more_data_available = !@user.cursored_friends(last_id: @users_last_id, size: 1).count.zero?
@type = :friend
render 'show_follow'
respond_to do |format|
format.html { render "show_follow" }
format.js { render "show_follow", layout: false }
end
end
def questions
@ -97,6 +105,11 @@ class UserController < ApplicationController
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
@questions_last_id = @questions.map(&:id).min
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
end
def data

View File

@ -7,4 +7,4 @@ module LayoutsHelper
@haml_buffer.buffer.replace output
self.output_buffer = ActionView::OutputBuffer.new(output)
end
end
end

View File

@ -15,8 +15,9 @@
.media
= render "notifications/type/#{notification.target_type.downcase}", notification: notification
= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type]
- unless @notifications.count.zero?
= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type]
- if @more_data_available
%button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }}
Load more
- if @more_data_available
%button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }}
Load more

View File

@ -1,6 +1,6 @@
$('#notifications').append('<% @notifications.each do |notification|
%><%= j render 'notifications/notification', notification: notification
%><% end %>');
%><li class="list-group-item"><div class="media"><%= j render "notifications/type/#{notification.target_type.downcase}", notification: notification
%></div></li><% end %>');
<% if @more_data_available %>
$('#pagination').html('<%= j render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type] %>');
<% else %>