Sha256: 9a86bd7cb5912a55bbc11b4020bdf22415507bc5176039e7d0dc447241668d35
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
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]) unless request.xhr? respond_to do |format| format.html do flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items" redirect_to :back end end else render :text => "OK" 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blacklight-3.0.0pre6 | app/controllers/folder_controller.rb |