Class: Hyrax::Dashboard::NestCollectionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Blacklight::Base
Defined in:
app/controllers/hyrax/dashboard/nest_collections_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_collection_underObject

create and link a NEW subcollection under this collection, with this collection as parent


26
27
28
29
30
31
32
33
34
# File 'app/controllers/hyrax/dashboard/nest_collections_controller.rb', line 26

def create_collection_under
  authorize! :deposit, form_params[:parent_id]

  if form.validate_add
    redirect_to new_dashboard_collection_path(collection_type_id: parent_type_id_for(form), parent_id: form.parent)
  else
    redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
  end
end

#create_relationship_underObject

link this collection as parent by adding existing collection as subcollection under this one


37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/hyrax/dashboard/nest_collections_controller.rb', line 37

def create_relationship_under
  authorize! :read, form_params[:parent_id]

  if form.save
    notice = I18n.t('create_under', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
    redirect_to redirect_path(item: form.parent), notice: notice
  else
    redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
  end
end

#create_relationship_withinObject

Add this collection as a subcollection within another existing collection


14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/hyrax/dashboard/nest_collections_controller.rb', line 14

def create_relationship_within
  authorize! :read, form_params[:child_id]

  if form.save
    notice = I18n.t('create_within', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
    redirect_to redirect_path(item: form.child), notice: notice
  else
    redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }
  end
end

#remove_relationship_aboveObject

remove a parent collection relationship from this collection


49
50
51
52
53
54
55
56
57
# File 'app/controllers/hyrax/dashboard/nest_collections_controller.rb', line 49

def remove_relationship_above
  authorize! :edit, form_params[:parent_id]
  if form.remove
    notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
    redirect_to redirect_path(item: form.child), notice: notice
  else
    redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }
  end
end

#remove_relationship_underObject

remove a subcollection relationship from this collection


60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/hyrax/dashboard/nest_collections_controller.rb', line 60

def remove_relationship_under
  authorize! :edit, form_params[:parent_id]

  if form.remove
    notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
    redirect_to redirect_path(item: form.parent), notice: notice
  else
    redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
  end
end