Class: Hyrax::Admin::AdminSetsController

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CollectionsControllerBehavior

#collection

Class Method Details

.local_prefixesObject

Override the default prefixes so that we use the collection partals.


120
121
122
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 120

def self.local_prefixes
  ["hyrax/admin/admin_sets", "hyrax/collections", 'catalog']
end

Instance Method Details

#after_createObject


73
74
75
76
77
78
79
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 73

def after_create
  Hyrax::SolrService.commit
  redirect_to hyrax.edit_admin_admin_set_path(admin_set_id),
              notice: I18n.t('new_admin_set',
                             scope: 'hyrax.admin.admin_sets.form.permission_update_notices',
                             name: @admin_set.title.first)
end

#after_create_error(err_msg: "") ⇒ Object


81
82
83
84
85
86
87
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 81

def after_create_error(err_msg: "")
  msg = "Failed to create admin set: #{err_msg}"
  setup_form
  flash[:error] = msg
  Hyrax.logger.error(msg)
  render :new
end

#createObject


89
90
91
92
93
94
95
96
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 89

def create
  case @admin_set
  when Valkyrie::Resource
    valkyrie_create
  else
    active_fedora_create
  end
end

#deny_adminset_access(exception) ⇒ Object


27
28
29
30
31
32
33
34
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 27

def deny_adminset_access(exception)
  if current_user&.persisted?
    redirect_to root_url, alert: exception.message
  else
    session['user_return_to'] = request.url
    redirect_to main_app.new_user_session_url, alert: exception.message
  end
end

#destroyObject


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 98

def destroy
  case @admin_set
  when Valkyrie::Resource
    transactions['admin_set_resource.destroy'].call(@admin_set).value_or do |failure|
      redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: failure.first
    end
    after_delete_success
  else
    if @admin_set.destroy
      after_delete_success
    else
      redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: @admin_set.errors.full_messages.to_sentence
    end
  end
end

#editObject


53
54
55
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 53

def edit
  setup_form
end

#filesObject

Renders a JSON response with a list of files in this admin set. This is used by the edit form to populate the thumbnail_id dropdown


59
60
61
62
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 59

def files
  result = form.select_files.map { |label, id| { id: id, text: label } }
  render json: result
end

#indexObject


44
45
46
47
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 44

def index
  # admin sets are listed with collections
  redirect_to hyrax.my_collections_url
end

#newObject


49
50
51
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 49

def new
  setup_form
end

#repositoryObject

for the AdminSetService


115
116
117
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 115

def repository
  repository_class.new(blacklight_config)
end

#showObject


36
37
38
39
40
41
42
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 36

def show
  add_breadcrumb I18n.t('hyrax.controls.home'), hyrax.root_path
  add_breadcrumb t(:'hyrax.dashboard.title'), hyrax.dashboard_path
  add_breadcrumb t(:'hyrax.dashboard.my.collections'), hyrax.my_collections_path
  add_breadcrumb @admin_set.title.first
  super
end

#updateObject


64
65
66
67
68
69
70
71
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 64

def update
  case @admin_set
  when Valkyrie::Resource
    valkyrie_update
  else
    active_fedora_update
  end
end