Class: Hyrax::Dashboard::CollectionMembersController

Inherits:
My::CollectionsController show all
Includes:
Collections::AcceptsBatches
Defined in:
app/controllers/hyrax/dashboard/collection_members_controller.rb

Overview

Shows a list of all collections to the admins

Instance Method Summary collapse

Methods included from Collections::AcceptsBatches

#batch, #batch=, #check_for_empty_batch?

Methods inherited from My::CollectionsController

configure_facets, #index, #search_builder_class

Methods inherited from MyController

configure_facets, #index

Instance Method Details

#after_updateObject


9
10
11
12
13
14
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 9

def after_update
  respond_to do |format|
    format.html { redirect_to success_return_path, notice: t('hyrax.dashboard.my.action.collection_update_success') }
    format.json { render json: @collection, status: :updated, location: dashboard_collection_path(@collection) }
  end
end

#after_update_error(err_msg) ⇒ Object


16
17
18
19
20
21
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 16

def after_update_error(err_msg)
  respond_to do |format|
    format.html { redirect_to err_return_path, alert: err_msg }
    format.json { render json: @collection.errors, status: :unprocessable_entity }
  end
end

#update_membersObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 23

def update_members
  err_msg = validate
  after_update_error(err_msg) if err_msg.present?
  return if err_msg.present?

  collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
  members = collection.add_member_objects batch_ids
  messages = members.collect { |member| member.errors.full_messages }.flatten
  if messages.size == members.size
    after_update_error(messages.uniq.join(', '))
  elsif messages.present?
    flash[:error] = messages.uniq.join(', ')
    after_update
  else
    after_update
  end
end