app/controllers/bookmarks_controller.rb in blacklight-5.6.0 vs app/controllers/bookmarks_controller.rb in blacklight-5.7.0

- old
+ new

@@ -62,15 +62,15 @@ end current_or_guest_user.save! unless current_or_guest_user.persisted? success = @bookmarks.all? do |bookmark| - current_or_guest_user.bookmarks.create(bookmark) unless current_or_guest_user.bookmarks.where(bookmark).exists? + current_or_guest_user.bookmarks.where(bookmark).exists? || current_or_guest_user.bookmarks.create(bookmark) end if request.xhr? - success ? head(:no_content) : render(:text => "", :status => "500") + success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500") else if @bookmarks.length > 0 && success flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length) elsif @bookmarks.length > 0 flash[:error] = I18n.t('blacklight.bookmarks.add.failure', :count => @bookmarks.length) @@ -94,13 +94,13 @@ flash[:error] = I18n.t('blacklight.bookmarks.remove.failure') end redirect_to :back else # ajaxy request needs no redirect and should not have flash set - success ? head(:no_content) : render(:text => "", :status => "500") + success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500") end end - + def clear if current_or_guest_user.bookmarks.clear flash[:notice] = I18n.t('blacklight.bookmarks.clear.success') else flash[:error] = I18n.t('blacklight.bookmarks.clear.failure')