geoblacklight_admin 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -9
- data/Rakefile +83 -47
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +1 -0
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +24 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +0 -5
- data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +1 -1
- data/app/controllers/admin/admin_controller.rb +16 -0
- data/app/controllers/admin/advanced_search_controller.rb +1 -1
- data/app/controllers/admin/assets_controller.rb +41 -5
- data/app/controllers/admin/bookmarks_controller.rb +14 -2
- data/app/controllers/admin/bulk_actions_controller.rb +31 -0
- data/app/controllers/admin/document_accesses_controller.rb +38 -0
- data/app/controllers/admin/document_assets_controller.rb +46 -9
- data/app/controllers/admin/document_distributions_controller.rb +172 -0
- data/app/controllers/admin/documents_controller.rb +41 -55
- data/app/controllers/admin/elements_controller.rb +22 -0
- data/app/controllers/admin/form_elements_controller.rb +31 -0
- data/app/controllers/admin/import_documents_controller.rb +11 -1
- data/app/controllers/admin/imports_controller.rb +32 -2
- data/app/controllers/admin/mappings_controller.rb +15 -0
- data/app/controllers/admin/notifications_controller.rb +27 -0
- data/app/controllers/admin/reference_types_controller.rb +106 -0
- data/app/controllers/admin/search_controller.rb +7 -0
- data/app/controllers/admin/users_controller.rb +10 -0
- data/app/helpers/asset_helper.rb +6 -0
- data/app/helpers/bulk_actions_helper.rb +9 -0
- data/app/helpers/document_helper.rb +36 -0
- data/app/helpers/geoblacklight_admin_helper.rb +88 -8
- data/app/helpers/mappings_helper.rb +26 -0
- data/app/indexers/document_indexer.rb +22 -2
- data/app/javascript/channels/consumer.js +6 -0
- data/app/javascript/channels/export_channel.js +30 -0
- data/app/javascript/channels/index.js +3 -0
- data/app/javascript/controllers/results_controller.js +14 -0
- data/app/javascript/index.js +8 -2
- data/app/jobs/export_job.rb +35 -8
- data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +19 -0
- data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
- data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +17 -0
- data/app/jobs/geoblacklight_admin/store_image_job.rb +22 -0
- data/app/models/asset.rb +20 -0
- data/app/models/bulk_action.rb +2 -1
- data/app/models/document/geom_validator.rb +8 -0
- data/app/models/document/reference.rb +65 -65
- data/app/models/document.rb +128 -71
- data/app/models/document_distribution.rb +145 -0
- data/app/models/element.rb +2 -0
- data/app/models/geoblacklight_admin/schema.rb +10 -2
- data/app/models/import_document_state_machine.rb +1 -0
- data/app/models/reference_type.rb +40 -0
- data/app/models/user.rb +4 -2
- data/app/services/export_csv_document_distributions_service.rb +61 -0
- data/app/services/geoblacklight_admin/image_service/tms.rb +0 -4
- data/app/services/geoblacklight_admin/image_service.rb +1 -1
- data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
- data/app/views/admin/bulk_actions/show.html.erb +1 -1
- data/app/views/admin/document_accesses/import.html.erb +6 -2
- data/app/views/admin/document_assets/_assets_table.html.erb +49 -0
- data/app/views/admin/document_assets/_form.html.erb +2 -3
- data/app/views/admin/document_assets/index.html.erb +1 -47
- data/app/views/admin/document_distributions/_document_distribution.html.erb +39 -0
- data/app/views/admin/document_distributions/_document_distribution.json.jbuilder +2 -0
- data/app/views/admin/document_distributions/_form.html.erb +34 -0
- data/app/views/admin/document_distributions/destroy_all.html.erb +82 -0
- data/app/views/admin/document_distributions/edit.html.erb +12 -0
- data/app/views/admin/document_distributions/import.html.erb +80 -0
- data/app/views/admin/document_distributions/index.html.erb +143 -0
- data/app/views/admin/document_distributions/index.json.jbuilder +1 -0
- data/app/views/admin/document_distributions/new.html.erb +11 -0
- data/app/views/admin/document_distributions/show.html.erb +10 -0
- data/app/views/admin/document_distributions/show.json.jbuilder +1 -0
- data/app/views/admin/documents/_document.html.erb +1 -3
- data/app/views/admin/documents/_form.html.erb +2 -4
- data/app/views/admin/documents/_form_control.html.erb +5 -2
- data/app/views/admin/documents/_form_nav.html.erb +14 -5
- data/app/views/admin/documents/_form_nav_kithe.html.erb +4 -1
- data/app/views/admin/documents/_json_aardvark.jbuilder +1 -1
- data/app/views/admin/documents/_json_gbl_v1.jbuilder +1 -1
- data/app/views/admin/documents/_result_selected_options.html.erb +5 -2
- data/app/views/admin/documents/admin.html.erb +5 -5
- data/app/views/admin/documents/features/_document_references.html.erb +23 -0
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +29 -26
- data/app/views/admin/ids/fetch.json.jbuilder +0 -2
- data/app/views/admin/ids/index.json.jbuilder +0 -2
- data/app/views/admin/imports/_form.html.erb +1 -1
- data/app/views/admin/imports/show.html.erb +1 -1
- data/app/views/admin/layouts/application.html.erb +4 -2
- data/app/views/admin/reference_types/_form.html.erb +25 -0
- data/app/views/admin/reference_types/_reference_type.html.erb +52 -0
- data/app/views/admin/reference_types/_reference_type.json.jbuilder +2 -0
- data/app/views/admin/reference_types/edit.html.erb +12 -0
- data/app/views/admin/reference_types/index.html.erb +52 -0
- data/app/views/admin/reference_types/index.json.jbuilder +1 -0
- data/app/views/admin/reference_types/new.html.erb +11 -0
- data/app/views/admin/reference_types/show.html.erb +3 -0
- data/app/views/admin/reference_types/show.json.jbuilder +1 -0
- data/app/views/admin/shared/_footer.html.erb +5 -2
- data/app/views/admin/shared/_js_behaviors.html.erb +2 -3
- data/app/views/admin/shared/_navbar.html.erb +9 -2
- data/app/views/admin/users/index.html.erb +0 -1
- data/app/views/catalog/_show_gbl_admin.html.erb +1 -1
- data/config/initializers/defaults.yml +310 -0
- data/config/initializers/rails_config.rb +8 -0
- data/config/locales/documents.en.yml +14 -0
- data/config/routes.rb +30 -5
- data/db/import_references_schema_support.numbers +0 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +0 -12
- data/db/migrate/20241009200524_create_admin_reference_types.rb +13 -0
- data/db/migrate/20241010161420_create_document_references.rb +14 -0
- data/db/migrate/20241120238823_rename_references_to_distributions.rb +5 -0
- data/db/seeds.rb +5 -0
- data/db/seeds_elements.csv +1 -1
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_reference_types.csv +29 -0
- data/db/seeds_reference_types.numbers +0 -0
- data/db/structure.sql +1 -38
- data/lib/compose.yml +31 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +48 -12
- data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +1 -1
- data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +0 -2
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/Dockerfile +31 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/compose.yml +42 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/start-server.sh +21 -0
- data/lib/geoblacklight_admin/engine.rb +4 -0
- data/lib/geoblacklight_admin/tasks/distributions.rake +69 -0
- data/lib/geoblacklight_admin/tasks/images.rake +1 -0
- data/lib/geoblacklight_admin/tasks/solr.rake +31 -0
- data/lib/geoblacklight_admin/version.rb +1 -1
- data/lib/geoblacklight_admin.rb +4 -0
- metadata +78 -41
- data/app/javascript/entrypoints/engine.js +0 -8
- data/config/locales/devise_invitable.en.yml +0 -31
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/edit.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/new.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.html.erb +0 -11
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.text.erb +0 -11
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::ElementsController
|
|
4
|
+
# This controller manages the CRUD operations for elements within the admin namespace.
|
|
5
|
+
# It includes actions for listing, showing, creating, updating, and deleting elements.
|
|
6
|
+
# Additionally, it provides a custom action for sorting elements.
|
|
4
7
|
module Admin
|
|
5
8
|
class ElementsController < Admin::AdminController
|
|
6
9
|
before_action :set_element, only: %i[show edit update destroy]
|
|
7
10
|
|
|
8
11
|
# GET /elements or /elements.json
|
|
12
|
+
# Lists all elements, ordered by position in ascending order.
|
|
13
|
+
# Uses pagination to limit the number of elements displayed per page.
|
|
9
14
|
def index
|
|
10
15
|
@pagy, @elements = pagy(Element.all.order(position: :asc), items: 100)
|
|
11
16
|
end
|
|
12
17
|
|
|
13
18
|
# GET /elements/1 or /elements/1.json
|
|
19
|
+
# Displays a specific element.
|
|
14
20
|
def show
|
|
15
21
|
end
|
|
16
22
|
|
|
17
23
|
# GET /elements/new
|
|
24
|
+
# Initializes a new element object.
|
|
18
25
|
def new
|
|
19
26
|
@element = Element.new
|
|
20
27
|
end
|
|
21
28
|
|
|
22
29
|
# GET /elements/1/edit
|
|
30
|
+
# Prepares an element for editing.
|
|
23
31
|
def edit
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
# POST /elements or /elements.json
|
|
35
|
+
# Creates a new element with the provided parameters.
|
|
36
|
+
# If successful, redirects to the element's show page with a success notice.
|
|
37
|
+
# If unsuccessful, re-renders the new element form with error messages.
|
|
27
38
|
def create
|
|
28
39
|
@element = Element.new(element_params)
|
|
29
40
|
|
|
@@ -39,6 +50,9 @@ module Admin
|
|
|
39
50
|
end
|
|
40
51
|
|
|
41
52
|
# PATCH/PUT /elements/1 or /elements/1.json
|
|
53
|
+
# Updates an existing element with the provided parameters.
|
|
54
|
+
# If successful, redirects to the element's show page with a success notice.
|
|
55
|
+
# If unsuccessful, re-renders the edit form with error messages.
|
|
42
56
|
def update
|
|
43
57
|
respond_to do |format|
|
|
44
58
|
if @element.update(element_params)
|
|
@@ -52,6 +66,8 @@ module Admin
|
|
|
52
66
|
end
|
|
53
67
|
|
|
54
68
|
# DELETE /elements/1 or /elements/1.json
|
|
69
|
+
# Deletes a specific element.
|
|
70
|
+
# Redirects to the elements index page with a success notice.
|
|
55
71
|
def destroy
|
|
56
72
|
@element.destroy
|
|
57
73
|
|
|
@@ -61,6 +77,9 @@ module Admin
|
|
|
61
77
|
end
|
|
62
78
|
end
|
|
63
79
|
|
|
80
|
+
# POST /elements/sort
|
|
81
|
+
# Sorts elements based on the provided list of IDs.
|
|
82
|
+
# Renders an empty response body.
|
|
64
83
|
def sort
|
|
65
84
|
Element.sort_elements(params[:id_list])
|
|
66
85
|
render body: nil
|
|
@@ -69,6 +88,8 @@ module Admin
|
|
|
69
88
|
private
|
|
70
89
|
|
|
71
90
|
# Use callbacks to share common setup or constraints between actions.
|
|
91
|
+
# Finds an element by ID and sets it as an instance variable.
|
|
92
|
+
# Redirects to the elements index page with an alert if the element is not found.
|
|
72
93
|
def set_element
|
|
73
94
|
@element = Element.find(params[:id])
|
|
74
95
|
rescue ActiveRecord::RecordNotFound
|
|
@@ -76,6 +97,7 @@ module Admin
|
|
|
76
97
|
end
|
|
77
98
|
|
|
78
99
|
# Only allow a list of trusted parameters through.
|
|
100
|
+
# Permits specific parameters for element creation and updates.
|
|
79
101
|
def element_params
|
|
80
102
|
params.require(:element).permit(:label, :solr_field, :field_definition, :field_type, :required, :repeatable,
|
|
81
103
|
:formable, :placeholder_text, :data_entry_hint, :test_fixture_example, :controlled_vocabulary, :js_behaviors, :html_attributes, :display_only_on_persisted, :importable, :import_deliminated, :import_transformation_method, :exportable, :export_transformation_method, :indexable, :index_transformation_method, :validation_method, :position)
|
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::FormElementsController
|
|
4
|
+
#
|
|
5
|
+
# This controller manages the CRUD operations for form elements within the admin namespace.
|
|
6
|
+
# It provides actions to list, show, create, update, and delete form elements.
|
|
7
|
+
#
|
|
8
|
+
# Actions:
|
|
9
|
+
# - index: Lists all form elements.
|
|
10
|
+
# - show: Displays a specific form element.
|
|
11
|
+
# - new: Renders a form for creating a new form element.
|
|
12
|
+
# - edit: Renders a form for editing an existing form element.
|
|
13
|
+
# - create: Creates a new form element.
|
|
14
|
+
# - update: Updates an existing form element.
|
|
15
|
+
# - destroy: Deletes a form element.
|
|
16
|
+
# - sort: Sorts form elements based on a provided list of IDs.
|
|
17
|
+
#
|
|
18
|
+
# Before Actions:
|
|
19
|
+
# - set_form_element: Sets the form element for show, edit, update, and destroy actions.
|
|
20
|
+
#
|
|
21
|
+
# Private Methods:
|
|
22
|
+
# - set_form_element: Finds and sets the form element by ID, redirects if not found.
|
|
23
|
+
# - form_element_params: Permits only trusted parameters for form elements.
|
|
4
24
|
module Admin
|
|
5
25
|
class FormElementsController < Admin::AdminController
|
|
6
26
|
before_action :set_form_element, only: %i[show edit update destroy]
|
|
7
27
|
|
|
8
28
|
# GET /form_elements or /form_elements.json
|
|
29
|
+
# Lists all form elements.
|
|
9
30
|
def index
|
|
10
31
|
@form_elements = FormElement.all
|
|
11
32
|
end
|
|
12
33
|
|
|
13
34
|
# GET /form_elements/1 or /form_elements/1.json
|
|
35
|
+
# Displays a specific form element.
|
|
14
36
|
def show
|
|
15
37
|
end
|
|
16
38
|
|
|
17
39
|
# GET /form_elements/new
|
|
40
|
+
# Renders a form for creating a new form element.
|
|
18
41
|
def new
|
|
19
42
|
@form_element = FormElement.new
|
|
20
43
|
end
|
|
21
44
|
|
|
22
45
|
# GET /form_elements/1/edit
|
|
46
|
+
# Renders a form for editing an existing form element.
|
|
23
47
|
def edit
|
|
24
48
|
end
|
|
25
49
|
|
|
26
50
|
# POST /form_elements or /form_elements.json
|
|
51
|
+
# Creates a new form element.
|
|
27
52
|
def create
|
|
28
53
|
@form_element = FormElement.new(form_element_params)
|
|
29
54
|
|
|
@@ -39,6 +64,7 @@ module Admin
|
|
|
39
64
|
end
|
|
40
65
|
|
|
41
66
|
# PATCH/PUT /form_elements/1 or /form_elements/1.json
|
|
67
|
+
# Updates an existing form element.
|
|
42
68
|
def update
|
|
43
69
|
respond_to do |format|
|
|
44
70
|
if @form_element.update(form_element_params)
|
|
@@ -52,6 +78,7 @@ module Admin
|
|
|
52
78
|
end
|
|
53
79
|
|
|
54
80
|
# DELETE /form_elements/1 or /form_elements/1.json
|
|
81
|
+
# Deletes a form element.
|
|
55
82
|
def destroy
|
|
56
83
|
@form_element.destroy
|
|
57
84
|
|
|
@@ -61,6 +88,8 @@ module Admin
|
|
|
61
88
|
end
|
|
62
89
|
end
|
|
63
90
|
|
|
91
|
+
# POST /form_elements/sort
|
|
92
|
+
# Sorts form elements based on a provided list of IDs.
|
|
64
93
|
def sort
|
|
65
94
|
FormElement.sort_elements(params[:id_list])
|
|
66
95
|
render body: nil
|
|
@@ -69,6 +98,7 @@ module Admin
|
|
|
69
98
|
private
|
|
70
99
|
|
|
71
100
|
# Use callbacks to share common setup or constraints between actions.
|
|
101
|
+
# Finds and sets the form element by ID, redirects if not found.
|
|
72
102
|
def set_form_element
|
|
73
103
|
@form_element = FormElement.find(params[:id])
|
|
74
104
|
rescue ActiveRecord::RecordNotFound
|
|
@@ -76,6 +106,7 @@ module Admin
|
|
|
76
106
|
end
|
|
77
107
|
|
|
78
108
|
# Only allow a list of trusted parameters through.
|
|
109
|
+
# Permits only trusted parameters for form elements.
|
|
79
110
|
def form_element_params
|
|
80
111
|
params.require(:form_element).permit(:type, :label, :element_solr_field)
|
|
81
112
|
end
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::ImportDocumentsController
|
|
4
|
+
#
|
|
5
|
+
# This controller handles the import documents within the admin namespace.
|
|
6
|
+
# It inherits from Admin::AdminController and provides actions related to
|
|
7
|
+
# import documents.
|
|
4
8
|
module Admin
|
|
5
9
|
class ImportDocumentsController < Admin::AdminController
|
|
10
|
+
# Before action callback to set the import document for the show action.
|
|
6
11
|
before_action :set_import_document, only: %i[show]
|
|
7
12
|
|
|
13
|
+
# GET /admin/import_documents/:id
|
|
14
|
+
#
|
|
15
|
+
# Displays a specific import document.
|
|
8
16
|
def show
|
|
9
17
|
end
|
|
10
18
|
|
|
11
19
|
private
|
|
12
20
|
|
|
13
|
-
#
|
|
21
|
+
# Sets the import document based on the ID provided in the parameters.
|
|
22
|
+
#
|
|
23
|
+
# @return [ImportDocument] the import document found by ID
|
|
14
24
|
def set_import_document
|
|
15
25
|
@import_document = ImportDocument.find(params[:id])
|
|
16
26
|
end
|
|
@@ -1,34 +1,60 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::ImportsController
|
|
4
|
+
#
|
|
5
|
+
# This controller handles the CRUD operations for Import objects within the admin namespace.
|
|
6
|
+
# It provides actions to list, show, create, update, and delete imports, as well as run an import.
|
|
7
|
+
#
|
|
8
|
+
# Before Actions:
|
|
9
|
+
# - set_import: Sets the @import instance variable for actions that require an import ID.
|
|
10
|
+
#
|
|
11
|
+
# Actions:
|
|
12
|
+
# - index: Lists all imports with pagination.
|
|
13
|
+
# - show: Displays a specific import and its associated documents, with pagination for success and failed states.
|
|
14
|
+
# - new: Initializes a new Import object.
|
|
15
|
+
# - edit: Prepares an existing Import object for editing.
|
|
16
|
+
# - create: Creates a new Import object and redirects to import mappings if successful.
|
|
17
|
+
# - update: Updates an existing Import object and redirects to the import if successful.
|
|
18
|
+
# - destroy: Deletes an Import object and redirects to the imports list.
|
|
19
|
+
# - run: Executes the import process and redirects to the import show page.
|
|
20
|
+
#
|
|
21
|
+
# Private Methods:
|
|
22
|
+
# - set_import: Finds and sets the import based on the provided ID.
|
|
23
|
+
# - permittable_params: Returns an array of permitted parameters for import.
|
|
24
|
+
# - import_params: Permits parameters for creating or updating an import, including nested attributes.
|
|
4
25
|
module Admin
|
|
5
26
|
class ImportsController < Admin::AdminController
|
|
6
27
|
before_action :set_import, only: %i[show edit update destroy run]
|
|
7
28
|
|
|
8
29
|
# GET /imports
|
|
9
30
|
# GET /imports.json
|
|
31
|
+
# Lists all imports with pagination.
|
|
10
32
|
def index
|
|
11
33
|
@pagy, @imports = pagy(Import.all.order("created_at DESC"), items: 20)
|
|
12
34
|
end
|
|
13
35
|
|
|
14
36
|
# GET /imports/1
|
|
15
37
|
# GET /imports/1.json
|
|
38
|
+
# Displays a specific import and its associated documents, with pagination for success and failed states.
|
|
16
39
|
def show
|
|
17
40
|
@pagy_failed, @import_failed_documents = pagy(@import.import_documents.not_in_state(:success), items: 50, page_param: :failed_page)
|
|
18
41
|
@pagy_success, @import_success_documents = pagy(@import.import_documents.in_state(:success), items: 50, page_param: :success_page)
|
|
19
42
|
end
|
|
20
43
|
|
|
21
44
|
# GET /imports/new
|
|
45
|
+
# Initializes a new Import object.
|
|
22
46
|
def new
|
|
23
47
|
@import = Import.new
|
|
24
48
|
end
|
|
25
49
|
|
|
26
50
|
# GET /imports/1/edit
|
|
51
|
+
# Prepares an existing Import object for editing.
|
|
27
52
|
def edit
|
|
28
53
|
end
|
|
29
54
|
|
|
30
55
|
# POST /imports
|
|
31
56
|
# POST /imports.json
|
|
57
|
+
# Creates a new Import object and redirects to import mappings if successful.
|
|
32
58
|
def create
|
|
33
59
|
@import = Import.new(import_params)
|
|
34
60
|
|
|
@@ -48,6 +74,7 @@ module Admin
|
|
|
48
74
|
|
|
49
75
|
# PATCH/PUT /imports/1
|
|
50
76
|
# PATCH/PUT /imports/1.json
|
|
77
|
+
# Updates an existing Import object and redirects to the import if successful.
|
|
51
78
|
def update
|
|
52
79
|
respond_to do |format|
|
|
53
80
|
if @import.update(import_params)
|
|
@@ -62,6 +89,7 @@ module Admin
|
|
|
62
89
|
|
|
63
90
|
# DELETE /imports/1
|
|
64
91
|
# DELETE /imports/1.json
|
|
92
|
+
# Deletes an Import object and redirects to the imports list.
|
|
65
93
|
def destroy
|
|
66
94
|
@import.destroy
|
|
67
95
|
respond_to do |format|
|
|
@@ -70,6 +98,7 @@ module Admin
|
|
|
70
98
|
end
|
|
71
99
|
end
|
|
72
100
|
|
|
101
|
+
# Runs the import process and redirects to the import show page.
|
|
73
102
|
def run
|
|
74
103
|
@import.run!
|
|
75
104
|
redirect_to admin_import_url(@import), notice: "Import is running. Check back soon for results."
|
|
@@ -78,17 +107,18 @@ module Admin
|
|
|
78
107
|
private
|
|
79
108
|
|
|
80
109
|
# Use callbacks to share common setup or constraints between actions.
|
|
110
|
+
# Finds and sets the import based on the provided ID.
|
|
81
111
|
def set_import
|
|
82
112
|
@import = Import.find(params[:id])
|
|
83
113
|
end
|
|
84
114
|
|
|
85
|
-
#
|
|
86
|
-
|
|
115
|
+
# Returns an array of permitted parameters for import.
|
|
87
116
|
def permittable_params
|
|
88
117
|
%i[type name filename source description row_count encoding content_type extension validity validation_result
|
|
89
118
|
csv_file run]
|
|
90
119
|
end
|
|
91
120
|
|
|
121
|
+
# Permits parameters for creating or updating an import, including nested attributes.
|
|
92
122
|
def import_params
|
|
93
123
|
# Handle STI key
|
|
94
124
|
key = (params.keys & %w[import import_btaa import_btaa_aardvark import_gblv1])[0]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::MappingsController
|
|
4
|
+
# This controller manages the CRUD operations for Mappings within an Import context.
|
|
5
|
+
# It provides actions to list, show, create, update, and destroy mappings.
|
|
4
6
|
module Admin
|
|
5
7
|
class MappingsController < Admin::AdminController
|
|
6
8
|
before_action :set_import
|
|
@@ -8,6 +10,7 @@ module Admin
|
|
|
8
10
|
|
|
9
11
|
# GET /import/:id/mappings
|
|
10
12
|
# GET /import/:id/mappings.json
|
|
13
|
+
# Lists all mappings for a specific import. If no mappings exist, it initializes a new one.
|
|
11
14
|
def index
|
|
12
15
|
@mappings = Mapping.where(import_id: @import)
|
|
13
16
|
|
|
@@ -17,21 +20,26 @@ module Admin
|
|
|
17
20
|
|
|
18
21
|
# GET /mappings/1
|
|
19
22
|
# GET /mappings/1.json
|
|
23
|
+
# Shows a specific mapping.
|
|
20
24
|
def show
|
|
21
25
|
@import = Import.find(params[:import_id])
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
# GET /mappings/new
|
|
29
|
+
# Initializes a new mapping object.
|
|
25
30
|
def new
|
|
26
31
|
@mapping = Mapping.new
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
# GET /mappings/1/edit
|
|
35
|
+
# Prepares a mapping for editing.
|
|
30
36
|
def edit
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
# POST /mappings
|
|
34
40
|
# POST /mappings.json
|
|
41
|
+
# Creates a new mapping. If successful, redirects to the mapping's show page.
|
|
42
|
+
# Otherwise, re-renders the new form.
|
|
35
43
|
def create
|
|
36
44
|
@mapping = Mapping.new(mapping_params)
|
|
37
45
|
|
|
@@ -50,6 +58,8 @@ module Admin
|
|
|
50
58
|
|
|
51
59
|
# PATCH/PUT /mappings/1
|
|
52
60
|
# PATCH/PUT /mappings/1.json
|
|
61
|
+
# Updates an existing mapping. If successful, redirects to the mappings index.
|
|
62
|
+
# Otherwise, re-renders the edit form.
|
|
53
63
|
def update
|
|
54
64
|
respond_to do |format|
|
|
55
65
|
if @mapping.update(mapping_params)
|
|
@@ -64,6 +74,7 @@ module Admin
|
|
|
64
74
|
|
|
65
75
|
# DELETE /mappings/1
|
|
66
76
|
# DELETE /mappings/1.json
|
|
77
|
+
# Deletes a mapping and redirects to the mappings index.
|
|
67
78
|
def destroy
|
|
68
79
|
@mapping.destroy
|
|
69
80
|
respond_to do |format|
|
|
@@ -75,15 +86,19 @@ module Admin
|
|
|
75
86
|
private
|
|
76
87
|
|
|
77
88
|
# Use callbacks to share common setup or constraints between actions.
|
|
89
|
+
|
|
90
|
+
# Sets the import based on the import_id parameter.
|
|
78
91
|
def set_import
|
|
79
92
|
@import = Import.find(params[:import_id])
|
|
80
93
|
end
|
|
81
94
|
|
|
95
|
+
# Sets the mapping based on the id parameter.
|
|
82
96
|
def set_mapping
|
|
83
97
|
@mapping = Mapping.find(params[:id])
|
|
84
98
|
end
|
|
85
99
|
|
|
86
100
|
# Only allow a list of trusted parameters through.
|
|
101
|
+
# Permits the parameters required for creating or updating a mapping.
|
|
87
102
|
def mapping_params
|
|
88
103
|
params.require(:mapping).permit(
|
|
89
104
|
:source_header,
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::NotificationsController
|
|
4
|
+
#
|
|
5
|
+
# This controller manages the notifications for the admin panel. It provides
|
|
6
|
+
# actions to list, update, destroy, and batch update notifications.
|
|
4
7
|
module Admin
|
|
5
8
|
class NotificationsController < Admin::AdminController
|
|
6
9
|
before_action :set_notification, only: %i[update destroy]
|
|
7
10
|
|
|
11
|
+
# GET /admin/notifications
|
|
12
|
+
#
|
|
13
|
+
# Lists all notifications for the current user, paginated.
|
|
14
|
+
#
|
|
15
|
+
# @return [void]
|
|
8
16
|
def index
|
|
9
17
|
@pagy, @notifications = pagy(current_user.notifications.order(created_at: :desc), items: 20)
|
|
10
18
|
end
|
|
11
19
|
|
|
20
|
+
# PATCH/PUT /admin/notifications/:id
|
|
21
|
+
#
|
|
22
|
+
# Updates the read status of a notification.
|
|
23
|
+
#
|
|
24
|
+
# @param [String] read The read status, "0" for unread, "1" for read.
|
|
25
|
+
# @return [void]
|
|
12
26
|
def update
|
|
13
27
|
case params[:read]
|
|
14
28
|
when "0"
|
|
@@ -25,6 +39,11 @@ module Admin
|
|
|
25
39
|
end
|
|
26
40
|
end
|
|
27
41
|
|
|
42
|
+
# DELETE /admin/notifications/:id
|
|
43
|
+
#
|
|
44
|
+
# Destroys a notification and purges its associated file.
|
|
45
|
+
#
|
|
46
|
+
# @return [void]
|
|
28
47
|
def destroy
|
|
29
48
|
@notification.file.purge
|
|
30
49
|
@notification.destroy
|
|
@@ -34,6 +53,11 @@ module Admin
|
|
|
34
53
|
end
|
|
35
54
|
end
|
|
36
55
|
|
|
56
|
+
# POST /admin/notifications/batch
|
|
57
|
+
#
|
|
58
|
+
# Marks all notifications as read.
|
|
59
|
+
#
|
|
60
|
+
# @return [void]
|
|
37
61
|
def batch
|
|
38
62
|
return unless params[:read] == "all"
|
|
39
63
|
|
|
@@ -44,6 +68,9 @@ module Admin
|
|
|
44
68
|
|
|
45
69
|
private
|
|
46
70
|
|
|
71
|
+
# Sets the notification based on the provided ID.
|
|
72
|
+
#
|
|
73
|
+
# @return [void]
|
|
47
74
|
def set_notification
|
|
48
75
|
@notification = Notification.find(params[:id])
|
|
49
76
|
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::ReferenceTypesController
|
|
4
|
+
#
|
|
5
|
+
# This controller manages the CRUD operations for ReferenceType objects
|
|
6
|
+
# within the admin namespace. It includes actions to list, show, create,
|
|
7
|
+
# update, and destroy reference types, as well as a custom sort action.
|
|
8
|
+
class Admin::ReferenceTypesController < Admin::AdminController
|
|
9
|
+
before_action :set_reference_type, only: %i[show edit update destroy]
|
|
10
|
+
|
|
11
|
+
# GET /admin/reference_types or /admin/reference_types.json
|
|
12
|
+
#
|
|
13
|
+
# Lists all reference types.
|
|
14
|
+
def index
|
|
15
|
+
@reference_types = ReferenceType.all
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# GET /admin/reference_types/1 or /admin/reference_types/1.json
|
|
19
|
+
#
|
|
20
|
+
# Shows a specific reference type.
|
|
21
|
+
def show
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /admin/reference_types/new
|
|
25
|
+
#
|
|
26
|
+
# Initializes a new reference type.
|
|
27
|
+
def new
|
|
28
|
+
@reference_type = ReferenceType.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# GET /admin/reference_types/1/edit
|
|
32
|
+
#
|
|
33
|
+
# Edits an existing reference type.
|
|
34
|
+
def edit
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# POST /admin/reference_types or /admin/reference_types.json
|
|
38
|
+
#
|
|
39
|
+
# Creates a new reference type. If successful, redirects to the show page
|
|
40
|
+
# of the newly created reference type. Otherwise, re-renders the new form.
|
|
41
|
+
def create
|
|
42
|
+
@reference_type = ReferenceType.new(reference_type_params)
|
|
43
|
+
|
|
44
|
+
respond_to do |format|
|
|
45
|
+
if @reference_type.save
|
|
46
|
+
format.html { redirect_to admin_reference_type_path(@reference_type), notice: "Reference type was successfully created." }
|
|
47
|
+
format.json { render :show, status: :created, location: @reference_type }
|
|
48
|
+
else
|
|
49
|
+
format.html { render :new, status: :unprocessable_entity }
|
|
50
|
+
format.json { render json: @reference_type.errors, status: :unprocessable_entity }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# PATCH/PUT /admin/reference_types/1 or /admin/reference_types/1.json
|
|
56
|
+
#
|
|
57
|
+
# Updates an existing reference type. If successful, redirects to the show
|
|
58
|
+
# page of the updated reference type. Otherwise, re-renders the edit form.
|
|
59
|
+
def update
|
|
60
|
+
respond_to do |format|
|
|
61
|
+
if @reference_type.update(reference_type_params)
|
|
62
|
+
format.html { redirect_to admin_reference_type_path(@reference_type), notice: "Reference type was successfully updated." }
|
|
63
|
+
format.json { render :show, status: :ok, location: @reference_type }
|
|
64
|
+
else
|
|
65
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
66
|
+
format.json { render json: @reference_type.errors, status: :unprocessable_entity }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# DELETE /admin/reference_types/1 or /admin/reference_types/1.json
|
|
72
|
+
#
|
|
73
|
+
# Destroys a reference type. Redirects to the index page with a notice.
|
|
74
|
+
def destroy
|
|
75
|
+
@reference_type.destroy!
|
|
76
|
+
|
|
77
|
+
respond_to do |format|
|
|
78
|
+
format.html { redirect_to admin_reference_types_path, status: :see_other, notice: "Reference type was successfully destroyed." }
|
|
79
|
+
format.json { head :no_content }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# POST /admin/reference_types/sort
|
|
84
|
+
#
|
|
85
|
+
# Sorts reference types based on the provided list of IDs.
|
|
86
|
+
def sort
|
|
87
|
+
ReferenceType.sort_elements(params[:id_list])
|
|
88
|
+
render body: nil
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
94
|
+
#
|
|
95
|
+
# Sets the @reference_type instance variable for actions that require it.
|
|
96
|
+
def set_reference_type
|
|
97
|
+
@reference_type = ReferenceType.find(params[:id])
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Only allow a list of trusted parameters through.
|
|
101
|
+
#
|
|
102
|
+
# Permits the parameters required for creating or updating a reference type.
|
|
103
|
+
def reference_type_params
|
|
104
|
+
params.require(:reference_type).permit(:name, :reference_type, :reference_uri, :label, :note, :position)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::SearchController
|
|
4
|
+
# This controller handles search-related actions for the admin interface.
|
|
4
5
|
module Admin
|
|
5
6
|
class SearchController < Admin::AdminController
|
|
7
|
+
# GET /admin/search
|
|
8
|
+
#
|
|
9
|
+
# This action sets up the request URL and retrieves facet options
|
|
10
|
+
# from the Blacklight API.
|
|
11
|
+
#
|
|
12
|
+
# @return [void]
|
|
6
13
|
def index
|
|
7
14
|
@request = "#{request.protocol}#{request.host}:#{request.port}"
|
|
8
15
|
@facet_options = BlacklightApiFacets.new(@request).facets
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::UsersController
|
|
4
|
+
#
|
|
5
|
+
# This controller handles the actions related to admin users.
|
|
6
|
+
# It inherits from Admin::AdminController, which provides
|
|
7
|
+
# common functionality for all admin-related controllers.
|
|
4
8
|
module Admin
|
|
5
9
|
class UsersController < Admin::AdminController
|
|
10
|
+
# GET /admin/users
|
|
11
|
+
#
|
|
12
|
+
# This action retrieves all users with admin privileges.
|
|
13
|
+
# It assigns the result to the @users instance variable,
|
|
14
|
+
# which can be used in the corresponding view to display
|
|
15
|
+
# the list of admin users.
|
|
6
16
|
def index
|
|
7
17
|
@users = User.where(admin: true)
|
|
8
18
|
end
|
data/app/helpers/asset_helper.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# AssetHelper
|
|
4
|
+
#
|
|
5
|
+
# This module provides helper methods for asset management.
|
|
4
6
|
module AssetHelper
|
|
7
|
+
# Determines if an asset has a thumbnail to render.
|
|
8
|
+
#
|
|
9
|
+
# @param asset [Object] The asset object to check.
|
|
10
|
+
# @return [Boolean] Returns true if the asset has a file URL and file derivatives present, otherwise false.
|
|
5
11
|
def asset_thumb_to_render?(asset)
|
|
6
12
|
asset&.file_url&.present? && asset&.file_derivatives&.present?
|
|
7
13
|
end
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# BulkActionsHelper
|
|
4
|
+
#
|
|
5
|
+
# This module provides helper methods for handling bulk actions
|
|
6
|
+
# within the GeoblacklightAdmin application.
|
|
4
7
|
module BulkActionsHelper
|
|
8
|
+
# Returns a collection of attributes that can be used for bulk actions.
|
|
9
|
+
#
|
|
10
|
+
# The collection includes all importable fields from the GeoblacklightAdmin
|
|
11
|
+
# schema, with "Publication State" prepended to the list.
|
|
12
|
+
#
|
|
13
|
+
# @return [Array<String>] an array of attribute names
|
|
5
14
|
def bulk_actions_collection
|
|
6
15
|
attrs = GeoblacklightAdmin::Schema.instance.importable_fields.collect { |key, _value| key }
|
|
7
16
|
attrs.prepend("Publication State")
|