geoblacklight_admin 0.0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -36
- data/Rakefile +47 -14
- data/app/assets/javascripts/geoblacklight_admin.js +2 -1
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +5 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_chosen.scss +425 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_forms.scss +108 -0
- data/app/controllers/admin/admin_controller.rb +4 -2
- data/app/controllers/admin/advanced_search_controller.rb +123 -103
- data/app/controllers/admin/api_controller.rb +123 -108
- data/app/controllers/admin/bookmarks_controller.rb +4 -4
- data/app/controllers/admin/bulk_actions_controller.rb +9 -4
- data/app/controllers/admin/concerns/upload_util.rb +2 -0
- data/app/controllers/admin/document_accesses_controller.rb +10 -4
- data/app/controllers/admin/document_assets_controller.rb +14 -11
- data/app/controllers/admin/document_downloads_controller.rb +12 -10
- data/app/controllers/admin/documents_controller.rb +32 -15
- data/app/controllers/admin/elements_controller.rb +6 -5
- data/app/controllers/admin/form_elements_controller.rb +4 -4
- data/app/controllers/admin/ids_controller.rb +107 -87
- data/app/controllers/admin/import_documents_controller.rb +1 -1
- data/app/controllers/admin/imports_controller.rb +7 -3
- data/app/controllers/admin/mappings_controller.rb +6 -4
- data/app/controllers/admin/notifications_controller.rb +1 -1
- data/app/controllers/admin/search_controller.rb +3 -2
- data/app/controllers/admin/users_controller.rb +2 -2
- data/app/helpers/form_input_helper.rb +4 -4
- data/app/helpers/geoblacklight_admin_helper.rb +1 -1
- data/app/indexers/document_indexer.rb +1 -1
- data/app/jobs/export_job.rb +9 -6
- data/app/jobs/export_json_bulk_job.rb +95 -0
- data/app/jobs/export_json_job.rb +14 -12
- data/app/models/admin/bookmark.rb +18 -0
- data/app/models/api_search_builder.rb +3 -1
- data/app/models/blacklight_api.rb +6 -6
- data/app/models/blacklight_api_facets.rb +7 -2
- data/app/models/blacklight_api_ids.rb +3 -4
- data/app/models/bulk_action.rb +1 -1
- data/app/models/document/bbox_validator.rb +9 -5
- data/app/models/document/date_range_validator.rb +13 -10
- data/app/models/document/geom_validator.rb +4 -2
- data/app/models/document.rb +15 -7
- data/app/models/element.rb +9 -7
- data/app/models/form_control.rb +2 -0
- data/app/models/form_element.rb +2 -0
- data/app/models/form_feature.rb +2 -0
- data/app/models/form_group.rb +2 -0
- data/app/models/form_header.rb +2 -0
- data/app/models/geoblacklight_admin/schema.rb +5 -2
- data/app/models/geoblacklight_admin.rb +2 -0
- data/app/models/import/csv_duplicates_validator.rb +2 -1
- data/app/models/import/csv_header_validator.rb +2 -1
- data/app/models/import.rb +4 -7
- data/app/models/user.rb +1 -1
- data/app/services/export_csv_service.rb +5 -1
- data/app/views/admin/advanced_search/facets.json.jbuilder +9 -8
- data/app/views/admin/advanced_search/index.json.jbuilder +8 -7
- data/app/views/admin/api/_field.json.jbuilder +1 -1
- data/app/views/admin/api/fetch.json.jbuilder +8 -7
- data/app/views/admin/api/index.json.jbuilder +8 -7
- data/app/views/admin/bookmarks/index.html.erb +2 -2
- data/app/views/admin/bulk_actions/index.html.erb +3 -3
- data/app/views/admin/bulk_actions/show.html.erb +1 -1
- data/app/views/admin/document_accesses/_form.html.erb +1 -1
- data/app/views/admin/document_accesses/destroy_all.html.erb +3 -3
- data/app/views/admin/document_accesses/edit.html.erb +1 -1
- data/app/views/admin/document_accesses/import.html.erb +2 -2
- data/app/views/admin/document_accesses/index.html.erb +9 -9
- data/app/views/admin/document_accesses/new.html.erb +1 -1
- data/app/views/admin/document_downloads/_form.html.erb +1 -1
- data/app/views/admin/document_downloads/destroy_all.html.erb +2 -2
- data/app/views/admin/document_downloads/edit.html.erb +2 -3
- data/app/views/admin/document_downloads/import.html.erb +1 -1
- data/app/views/admin/document_downloads/index.html.erb +9 -9
- data/app/views/admin/document_downloads/new.html.erb +1 -1
- data/app/views/admin/document_downloads/show.html.erb +2 -2
- data/app/views/admin/documents/_document_bookmark.html.erb +1 -1
- data/app/views/admin/documents/_form_nav.html.erb +3 -1
- data/app/views/admin/documents/_json_btaa_aardvark.jbuilder +1 -3
- data/app/views/admin/documents/_json_file.jbuilder +14 -0
- data/app/views/admin/documents/_result_selected_options.html.erb +3 -1
- data/app/views/admin/documents/edit.html.erb +1 -1
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +2 -2
- data/app/views/admin/documents/fetch.json_file.jbuilder +9 -0
- data/app/views/admin/documents/index.html.erb +2 -4
- data/app/views/admin/documents/index.json_file.jbuilder +9 -0
- data/app/views/admin/documents/versions.html.erb +1 -1
- data/app/views/admin/elements/_element.json.jbuilder +4 -1
- data/app/views/admin/elements/_form.html.erb +1 -1
- data/app/views/admin/elements/edit.html.erb +2 -2
- data/app/views/admin/elements/index.html.erb +4 -4
- data/app/views/admin/elements/index.json.jbuilder +2 -0
- data/app/views/admin/elements/new.html.erb +1 -1
- data/app/views/admin/elements/show.html.erb +6 -6
- data/app/views/admin/elements/show.json.jbuilder +2 -0
- data/app/views/admin/form_elements/_form.html.erb +1 -1
- data/app/views/admin/form_elements/_form_element.json.jbuilder +2 -0
- data/app/views/admin/form_elements/edit.html.erb +2 -2
- data/app/views/admin/form_elements/index.html.erb +2 -2
- data/app/views/admin/form_elements/index.json.jbuilder +2 -0
- data/app/views/admin/form_elements/new.html.erb +1 -1
- data/app/views/admin/form_elements/show.html.erb +2 -2
- data/app/views/admin/form_elements/show.json.jbuilder +2 -0
- data/app/views/admin/ids/fetch.json.jbuilder +8 -7
- data/app/views/admin/ids/index.json.jbuilder +3 -2
- data/app/views/admin/import_documents/show.html.haml +1 -1
- data/app/views/admin/imports/_import.json.jbuilder +2 -1
- data/app/views/admin/imports/_show_failed_tab.html.erb +2 -2
- data/app/views/admin/imports/_show_success_tab.html.erb +1 -1
- data/app/views/admin/imports/edit.html.erb +3 -3
- data/app/views/admin/imports/index.html.erb +3 -3
- data/app/views/admin/layouts/application.html.erb +4 -4
- data/app/views/admin/mappings/_form.html.erb +1 -1
- data/app/views/admin/mappings/_mapping.json.jbuilder +2 -1
- data/app/views/admin/mappings/edit.html.erb +2 -2
- data/app/views/admin/mappings/new.html.erb +1 -1
- data/app/views/admin/mappings/show.html.erb +2 -2
- data/app/views/admin/notifications/index.html.erb +3 -3
- data/app/views/admin/search/index.html.erb +2 -2
- data/app/views/admin/shared/_navbar.html.erb +11 -6
- data/app/views/admin/shared/_toast.html.erb +1 -1
- data/app/views/admin/users/index.html.erb +1 -1
- data/app/views/catalog/_show_gbl_admin.html.erb +3 -0
- data/config/locales/documents.en.yml +3 -0
- data/config/routes.rb +37 -33
- data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +409 -0
- data/db/seeds.rb +7 -6
- data/db/seeds_elements.csv +56 -55
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_form_elements.csv +65 -64
- data/db/seeds_form_elements.numbers +0 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +61 -94
- data/lib/generators/geoblacklight_admin/install_generator.rb +3 -12
- data/lib/generators/geoblacklight_admin/jobs_generator.rb +3 -2
- data/lib/generators/geoblacklight_admin/models_generator.rb +0 -1
- data/lib/generators/geoblacklight_admin/templates/_show_sidebar.html.erb +19 -0
- data/lib/generators/geoblacklight_admin/templates/_user_util_links.html.erb +1 -1
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +9 -5
- data/lib/generators/geoblacklight_admin/templates/config/geomg_aardvark_schema.json +12 -6
- data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +315 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +1 -2
- data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +2 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +15 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +152 -68
- data/lib/generators/geoblacklight_admin/templates/config/initializers/simple_form.rb +178 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/simple_form_bootstrap.rb +365 -0
- data/lib/generators/geoblacklight_admin/templates/config/settings.yml +293 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/results_controller.js +10 -0
- data/lib/generators/geoblacklight_admin/templates/package.json +3 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/schema.xml +3 -3
- data/lib/generators/geoblacklight_admin/views_generator.rb +2 -3
- data/lib/geoblacklight_admin/engine.rb +5 -6
- data/lib/geoblacklight_admin/version.rb +1 -1
- data/lib/geoblacklight_admin.rb +1 -1
- data/lib/tasks/geoblacklight_admin.rake +15 -11
- metadata +101 -63
- data/.editorconfig +0 -18
- data/.gitignore +0 -75
- data/.standard.yml +0 -4
- data/Gemfile +0 -59
- data/LICENSE +0 -21
- data/app/assets/images/.keep +0 -0
- data/app/controllers/admin/concerns/.keep +0 -0
- data/app/models/bookmark.rb +0 -17
- data/app/models/concerns/.keep +0 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin.rb +0 -399
- data/geoblacklight_admin.gemspec +0 -67
- data/lib/generators/geoblacklight_admin/example_docs_generator.rb +0 -18
- data/lib/generators/geoblacklight_admin/templates/.env.development.example +0 -28
- data/lib/generators/geoblacklight_admin/templates/.solr_wrapper.yml +0 -7
- data/lib/generators/geoblacklight_admin/templates/solr/snapshots/.keep +0 -0
- data/lib/tasks/.keep +0 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -35
- data/template.rb +0 -16
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/confirmations/new.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/invitations/edit.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/invitations/new.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/mailer/invitation_instructions.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/mailer/invitation_instructions.text.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/passwords/edit.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/passwords/new.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/registrations/edit.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/registrations/new.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/sessions/new.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/shared/_links.html.erb +0 -0
- /data/{app/views/admin → lib/generators/geoblacklight_admin/templates}/devise/unlocks/new.html.erb +0 -0
@@ -39,7 +39,8 @@ module Admin
|
|
39
39
|
respond_to do |format|
|
40
40
|
if @document_download.save
|
41
41
|
format.html do
|
42
|
-
redirect_to
|
42
|
+
redirect_to admin_document_document_downloads_path(@document_download.document),
|
43
|
+
notice: "Document download was successfully created."
|
43
44
|
end
|
44
45
|
format.json { render :show, status: :created, location: @document_download }
|
45
46
|
else
|
@@ -54,7 +55,8 @@ module Admin
|
|
54
55
|
respond_to do |format|
|
55
56
|
if @document_download.update(document_download_params)
|
56
57
|
format.html do
|
57
|
-
redirect_to
|
58
|
+
redirect_to admin_document_document_downloads_path(@document_download.document),
|
59
|
+
notice: "Document download was successfully updated."
|
58
60
|
end
|
59
61
|
format.json { render :show, status: :ok, location: @document_download }
|
60
62
|
else
|
@@ -69,7 +71,7 @@ module Admin
|
|
69
71
|
@document_download.destroy
|
70
72
|
|
71
73
|
respond_to do |format|
|
72
|
-
format.html { redirect_to
|
74
|
+
format.html { redirect_to admin_document_downloads_url, notice: "Document download was successfully destroyed." }
|
73
75
|
format.json { head :no_content }
|
74
76
|
end
|
75
77
|
end
|
@@ -80,12 +82,12 @@ module Admin
|
|
80
82
|
|
81
83
|
respond_to do |format|
|
82
84
|
if DocumentDownload.destroy_all(params.dig(:document_download, :downloads, :file))
|
83
|
-
format.html { redirect_to
|
85
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links were created destroyed." }
|
84
86
|
else
|
85
|
-
format.html { redirect_to
|
87
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be destroyed." }
|
86
88
|
end
|
87
89
|
rescue => e
|
88
|
-
format.html { redirect_to
|
90
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be destroyed. #{e}" }
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
@@ -97,12 +99,12 @@ module Admin
|
|
97
99
|
|
98
100
|
respond_to do |format|
|
99
101
|
if DocumentDownload.import(params.dig(:document_download, :downloads, :file))
|
100
|
-
format.html { redirect_to
|
102
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links were created successfully." }
|
101
103
|
else
|
102
|
-
format.html { redirect_to
|
104
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be created." }
|
103
105
|
end
|
104
106
|
rescue => e
|
105
|
-
format.html { redirect_to
|
107
|
+
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be created. #{e}" }
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
@@ -124,4 +126,4 @@ module Admin
|
|
124
126
|
params.require(:document_download).permit(:friendlier_id, :label, :value, :position)
|
125
127
|
end
|
126
128
|
end
|
127
|
-
end
|
129
|
+
end
|
@@ -10,6 +10,8 @@ module Admin
|
|
10
10
|
# GET /documents
|
11
11
|
# GET /documents.json
|
12
12
|
def index
|
13
|
+
@request = "#{request.protocol}#{request.host}:#{request.port}"
|
14
|
+
|
13
15
|
query_params = {
|
14
16
|
q: params["q"],
|
15
17
|
f: params["f"],
|
@@ -18,7 +20,7 @@ module Admin
|
|
18
20
|
sort: params["sort"] || "score desc",
|
19
21
|
daterange: params["daterange"] || nil
|
20
22
|
}
|
21
|
-
@documents = BlacklightApi.new(**query_params)
|
23
|
+
@documents = BlacklightApi.new(@request, **query_params)
|
22
24
|
|
23
25
|
respond_to do |format|
|
24
26
|
format.html { render :index }
|
@@ -26,37 +28,44 @@ module Admin
|
|
26
28
|
|
27
29
|
# JSON - BTAA Aardvark
|
28
30
|
format.json_btaa_aardvark do
|
29
|
-
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_btaa_aardvark"}),
|
31
|
+
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_btaa_aardvark"}),
|
32
|
+
ExportJsonService)
|
30
33
|
head :no_content
|
31
34
|
end
|
32
35
|
|
33
36
|
# JSON - GBL Aardvark
|
34
37
|
format.json_aardvark do
|
35
|
-
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
|
38
|
+
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
|
36
39
|
head :no_content
|
37
40
|
end
|
38
41
|
|
39
42
|
# JSON - GBL v1
|
40
43
|
format.json_gbl_v1 do
|
41
|
-
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
|
44
|
+
ExportJsonJob.perform_later(@request, current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
|
45
|
+
head :no_content
|
46
|
+
end
|
47
|
+
|
48
|
+
# JSON - FILE
|
49
|
+
format.json_file do
|
50
|
+
ExportJsonBulkJob.perform_later(@request, current_user, query_params.merge!({format: "json_file"}), ExportJsonService)
|
42
51
|
head :no_content
|
43
52
|
end
|
44
53
|
|
45
54
|
# CSV - B1G
|
46
55
|
format.csv do
|
47
|
-
ExportJob.perform_later(current_user, query_params, ExportCsvService)
|
56
|
+
ExportJob.perform_later(@request, current_user, query_params, ExportCsvService)
|
48
57
|
head :no_content
|
49
58
|
end
|
50
59
|
|
51
60
|
# CSV Document Downloads - B1G
|
52
61
|
format.csv_document_downloads do
|
53
|
-
ExportJob.perform_later(current_user, query_params, ExportCsvDocumentDownloadsService)
|
62
|
+
ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentDownloadsService)
|
54
63
|
head :no_content
|
55
64
|
end
|
56
65
|
|
57
66
|
# CSV Document Access Links - B1G
|
58
67
|
format.csv_document_access_links do
|
59
|
-
ExportJob.perform_later(current_user, query_params, ExportCsvDocumentAccessLinksService)
|
68
|
+
ExportJob.perform_later(@request, current_user, query_params, ExportCsvDocumentAccessLinksService)
|
60
69
|
head :no_content
|
61
70
|
end
|
62
71
|
end
|
@@ -64,6 +73,7 @@ module Admin
|
|
64
73
|
|
65
74
|
# Fetch documents from array of friendlier_ids
|
66
75
|
def fetch
|
76
|
+
@request = "#{request.protocol}#{request.host}:#{request.port}"
|
67
77
|
@documents = Document.where(friendlier_id: params["ids"])
|
68
78
|
|
69
79
|
respond_to do |format|
|
@@ -72,38 +82,43 @@ module Admin
|
|
72
82
|
|
73
83
|
# JSON - BTAA Aardvark
|
74
84
|
format.json_btaa_aardvark do
|
75
|
-
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
|
85
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
|
76
86
|
ExportJsonService)
|
77
87
|
head :no_content
|
78
88
|
end
|
79
89
|
|
80
90
|
# JSON - GBL Aardvark
|
81
91
|
format.json_aardvark do
|
82
|
-
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"},
|
92
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"},
|
93
|
+
ExportJsonService)
|
83
94
|
head :no_content
|
84
95
|
end
|
85
96
|
|
86
97
|
# JSON - GBL v1
|
87
98
|
format.json_gbl_v1 do
|
88
|
-
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"},
|
99
|
+
ExportJsonJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"},
|
100
|
+
ExportJsonService)
|
89
101
|
head :no_content
|
90
102
|
end
|
91
103
|
|
92
104
|
# CSV - B1G
|
93
105
|
format.csv do
|
94
|
-
ExportJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"},
|
106
|
+
ExportJob.perform_later(@request, current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"},
|
107
|
+
ExportCsvService)
|
95
108
|
head :no_content
|
96
109
|
end
|
97
110
|
|
98
111
|
# CSV Document Downloads - B1G
|
99
112
|
format.csv_document_downloads do
|
100
|
-
ExportJob.perform_later(
|
113
|
+
ExportJob.perform_later(@request, current_user,
|
114
|
+
{ids: @documents.pluck(:friendlier_id), format: "csv_document_downloads"}, ExportCsvDocumentDownloadsService)
|
101
115
|
head :no_content
|
102
116
|
end
|
103
117
|
|
104
118
|
# CSV Document Downloads - B1G
|
105
119
|
format.csv_document_access_links do
|
106
|
-
ExportJob.perform_later(
|
120
|
+
ExportJob.perform_later(@request, current_user,
|
121
|
+
{ids: @documents.pluck(:friendlier_id), format: "csv_document_access_links"}, ExportCsvDocumentAccessLinksService)
|
107
122
|
head :no_content
|
108
123
|
end
|
109
124
|
end
|
@@ -158,7 +173,9 @@ module Admin
|
|
158
173
|
def destroy
|
159
174
|
@document.destroy
|
160
175
|
respond_to do |format|
|
161
|
-
format.html
|
176
|
+
format.html do
|
177
|
+
redirect_to admin_documents_url, notice: "Document '#{@document.title}' was successfully destroyed."
|
178
|
+
end
|
162
179
|
format.json { head :no_content }
|
163
180
|
end
|
164
181
|
end
|
@@ -216,4 +233,4 @@ module Admin
|
|
216
233
|
end
|
217
234
|
end
|
218
235
|
end
|
219
|
-
end
|
236
|
+
end
|
@@ -29,7 +29,7 @@ module Admin
|
|
29
29
|
|
30
30
|
respond_to do |format|
|
31
31
|
if @element.save
|
32
|
-
format.html { redirect_to
|
32
|
+
format.html { redirect_to admin_element_url(@element), notice: "Element was successfully created." }
|
33
33
|
format.json { render :show, status: :created, location: @element }
|
34
34
|
else
|
35
35
|
format.html { render :new, status: :unprocessable_entity }
|
@@ -42,7 +42,7 @@ module Admin
|
|
42
42
|
def update
|
43
43
|
respond_to do |format|
|
44
44
|
if @element.update(element_params)
|
45
|
-
format.html { redirect_to
|
45
|
+
format.html { redirect_to admin_element_url(@element), notice: "Element was successfully updated." }
|
46
46
|
format.json { render :show, status: :ok, location: @element }
|
47
47
|
else
|
48
48
|
format.html { render :edit, status: :unprocessable_entity }
|
@@ -56,7 +56,7 @@ module Admin
|
|
56
56
|
@element.destroy
|
57
57
|
|
58
58
|
respond_to do |format|
|
59
|
-
format.html { redirect_to
|
59
|
+
format.html { redirect_to admin_elements_url, notice: "Element was successfully destroyed." }
|
60
60
|
format.json { head :no_content }
|
61
61
|
end
|
62
62
|
end
|
@@ -75,7 +75,8 @@ module Admin
|
|
75
75
|
|
76
76
|
# Only allow a list of trusted parameters through.
|
77
77
|
def element_params
|
78
|
-
params.require(:element).permit(:label, :solr_field, :field_definition, :field_type, :required, :repeatable,
|
78
|
+
params.require(:element).permit(:label, :solr_field, :field_definition, :field_type, :required, :repeatable,
|
79
|
+
: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)
|
79
80
|
end
|
80
81
|
end
|
81
|
-
end
|
82
|
+
end
|
@@ -29,7 +29,7 @@ module Admin
|
|
29
29
|
|
30
30
|
respond_to do |format|
|
31
31
|
if @form_element.save
|
32
|
-
format.html { redirect_to
|
32
|
+
format.html { redirect_to admin_form_elements_path, notice: "Form element was successfully created." }
|
33
33
|
format.json { render :show, status: :created, location: @form_element }
|
34
34
|
else
|
35
35
|
format.html { render :new, status: :unprocessable_entity }
|
@@ -42,7 +42,7 @@ module Admin
|
|
42
42
|
def update
|
43
43
|
respond_to do |format|
|
44
44
|
if @form_element.update(form_element_params)
|
45
|
-
format.html { redirect_to
|
45
|
+
format.html { redirect_to admin_form_element_url(@form_element), notice: "Form element was successfully updated." }
|
46
46
|
format.json { render :show, status: :ok, location: @form_element }
|
47
47
|
else
|
48
48
|
format.html { render :edit, status: :unprocessable_entity }
|
@@ -56,7 +56,7 @@ module Admin
|
|
56
56
|
@form_element.destroy
|
57
57
|
|
58
58
|
respond_to do |format|
|
59
|
-
format.html { redirect_to
|
59
|
+
format.html { redirect_to admin_form_elements_url, notice: "Form element was successfully destroyed." }
|
60
60
|
format.json { head :no_content }
|
61
61
|
end
|
62
62
|
end
|
@@ -78,4 +78,4 @@ module Admin
|
|
78
78
|
params.require(:form_element).permit(:type, :label, :element_solr_field)
|
79
79
|
end
|
80
80
|
end
|
81
|
-
end
|
81
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require "blacklight/catalog"
|
4
|
+
require "blacklight_range_limit/controller_override"
|
5
5
|
|
6
6
|
# Admin::IdsController
|
7
7
|
module Admin
|
@@ -10,6 +10,9 @@ module Admin
|
|
10
10
|
include BlacklightRangeLimit::ControllerOverride
|
11
11
|
include Blacklight::Catalog
|
12
12
|
|
13
|
+
# No need to auth, only queries Solr
|
14
|
+
skip_before_action :authenticate_admin!
|
15
|
+
|
13
16
|
configure_blacklight do |config|
|
14
17
|
# special search builder / fails
|
15
18
|
config.search_builder_class = ApiSearchBuilder
|
@@ -18,42 +21,44 @@ module Admin
|
|
18
21
|
config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
|
19
22
|
|
20
23
|
# Blacklight update to 7.0.0
|
21
|
-
config.add_results_document_tool(:bookmark, partial:
|
24
|
+
config.add_results_document_tool(:bookmark, partial: "bookmark_control", if: :render_bookmarks_control?)
|
22
25
|
|
23
26
|
config.add_results_collection_tool(:sort_widget)
|
24
27
|
config.add_results_collection_tool(:per_page_widget)
|
25
28
|
config.add_results_collection_tool(:view_type_group)
|
26
29
|
|
27
|
-
config.add_show_tools_partial(:bookmark, partial:
|
30
|
+
config.add_show_tools_partial(:bookmark, partial: "bookmark_control", if: :render_bookmarks_control?)
|
28
31
|
config.add_show_tools_partial(:email, callback: :email_action, validator: :validate_email_params)
|
29
|
-
config.add_show_tools_partial(:sms, if: :render_sms_action?, callback: :sms_action,
|
32
|
+
config.add_show_tools_partial(:sms, if: :render_sms_action?, callback: :sms_action,
|
33
|
+
validator: :validate_sms_params)
|
30
34
|
|
31
|
-
config.add_nav_action(:bookmark, partial:
|
35
|
+
config.add_nav_action(:bookmark, partial: "blacklight/nav/bookmark", if: :render_bookmarks_control?)
|
32
36
|
# Blacklight update to 7.0.0
|
33
37
|
|
34
38
|
# Advanced config values
|
35
39
|
config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
|
36
|
-
config.advanced_search[:url_key] ||=
|
37
|
-
config.advanced_search[:query_parser] ||=
|
40
|
+
config.advanced_search[:url_key] ||= "advanced"
|
41
|
+
config.advanced_search[:query_parser] ||= "edismax"
|
38
42
|
config.advanced_search[:form_solr_parameters] ||= {}
|
39
|
-
config.advanced_search[:form_solr_parameters][
|
40
|
-
|
41
|
-
config.advanced_search[:form_solr_parameters][
|
42
|
-
config.advanced_search[:form_solr_parameters][
|
43
|
+
config.advanced_search[:form_solr_parameters]["facet.field"] ||= [Settings.FIELDS.PROVIDER,
|
44
|
+
Settings.FIELDS.B1G_CODE, Settings.FIELDS.MEMBER_OF, Settings.FIELDS.IS_PART_OF, Settings.FIELDS.RESOURCE_CLASS, Settings.FIELDS.RESOURCE_TYPE, Settings.FIELDS.SUBJECT, Settings.FIELDS.THEME, Settings.FIELDS.FORMAT, Settings.FIELDS.SUPPRESSED, Settings.FIELDS.B1G_CHILD_RECORD, Settings.FIELDS.GEOREFERENCED]
|
45
|
+
config.advanced_search[:form_solr_parameters]["facet.query"] ||= ""
|
46
|
+
config.advanced_search[:form_solr_parameters]["facet.limit"] ||= -1
|
47
|
+
config.advanced_search[:form_solr_parameters]["facet.sort"] ||= "index"
|
43
48
|
|
44
49
|
# Map views
|
45
50
|
config.view.mapview.partials = [:index]
|
46
|
-
config.view[
|
47
|
-
config.view[
|
51
|
+
config.view["split"].title = "List view"
|
52
|
+
config.view["mapview"].title = "Map view"
|
48
53
|
|
49
54
|
config.raw_endpoint.enabled = true
|
50
55
|
|
51
56
|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
|
52
57
|
config.default_solr_params = {
|
53
58
|
:start => 0,
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
"q.alt" => "*:*",
|
60
|
+
"bf" => ["if(exists(#{Settings.FIELDS.B1G_CHILD_RECORD}),0,100)^0.5"],
|
61
|
+
"admin.api" => true
|
57
62
|
}
|
58
63
|
|
59
64
|
config.default_per_page = 1000 # Works!
|
@@ -62,8 +67,8 @@ module Admin
|
|
62
67
|
## parameters included in the Blacklight-jetty document requestHandler.
|
63
68
|
#
|
64
69
|
config.default_document_solr_params = {
|
65
|
-
|
66
|
-
|
70
|
+
qt: "document",
|
71
|
+
q: "{!raw f=#{Settings.FIELDS.B1G_GEOMG_ID} v=$id}"
|
67
72
|
}
|
68
73
|
|
69
74
|
# config.search_builder_class = Geoblacklight::SearchBuilder
|
@@ -77,7 +82,7 @@ module Admin
|
|
77
82
|
|
78
83
|
# solr field configuration for document/show views
|
79
84
|
|
80
|
-
config.show.display_type_field =
|
85
|
+
config.show.display_type_field = "format"
|
81
86
|
|
82
87
|
# Custom GeoBlacklight fields which currently map to GeoBlacklight-Schema
|
83
88
|
# v0.3.2
|
@@ -115,16 +120,22 @@ module Admin
|
|
115
120
|
## FACETS
|
116
121
|
#
|
117
122
|
# Date Range Filter
|
118
|
-
config.add_facet_field
|
123
|
+
# config.add_facet_field "date_created_drsim", label: "Date Created", show: false
|
119
124
|
|
120
125
|
# Date Created
|
121
|
-
config.add_facet_field
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
config.add_facet_field "time_period", label: "Date Created", query: {
|
127
|
+
"today" => {label: "Today",
|
128
|
+
fq: "date_created_drsim:[#{Date.today.beginning_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{Date.today.end_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"},
|
129
|
+
"this_week" => {label: "This week",
|
130
|
+
fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.week).to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{Date.today.end_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"},
|
131
|
+
"this_month" => {label: "This month",
|
132
|
+
fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.month).to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{Date.today.end_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"},
|
133
|
+
"last_month" => {label: "Last month",
|
134
|
+
fq: "date_created_drsim:[#{(Date.today.end_of_day - 2.months).to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{(Date.today.end_of_day - 1.month).to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"},
|
135
|
+
"this_quarter" => {label: "This quarter",
|
136
|
+
fq: "date_created_drsim:[#{(Date.today.end_of_day - 3.months).to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{Date.today.end_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"},
|
137
|
+
"this_year" => {label: "This year",
|
138
|
+
fq: "date_created_drsim:[#{(Date.today.end_of_day - 1.year).to_time.strftime("%Y-%m-%dT%H:%M:%S")} TO #{Date.today.end_of_day.to_time.strftime("%Y-%m-%dT%H:%M:%S")}]"}
|
128
139
|
}
|
129
140
|
|
130
141
|
# Publication State
|
@@ -145,34 +156,34 @@ module Admin
|
|
145
156
|
# ADVANCED SEARCH
|
146
157
|
#
|
147
158
|
# Code
|
148
|
-
config.add_facet_field Settings.FIELDS.B1G_CODE, label:
|
159
|
+
config.add_facet_field Settings.FIELDS.B1G_CODE, label: "Code", limit: 1000
|
149
160
|
|
150
161
|
# Is Part Of
|
151
|
-
config.add_facet_field Settings.FIELDS.IS_PART_OF, label:
|
162
|
+
config.add_facet_field Settings.FIELDS.IS_PART_OF, label: "Is Part Of", limit: 1000
|
152
163
|
|
153
164
|
# Member Of
|
154
|
-
config.add_facet_field Settings.FIELDS.MEMBER_OF, label:
|
165
|
+
config.add_facet_field Settings.FIELDS.MEMBER_OF, label: "Member Of", limit: 1000
|
155
166
|
|
156
167
|
# Resource Type
|
157
|
-
config.add_facet_field Settings.FIELDS.RESOURCE_TYPE, label:
|
168
|
+
config.add_facet_field Settings.FIELDS.RESOURCE_TYPE, label: "Resource Type", limit: 1000
|
158
169
|
|
159
170
|
# Subject
|
160
|
-
config.add_facet_field Settings.FIELDS.SUBJECT, label:
|
171
|
+
config.add_facet_field Settings.FIELDS.SUBJECT, label: "Subject", limit: 1000
|
161
172
|
|
162
173
|
# Theme
|
163
|
-
config.add_facet_field Settings.FIELDS.THEME, label:
|
174
|
+
config.add_facet_field Settings.FIELDS.THEME, label: "Theme", limit: 1000
|
164
175
|
|
165
176
|
# Format
|
166
|
-
config.add_facet_field Settings.FIELDS.FORMAT, label:
|
177
|
+
config.add_facet_field Settings.FIELDS.FORMAT, label: "Format", limit: 1000
|
167
178
|
|
168
179
|
# Suppressed
|
169
|
-
config.add_facet_field Settings.FIELDS.SUPPRESSED, label:
|
180
|
+
config.add_facet_field Settings.FIELDS.SUPPRESSED, label: "Suppressed"
|
170
181
|
|
171
182
|
# Child Record
|
172
|
-
config.add_facet_field Settings.FIELDS.B1G_CHILD_RECORD, label:
|
183
|
+
config.add_facet_field Settings.FIELDS.B1G_CHILD_RECORD, label: "Child Record"
|
173
184
|
|
174
185
|
# Georeferenced
|
175
|
-
config.add_facet_field Settings.FIELDS.GEOREFERENCED, label:
|
186
|
+
config.add_facet_field Settings.FIELDS.GEOREFERENCED, label: "Georeferenced"
|
176
187
|
|
177
188
|
# Have BL send all facet field names to Solr, which has been the default
|
178
189
|
# previously. Simply remove these lines if you'd rather use Solr request
|
@@ -238,48 +249,48 @@ module Admin
|
|
238
249
|
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
239
250
|
# since we aren't specifying it otherwise.
|
240
251
|
|
241
|
-
config.add_search_field(
|
252
|
+
config.add_search_field("all_fields") do |field|
|
242
253
|
field.include_in_advanced_search = false
|
243
|
-
field.label =
|
254
|
+
field.label = "All Fields"
|
244
255
|
end
|
245
256
|
|
246
|
-
config.add_search_field(
|
257
|
+
config.add_search_field("keyword") do |field|
|
247
258
|
field.include_in_simple_select = false
|
248
|
-
field.qt =
|
249
|
-
field.label =
|
259
|
+
field.qt = "search"
|
260
|
+
field.label = "Keyword"
|
250
261
|
field.solr_local_parameters = {
|
251
|
-
qf:
|
252
|
-
pf:
|
262
|
+
qf: "$qf",
|
263
|
+
pf: "$pf"
|
253
264
|
}
|
254
265
|
end
|
255
266
|
|
256
|
-
config.add_search_field(
|
267
|
+
config.add_search_field("title") do |field|
|
257
268
|
field.include_in_simple_select = false
|
258
|
-
field.qt =
|
259
|
-
field.label =
|
269
|
+
field.qt = "search"
|
270
|
+
field.label = "Title"
|
260
271
|
field.solr_local_parameters = {
|
261
|
-
qf:
|
262
|
-
pf:
|
272
|
+
qf: "$title_qf",
|
273
|
+
pf: "$title_pf"
|
263
274
|
}
|
264
275
|
end
|
265
276
|
|
266
|
-
config.add_search_field(
|
277
|
+
config.add_search_field("placename") do |field|
|
267
278
|
field.include_in_simple_select = false
|
268
|
-
field.qt =
|
269
|
-
field.label =
|
279
|
+
field.qt = "search"
|
280
|
+
field.label = "Place"
|
270
281
|
field.solr_local_parameters = {
|
271
|
-
qf:
|
272
|
-
pf:
|
282
|
+
qf: "$placename_qf",
|
283
|
+
pf: "$placename_pf"
|
273
284
|
}
|
274
285
|
end
|
275
286
|
|
276
|
-
config.add_search_field(
|
287
|
+
config.add_search_field("publisher") do |field|
|
277
288
|
field.include_in_simple_select = false
|
278
|
-
field.qt =
|
279
|
-
field.label =
|
289
|
+
field.qt = "search"
|
290
|
+
field.label = "Publisher/Creator"
|
280
291
|
field.solr_local_parameters = {
|
281
|
-
qf:
|
282
|
-
pf:
|
292
|
+
qf: "$publisher_qf",
|
293
|
+
pf: "$publisher_pf"
|
283
294
|
}
|
284
295
|
end
|
285
296
|
|
@@ -287,37 +298,48 @@ module Admin
|
|
287
298
|
# label in pulldown is followed by the name of the SOLR field to sort by and
|
288
299
|
# whether the sort is ascending or descending (it must be asc or desc
|
289
300
|
# except in the relevancy case).
|
290
|
-
config.add_sort_field
|
291
|
-
config.add_sort_field "#{Settings.FIELDS.INDEX_YEAR} desc, dct_title_sort asc", :
|
292
|
-
config.add_sort_field
|
301
|
+
config.add_sort_field "score desc, dct_title_sort asc", label: "relevance"
|
302
|
+
config.add_sort_field "#{Settings.FIELDS.INDEX_YEAR} desc, dct_title_sort asc", label: "year"
|
303
|
+
config.add_sort_field "dct_title_sort asc", label: "title"
|
293
304
|
|
294
305
|
# If there are more than this many search results, no spelling ("did you
|
295
306
|
# mean") suggestion is offered.
|
296
307
|
config.spell_max = 5
|
297
308
|
|
298
309
|
# Custom tools for GeoBlacklight
|
299
|
-
config.add_show_tools_partial :more_details, partial:
|
300
|
-
|
301
|
-
|
302
|
-
config.add_show_tools_partial :
|
303
|
-
|
310
|
+
config.add_show_tools_partial :more_details, partial: "more_details", if: proc { |_context, _config, options|
|
311
|
+
options[:document] && (!options[:document].references.nil? & !options[:document].references.url.nil?)
|
312
|
+
}
|
313
|
+
config.add_show_tools_partial :metadata, if: proc { |_context, _config, options|
|
314
|
+
options[:document] && (Settings.METADATA_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any?
|
315
|
+
}
|
316
|
+
config.add_show_tools_partial :web_services, if: proc { |_context, _config, options|
|
317
|
+
options[:document] && (Settings.WEBSERVICES_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any?
|
318
|
+
}
|
319
|
+
config.add_show_tools_partial :exports, partial: "exports", if: proc { |_context, _config, options|
|
320
|
+
options[:document]
|
321
|
+
}
|
322
|
+
config.add_show_tools_partial :data_dictionary, partial: "data_dictionary", if: proc { |_context, _config, options|
|
323
|
+
options[:document] && options[:document].data_dictionary_download.present?
|
324
|
+
}
|
304
325
|
config.add_show_tools_partial(:citation)
|
305
|
-
config.add_show_tools_partial(:access_links, partial:
|
326
|
+
config.add_show_tools_partial(:access_links, partial: "access_links", if: proc { |_context, _config, options|
|
327
|
+
options[:document] && options[:document].access_links.present?
|
328
|
+
})
|
306
329
|
|
307
330
|
# Remove nav actions
|
308
|
-
config.add_nav_action(:bookmark, partial:
|
331
|
+
config.add_nav_action(:bookmark, partial: "blacklight/nav/bookmark", if: false)
|
309
332
|
|
310
333
|
# Remove show tools
|
311
334
|
config.show.partials.delete(:show_header)
|
312
335
|
config.show.partials.delete(:show)
|
313
336
|
|
314
|
-
config.show.display_type_field =
|
315
|
-
config.show.partials <<
|
316
|
-
config.show.partials <<
|
317
|
-
config.show.partials <<
|
318
|
-
config.show.partials <<
|
319
|
-
config.show.partials <<
|
320
|
-
|
337
|
+
config.show.display_type_field = "format"
|
338
|
+
config.show.partials << "show_header"
|
339
|
+
config.show.partials << "show_default_viewer_container"
|
340
|
+
config.show.partials << "show_default_viewer_information"
|
341
|
+
config.show.partials << "show_default_attribute_table"
|
342
|
+
config.show.partials << "show"
|
321
343
|
|
322
344
|
config.show.document_actions.delete(:email)
|
323
345
|
config.show.document_actions.delete(:bookmark)
|
@@ -329,30 +351,30 @@ module Admin
|
|
329
351
|
# 'mapquest' http://developer.mapquest.com/web/products/open/map
|
330
352
|
# 'positron' http://cartodb.com/basemaps/
|
331
353
|
# 'darkMatter' http://cartodb.com/basemaps/
|
332
|
-
config.basemap_provider =
|
333
|
-
config.max_per_page =
|
354
|
+
config.basemap_provider = "esri"
|
355
|
+
config.max_per_page = 100_000
|
334
356
|
|
335
357
|
# Configuration for autocomplete suggestor
|
336
358
|
config.autocomplete_enabled = true
|
337
|
-
config.autocomplete_path =
|
359
|
+
config.autocomplete_path = "suggest"
|
338
360
|
end
|
339
361
|
|
340
362
|
# Administrative view of document
|
341
363
|
# - Sidecar Image
|
342
364
|
# - URIs
|
343
365
|
def admin
|
344
|
-
|
366
|
+
_, @document = search_service.fetch(params[:id])
|
345
367
|
end
|
346
368
|
|
347
369
|
# Administrative view for array of document ids
|
348
370
|
# - bookmarks
|
349
371
|
def fetch
|
350
|
-
@response,
|
372
|
+
@response, = search_service.fetch(params[:id])
|
351
373
|
|
352
374
|
respond_to do |format|
|
353
375
|
format.json do
|
354
376
|
@presenter = Blacklight::JsonPresenter.new(@response,
|
355
|
-
|
377
|
+
blacklight_config)
|
356
378
|
end
|
357
379
|
end
|
358
380
|
end
|
@@ -362,16 +384,14 @@ module Admin
|
|
362
384
|
# We want to find the facets available for the current search, but:
|
363
385
|
# * IGNORING current query (add in facets_for_advanced_search_form filter)
|
364
386
|
# * IGNORING current advanced search facets (remove add_advanced_search_to_solr filter)
|
365
|
-
@response,
|
387
|
+
@response, = search_service.search_results do |search_builder|
|
366
388
|
search_builder.except(:add_advanced_search_to_solr).append(:facets_for_advanced_search_form)
|
367
389
|
end
|
368
390
|
|
369
|
-
@response
|
370
|
-
|
371
391
|
respond_to do |format|
|
372
392
|
format.json do
|
373
393
|
@presenter = Blacklight::JsonPresenter.new(@response,
|
374
|
-
|
394
|
+
blacklight_config)
|
375
395
|
end
|
376
396
|
end
|
377
397
|
end
|