Sha256: 3b5f63ece028ab6f47391d5f8657459fcb94f7f429fdfa5f41a3641ffeb1913c

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

# -*- encoding : utf-8 -*-
class FolderController < ApplicationController
  include Blacklight::SolrHelper
  helper CatalogHelper

  # fetch the documents that match the ids in the folder
  def index
    @response, @documents = get_solr_response_for_field_values("id",session[:folder_document_ids] || [])
  end
    

  # add a document_id to the folder. :id of action is solr doc id 
  def update
    session[:folder_document_ids] = session[:folder_document_ids] || []
    session[:folder_document_ids] << params[:id] 
    # Rails 3 uses a one line notation for setting the flash notice.
    #    flash[:notice] = "#{params[:title] || "Item"} successfully added to Folder"
    respond_to do |format|
      format.html { redirect_to :back, :notice =>  "#{params[:title] || "Item"} successfully added to Folder"}
      format.js { render :json => session[:folder_document_ids] }
    end
  end
 
  # remove a document_id from the folder. :id of action is solr_doc_id
  def destroy
    session[:folder_document_ids].delete(params[:id])
          
    respond_to do |format|
      format.html do
        flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items"
        redirect_to :back
      end
      format.js do
        render :json => {"OK" => "OK"}
      end
    end
          
  end
 
  # get rid of the items in the folder
  def clear
    flash[:notice] = "Cleared Selected Items"
    session[:folder_document_ids] = []
    respond_to do |format|
      format.html { redirect_to :back }
      format.js { render :json => session[:folder_document_ids] }
    end
  end
 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-3.1.2 app/controllers/folder_controller.rb
blacklight-3.1.1 app/controllers/folder_controller.rb
blacklight-3.1.0 app/controllers/folder_controller.rb
blacklight-3.0.0 app/controllers/folder_controller.rb
blacklight-3.0.0pre8 app/controllers/folder_controller.rb
blacklight-3.0.0pre7 app/controllers/folder_controller.rb