Class: Spotlight::TagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/tags_controller.rb

Overview

CRUD actions for document tags

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#destroyObject



27
28
29
30
31
# File 'app/controllers/spotlight/tags_controller.rb', line 27

def destroy
  Spotlight::RenameTagsJob.perform_later(@exhibit, @tag, to: nil)

  redirect_to exhibit_tags_path(@exhibit)
end

#indexObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/spotlight/tags_controller.rb', line 15

def index
  @tags = @exhibit.owned_tags
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.curation.sidebar.tags'), exhibit_tags_path(@exhibit)

  respond_to do |format|
    format.html
    format.json { render json: @tags.map(&:name) }
  end
end

#renameObject



33
34
35
36
37
# File 'app/controllers/spotlight/tags_controller.rb', line 33

def rename
  Spotlight::RenameTagsJob.perform_later(@exhibit, @tag, to: params[:new_tag])

  redirect_to exhibit_tags_path(@exhibit)
end

#update_allObject



39
40
41
42
43
44
45
46
47
# File 'app/controllers/spotlight/tags_controller.rb', line 39

def update_all
  tags_to_rename = batch_update_params['owned_tags_attributes'].values.select do |tag|
    tag[:name]&.present? && tag[:current_name]&.strip != tag[:name]&.strip
  end

  rename_tags_later!(tags_to_rename)

  redirect_back fallback_location: fallback_url, notice: t(:'helpers.submit.tags.batch_updated', count: tags_to_rename.count)
end