geoblacklight_admin 0.8.0 → 0.9.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/app/controllers/admin/document_licensed_accesses_controller.rb +169 -0
- data/app/controllers/admin/documents_controller.rb +12 -12
- data/app/controllers/admin/elements_controller.rb +1 -1
- data/app/controllers/admin/import_distributions_controller.rb +2 -1
- data/app/controllers/admin/imports_controller.rb +2 -1
- data/app/indexers/document_indexer.rb +2 -2
- data/app/javascript/controllers/results_controller.js +5 -15
- data/app/jobs/bulk_action_run_document_job.rb +12 -2
- data/app/jobs/export_job.rb +40 -30
- data/app/jobs/export_json_bulk_job.rb +1 -1
- data/app/jobs/export_json_job.rb +1 -1
- data/app/jobs/import_document_job.rb +12 -1
- data/app/jobs/import_run_job.rb +5 -0
- data/app/models/asset.rb +13 -3
- data/app/models/document/controlled_lists.rb +3 -2
- data/app/models/document/date_validator.rb +14 -12
- data/app/models/document.rb +21 -107
- data/app/models/{document_access.rb → document_licensed_access.rb} +8 -6
- data/app/models/geoblacklight_admin/schema.rb +0 -10
- data/app/models/import_document.rb +5 -0
- data/app/services/export_csv_document_distributions_service.rb +8 -4
- data/app/services/export_csv_document_licensed_access_links_service.rb +27 -0
- data/app/services/export_csv_service.rb +5 -1
- data/app/views/admin/document_assets/_assets_table.html.erb +4 -0
- data/app/views/admin/document_assets/index.html.erb +3 -1
- data/app/views/admin/document_distributions/destroy_all.html.erb +1 -1
- data/app/views/admin/document_distributions/index.html.erb +5 -7
- data/app/views/admin/document_licensed_accesses/_document_licensed_access.json.jbuilder +4 -0
- data/app/views/admin/{document_accesses → document_licensed_accesses}/_form.html.erb +4 -5
- data/app/views/admin/{document_accesses → document_licensed_accesses}/destroy_all.html.erb +7 -7
- data/app/views/admin/document_licensed_accesses/edit.html.erb +5 -0
- data/app/views/admin/{document_accesses → document_licensed_accesses}/import.html.erb +12 -9
- data/app/views/admin/document_licensed_accesses/index.html.erb +78 -0
- data/app/views/admin/document_licensed_accesses/index.json.jbuilder +3 -0
- data/app/views/admin/document_licensed_accesses/new.html.erb +8 -0
- data/app/views/admin/documents/_form_control.html.erb +0 -10
- data/app/views/admin/documents/_form_nav.html.erb +3 -12
- data/app/views/admin/documents/_form_nav_kithe.html.erb +0 -4
- data/app/views/admin/documents/_result_selected_options.html.erb +14 -18
- data/app/views/admin/documents/features/_document_references.html.erb +18 -20
- data/app/views/admin/documents/features/_licensed_access.html.erb +3 -0
- data/app/views/admin/elements/index.html.erb +0 -18
- data/app/views/admin/import_distributions/_form.html.erb +1 -1
- data/app/views/admin/import_distributions/_show_queued_tab.html.erb +36 -0
- data/app/views/admin/import_distributions/index.html.erb +3 -3
- data/app/views/admin/import_distributions/new.html.erb +3 -1
- data/app/views/admin/import_distributions/show.html.erb +5 -0
- data/app/views/admin/imports/_form.html.erb +1 -1
- data/app/views/admin/imports/_show_queued_tab.html.erb +31 -0
- data/app/views/admin/imports/index.html.erb +3 -3
- data/app/views/admin/imports/new.html.erb +3 -1
- data/app/views/admin/imports/show.html.erb +6 -0
- data/app/views/admin/notifications/_notification.html.haml +0 -1
- data/app/views/admin/notifications/index.html.erb +2 -2
- data/app/views/admin/notifications/update.js.erb +1 -1
- data/app/views/admin/shared/_navbar.html.erb +9 -8
- data/config/routes.rb +2 -25
- data/db/migrate/20240321000000_rename_document_accesses_to_document_licensed_accesses.rb +5 -0
- data/db/seeds_form_elements.csv +1 -2
- data/db/seeds_form_elements.numbers +0 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +4 -26
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -1
- data/lib/geoblacklight_admin/version.rb +1 -1
- metadata +17 -30
- data/app/controllers/admin/document_accesses_controller.rb +0 -169
- data/app/controllers/admin/document_downloads_controller.rb +0 -129
- data/app/models/document_download.rb +0 -39
- data/app/services/export_csv_document_access_links_service.rb +0 -47
- data/app/services/export_csv_document_downloads_service.rb +0 -47
- data/app/views/admin/document_accesses/_document_access.json.jbuilder +0 -4
- data/app/views/admin/document_accesses/edit.html.erb +0 -5
- data/app/views/admin/document_accesses/index.html.erb +0 -78
- data/app/views/admin/document_accesses/index.json.jbuilder +0 -3
- data/app/views/admin/document_accesses/new.html.erb +0 -6
- data/app/views/admin/document_accesses/show.html.erb +0 -19
- data/app/views/admin/document_accesses/show.json.jbuilder +0 -3
- data/app/views/admin/document_downloads/_document_download.json.jbuilder +0 -4
- data/app/views/admin/document_downloads/_form.html.erb +0 -15
- data/app/views/admin/document_downloads/destroy_all.html.erb +0 -70
- data/app/views/admin/document_downloads/edit.html.erb +0 -5
- data/app/views/admin/document_downloads/import.html.erb +0 -74
- data/app/views/admin/document_downloads/index.html.erb +0 -72
- data/app/views/admin/document_downloads/index.json.jbuilder +0 -3
- data/app/views/admin/document_downloads/new.html.erb +0 -5
- data/app/views/admin/document_downloads/show.html.erb +0 -24
- data/app/views/admin/document_downloads/show.json.jbuilder +0 -3
- data/app/views/admin/documents/features/_institutional_access_links.html.erb +0 -3
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +0 -30
data/app/models/document.rb
CHANGED
@@ -27,12 +27,8 @@ class Document < Kithe::Work
|
|
27
27
|
inverse_of: :document
|
28
28
|
|
29
29
|
# Document Collections
|
30
|
-
# -
|
31
|
-
has_many :
|
32
|
-
inverse_of: :document
|
33
|
-
|
34
|
-
# - DocumentDownloads
|
35
|
-
has_many :document_downloads, primary_key: "friendlier_id", foreign_key: "friendlier_id", autosave: false, dependent: :destroy,
|
30
|
+
# - DocumentLicensedAccesses
|
31
|
+
has_many :document_licensed_accesses, primary_key: "friendlier_id", foreign_key: "friendlier_id", autosave: false, dependent: :destroy,
|
36
32
|
inverse_of: :document
|
37
33
|
|
38
34
|
# - DocumentDataDictionaries
|
@@ -94,7 +90,7 @@ class Document < Kithe::Work
|
|
94
90
|
|
95
91
|
# Downloadable Resouce
|
96
92
|
def a_downloadable_resource?
|
97
|
-
|
93
|
+
json_attributes["dct_references_s"]&.any? { |ref| ref.category == "download" }
|
98
94
|
end
|
99
95
|
|
100
96
|
validates_with Document::DateValidator
|
@@ -118,53 +114,16 @@ class Document < Kithe::Work
|
|
118
114
|
attr_json :dct_references_s, Document::Reference.to_type, array: true, default: -> { [] }
|
119
115
|
|
120
116
|
# Distributions
|
121
|
-
# - BEFORE DocumentDistributions
|
122
|
-
# - Use dct_references_s
|
123
|
-
# - Use multiple downloads
|
124
|
-
# - Use distributable assets
|
125
|
-
# - AFTER DocumentDistributions
|
126
|
-
# - Use document_distributions
|
127
|
-
# - Use distributable assets
|
128
|
-
# @TODO: Remove BEFORE path once we've migrated to DocumentDistributions
|
129
117
|
def distributions
|
130
|
-
|
131
|
-
|
132
|
-
logger.debug("Document#distributions >
|
133
|
-
|
134
|
-
# AFTER - Add DocumentDistributions to distributions
|
135
|
-
if ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "true"
|
136
|
-
distributions = document_distributions.to_aardvark_distributions
|
137
|
-
|
138
|
-
logger.debug("Document#distributions > document_distributions: #{distributions}")
|
139
|
-
else
|
140
|
-
# BEFORE - Prep value arrays
|
141
|
-
# @TODO: Remove this once we've migrated to DocumentDistributions
|
142
|
-
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
|
143
|
-
if ref.category.present?
|
144
|
-
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] = []
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# BEFORE - Seed value arrays
|
149
|
-
# @TODO: Remove this once we've migrated to DocumentDistributions
|
150
|
-
send(GeoblacklightAdmin::Schema.instance.solr_fields[:reference]).each do |ref|
|
151
|
-
if ref.category.present?
|
152
|
-
distributions[Document::Reference::REFERENCE_VALUES[ref.category.to_sym][:uri]] << ref.value
|
153
|
-
end
|
154
|
-
end
|
155
|
-
logger.debug("\n\nDocument#distributions > seeded: #{distributions}")
|
118
|
+
# Add DocumentDistributions to distributions
|
119
|
+
distributions = document_distributions.to_aardvark_distributions
|
120
|
+
logger.debug("Document#distributions > document_distributions: #{distributions}")
|
156
121
|
|
157
|
-
|
158
|
-
# @TODO: Remove this once we've migrated to DocumentDistributions
|
159
|
-
distributions = apply_downloads(distributions)
|
160
|
-
logger.debug("Document#distributions > downloads: #{distributions}")
|
161
|
-
end
|
162
|
-
|
163
|
-
# BEFORE & AFTER - Apply Distributable Assets
|
122
|
+
# Apply Distributable Assets
|
164
123
|
distributions = apply_assets(distributions)
|
165
124
|
logger.debug("Document#distributions > assets: #{distributions}")
|
166
125
|
|
167
|
-
#
|
126
|
+
# Flatten the arrays here to avoid the following potential error:
|
168
127
|
# - ArgumentError: Please use symbols for polymorphic route arguments.
|
169
128
|
# - Via: app/helpers/geoblacklight_helper.rb:224:in `render_references_url'
|
170
129
|
distributions.each do |key, value|
|
@@ -180,17 +139,10 @@ class Document < Kithe::Work
|
|
180
139
|
# Distributions JSON
|
181
140
|
# - Indexes to Solr as dct_distributions_s
|
182
141
|
def distributions_json
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
distributions.to_json
|
188
|
-
else
|
189
|
-
logger.debug("Document#distributions > #{distributions.inspect}")
|
190
|
-
logger.debug("Document#distributions_json > using distributions")
|
191
|
-
logger.warn("Deprecation warning: AttrJSON-based dct_references_s will not be supported soon.")
|
192
|
-
self.distributions.to_json
|
193
|
-
end
|
142
|
+
logger.debug("Document#distributions_json > using document_distributions")
|
143
|
+
distributions = document_distributions.to_aardvark_distributions
|
144
|
+
distributions = apply_assets(distributions)
|
145
|
+
distributions.to_json
|
194
146
|
end
|
195
147
|
|
196
148
|
def distributions_csv
|
@@ -248,51 +200,6 @@ class Document < Kithe::Work
|
|
248
200
|
distributions
|
249
201
|
end
|
250
202
|
|
251
|
-
# BEFORE - Apply Downloads
|
252
|
-
# @TODO: Remove this once we've migrated to DocumentDistributions
|
253
|
-
# 1. Native Aardvark Downloads
|
254
|
-
# 2. Multiple Document Download Links
|
255
|
-
# 3. Downloadable Document Assets
|
256
|
-
def apply_downloads(distributions)
|
257
|
-
multiple_downloads = []
|
258
|
-
|
259
|
-
dct_downloads = distributions["http://schema.org/downloadUrl"]
|
260
|
-
|
261
|
-
logger.debug("Document#dct_downloads > init: #{dct_downloads}\n\n")
|
262
|
-
|
263
|
-
# Native Aardvark Downloads
|
264
|
-
# - Via CSV Import or via the webform
|
265
|
-
if dct_downloads.present?
|
266
|
-
dct_downloads.each do |download|
|
267
|
-
multiple_downloads << {label: download_text(send(GeoblacklightAdmin::Schema.instance.solr_fields[:format])),
|
268
|
-
url: download}
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
logger.debug("Document#multiple_downloads > aardvark: #{multiple_downloads.inspect}\n\n")
|
273
|
-
|
274
|
-
# Multiple Document Download Links
|
275
|
-
# - Via DocumentDownloads
|
276
|
-
if document_downloads.present?
|
277
|
-
multiple_downloads_array.each do |download|
|
278
|
-
multiple_downloads << download
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
logger.debug("Document#dct_downloads > document_downloads: #{multiple_downloads.inspect}\n\n")
|
283
|
-
|
284
|
-
multiple_downloads = multiple_downloads.uniq { |d| [d[:label], d[:url]] } unless multiple_downloads.empty?
|
285
|
-
|
286
|
-
distributions["http://schema.org/downloadUrl"] = multiple_downloads.flatten unless multiple_downloads.empty?
|
287
|
-
distributions
|
288
|
-
end
|
289
|
-
|
290
|
-
# BEFORE - Multiple Downloads Array
|
291
|
-
# @TODO: Remove this once we've migrated to DocumentDistributions
|
292
|
-
def multiple_downloads_array
|
293
|
-
document_downloads.collect { |d| {label: d.label, url: d.value} }
|
294
|
-
end
|
295
|
-
|
296
203
|
### From GBL
|
297
204
|
##
|
298
205
|
# Looks up properly formatted names for formats
|
@@ -497,7 +404,7 @@ class Document < Kithe::Work
|
|
497
404
|
|
498
405
|
# Institutional Access URLs
|
499
406
|
def access_urls
|
500
|
-
|
407
|
+
DocumentLicensedAccess.where(friendlier_id: friendlier_id).order(institution_code: :asc)
|
501
408
|
end
|
502
409
|
|
503
410
|
def derive_locn_geometry
|
@@ -567,6 +474,13 @@ class Document < Kithe::Work
|
|
567
474
|
private
|
568
475
|
|
569
476
|
def transition_publication_state
|
570
|
-
|
477
|
+
logger.debug("Document#transition_publication_state > publication_state: #{publication_state}")
|
478
|
+
logger.debug("Document#transition_publication_state > b1g_publication_state_s: #{b1g_publication_state_s}")
|
479
|
+
|
480
|
+
if publication_state_changed?
|
481
|
+
state_machine.transition_to!(publication_state.downcase)
|
482
|
+
elsif b1g_publication_state_s_changed?
|
483
|
+
state_machine.transition_to!(b1g_publication_state_s.downcase)
|
484
|
+
end
|
571
485
|
end
|
572
486
|
end
|
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
require "csv"
|
4
4
|
|
5
|
-
#
|
6
|
-
class
|
5
|
+
# DocumentLicensedAccess
|
6
|
+
class DocumentLicensedAccess < ApplicationRecord
|
7
7
|
belongs_to :document, foreign_key: :friendlier_id, primary_key: :friendlier_id
|
8
8
|
after_save :reindex_document
|
9
9
|
|
10
10
|
# Validations
|
11
|
-
validates :
|
11
|
+
validates :access_url, presence: true
|
12
|
+
validates :institution_code, presence: true
|
13
|
+
validates :institution_code, uniqueness: {scope: :friendlier_id}
|
12
14
|
|
13
15
|
def self.import(file)
|
14
16
|
logger.debug("CSV Import")
|
15
17
|
::CSV.foreach(file.path, headers: true) do |row|
|
16
18
|
logger.debug("CSV Row: #{row.to_hash}")
|
17
|
-
|
18
|
-
|
19
|
+
document_licensed_access = DocumentLicensedAccess.find_or_initialize_by(friendlier_id: row[0], institution_code: row[1])
|
20
|
+
document_licensed_access.update!(row.to_hash)
|
19
21
|
end
|
20
22
|
true
|
21
23
|
end
|
@@ -24,7 +26,7 @@ class DocumentAccess < ApplicationRecord
|
|
24
26
|
logger.debug("CSV Destroy")
|
25
27
|
::CSV.foreach(file.path, headers: true) do |row|
|
26
28
|
logger.debug("CSV Row: #{row.to_hash}")
|
27
|
-
|
29
|
+
DocumentLicensedAccess.destroy_by(id: row[0], friendlier_id: row[1])
|
28
30
|
end
|
29
31
|
true
|
30
32
|
end
|
@@ -31,11 +31,6 @@ module GeoblacklightAdmin
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
unless ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "true"
|
35
|
-
Rails.logger.warn("Deprecation warning: AttrJSON-based dct_references_s will not be supported soon.")
|
36
|
-
@fields = @fields.merge(dct_references_import_mappings)
|
37
|
-
end
|
38
|
-
|
39
34
|
@fields
|
40
35
|
end
|
41
36
|
|
@@ -67,11 +62,6 @@ module GeoblacklightAdmin
|
|
67
62
|
}
|
68
63
|
}
|
69
64
|
|
70
|
-
unless ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "true"
|
71
|
-
Rails.logger.warn("Deprecation warning: AttrJSON-based dct_references_s will not be supported soon.")
|
72
|
-
@fields = @fields.merge(dct_references_import_mappings)
|
73
|
-
end
|
74
|
-
|
75
65
|
@fields = @fields.merge(object_metadata)
|
76
66
|
@fields
|
77
67
|
end
|
@@ -21,6 +21,11 @@ class ImportDocument < ApplicationRecord
|
|
21
21
|
import_id: import_id
|
22
22
|
}
|
23
23
|
|
24
|
+
# Set publication state if it exists in json_attributes
|
25
|
+
if json_attributes["b1g_publication_state_s"].present?
|
26
|
+
data_hash[:publication_state] = json_attributes["b1g_publication_state_s"]
|
27
|
+
end
|
28
|
+
|
24
29
|
append_created_at(data_hash)
|
25
30
|
append_updated_at(data_hash)
|
26
31
|
end
|
@@ -11,7 +11,11 @@ class ExportCsvDocumentDistributionsService
|
|
11
11
|
#
|
12
12
|
# @return [String] the short name of the service.
|
13
13
|
def self.short_name
|
14
|
-
"
|
14
|
+
"Distributions"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.include_distributions?
|
18
|
+
false
|
15
19
|
end
|
16
20
|
|
17
21
|
# Initiates the CSV export process for the given document IDs.
|
@@ -45,10 +49,10 @@ class ExportCsvDocumentDistributionsService
|
|
45
49
|
slice.each do |doc_id|
|
46
50
|
doc = Document.find_by(friendlier_id: doc_id)
|
47
51
|
|
48
|
-
Rails.logger.debug { "\n\nDocDistributions: #{doc.
|
52
|
+
Rails.logger.debug { "\n\nDocDistributions: #{doc.distributions_csv.size}\n\n" }
|
49
53
|
|
50
|
-
doc.
|
51
|
-
csv_file << distribution
|
54
|
+
doc.distributions_csv.each do |distribution|
|
55
|
+
csv_file << distribution
|
52
56
|
end
|
53
57
|
rescue NoMethodError
|
54
58
|
Rails.logger.debug { "\n\nExport Failed: #{doc_id.inspect}\n\n" }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "csv"
|
4
|
+
|
5
|
+
class ExportCsvDocumentLicensedAccessLinksService
|
6
|
+
def self.short_name
|
7
|
+
"Licensed Access"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.include_distributions?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.call(document_ids)
|
15
|
+
Rails.logger.debug { "\n\nExportCsvDocumentLicensedAccessLinksService: #{document_ids.inspect}\n\n" }
|
16
|
+
|
17
|
+
csv_file = []
|
18
|
+
csv_file << DocumentLicensedAccess.column_names
|
19
|
+
records = DocumentLicensedAccess.where(friendlier_id: document_ids)
|
20
|
+
Rails.logger.debug { "Found #{records.count} records" }
|
21
|
+
records.find_each do |access|
|
22
|
+
csv_file << access.attributes.values
|
23
|
+
end
|
24
|
+
|
25
|
+
csv_file
|
26
|
+
end
|
27
|
+
end
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<th>Preview</th>
|
7
7
|
<th>Title</th>
|
8
8
|
<th>Label</th>
|
9
|
+
<th>File Size</th>
|
9
10
|
<th>MimeType</th>
|
10
11
|
<th>Reference URI Type</th>
|
11
12
|
<th colspan="2">Actions</th>
|
@@ -29,6 +30,9 @@
|
|
29
30
|
</td>
|
30
31
|
<td><%= link_to(document_asset.title, document_asset.file.url) %></td>
|
31
32
|
<td><%= document_asset.label %></td>
|
33
|
+
<td>
|
34
|
+
<%= number_to_human_size(document_asset.file_data["metadata"]["size"]) %>
|
35
|
+
</td>
|
32
36
|
<td>
|
33
37
|
<%= document_asset.file_data["metadata"]["mime_type"] %>
|
34
38
|
<span class="sr-only"><%= document_asset.inspect %></span>
|
@@ -13,7 +13,9 @@
|
|
13
13
|
<h2 class='h3'>
|
14
14
|
<%= link_to(@document.title, admin_document_path(@document)) %>
|
15
15
|
·
|
16
|
-
<%= @document_assets.count %> assets
|
16
|
+
<%= @document_assets.count %> assets
|
17
|
+
·
|
18
|
+
<%= number_to_human_size(@document.gbl_fileSize_s) %>
|
17
19
|
</h2>
|
18
20
|
<% else %>
|
19
21
|
<h2 class='h3'>Assets</h2>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<p id="notice"><%= notice %></p>
|
2
2
|
|
3
3
|
<h1 style="width:100%; border-bottom:dotted;" class="mb-4">
|
4
|
-
|
4
|
+
Destroy Distributions
|
5
5
|
<% if params[:document_id] %>
|
6
6
|
<%= link_to '+ New Distribution', new_document_document_distribution_path(@document), { class: 'btn btn-primary float-right' } %>
|
7
7
|
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%- @page_title = "GBL♦Admin -
|
1
|
+
<%- @page_title = "GBL♦Admin - Distributions" %>
|
2
2
|
|
3
3
|
<div class="row mb-2">
|
4
4
|
<div class="col">
|
5
5
|
<h1 style="width:100%;">
|
6
|
-
|
6
|
+
Distributions
|
7
7
|
|
8
8
|
<% if params[:document_id] %>
|
9
9
|
<%= link_to '+ Import CSV', new_admin_import_distribution_path, { class: 'btn btn-primary float-right' } %>
|
@@ -16,11 +16,9 @@
|
|
16
16
|
</h1>
|
17
17
|
|
18
18
|
<% if params[:document_id] %>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<% else %>
|
23
|
-
<h2 class='h3'>Distributions</h2>
|
19
|
+
<h2 class='h3'>
|
20
|
+
<%= link_to(@document.title, admin_document_path(@document)) %>
|
21
|
+
</h2>
|
24
22
|
<% end %>
|
25
23
|
|
26
24
|
<!-- Tab navigation -->
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
<%= simple_form_for [:admin, @document, @document_access] do |f| %>
|
1
|
+
<%= simple_form_for [:admin, @document, @document_licensed_access] do |f| %>
|
3
2
|
<%= f.error_notification %>
|
4
3
|
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
|
5
4
|
|
@@ -8,10 +7,10 @@
|
|
8
7
|
|
9
8
|
<%= f.input :institution_code, collection: b1g_institution_codes, label_method: ->(obj){ "#{obj[0]} - #{obj[1]}" }, value_method: :first, include_blank: true, input_html: { autofocus: true } %>
|
10
9
|
|
11
|
-
<%= f.input :access_url %>
|
10
|
+
<%= f.input :access_url, label: 'Licensed Access URL' %>
|
12
11
|
</div>
|
13
12
|
|
14
13
|
<div class="form-actions">
|
15
|
-
<%= f.button :submit, 'Create Access
|
14
|
+
<%= f.button :submit, @document_licensed_access.new_record? ? 'Create Licensed Access' : 'Update Licensed Access', class: 'btn btn-primary' %>
|
16
15
|
</div>
|
17
|
-
<% end %>
|
16
|
+
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<p id="notice"><%= notice %></p>
|
2
2
|
|
3
3
|
<h1 style="width:100%; border-bottom:dotted;" class="mb-4">
|
4
|
-
Document · Destroy Document Access
|
4
|
+
Document · Destroy Document Licensed Access
|
5
5
|
<% if params[:document_id] %>
|
6
|
-
<%= link_to '+ New Access
|
6
|
+
<%= link_to '+ New Licensed Access', new_admin_document_document_licensed_access_path(@document), { class: 'btn btn-primary float-right' } %>
|
7
7
|
<% end %>
|
8
8
|
</h1>
|
9
9
|
|
@@ -12,15 +12,15 @@
|
|
12
12
|
<% if params[:document_id] %>
|
13
13
|
<h2 class='h3'><%= @document.title %></h2>
|
14
14
|
<% else %>
|
15
|
-
<h2 class='h3'>Destroy Multiple Document Access
|
15
|
+
<h2 class='h3'>Destroy Multiple Document Licensed Access</h2>
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<p class="alert alert-danger" role="alert">
|
19
|
-
<strong>Warning:</strong> All matching Document Access
|
19
|
+
<strong>Warning:</strong> All matching Document Licensed Access will be destroyed. There is <strong>NO UNDO</strong> here.
|
20
20
|
</p>
|
21
21
|
<h3 class='h4'>Upload a CSV File</h3>
|
22
22
|
|
23
|
-
<%= simple_form_for
|
23
|
+
<%= simple_form_for DocumentLicensedAccess.new, url: destroy_all_admin_document_licensed_accesses_path, method: :post, multipart: true do |f| %>
|
24
24
|
<div class="form-group">
|
25
25
|
<div class="form-inputs">
|
26
26
|
<%= f.simple_fields_for :assets do |asset_fields| %>
|
@@ -64,7 +64,7 @@
|
|
64
64
|
<dt>id</dt>
|
65
65
|
<dd>The database table row identifier</dd>
|
66
66
|
<dt>friendlier_id</dt>
|
67
|
-
<dd>The associated
|
67
|
+
<dd>The associated GBL ADMIN document's friendlier id</dd>
|
68
68
|
</dl>
|
69
69
|
</div>
|
70
|
-
</div>
|
70
|
+
</div>
|
@@ -1,9 +1,12 @@
|
|
1
|
+
<%- @page_title = "GBL♦Admin - New Licensed Access Import" %>
|
2
|
+
|
1
3
|
<p id="notice"><%= notice %></p>
|
2
4
|
|
3
5
|
<h1 style="width:100%; border-bottom:dotted;" class="mb-4">
|
4
|
-
|
6
|
+
New Licensed Access Import
|
7
|
+
|
5
8
|
<% if params[:document_id] %>
|
6
|
-
<%= link_to '+ New Access
|
9
|
+
<%= link_to '+ New Licensed Access', new_admin_document_document_licensed_access_path(@document), { class: 'btn btn-primary float-right' } %>
|
7
10
|
<% end %>
|
8
11
|
</h1>
|
9
12
|
|
@@ -12,15 +15,15 @@
|
|
12
15
|
<% if params[:document_id] %>
|
13
16
|
<h2 class='h3'><%= @document.title %></h2>
|
14
17
|
<% else %>
|
15
|
-
<h2 class='h3'>Import for Multiple
|
18
|
+
<h2 class='h3'>Import for Multiple Items</h2>
|
16
19
|
<% end %>
|
17
20
|
|
18
21
|
<p class="alert alert-info" role="alert">
|
19
|
-
<strong>Note:</strong> New
|
22
|
+
<strong>Note:</strong> New Licensed Access URLs will be created. Existing Licensed Access URLs will be updated per the CSV file.
|
20
23
|
</p>
|
21
24
|
|
22
25
|
<h3 class='h4'>Upload a CSV File</h3>
|
23
|
-
<%= simple_form_for
|
26
|
+
<%= simple_form_for DocumentLicensedAccess.new, url: import_admin_document_licensed_accesses_path, method: :post, multipart: true do |f| %>
|
24
27
|
<div class="form-inputs">
|
25
28
|
<%= f.simple_fields_for :assets do |asset_fields| %>
|
26
29
|
<%= asset_fields.input :file, as: :file, input_html: {} %>
|
@@ -28,7 +31,7 @@
|
|
28
31
|
</div>
|
29
32
|
|
30
33
|
<div class="form-actions">
|
31
|
-
<%= submit_tag "+ Import
|
34
|
+
<%= submit_tag "+ Create Licensed Access Import", {class: 'btn btn-primary'} %>
|
32
35
|
</div>
|
33
36
|
<% end %>
|
34
37
|
</div>
|
@@ -64,11 +67,11 @@
|
|
64
67
|
<h5>CSV File Column Definitions</h5>
|
65
68
|
<dl>
|
66
69
|
<dt>friendlier_id</dt>
|
67
|
-
<dd>The associated
|
70
|
+
<dd>The associated GBL ADMIN document's friendlier id</dd>
|
68
71
|
<dt>institution_code</dt>
|
69
72
|
<dd>The <a target="_blank" href="https://github.com/geobtaa/geomg/blob/be1b6ac6628bd8f537ab10ecb88e5f4804540e2b/app/helpers/application_helper.rb#L28-L44">code</a> for the institution</dd>
|
70
73
|
<dt>access_url</dt>
|
71
|
-
<dd>The URL for the Access link</dd>
|
74
|
+
<dd>The URL for the Licensed Access link</dd>
|
72
75
|
</dl>
|
73
76
|
</div>
|
74
|
-
</div>
|
77
|
+
</div>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
<%- @page_title = "GBL♦Admin - Document - Licensed Access" %>
|
2
|
+
|
3
|
+
<div class="row mb-2">
|
4
|
+
<div class="col">
|
5
|
+
<h1 style="width:100%;">
|
6
|
+
Document · Licensed Access
|
7
|
+
|
8
|
+
<% if params[:document_id] %>
|
9
|
+
<%= link_to '+ Import CSV', import_admin_document_document_licensed_accesses_path(@document), { class: 'btn btn-primary float-right' } %>
|
10
|
+
|
11
|
+
<%= link_to '+ New Licensed Access', new_admin_document_document_licensed_access_path(@document), { class: 'btn btn-primary float-right mr-2' } %>
|
12
|
+
<% else %>
|
13
|
+
<%= link_to '- Delete CSV', destroy_all_admin_document_licensed_accesses_path, { class: 'btn btn-danger float-right' } %>
|
14
|
+
<%= link_to '+ Import CSV', import_admin_document_licensed_accesses_path, { class: 'btn btn-primary float-right mr-4' } %>
|
15
|
+
<% end %>
|
16
|
+
</h1>
|
17
|
+
<% if params[:document_id] %>
|
18
|
+
<h2 class='h3'>
|
19
|
+
<%= link_to(@document.title, admin_document_path(@document)) %>
|
20
|
+
·
|
21
|
+
<%= @document_licensed_accesses.count %> urls
|
22
|
+
</h2>
|
23
|
+
<% else %>
|
24
|
+
<h2 class='h3'>Licensed Access</h2>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<% if @pagy %>
|
28
|
+
<h6>
|
29
|
+
<span class='float-left mt-3'>
|
30
|
+
<%== pagy_info(@pagy) %>
|
31
|
+
</span>
|
32
|
+
<span class='float-right'>
|
33
|
+
<%== pagy_bootstrap_nav(@pagy) %>
|
34
|
+
</span>
|
35
|
+
</h6>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
|
39
|
+
<table class="table table-striped table-bordered sortable">
|
40
|
+
<thead class="thead-dark">
|
41
|
+
<tr>
|
42
|
+
<th class="header">id</th>
|
43
|
+
<th class="header">friendlier_id</th>
|
44
|
+
<th class="header">institution_code</th>
|
45
|
+
<th class="header">institution_name</th>
|
46
|
+
<th class="header" style="max-width:200px;">access_url</th>
|
47
|
+
<th class="header" colspan="2">Actions</th>
|
48
|
+
</tr>
|
49
|
+
</thead>
|
50
|
+
|
51
|
+
<tbody>
|
52
|
+
<% @document_licensed_accesses.each do |document_licensed_access| %>
|
53
|
+
<tr>
|
54
|
+
<td><%= document_licensed_access.id %></td>
|
55
|
+
<td><%= link_to document_licensed_access.friendlier_id, admin_document_path(document_licensed_access.document) %></td>
|
56
|
+
<td><%= document_licensed_access.institution_code %></td>
|
57
|
+
<td><%= b1g_institution_codes[document_licensed_access.institution_code] %></td>
|
58
|
+
<td><%= link_to(document_licensed_access.access_url, document_licensed_access.access_url) %></td>
|
59
|
+
<td><%= link_to 'Edit', edit_admin_document_document_licensed_access_path(document_licensed_access.document, document_licensed_access) %></td>
|
60
|
+
<td><%= link_to 'Destroy', admin_document_document_licensed_access_path(document_licensed_access.document, document_licensed_access), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
61
|
+
</tr>
|
62
|
+
<% end %>
|
63
|
+
</tbody>
|
64
|
+
</table>
|
65
|
+
|
66
|
+
<% if @pagy %>
|
67
|
+
<h6>
|
68
|
+
<span class='float-left mt-3'>
|
69
|
+
<%== pagy_info(@pagy) %>
|
70
|
+
</span>
|
71
|
+
<span class='float-right'>
|
72
|
+
<%== pagy_bootstrap_nav(@pagy) %>
|
73
|
+
</span>
|
74
|
+
</h6>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%- @page_title = "GBL♦Admin - New Document Licensed Access" %>
|
2
|
+
|
3
|
+
<h1>New Document Licensed Access</h1>
|
4
|
+
<h2 class='h3'><%= @document.title %></h2>
|
5
|
+
|
6
|
+
<%= render 'form', document_licensed_access: @document_licensed_access %>
|
7
|
+
|
8
|
+
<%= link_to 'Back', admin_document_document_licensed_accesses_path(@document) %>
|
@@ -35,17 +35,7 @@
|
|
35
35
|
<%= f.hidden_field :publication_state %>
|
36
36
|
<% end %>
|
37
37
|
|
38
|
-
<% # References are a special, special case %>
|
39
|
-
<% elsif element.solr_field == 'dct_references_s' %>
|
40
|
-
<% unless ENV["GBL_ADMIN_REFERENCES_MIGRATED"] == "true" %>
|
41
|
-
<%- Rails.logger.warn("Deprecation warning: AttrJSON-based dct_references_s will not be supported soon.") %>
|
42
|
-
<%= f.repeatable_attr_input(element.solr_field.to_sym, build: :at_least_one, html_attributes: options[:html_attributes], simple_form_input_args: { label: element.label }) do |sub_form| %>
|
43
|
-
<%= category_and_value(sub_form, category_list: Document::Reference::REFERENCE_VALUES.keys) %>
|
44
|
-
<% end %>
|
45
|
-
<% end %>
|
46
|
-
|
47
38
|
<% elsif element.repeatable? %>
|
48
|
-
|
49
39
|
<% # Text Fields %>
|
50
40
|
<% if element.field_type == 'text' %>
|
51
41
|
<%= f.repeatable_attr_input(element.solr_field.to_sym, build: :at_least_one, html_attributes: options[:html_attributes], simple_form_input_args: { label: element.label }) do |input_name, value| %>
|