Module: Hydra::BatchEditBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- BatchEditsController
- Defined in:
- app/controllers/concerns/hydra/batch_edit_behavior.rb
Instance Method Summary collapse
-
#after_destroy_collection ⇒ Object
pulled out to allow a user to override the default redirect.
-
#after_update ⇒ Object
pulled out to allow a user to override the default redirect.
- #all ⇒ Object
- #check_for_empty! ⇒ Object
- #destroy_collection ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
fetch the documents that match the ids in the folder.
- #state ⇒ Object
- #update ⇒ Object
-
#update_document(obj) ⇒ Object
called before the save of the document on update to do addition processes on the document beyond update_attributes.
Instance Method Details
#after_destroy_collection ⇒ Object
pulled out to allow a user to override the default redirect
55 56 57 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 55 def after_destroy_collection redirect_to catalog_index_path end |
#after_update ⇒ Object
pulled out to allow a user to override the default redirect
26 27 28 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 26 def after_update redirect_to catalog_index_path end |
#all ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 46 def all self.batch = CurationConcerns::Collections::SearchService.new(session, current_user.user_key).last_search_documents.map(&:id) respond_to do |format| format.html { redirect_to edit_batch_edits_path } format.js { render :json => batch } end end |
#check_for_empty! ⇒ Object
68 69 70 71 72 73 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 68 def check_for_empty! if check_for_empty_batch? redirect_to :back return false end end |
#destroy_collection ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 59 def destroy_collection batch.each do |doc_id| obj = ActiveFedora::Base.find(doc_id, :cast=>true) obj.destroy end flash[:notice] = "Batch delete complete" after_destroy_collection end |
#edit ⇒ Object
22 23 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 22 def edit end |
#index ⇒ Object
fetch the documents that match the ids in the folder
13 14 15 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 13 def index @response, @documents = get_solr_response_for_field_values("id", batch) end |
#state ⇒ Object
17 18 19 20 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 17 def state session[:batch_edit_state] = params[:state] render :json => {"OK" => "OK"} end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 36 def update batch.each do |doc_id| obj = ActiveFedora::Base.find(doc_id, :cast=>true) update_document(obj) obj.save end flash[:notice] = "Batch update complete" after_update end |
#update_document(obj) ⇒ Object
called before the save of the document on update to do addition processes on the document beyond update_attributes
31 32 33 34 |
# File 'app/controllers/concerns/hydra/batch_edit_behavior.rb', line 31 def update_document(obj) type = obj.class.to_s.underscore.to_sym obj.update_attributes(params[type].reject{|k, v| v.blank?}) end |