geoblacklight_admin 0.7.1 → 0.8.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_data_dictionaries_controller.rb +5 -0
- data/app/models/document_data_dictionary.rb +16 -4
- data/app/models/document_data_dictionary_entry.rb +1 -0
- data/app/models/document_distribution.rb +2 -0
- data/app/views/admin/document_data_dictionaries/_data_dictionaries_table.html.erb +4 -0
- data/app/views/catalog/_show_gbl_admin_data_dictionaries.html.erb +1 -0
- data/lib/geoblacklight_admin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccbde8ddbc9a147e70292b99dc32062b43c8517821ad3aff392e73b7bcd428c8
|
4
|
+
data.tar.gz: 13405c8253ee7f0f6ce925eba479a880f7ef06634841169622be946cc6ee2c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f19df4aecd8bbf08e0536b1cbcdc720d5f8c55e20e5c13d5296bbff61a8e8f79f724adda0899fbe566131bc7de2fdc3da141742fa064263b4136d9443dc26e
|
7
|
+
data.tar.gz: 524b5e9a4a1c37205d01456b5d3585183493e9d1c18397669ec692eb9072c31d1defbe8d7ca71cc3fdfef8b3dd6336ece4453cc589f4c7db92312fa00b84c9af
|
@@ -22,6 +22,11 @@ module Admin
|
|
22
22
|
# GET /document_data_dictionaries/1 or /document_data_dictionaries/1.json
|
23
23
|
def show
|
24
24
|
@pagy, @document_data_dictionary_entries = pagy(@document_data_dictionary.document_data_dictionary_entries.order(position: :asc), items: 100)
|
25
|
+
|
26
|
+
respond_to do |format|
|
27
|
+
format.html
|
28
|
+
format.csv { render plain: @document_data_dictionary.to_csv }
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
# GET /document_data_dictionaries/new
|
@@ -15,15 +15,27 @@ class DocumentDataDictionary < ApplicationRecord
|
|
15
15
|
|
16
16
|
# Validations
|
17
17
|
validates :name, presence: true
|
18
|
-
validates :csv_file,
|
19
|
-
|
20
|
-
|
18
|
+
validates :csv_file, content_type: {in: "text/csv", message: "is not a CSV file"}, if: -> { csv_file.attached? }
|
19
|
+
validates_with DocumentDataDictionary::CsvHeaderValidator, if: -> { csv_file.attached? }
|
20
|
+
|
21
|
+
def to_csv
|
22
|
+
CSV.generate do |csv|
|
23
|
+
csv << DocumentDataDictionaryEntry.column_names.excluding("id", "created_at", "updated_at")
|
24
|
+
document_data_dictionary_entries.each do |entry|
|
25
|
+
csv << entry.attributes.values_at(*DocumentDataDictionaryEntry.column_names.excluding("id", "created_at", "updated_at"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
21
29
|
|
22
30
|
def parse_csv_file
|
23
31
|
if csv_file.attached?
|
24
32
|
csv_data = CSV.parse(csv_file.download, headers: true)
|
25
33
|
csv_data.each do |row|
|
26
|
-
document_data_dictionary_entries.
|
34
|
+
entry = document_data_dictionary_entries.find_or_initialize_by(
|
35
|
+
friendlier_id: row["friendlier_id"],
|
36
|
+
field_name: row["field_name"]
|
37
|
+
)
|
38
|
+
entry.update(row.to_h)
|
27
39
|
end
|
28
40
|
end
|
29
41
|
end
|
@@ -13,6 +13,7 @@ require "csv"
|
|
13
13
|
#
|
14
14
|
# Callbacks:
|
15
15
|
# - after_save :reindex_document
|
16
|
+
# - after_destroy :reindex_document
|
16
17
|
#
|
17
18
|
# Validations:
|
18
19
|
# - Validates presence of :friendlier_id, :reference_type_id, :url
|
@@ -25,6 +26,7 @@ class DocumentDistribution < ApplicationRecord
|
|
25
26
|
belongs_to :document, foreign_key: :friendlier_id, primary_key: :friendlier_id
|
26
27
|
belongs_to :reference_type
|
27
28
|
after_save :reindex_document
|
29
|
+
after_destroy :reindex_document
|
28
30
|
|
29
31
|
# Validations
|
30
32
|
validates :friendlier_id, :reference_type_id, :url, presence: true
|
@@ -7,6 +7,7 @@
|
|
7
7
|
<th>Staff Notes</th>
|
8
8
|
<th>Tags</th>
|
9
9
|
<th>Entries</th>
|
10
|
+
<th>Export</th>
|
10
11
|
<th colspan="2">Actions</th>
|
11
12
|
</tr>
|
12
13
|
</thead>
|
@@ -27,6 +28,9 @@
|
|
27
28
|
<td>
|
28
29
|
<%= link_to "#{document_data_dictionary.document_data_dictionary_entries.count} entries", admin_document_document_data_dictionary_path(document_data_dictionary.friendlier_id, document_data_dictionary) %>
|
29
30
|
</td>
|
31
|
+
<td>
|
32
|
+
<%= link_to 'Export to CSV', admin_document_document_data_dictionary_path(document_data_dictionary.friendlier_id, document_data_dictionary, format: :csv), class: 'btn btn-outline-primary btn-block' %>
|
33
|
+
</td>
|
30
34
|
<td>
|
31
35
|
<%= link_to 'Edit', edit_admin_document_document_data_dictionary_path(document_data_dictionary.friendlier_id, document_data_dictionary) %>
|
32
36
|
</td>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% if document&.kithe_model&.document_data_dictionaries.present? %>
|
2
2
|
<% document.kithe_model.document_data_dictionaries.each do |dictionary| %>
|
3
3
|
<h3><%= dictionary.name %></h3>
|
4
|
+
<p><%= dictionary.description %></p>
|
4
5
|
<table class="table table-striped table-bordered">
|
5
6
|
<thead class="thead-dark">
|
6
7
|
<tr>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoblacklight_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Larson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_storage_validations
|