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



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

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



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

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



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

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



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

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



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

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

#updateObject



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

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