Class: BookmarksController

Inherits:
CatalogController
  • Object
show all
Includes:
Blacklight::Bookmarks
Defined in:
app/controllers/bookmarks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

LOCAL OVERRIDE to render update.js.erb partial when bookmark created



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/bookmarks_controller.rb', line 7

def create
  @bookmarks = if params[:bookmarks]
                 params[:bookmarks]
               else
                 [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
               end

  current_or_guest_user.save! unless current_or_guest_user.persisted?

  success = @bookmarks.all? do |bookmark|
    current_or_guest_user.bookmarks.where(bookmark).exists? || current_or_guest_user.bookmarks.create(bookmark)
  end

  if request.xhr?
    # success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
    success ? render(:update) : render(:text => "", :status => "500")
  else
    if @bookmarks.any? && success
      flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length)
    elsif @bookmarks.any?
      flash[:error] = I18n.t('blacklight.bookmarks.add.failure', :count => @bookmarks.length)
    end

    redirect_to :back
  end
end

#folder_item_actionsObject



34
35
36
# File 'app/controllers/bookmarks_controller.rb', line 34

def folder_item_actions
  redirect_to :action => "index"
end