geoblacklight_admin 0.5.0 → 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 +24 -11
- 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 +7 -1
- data/app/controllers/admin/assets_controller.rb +47 -32
- data/app/controllers/admin/bookmarks_controller.rb +17 -5
- data/app/controllers/admin/bulk_actions_controller.rb +32 -1
- data/app/controllers/admin/document_accesses_controller.rb +38 -0
- data/app/controllers/admin/document_assets_controller.rb +47 -89
- data/app/controllers/admin/document_distributions_controller.rb +172 -0
- data/app/controllers/admin/documents_controller.rb +43 -57
- data/app/controllers/admin/elements_controller.rb +24 -0
- data/app/controllers/admin/form_elements_controller.rb +33 -0
- data/app/controllers/admin/ids_controller.rb +6 -0
- data/app/controllers/admin/import_documents_controller.rb +11 -1
- data/app/controllers/admin/imports_controller.rb +34 -4
- 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 +10 -1
- 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/bulk_action_revert_document_job.rb +4 -12
- data/app/jobs/bulk_action_run_document_job.rb +2 -10
- 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/jobs/import_document_job.rb +1 -4
- data/app/jobs/import_run_job.rb +1 -1
- data/app/models/admin/bookmark.rb +1 -1
- data/app/models/asset.rb +20 -0
- data/app/models/bulk_action.rb +2 -1
- data/app/models/bulk_actions/change_publication_state.rb +0 -25
- data/app/models/bulk_actions/delete_thumbnails.rb +6 -0
- data/app/models/bulk_actions/draft_document.rb +6 -0
- data/app/models/bulk_actions/harvest_thumbnails.rb +6 -0
- data/app/models/bulk_actions/publish_document.rb +6 -0
- data/app/models/bulk_actions/unpublish_document.rb +6 -0
- data/app/models/document/geom_validator.rb +8 -0
- data/app/models/document/reference.rb +65 -65
- data/app/models/document.rb +129 -72
- 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/csv_duplicates_validator.rb +2 -0
- data/app/models/import/csv_header_validator.rb +3 -1
- data/app/models/import_btaa_aardvark.rb +2 -2
- data/app/models/import_document_state_machine.rb +1 -0
- data/app/models/import_gblv1.rb +2 -2
- 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/iiif_manifest.rb +39 -43
- data/app/services/geoblacklight_admin/image_service/tms.rb +0 -8
- data/app/services/geoblacklight_admin/image_service.rb +1 -1
- data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
- data/app/views/admin/bookmarks/index.html.erb +19 -14
- 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/mappings/index.html.erb +1 -1
- data/app/views/admin/notifications/_notification.html.haml +29 -28
- 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 +53 -12
- data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
- data/lib/generators/geoblacklight_admin/templates/btaa_sample_records.csv +5 -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/rake_task.rb +2 -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 +137 -53
- data/app/helpers/import_documents_helper.rb +0 -5
- 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,17 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Admin::DocumentsController
|
|
4
|
+
# This controller handles the management of documents within the admin interface.
|
|
5
|
+
# It provides actions to list, create, update, and delete documents, as well as
|
|
6
|
+
# export them in various formats.
|
|
4
7
|
module Admin
|
|
5
8
|
class DocumentsController < Admin::AdminController
|
|
9
|
+
# Allow all parameters (not recommended for production use)
|
|
6
10
|
ActionController::Parameters.permit_all_parameters = true
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
# Set the document before certain actions
|
|
13
|
+
before_action :set_document, only: %i[show edit update destroy admin versions]
|
|
9
14
|
|
|
10
15
|
# GET /documents
|
|
11
16
|
# GET /documents.json
|
|
17
|
+
# Lists all documents with support for various export formats.
|
|
12
18
|
def index
|
|
19
|
+
# Construct the request URL
|
|
13
20
|
@request = "#{request.protocol}#{request.host}:#{request.port}"
|
|
14
21
|
|
|
22
|
+
# Define query parameters for the document search
|
|
15
23
|
query_params = {
|
|
16
24
|
q: params["q"],
|
|
17
25
|
f: params["f"],
|
|
@@ -22,56 +30,47 @@ module Admin
|
|
|
22
30
|
}
|
|
23
31
|
@documents = BlacklightApi.new(@request, **query_params)
|
|
24
32
|
|
|
33
|
+
# Respond to different formats
|
|
25
34
|
respond_to do |format|
|
|
26
35
|
format.html { render :index }
|
|
27
36
|
format.json { render json: @documents.results.to_json }
|
|
28
|
-
|
|
29
|
-
# JSON - BTAA Aardvark
|
|
30
37
|
format.json_btaa_aardvark do
|
|
31
|
-
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_btaa_aardvark"}),
|
|
32
|
-
ExportJsonService)
|
|
38
|
+
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_btaa_aardvark"}), ExportJsonService)
|
|
33
39
|
head :no_content
|
|
34
40
|
end
|
|
35
|
-
|
|
36
|
-
# JSON - GBL Aardvark
|
|
37
41
|
format.json_aardvark do
|
|
38
42
|
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
|
|
39
43
|
head :no_content
|
|
40
44
|
end
|
|
41
|
-
|
|
42
|
-
# JSON - GBL v1
|
|
43
45
|
format.json_gbl_v1 do
|
|
44
46
|
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
|
|
45
47
|
head :no_content
|
|
46
48
|
end
|
|
47
|
-
|
|
48
|
-
# JSON - FILE
|
|
49
49
|
format.json_file do
|
|
50
50
|
ExportJsonBulkJob.perform_later(@request, current_user, query_params.merge!({format: "json_file"}), ExportJsonService)
|
|
51
51
|
head :no_content
|
|
52
52
|
end
|
|
53
|
-
|
|
54
|
-
# CSV - B1G
|
|
55
53
|
format.csv do
|
|
56
54
|
ExportJob.perform_later(@request, current_user, query_params, ExportCsvService)
|
|
57
55
|
head :no_content
|
|
58
56
|
end
|
|
59
|
-
|
|
60
|
-
# CSV Document Downloads - B1G
|
|
61
57
|
format.csv_document_downloads do
|
|
62
58
|
ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentDownloadsService)
|
|
63
59
|
head :no_content
|
|
64
60
|
end
|
|
65
|
-
|
|
66
|
-
# CSV Document Access Links - B1G
|
|
67
61
|
format.csv_document_access_links do
|
|
68
62
|
ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentAccessLinksService)
|
|
69
63
|
head :no_content
|
|
70
64
|
end
|
|
65
|
+
format.csv_document_distributions do
|
|
66
|
+
ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentDistributionsService)
|
|
67
|
+
head :no_content
|
|
68
|
+
end
|
|
71
69
|
end
|
|
72
70
|
end
|
|
73
71
|
|
|
74
|
-
# Fetch documents from array of friendlier_ids
|
|
72
|
+
# Fetch documents from an array of friendlier_ids
|
|
73
|
+
# This action retrieves documents based on their friendlier IDs.
|
|
75
74
|
def fetch
|
|
76
75
|
@request = "#{request.protocol}#{request.host}:#{request.port}"
|
|
77
76
|
@documents = Document.where(friendlier_id: params["ids"])
|
|
@@ -79,71 +78,62 @@ module Admin
|
|
|
79
78
|
respond_to do |format|
|
|
80
79
|
format.html { render :index }
|
|
81
80
|
format.json { render json: @documents.to_json }
|
|
82
|
-
|
|
83
|
-
# JSON - BTAA Aardvark
|
|
84
81
|
format.json_btaa_aardvark do
|
|
85
|
-
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
|
|
86
|
-
ExportJsonService)
|
|
82
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"}, ExportJsonService)
|
|
87
83
|
head :no_content
|
|
88
84
|
end
|
|
89
|
-
|
|
90
|
-
# JSON - GBL Aardvark
|
|
91
85
|
format.json_aardvark do
|
|
92
|
-
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"},
|
|
93
|
-
ExportJsonService)
|
|
86
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"}, ExportJsonService)
|
|
94
87
|
head :no_content
|
|
95
88
|
end
|
|
96
|
-
|
|
97
|
-
# JSON - GBL v1
|
|
98
89
|
format.json_gbl_v1 do
|
|
99
|
-
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"},
|
|
100
|
-
ExportJsonService)
|
|
90
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"}, ExportJsonService)
|
|
101
91
|
head :no_content
|
|
102
92
|
end
|
|
103
|
-
|
|
104
|
-
# CSV - B1G
|
|
105
93
|
format.csv do
|
|
106
|
-
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"},
|
|
107
|
-
ExportCsvService)
|
|
94
|
+
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"}, ExportCsvService)
|
|
108
95
|
head :no_content
|
|
109
96
|
end
|
|
110
|
-
|
|
111
|
-
# CSV Document Downloads - B1G
|
|
112
97
|
format.csv_document_downloads do
|
|
113
|
-
ExportJob.perform_later(@request, current_user,
|
|
114
|
-
{ids: @documents.pluck(:friendlier_id), format: "csv_document_downloads"}, ExportCsvDocumentDownloadsService)
|
|
98
|
+
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv_document_downloads"}, ExportCsvDocumentDownloadsService)
|
|
115
99
|
head :no_content
|
|
116
100
|
end
|
|
117
|
-
|
|
118
|
-
# CSV Document Downloads - B1G
|
|
119
101
|
format.csv_document_access_links do
|
|
120
|
-
ExportJob.perform_later(@request, current_user,
|
|
121
|
-
|
|
102
|
+
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv_document_access_links"}, ExportCsvDocumentAccessLinksService)
|
|
103
|
+
head :no_content
|
|
104
|
+
end
|
|
105
|
+
format.csv_document_distributions do
|
|
106
|
+
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv_document_distributions"}, ExportCsvDocumentDistributionsService)
|
|
122
107
|
head :no_content
|
|
123
108
|
end
|
|
124
109
|
end
|
|
125
110
|
end
|
|
126
111
|
|
|
127
112
|
# GET /documents/new
|
|
113
|
+
# Renders a form for creating a new document.
|
|
128
114
|
def new
|
|
129
115
|
@document = Document.new
|
|
130
116
|
render :edit
|
|
131
117
|
end
|
|
132
118
|
|
|
133
119
|
# GET /documents/1/edit
|
|
120
|
+
# Renders a form for editing an existing document.
|
|
134
121
|
def edit
|
|
135
122
|
end
|
|
136
123
|
|
|
137
124
|
# GET /documents/1/admin
|
|
125
|
+
# Admin view for a specific document.
|
|
138
126
|
def admin
|
|
139
127
|
end
|
|
140
128
|
|
|
141
129
|
# GET /documents/1/versions
|
|
130
|
+
# Displays the version history of a document.
|
|
142
131
|
def versions
|
|
143
132
|
end
|
|
144
133
|
|
|
145
134
|
# POST /documents
|
|
146
135
|
# POST /documents.json
|
|
136
|
+
# Creates a new document with the provided parameters.
|
|
147
137
|
def create
|
|
148
138
|
@document = Document.new(document_params)
|
|
149
139
|
@document.friendlier_id = @document.send(GeoblacklightAdmin::Schema.instance.solr_fields[:id])
|
|
@@ -152,7 +142,7 @@ module Admin
|
|
|
152
142
|
format.html { redirect_to edit_admin_document_path(@document), notice: "Document was successfully created." }
|
|
153
143
|
format.json { render :show, status: :created, location: @document }
|
|
154
144
|
else
|
|
155
|
-
format.html { render :edit }
|
|
145
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
156
146
|
format.json { render json: @document.errors, status: :unprocessable_entity }
|
|
157
147
|
end
|
|
158
148
|
end
|
|
@@ -160,13 +150,14 @@ module Admin
|
|
|
160
150
|
|
|
161
151
|
# PATCH/PUT /documents/1
|
|
162
152
|
# PATCH/PUT /documents/1.json
|
|
153
|
+
# Updates an existing document with the provided parameters.
|
|
163
154
|
def update
|
|
164
155
|
respond_to do |format|
|
|
165
156
|
if @document.update(document_params)
|
|
166
157
|
format.html { redirect_to edit_admin_document_path(@document), notice: "Document was successfully updated." }
|
|
167
158
|
format.json { render :show, status: :ok, location: @document }
|
|
168
159
|
else
|
|
169
|
-
format.html { render :edit }
|
|
160
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
170
161
|
format.json { render json: @document.errors, status: :unprocessable_entity }
|
|
171
162
|
end
|
|
172
163
|
end
|
|
@@ -174,6 +165,7 @@ module Admin
|
|
|
174
165
|
|
|
175
166
|
# DELETE /documents/1
|
|
176
167
|
# DELETE /documents/1.json
|
|
168
|
+
# Deletes a document.
|
|
177
169
|
def destroy
|
|
178
170
|
@document.destroy
|
|
179
171
|
respond_to do |format|
|
|
@@ -184,6 +176,8 @@ module Admin
|
|
|
184
176
|
end
|
|
185
177
|
end
|
|
186
178
|
|
|
179
|
+
# GET /documents/1
|
|
180
|
+
# Shows a document in various formats.
|
|
187
181
|
def show
|
|
188
182
|
respond_to do |format|
|
|
189
183
|
format.html { redirect_to edit_admin_document_url(@document) }
|
|
@@ -191,37 +185,29 @@ module Admin
|
|
|
191
185
|
format.json_aardvark
|
|
192
186
|
format.json_btaa_aardvark
|
|
193
187
|
format.json_gbl_v1
|
|
194
|
-
# B1G CSV
|
|
195
188
|
format.csv { send_data collect_csv([@document]), filename: "documents-#{Time.zone.today}.csv" }
|
|
196
|
-
|
|
197
|
-
# @TODO:
|
|
198
|
-
# geoblacklight_version: 1.0 (strict)
|
|
199
|
-
# geoblacklight_version: 1.0 + B1G customizations
|
|
200
|
-
# geoblacklight_version: 2.0 (strict)
|
|
201
|
-
# geoblacklight_version: 2.0 + B1G customizations
|
|
202
189
|
end
|
|
203
190
|
end
|
|
204
191
|
|
|
205
192
|
private
|
|
206
193
|
|
|
207
194
|
# Use callbacks to share common setup or constraints between actions.
|
|
195
|
+
# Finds and sets the document based on the friendlier_id.
|
|
208
196
|
def set_document
|
|
209
197
|
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:id] || params[:document_id])
|
|
210
198
|
end
|
|
211
199
|
|
|
212
|
-
#
|
|
213
|
-
# Plus sanitization or any other mutation.
|
|
214
|
-
#
|
|
215
|
-
# This could be done in a form object or otherwise abstracted, but this is good
|
|
216
|
-
# enough for now.
|
|
200
|
+
# Defines the list of permitted parameters for document creation and updates.
|
|
217
201
|
def permittable_params
|
|
218
202
|
%i[title publication_state layer_geom_type_s dct_references_s q f page sort rows daterange]
|
|
219
203
|
end
|
|
220
204
|
|
|
205
|
+
# Strong parameters for document creation and updates.
|
|
221
206
|
def document_params
|
|
222
207
|
Kithe::Parameters.new(params).require(:document).permit_attr_json(Document).permit(permittable_params)
|
|
223
208
|
end
|
|
224
209
|
|
|
210
|
+
# Collects documents into a CSV format.
|
|
225
211
|
def collect_csv(documents)
|
|
226
212
|
CSV.generate(headers: true) do |csv|
|
|
227
213
|
csv << GeoblacklightAdmin::Schema.instance.exportable_fields.map { |k, _v| k.to_s }
|
|
@@ -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,11 +88,16 @@ 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])
|
|
95
|
+
rescue ActiveRecord::RecordNotFound
|
|
96
|
+
redirect_to admin_elements_url, alert: "Element not found."
|
|
74
97
|
end
|
|
75
98
|
|
|
76
99
|
# Only allow a list of trusted parameters through.
|
|
100
|
+
# Permits specific parameters for element creation and updates.
|
|
77
101
|
def element_params
|
|
78
102
|
params.require(:element).permit(:label, :solr_field, :field_definition, :field_type, :required, :repeatable,
|
|
79
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,11 +98,15 @@ 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])
|
|
104
|
+
rescue ActiveRecord::RecordNotFound
|
|
105
|
+
redirect_to admin_form_elements_url, alert: "Form element not found."
|
|
74
106
|
end
|
|
75
107
|
|
|
76
108
|
# Only allow a list of trusted parameters through.
|
|
109
|
+
# Permits only trusted parameters for form elements.
|
|
77
110
|
def form_element_params
|
|
78
111
|
params.require(:form_element).permit(:type, :label, :element_solr_field)
|
|
79
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
|
|
|
@@ -40,7 +66,7 @@ module Admin
|
|
|
40
66
|
end
|
|
41
67
|
format.json { render :show, status: :created, location: @import }
|
|
42
68
|
else
|
|
43
|
-
format.html { render :new }
|
|
69
|
+
format.html { render :new, status: :unprocessable_entity }
|
|
44
70
|
format.json { render json: @import.errors, status: :unprocessable_entity }
|
|
45
71
|
end
|
|
46
72
|
end
|
|
@@ -48,13 +74,14 @@ 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)
|
|
54
81
|
format.html { redirect_to admin_import_path(@import), notice: "Import was successfully updated." }
|
|
55
82
|
format.json { render :show, status: :ok, location: @import }
|
|
56
83
|
else
|
|
57
|
-
format.html { render :edit }
|
|
84
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
58
85
|
format.json { render json: @import.errors, status: :unprocessable_entity }
|
|
59
86
|
end
|
|
60
87
|
end
|
|
@@ -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,
|