Class: Hyrax::Dashboard::CollectionMembersController
- Inherits:
-
My::CollectionsController
- Object
- ApplicationController
- MyController
- My::CollectionsController
- Hyrax::Dashboard::CollectionMembersController
- 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
- #after_update ⇒ Object
- #after_update_error(err_msg) ⇒ Object
-
#update_members ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods included from Collections::AcceptsBatches
#batch, #batch=, #check_for_empty_batch?
Methods inherited from My::CollectionsController
Methods inherited from MyController
Instance Method Details
#after_update ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 14 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
21 22 23 24 25 26 |
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 21 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_members ⇒ Object
rubocop:disable Metrics/MethodLength
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/hyrax/dashboard/collection_members_controller.rb', line 28 def update_members # rubocop:disable Metrics/MethodLength err_msg = validate after_update_error(err_msg) if err_msg.present? return if err_msg.present? begin Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: collection_id, new_member_ids: batch_ids, user: current_user) after_update rescue Hyrax::SingleMembershipError => err = JSON.parse(err.) if .size == batch_ids.size after_update_error(.uniq.join(', ')) elsif .present? flash[:error] = .uniq.join(', ') after_update end end end |