Class: Hyrax::Admin::CollectionTypesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/hyrax/admin/collection_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 26

def create
  @collection_type = Hyrax::CollectionType.new(collection_type_params)
  if @collection_type.save
    Hyrax::CollectionTypes::CreateService.add_default_participants(@collection_type.id)
    redirect_to hyrax.edit_admin_collection_type_path(@collection_type), notice: t(:'hyrax.admin.collection_types.create.notification', name: @collection_type.title)
  else
    report_error_msg
    setup_form
    add_common_breadcrumbs
    add_breadcrumb t(:'hyrax.admin.collection_types.new.header'), hyrax.new_admin_collection_type_path
    render :new
  end
end

#destroyObject


58
59
60
61
62
63
64
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 58

def destroy
  if @collection_type.destroy
    redirect_to hyrax.admin_collection_types_path, notice: t(:'hyrax.admin.collection_types.delete.notification', name: @collection_type.title)
  else
    redirect_to hyrax.admin_collection_types_path, alert: @collection_type.errors.full_messages.to_sentence
  end
end

#editObject


40
41
42
43
44
45
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 40

def edit
  setup_form
  setup_participants_form
  add_common_breadcrumbs
  add_breadcrumb t(:'hyrax.admin.collection_types.edit.header'), hyrax.edit_admin_collection_type_path
end

#indexObject


13
14
15
16
17
18
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 13

def index
  # TODO: How do we know if a collection_type has existing collections?
  # Will that be a property on @collection_types here?
  @collection_types = Hyrax::CollectionType.all
  add_common_breadcrumbs
end

#newObject


20
21
22
23
24
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 20

def new
  setup_form
  add_common_breadcrumbs
  add_breadcrumb t(:'hyrax.admin.collection_types.new.header'), hyrax.new_admin_collection_type_path
end

#updateObject


47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/hyrax/admin/collection_types_controller.rb', line 47

def update
  if @collection_type.update(collection_type_params)
    redirect_to update_referer, notice: t(:'hyrax.admin.collection_types.update.notification', name: @collection_type.title)
  else
    setup_form
    add_common_breadcrumbs
    add_breadcrumb t(:'hyrax.admin.collection_types.edit.header'), hyrax.edit_admin_collection_type_path
    render :edit
  end
end