geoblacklight_admin 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +1 -1
  4. data/app/assets/stylesheets/geoblacklight_admin/modules/_icons.scss +9 -0
  5. data/app/controllers/admin/document_data_dictionaries_controller.rb +126 -0
  6. data/app/controllers/admin/document_data_dictionary_entries_controller.rb +124 -0
  7. data/app/controllers/admin/document_distributions_controller.rb +0 -38
  8. data/app/controllers/admin/import_distributions_controller.rb +126 -0
  9. data/app/javascript/index.js +1 -1
  10. data/app/jobs/import_distributions_run_job.rb +32 -0
  11. data/app/jobs/import_document_distribution_job.rb +23 -0
  12. data/app/models/document.rb +5 -0
  13. data/app/models/document_data_dictionary/csv_header_validator.rb +30 -0
  14. data/app/models/document_data_dictionary.rb +39 -0
  15. data/app/models/document_data_dictionary_entry.rb +9 -0
  16. data/app/models/import_distribution/csv_header_validator.rb +32 -0
  17. data/app/models/import_distribution.rb +55 -0
  18. data/app/models/import_distribution_state_machine.rb +14 -0
  19. data/app/models/import_distribution_transition.rb +26 -0
  20. data/app/models/import_document_distribution.rb +25 -0
  21. data/app/models/import_document_distribution_state_machine.rb +13 -0
  22. data/app/models/import_document_distribution_transition.rb +19 -0
  23. data/app/views/admin/document_data_dictionaries/_data_dictionaries_table.html.erb +40 -0
  24. data/app/views/admin/document_data_dictionaries/_document_data_dictionary.html.erb +37 -0
  25. data/app/views/admin/document_data_dictionaries/_document_data_dictionary.json.jbuilder +2 -0
  26. data/app/views/admin/document_data_dictionaries/_form.html.erb +17 -0
  27. data/app/views/admin/document_data_dictionaries/edit.html.erb +12 -0
  28. data/app/views/admin/document_data_dictionaries/index.html.erb +45 -0
  29. data/app/views/admin/document_data_dictionaries/index.json.jbuilder +1 -0
  30. data/app/views/admin/document_data_dictionaries/new.html.erb +78 -0
  31. data/app/views/admin/document_data_dictionaries/show.html.erb +78 -0
  32. data/app/views/admin/document_data_dictionaries/show.json.jbuilder +1 -0
  33. data/app/views/admin/document_data_dictionary_entries/_form.html.erb +19 -0
  34. data/app/views/admin/document_data_dictionary_entries/edit.html.erb +12 -0
  35. data/app/views/admin/document_data_dictionary_entries/new.html.erb +16 -0
  36. data/app/views/admin/document_distributions/index.html.erb +2 -2
  37. data/app/views/admin/documents/_form_nav.html.erb +4 -0
  38. data/app/views/admin/import_distributions/_form.html.erb +21 -0
  39. data/app/views/admin/import_distributions/_import_distribution.json.jbuilder +5 -0
  40. data/app/views/admin/import_distributions/_show_failed_tab.html.erb +36 -0
  41. data/app/views/admin/import_distributions/_show_success_tab.html.erb +35 -0
  42. data/app/views/admin/import_distributions/edit.html.erb +8 -0
  43. data/app/views/admin/import_distributions/index.html.erb +58 -0
  44. data/app/views/admin/import_distributions/index.json.jbuilder +3 -0
  45. data/app/views/admin/import_distributions/new.html.erb +7 -0
  46. data/app/views/admin/import_distributions/show.html.erb +121 -0
  47. data/app/views/admin/import_distributions/show.json.jbuilder +3 -0
  48. data/app/views/admin/imports/index.html.erb +2 -2
  49. data/app/views/admin/shared/_navbar.html.erb +2 -2
  50. data/app/views/catalog/_gbl_admin_data_dictionaries.html.erb +3 -0
  51. data/app/views/catalog/_show_gbl_admin_data_dictionaries.html.erb +44 -0
  52. data/app/views/catalog/data_dictionaries.html.erb +12 -0
  53. data/db/migrate/20241204163117_create_document_data_dictionaries.rb +14 -0
  54. data/db/migrate/20241218174455_create_document_data_dictionary_entries.rb +17 -0
  55. data/db/migrate/20250113213655_import_distributions.rb +56 -0
  56. data/lib/generators/geoblacklight_admin/config_generator.rb +61 -4
  57. data/lib/generators/geoblacklight_admin/templates/btaa_sample_document_data_dictionary_entries.csv +9 -0
  58. data/lib/generators/geoblacklight_admin/templates/btaa_sample_document_distributions.csv +17 -0
  59. data/lib/geoblacklight_admin/routes/data_dictionariesable.rb +17 -0
  60. data/lib/geoblacklight_admin/version.rb +1 -1
  61. metadata +49 -2
@@ -0,0 +1,35 @@
1
+ <h6>
2
+ <span class='float-left mt-3'>
3
+ <%== pagy_info(@pagy_success) %>
4
+ </span>
5
+ <span class='float-right'>
6
+ <%== pagy_bootstrap_nav(@pagy_success) %>
7
+ </span>
8
+ </h6>
9
+
10
+ <table class="table table-striped">
11
+ <thead>
12
+ <tr>
13
+ <th>State</th>
14
+ <th>Friendlier ID</th>
15
+ <th>Distribution URL</th>
16
+ <th>Reference Type</th>
17
+ <th>Label</th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <% @import_success_distributions.each_with_index do |distribution, index| %>
22
+ <tr>
23
+ <td>
24
+ <span class="badge badge-success">
25
+ <%= distribution.state_machine.current_state %>
26
+ </span>
27
+ </td>
28
+ <td><%= distribution.friendlier_id %></td>
29
+ <td><%= distribution.distribution_url %></td>
30
+ <td><%= distribution.reference_type %></td>
31
+ <td><%= distribution.label %></td>
32
+ </tr>
33
+ <% end %>
34
+ </tbody>
35
+ </table>
@@ -0,0 +1,8 @@
1
+ <h1>Editing Import Distribution</h1>
2
+
3
+ <%= simple_form_for(@import_distribution, :url => admin_import_distribution_path) do |f| %>
4
+ <%= render 'form', import_distribution: @import_distribution, f: f %>
5
+ <% end %>
6
+
7
+ <%= link_to 'Show', admin_import_distribution_path(@import_distribution) %> |
8
+ <%= link_to 'Back', admin_import_distributions_path %>
@@ -0,0 +1,58 @@
1
+ <%- @page_title = "GBL♦Admin - Import Distributions" %>
2
+
3
+ <div class="row mb-2">
4
+ <div class="col">
5
+ <h1 style="width:100%;">
6
+ Import Distributions
7
+ <%= link_to '+ New Distributions Import', new_admin_import_distribution_path, { class: 'btn btn-primary float-right' } %>
8
+ </h1>
9
+
10
+ <h6>
11
+ <span class='float-left mt-3'>
12
+ <%== pagy_info(@pagy) %>
13
+ </span>
14
+ <span class='float-right'>
15
+ <%== pagy_bootstrap_nav(@pagy) %>
16
+ </span>
17
+ </h6>
18
+
19
+ <table class="table table-striped table-bordered sortable">
20
+ <thead class="thead-dark">
21
+ <tr>
22
+ <th class="header">Name</th>
23
+ <th class="header">Filename</th>
24
+ <th class="header">Source</th>
25
+ <th class="header">Description</th>
26
+ <th class="header">Row count</th>
27
+ <th class="header">Date</th>
28
+ <th class="header" colspan="3">Actions</th>
29
+ </tr>
30
+ </thead>
31
+
32
+ <tbody>
33
+ <% @import_distributions.each do |import_distribution| %>
34
+ <tr>
35
+ <td><%= import_distribution.name %></td>
36
+ <td><%= import_distribution.filename %></td>
37
+ <td><%= import_distribution.source %></td>
38
+ <td><%= import_distribution.description %></td>
39
+ <td><%= import_distribution.row_count %></td>
40
+ <td><%= import_distribution.created_at %></td>
41
+ <td><%= link_to 'Show', admin_import_distribution_path(import_distribution) %></td>
42
+ <td><%= link_to 'Edit', edit_admin_import_distribution_path(import_distribution) %></td>
43
+ <td><%= link_to 'Destroy', admin_import_distribution_path(import_distribution), method: :delete, data: { confirm: 'Are you sure?' } %></td>
44
+ </tr>
45
+ <% end %>
46
+ </tbody>
47
+ </table>
48
+
49
+ <h6>
50
+ <span class='float-left mt-3'>
51
+ <%== pagy_info(@pagy) %>
52
+ </span>
53
+ <span class='float-right'>
54
+ <%== pagy_bootstrap_nav(@pagy) %>
55
+ </span>
56
+ </h6>
57
+ </div>
58
+ </div>
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ json.array! @import_distributions, partial: "import_distributions/import_distribution", as: :import_distribution
@@ -0,0 +1,7 @@
1
+ <h1>New Import Distribution</h1>
2
+
3
+ <%= simple_form_for(@import_distribution.becomes(ImportDistribution), url: admin_import_distributions_path) do |f| %>
4
+ <%= render 'form', import_distribution: @import_distribution, f: f %>
5
+ <% end %>
6
+
7
+ <%= link_to 'Back', admin_import_distributions_path %>
@@ -0,0 +1,121 @@
1
+ <%= link_to 'Edit Import Distribution', edit_admin_import_distribution_path(@import_distribution) %> |
2
+ <%= link_to 'Back', admin_import_distributions_path %>
3
+
4
+ <div class="row">
5
+ <div class="col-md-6">
6
+ <h1>Import Distribution</h1>
7
+ <p>
8
+ <strong>Name:</strong>
9
+ <%= @import_distribution.name %>
10
+ </p>
11
+
12
+ <p>
13
+ <strong>Filename:</strong>
14
+ <a href="<%= rails_blob_path(@import_distribution.csv_file, disposition: "attachment")%>">
15
+ <%= @import_distribution.filename %>
16
+ </a> (<%= @import_distribution.content_type %>)
17
+ </p>
18
+
19
+ <p>
20
+ <strong>State:</strong>
21
+ <%= @import_distribution.state_machine.current_state %>
22
+ </p>
23
+
24
+ <p>
25
+ <strong>Source:</strong>
26
+ <%= @import_distribution.source %>
27
+ </p>
28
+
29
+ <p>
30
+ <strong>Description:</strong>
31
+ <%= @import_distribution.description %>
32
+ </p>
33
+ </div>
34
+ <div class="col-md-3">
35
+ <div class="card">
36
+ <div class="card-header text-center">
37
+ <h3 class="h5">CSV Row Count</h3>
38
+ </div>
39
+ <ul class="list-group list-group-flush">
40
+ <li class="list-group-item text-center">
41
+ <%= @import_distribution.row_count %>
42
+ </li>
43
+ </ul>
44
+ </div>
45
+ </div>
46
+
47
+ <div class="col-md-3">
48
+ <div class="card">
49
+ <div class="card-header text-center">
50
+ <h3 class="h5">Imported Distributions</h3>
51
+ </div>
52
+ <ul class="list-group list-group-flush">
53
+ <li class="list-group-item">
54
+ <% if @import_distribution.state_machine.current_state == 'created' %>
55
+ <%= form_tag run_admin_import_distribution_path(@import_distribution), method: :patch do -%>
56
+ <%= hidden_field_tag :run, true -%>
57
+ <%= submit_tag '+ Run Distribution Import', class: 'btn btn-primary btn-block' -%>
58
+ <%- end -%>
59
+ <% end %>
60
+ <% if @import_distribution.state_machine.current_state == 'imported' %>
61
+ <table class="table table-sm table-bordered import-documents">
62
+ <thead>
63
+ <tr>
64
+ <th>State</th>
65
+ <th>Distribution Count</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr>
70
+ <td>Success</td>
71
+ <td><%= @pagy_success.count %></td>
72
+ </tr>
73
+ <tr>
74
+ <td>Failed</td>
75
+ <td><%= @pagy_failed.count %></td>
76
+ </tr>
77
+ </tbody>
78
+ <tfoot>
79
+ <tr>
80
+ <th>Total</th>
81
+ <td><%= @pagy_success.count + @pagy_failed.count %></td>
82
+ </tr>
83
+ </tfoot>
84
+ </table>
85
+ <% end %>
86
+ </li>
87
+ </ul>
88
+ </div>
89
+ </div>
90
+ </div>
91
+
92
+ <nav>
93
+ <div class="nav nav-tabs" id="import-tabs" role="tablist">
94
+ <a class="nav-item nav-link <%= @import_distribution.state_machine.current_state == 'imported' ? 'active' : '' %>" id="import-results-tab" data-toggle="tab" href="#import-results" role="tab" aria-controls="import-results"
95
+ aria-selected="true">Import Results</a>
96
+ </div>
97
+ </nav>
98
+
99
+ <div class="tab-pane fade <%= @import_distribution.state_machine.current_state == 'imported' ? 'show active' : '' %>" id="import-results" role="tabpanel" aria-labelledby="import-results-tab">
100
+ <h3 class="sr-only">Import Results</h3>
101
+
102
+ <br/>
103
+
104
+ <nav>
105
+ <div class="nav nav-tabs" id="import-state-tabs" role="tablist">
106
+ <a class="nav-item nav-link active" id="import-success-tab" data-toggle="tab" href="#import-state-success" role="tab" aria-controls="import-state-success" aria-selected="true">Success <span class="badge badge-success"><%= @pagy_success.count %></span></a>
107
+ <a class="nav-item nav-link" id="import-failed-tab" data-toggle="tab" href="#import-state-failed" role="tab" aria-controls="import-state-failed" aria-selected="false">Failed <span class="badge badge-danger"><%= @pagy_failed.count %></span> </a>
108
+ </div>
109
+ </nav>
110
+
111
+ <div class="tab-content" id="import-states">
112
+ <div class="tab-pane fade show active" id="import-state-success" role="tabpanel" aria-labelledby="import-state-success-tab">
113
+ <%= render partial: 'show_success_tab' %>
114
+ </div>
115
+
116
+ <div class="tab-pane fade" id="import-state-failed" role="tabpanel" aria-labelledby="import-state-failed-tab">
117
+ <%= render partial: 'show_failed_tab' %>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ json.partial! "import_distributions/import_distribution", import_distribution: @import_distribution
@@ -3,8 +3,8 @@
3
3
  <div class="row mb-2">
4
4
  <div class="col">
5
5
  <h1 style="width:100%;">
6
- Imports
7
- <%= link_to '+ New Import', new_admin_import_path, { class: 'btn btn-primary float-right' } %>
6
+ Import Documents
7
+ <%= link_to '+ New Documents Import', new_admin_import_path, { class: 'btn btn-primary float-right' } %>
8
8
  </h1>
9
9
 
10
10
  <h6>
@@ -46,14 +46,14 @@
46
46
  <div class="dropdown-menu" aria-labelledby="navbarDropdown">
47
47
  <h6 class="dropdown-header">Data Management</h6>
48
48
  <%= link_to "Documents", admin_documents_path, {class: 'dropdown-item'} %>
49
- <%= link_to "Imports", admin_imports_path, {class: 'dropdown-item'} %>
49
+ <%= link_to "Import Documents", admin_imports_path, {class: 'dropdown-item'} %>
50
+ <%= link_to "Import Distributions", admin_import_distributions_path, {class: 'dropdown-item'} %>
50
51
  <%= link_to "Bulk Actions", admin_bulk_actions_path, {class: 'dropdown-item'} %>
51
52
  <div class="dropdown-divider"></div>
52
53
  <h6 class="dropdown-header">Document Relationships</h6>
53
54
  <%= link_to "Access Links", admin_document_accesses_path, {class: 'dropdown-item'} %>
54
55
  <%= link_to "Assets", admin_assets_path, {class: 'dropdown-item'} %>
55
56
  <%= link_to "Distributions", admin_document_distributions_path, {class: 'dropdown-item'} %>
56
- <%= link_to "Download Links", admin_document_downloads_path, {class: 'dropdown-item'} %>
57
57
  <div class="dropdown-divider"></div>
58
58
  <h6 class="dropdown-header">Business Intelligence</h6>
59
59
  <%= link_to "Blazer", '/admin/blazer', {class: 'dropdown-item', data: { turbolinks: false }} %>
@@ -0,0 +1,3 @@
1
+ <% if document.kithe_model.document_data_dictionaries.present? %>
2
+ <%= link_to "Data Dictionary", data_dictionaries_solr_document_path(document.id), id: "dataDictionariesLink", class: "nav-link", data: { blacklight_modal: "trigger", turbo: false } %>
3
+ <% end %>
@@ -0,0 +1,44 @@
1
+ <% if document&.kithe_model&.document_data_dictionaries.present? %>
2
+ <% document.kithe_model.document_data_dictionaries.each do |dictionary| %>
3
+ <h3><%= dictionary.name %></h3>
4
+ <table class="table table-striped table-bordered">
5
+ <thead class="thead-dark">
6
+ <tr>
7
+ <th class="header">Field Name</th>
8
+ <th class="header">Field Type</th>
9
+ <th class="header">Value(s)</th>
10
+ <th class="header">Definition</th>
11
+ <th class="header">Definition Source</th>
12
+ </tr>
13
+ </thead>
14
+ <% dictionary.document_data_dictionary_entries.order(:position).each do |entry| %>
15
+ <% next if entry.parent_field_name.present? %>
16
+ <tr>
17
+ <td><%= entry.field_name %></td>
18
+ <td><%= entry.field_type %></td>
19
+ <td><%= entry.values %></td>
20
+ <td><%= entry.definition %></td>
21
+ <td><%= entry.definition_source %></td>
22
+ </tr>
23
+ <% if dictionary.document_data_dictionary_entries.where(parent_field_name: entry.field_name).present? %>
24
+ <% sub_entries = dictionary.document_data_dictionary_entries.where(parent_field_name: entry.field_name) %>
25
+ <tr>
26
+ <td colspan="5">
27
+ <table>
28
+ <% sub_entries.each do |sub_entry| %>
29
+ <tr>
30
+ <td><%= sub_entry.field_name %></td>
31
+ <td><%= sub_entry.field_type %></td>
32
+ <td><%= sub_entry.values %></td>
33
+ <td><%= sub_entry.definition %></td>
34
+ <td><%= sub_entry.definition_source %></td>
35
+ </tr>
36
+ <% end %>
37
+ </table>
38
+ </td>
39
+ </tr>
40
+ <% end %>
41
+ <% end %>
42
+ </table>
43
+ <% end %>
44
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <div class="modal-header">
2
+ <h3 class="modal-title">Data Dictionary</h3>
3
+ <button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">
4
+ <span aria-hidden="true">&times;</span>
5
+ </button>
6
+ </div>
7
+ <div class="modal-body metadata-body">
8
+ <%= render partial: 'show_gbl_admin_data_dictionaries', locals: { document: @documents.first } %>
9
+ </div>
10
+ <div class="modal-footer">
11
+ <button type="button" class="btn btn-default hide-without-js" data-dismiss="modal">Close</button>
12
+ </div>
@@ -0,0 +1,14 @@
1
+ class CreateDocumentDataDictionaries < ActiveRecord::Migration[7.2]
2
+ def change
3
+ create_table :document_data_dictionaries do |t|
4
+ t.string :friendlier_id
5
+ t.string :name
6
+ t.text :description
7
+ t.text :staff_notes
8
+ t.string :tags, limit: 4096, default: "", null: false
9
+ t.integer :position
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ class CreateDocumentDataDictionaryEntries < ActiveRecord::Migration[7.2]
2
+ def change
3
+ create_table :document_data_dictionary_entries do |t|
4
+ t.references :document_data_dictionary, null: false, foreign_key: true
5
+ t.string :friendlier_id
6
+ t.string :field_name
7
+ t.string :field_type
8
+ t.string :values
9
+ t.string :definition
10
+ t.string :definition_source
11
+ t.string :parent_field_name
12
+ t.integer :position
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,56 @@
1
+ class ImportDistributions < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :document_distributions, :import_distribution_id, :bigint
4
+
5
+ create_table :import_distributions do |t|
6
+ t.string :name
7
+ t.string :source
8
+ t.text :description
9
+ t.string :filename
10
+ t.integer :row_count
11
+ t.text :headers, default: [], array: true
12
+ t.string :encoding
13
+ t.string :content_type
14
+ t.string :extension
15
+ t.boolean :validity, default: false
16
+ t.text :validation_result
17
+
18
+ t.timestamps
19
+ end
20
+
21
+ create_table :import_distribution_transitions do |t|
22
+ t.string :to_state, null: false
23
+ t.text :metadata, default: "{}"
24
+ t.integer :sort_key, null: false
25
+ t.integer :import_distribution_id, null: false
26
+ t.boolean :most_recent, null: false
27
+ t.datetime :created_at, null: false
28
+ t.datetime :updated_at, null: false
29
+ t.index ["import_distribution_id", "most_recent"], name: "index_import_distribution_transitions_parent_most_recent", unique: true, where: "most_recent"
30
+ t.index ["import_distribution_id", "sort_key"], name: "index_import_distribution_transitions_parent_sort", unique: true
31
+ end
32
+
33
+ create_table :import_document_distributions do |t|
34
+ t.string :friendlier_id
35
+ t.string :reference_type
36
+ t.text :distribution_url
37
+ t.string :label
38
+ t.bigint :import_distribution_id, null: false
39
+ t.index ["import_distribution_id"], name: "index_import_distributions_on_import_distribution_id"
40
+
41
+ t.timestamps
42
+ end
43
+
44
+ create_table :import_document_distribution_transitions do |t|
45
+ t.string :to_state, null: false
46
+ t.text :metadata, default: "{}"
47
+ t.integer :sort_key, null: false
48
+ t.integer :import_document_distribution_id, null: false
49
+ t.boolean :most_recent, null: false
50
+ t.datetime :created_at, null: false
51
+ t.datetime :updated_at, null: false
52
+ t.index ["import_document_distribution_id", "most_recent"], name: "index_import_doc_distribution_transitions_parent_most_recent", unique: true, where: "most_recent"
53
+ t.index ["import_document_distribution_id", "sort_key"], name: "index_import_doc_distribution_transitions_parent_sort", unique: true
54
+ end
55
+ end
56
+ end
@@ -129,6 +129,12 @@ module GeoblacklightAdmin
129
129
  patch :run, on: :member
130
130
  end
131
131
 
132
+ # Import Distributions
133
+ resources :import_distributions do
134
+ resources :import_document_distributions, only: [:show]
135
+ patch :run, on: :member
136
+ end
137
+
132
138
  # Elements
133
139
  resources :elements do
134
140
  post :sort, on: :collection
@@ -205,6 +211,25 @@ module GeoblacklightAdmin
205
211
  end
206
212
  end
207
213
 
214
+ # Data Dictionaries
215
+ resources :document_data_dictionaries, path: "data_dictionaries" do
216
+ collection do
217
+ get "import"
218
+ post "import"
219
+
220
+ get "destroy_all"
221
+ post "destroy_all"
222
+ end
223
+
224
+ resources :document_data_dictionary_entries, path: "entries" do
225
+ collection do
226
+ post "sort"
227
+ get "destroy_all"
228
+ post "destroy_all"
229
+ end
230
+ end
231
+ end
232
+
208
233
  # DocumentDownloads
209
234
  resources :document_downloads, path: "downloads" do
210
235
  collection do
@@ -222,9 +247,6 @@ module GeoblacklightAdmin
222
247
  get "display_attach_form"
223
248
  post "attach_files"
224
249
 
225
- get "import"
226
- post "import"
227
-
228
250
  get "destroy_all"
229
251
  post "destroy_all"
230
252
  end
@@ -310,6 +332,16 @@ module GeoblacklightAdmin
310
332
  inject_into_file "config/routes.rb", gbl_admin_routes, before: /^end/
311
333
  end
312
334
 
335
+ def add_gbl_admin_data_dictionariesable
336
+ inject_into_file "config/routes.rb", before: /^end/ do
337
+ "\n concern :gbl_admin_data_dictionariesable, GeoblacklightAdmin::Routes::DataDictionariesable.new
338
+ resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do
339
+ concerns :gbl_admin_data_dictionariesable
340
+ end
341
+ \n\n"
342
+ end
343
+ end
344
+
313
345
  def set_development_mailer_host
314
346
  mailer_host = "\n config.action_mailer.default_url_options = { :host => 'localhost:3000' }\n"
315
347
  inject_into_file "config/environments/development.rb", mailer_host, after: "config.action_mailer.perform_caching = false"
@@ -386,9 +418,32 @@ module GeoblacklightAdmin
386
418
  end
387
419
  end
388
420
 
421
+ def add_show_gbl_admin_data_dictionaries
422
+ inject_into_file "app/controllers/catalog_controller.rb", after: "# Custom tools for GeoBlacklight" do
423
+ "\n config.add_show_tools_partial :gbl_admin_data_dictionaries, partial: 'gbl_admin_data_dictionaries'"
424
+ end
425
+ end
426
+
427
+ def add_data_dictionaries_action
428
+ inject_into_file "app/controllers/catalog_controller.rb", before: "\nend" do
429
+ "\n def data_dictionaries
430
+ \n @response, @documents = action_documents
431
+ \n respond_to do |format|
432
+ \n format.html do
433
+ \n return render layout: false if request.xhr?
434
+ \n # Otherwise draw the full page
435
+ \n end
436
+ \n end
437
+ \n end"
438
+ end
439
+ end
440
+
389
441
  def add_kithe_model_to_solr_document
390
442
  inject_into_file "app/models/solr_document.rb", after: "include Geoblacklight::SolrDocument" do
391
- "\n\nattr_accessor :model"
443
+ "\n\nattr_accessor :model
444
+ \n def kithe_model
445
+ Kithe::Model.find_by_friendlier_id(self.id)
446
+ end\n\n"
392
447
  end
393
448
  end
394
449
 
@@ -420,6 +475,8 @@ module GeoblacklightAdmin
420
475
  # Add test fixture files - Necessary for import background job tests
421
476
  def add_test_fixture_files
422
477
  copy_file "btaa_sample_records.csv", "test/fixtures/files/btaa_sample_records.csv", force: true
478
+ copy_file "btaa_sample_document_distributions.csv", "test/fixtures/files/btaa_sample_document_distributions.csv", force: true
479
+ copy_file "btaa_sample_document_data_dictionary_entries.csv", "test/fixtures/files/btaa_sample_document_data_dictionary_entries.csv", force: true
423
480
  end
424
481
 
425
482
  # Run bundle with vite install
@@ -0,0 +1,9 @@
1
+ friendlier_id,field_name,field_type,values,definition,definition_source,parent_field_name
2
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,AREA,Real,6,Area of polygon,Software generated,
3
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,PERIMETER,Real,6,Perimeter of polygon,Software generated,
4
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,NAME_U,String,10,County names in upper case letters,USGS 7.5-minute quadrangles,
5
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,NAME_L,String,10,County names in upper and lower case letters,IGS standard,
6
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,NCAPC,Integer,2,Numeric county alphabetic prefix code,Indiana Bureau of Motor Vehicles,
7
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable A,String,A,Definition,Definition source,PERIMETER
8
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable B,String,B,Definition,Definition Source,PERIMETER
9
+ 35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable C,String,C,Definition,Definition Source,PERIMETER
@@ -0,0 +1,17 @@
1
+ friendlier_id,reference_type,distribution_url,label
2
+ 82784459-acde-42ed-b615-d8300577110e,documentation_external,https://gisdata.mn.gov/dataset/82784459-acde-42ed-b615-d8300577110e,
3
+ 82784459-acde-42ed-b615-d8300577110e,download,https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dnr/water_lake_superior_basin/fgdb_water_lake_superior_basin.zip,Geodatabase
4
+ 82784459-acde-42ed-b615-d8300577110e,download,https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dnr/water_lake_superior_basin/gpkg_water_lake_superior_basin.zip,GeoPackage
5
+ 82784459-acde-42ed-b615-d8300577110e,download,https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dnr/water_lake_superior_basin/shp_water_lake_superior_basin.zip,Shapefile
6
+ 82784459-acde-42ed-b615-d8300577110e,full_layer_description,https://gisdata.mn.gov/dataset/82784459-acde-42ed-b615-d8300577110e,Landing Page
7
+ 82784459-acde-42ed-b615-d8300577110e,image,https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dnr/water_lake_superior_basin/metadata/preview.jpg,Static Preview - Sample Image
8
+ 82784459-acde-42ed-b615-d8300577110e,metadata_html,https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dnr/water_lake_superior_basin/metadata/metadata.html,Full Metadata Record
9
+ p16022coll230:1933,documentation_external,https://umedia.lib.umn.edu/item/p16022coll230:1933,
10
+ p16022coll230:1933,iiif_image,https://cdm16022.contentdm.oclc.org/digital/iiif/p16022coll230/1933/info.json,
11
+ p16022coll230:1933,iiif_manifest,https://cdm16022.contentdm.oclc.org/iiif/info/p16022coll230/1933/manifest.json,
12
+ p16022coll230:321,documentation_external,https://umedia.lib.umn.edu/item/p16022coll230:321,
13
+ p16022coll230:321,iiif_image,https://cdm16022.contentdm.oclc.org/digital/iiif/p16022coll230/321/info.json,
14
+ p16022coll230:321,iiif_manifest,https://cdm16022.contentdm.oclc.org/iiif/info/p16022coll230/321/manifest.json,
15
+ p16022coll230:4115,documentation_external,https://umedia.lib.umn.edu/item/p16022coll230:4115,
16
+ p16022coll230:4115,iiif_image,https://cdm16022.contentdm.oclc.org/digital/iiif/p16022coll230/4115/info.json,
17
+ p16022coll230:4115,iiif_manifest,https://cdm16022.contentdm.oclc.org/iiif/info/p16022coll230/4115/manifest.json,
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GeoblacklightAdmin
4
+ module Routes
5
+ class DataDictionariesable
6
+ def initialize(defaults = {})
7
+ @defaults = defaults
8
+ end
9
+
10
+ def call(mapper, _options = {})
11
+ mapper.member do
12
+ mapper.get "data_dictionaries"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GeoblacklightAdmin
4
- VERSION = "0.6.3"
4
+ VERSION = "0.7.0"
5
5
  end