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.



98
99
100
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 98

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

Instance Method Details

#createObject



75
76
77
78
79
80
81
82
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 75

def create
  if create_admin_set
    redirect_to hyrax.edit_admin_admin_set_path(@admin_set), notice: I18n.t('new_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
  else
    setup_form
    render :new
  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



84
85
86
87
88
89
90
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 84

def destroy
  if @admin_set.destroy
    after_delete_success
  else
    redirect_to hyrax.admin_admin_set_path(@admin_set), alert: @admin_set.errors.full_messages.to_sentence
  end
end

#editObject



55
56
57
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 55

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



61
62
63
64
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 61

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

#indexObject



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

def index
  add_breadcrumb t(:'hyrax.controls.home'), root_path
  add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
  add_breadcrumb t(:'hyrax.admin.sidebar.admin_sets'), hyrax.admin_admin_sets_path
  @admin_sets = Hyrax::AdminSetService.new(self).search_results(:edit)
end

#newObject



51
52
53
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 51

def new
  setup_form
end

#repositoryObject

for the AdminSetService



93
94
95
# File 'app/controllers/hyrax/admin/admin_sets_controller.rb', line 93

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



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

def update
  if @admin_set.update(admin_set_params)
    redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
  else
    setup_form
    render :edit
  end
end