geoblacklight_admin 0.4.1 → 0.5.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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -55
  3. data/Rakefile +3 -0
  4. data/app/assets/javascripts/geoblacklight_admin/chosen.js +7 -3
  5. data/app/assets/javascripts/geoblacklight_admin/datepicker.js +2 -2
  6. data/app/assets/javascripts/geoblacklight_admin/inputmask.js +2 -2
  7. data/app/assets/javascripts/geoblacklight_admin/truncate.js +2 -2
  8. data/app/assets/javascripts/geoblacklight_admin.js +1 -4
  9. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +3 -1
  10. data/app/assets/stylesheets/geoblacklight_admin/modules/_images.scss +4 -0
  11. data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +4 -0
  12. data/app/assets/stylesheets/geoblacklight_admin/modules/_results.scss +5 -0
  13. data/app/controllers/admin/admin_controller.rb +1 -1
  14. data/app/controllers/admin/advanced_search_controller.rb +0 -1
  15. data/app/controllers/admin/assets_controller.rb +142 -0
  16. data/app/controllers/admin/bulk_actions_controller.rb +1 -1
  17. data/app/controllers/admin/document_accesses_controller.rb +3 -3
  18. data/app/controllers/admin/document_assets_controller.rb +33 -23
  19. data/app/controllers/admin/documents_controller.rb +6 -2
  20. data/app/controllers/admin/ids_controller.rb +0 -1
  21. data/app/controllers/admin/imports_controller.rb +2 -2
  22. data/app/helpers/asset_helper.rb +8 -0
  23. data/app/helpers/document_helper.rb +4 -0
  24. data/app/helpers/geoblacklight_admin_helper.rb +11 -1
  25. data/{lib/generators/geoblacklight_admin/templates → app}/javascript/controllers/results_controller.js +38 -0
  26. data/app/javascript/entrypoints/engine.js +8 -0
  27. data/app/javascript/index.js +8 -0
  28. data/app/jobs/bulk_action_revert_document_job.rb +2 -2
  29. data/app/jobs/bulk_action_run_document_job.rb +5 -1
  30. data/app/jobs/bulk_action_run_job.rb +11 -1
  31. data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +17 -0
  32. data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
  33. data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +19 -0
  34. data/app/jobs/geoblacklight_admin/store_image_job.rb +21 -2
  35. data/app/models/asset.rb +38 -0
  36. data/app/models/blacklight_api.rb +2 -2
  37. data/app/models/blacklight_api_facets.rb +1 -1
  38. data/app/models/blacklight_api_ids.rb +2 -2
  39. data/app/models/bulk_action_document_state_machine.rb +2 -4
  40. data/app/models/bulk_action_state_machine.rb +3 -3
  41. data/app/models/bulk_actions/change_publication_state.rb +10 -0
  42. data/app/models/document/reference.rb +24 -0
  43. data/app/models/document.rb +122 -11
  44. data/app/models/document_thumbnail_state_machine.rb +22 -0
  45. data/app/models/document_thumbnail_transition.rb +26 -0
  46. data/app/models/element.rb +1 -1
  47. data/app/models/geoblacklight_admin/field_mappings_btaa_aardvark.rb +7 -1
  48. data/app/models/geoblacklight_admin/schema.rb +37 -1
  49. data/app/models/geoblacklight_admin/solr_utils.rb +87 -0
  50. data/app/models/kithe/vips_cli_image_to_png.rb +114 -0
  51. data/app/services/geoblacklight_admin/image_service/iiif.rb +2 -2
  52. data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +111 -0
  53. data/app/services/geoblacklight_admin/image_service/tms.rb +50 -0
  54. data/app/services/geoblacklight_admin/image_service/wms.rb +1 -4
  55. data/app/services/geoblacklight_admin/image_service.rb +16 -40
  56. data/app/services/geoblacklight_admin/item_viewer.rb +1 -1
  57. data/app/uploaders/asset_uploader.rb +6 -11
  58. data/app/views/admin/assets/_form.html.erb +19 -0
  59. data/app/views/admin/assets/display_attach_form.html.erb +39 -0
  60. data/app/views/admin/assets/edit.html.erb +9 -0
  61. data/app/views/admin/assets/index.html.erb +75 -0
  62. data/app/views/admin/assets/show.html.erb +100 -0
  63. data/app/views/admin/bulk_actions/index.html.erb +50 -48
  64. data/app/views/admin/bulk_actions/show.html.erb +3 -2
  65. data/app/views/admin/document_accesses/index.html.erb +68 -64
  66. data/app/views/admin/document_assets/_form.html.erb +17 -0
  67. data/app/views/admin/document_assets/display_attach_form.html.erb +4 -9
  68. data/app/views/admin/document_assets/edit.html.erb +5 -0
  69. data/app/views/admin/document_assets/index.html.erb +88 -72
  70. data/app/views/admin/document_downloads/index.html.erb +64 -62
  71. data/app/views/admin/documents/_document.html.erb +37 -16
  72. data/app/views/admin/documents/_form.html.erb +21 -6
  73. data/app/views/admin/documents/_form_nav.html.erb +12 -3
  74. data/app/views/admin/documents/_result_selected_options.html.erb +6 -1
  75. data/app/views/admin/documents/admin.html.erb +210 -0
  76. data/app/views/admin/documents/index.html.erb +10 -1
  77. data/app/views/admin/documents/versions.html.erb +3 -3
  78. data/app/views/admin/elements/index.html.erb +55 -54
  79. data/app/views/admin/form_elements/index.html.erb +38 -35
  80. data/app/views/admin/imports/index.html.erb +52 -50
  81. data/app/views/admin/layouts/application.html.erb +7 -4
  82. data/app/views/admin/shared/_js_behaviors.html.erb +6 -3
  83. data/app/views/admin/shared/_navbar.html.erb +11 -8
  84. data/config/locales/documents.en.yml +6 -0
  85. data/config/routes.rb +1 -0
  86. data/config/vite.json +14 -0
  87. data/db/migrate/20240619171628_create_document_thumbnail_statesman.rb +18 -0
  88. data/lib/generators/geoblacklight_admin/config_generator.rb +63 -15
  89. data/lib/generators/geoblacklight_admin/install_generator.rb +1 -0
  90. data/lib/generators/geoblacklight_admin/templates/api_controller.rb +0 -2
  91. data/lib/generators/geoblacklight_admin/templates/base.html.erb +53 -0
  92. data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +1 -0
  93. data/lib/generators/geoblacklight_admin/templates/config/settings.yml +15 -1
  94. data/lib/generators/geoblacklight_admin/templates/config/vite.json +16 -0
  95. data/lib/generators/geoblacklight_admin/templates/frontend/entrypoints/application.js +30 -0
  96. data/lib/generators/geoblacklight_admin/templates/package-test.json +10 -0
  97. data/lib/generators/geoblacklight_admin/templates/package.json +5 -29
  98. data/lib/generators/geoblacklight_admin/templates/vite.config.ts +8 -0
  99. data/lib/geoblacklight_admin/engine.rb +1 -0
  100. data/lib/geoblacklight_admin/rake_task.rb +5 -0
  101. data/lib/geoblacklight_admin/tasks/images.rake +33 -0
  102. data/lib/geoblacklight_admin/tasks/solr.rake +11 -0
  103. data/lib/geoblacklight_admin/version.rb +1 -1
  104. metadata +75 -19
  105. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/application_controller.js +0 -17
  106. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/document_controller.js +0 -26
  107. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/index.js +0 -10
  108. data/lib/tasks/geoblacklight_admin/images.rake +0 -30
  109. data/lib/tasks/geoblacklight_admin.rake +0 -213
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5514d1f3dfc7ba946eb58f955e9c3cfc76b073aeafcc86d0f62e3807bf013aba
4
- data.tar.gz: 34c448fd3cb662cabf2f3f6cfd2f82b3b5166f681d7e4c0c3ef542ecad575893
3
+ metadata.gz: 1f4725f14826124fd7393a3b7cbb37baa28b606d15cc1381186a122ef2f0a199
4
+ data.tar.gz: e7ba31886ae77990e504f108c8e5f9004853ee2f86266b5203490ca022dfc7ca
5
5
  SHA512:
6
- metadata.gz: 2dcfb661be04c25e22a1941471c06b1dabcf6ee14744fe2faf815172e32b2a00b06639a808fb35f5bb05fef8ef8b0ddde038c8a786b45d38f5aff3aa856c648a
7
- data.tar.gz: 38a23540721636da43ee97a2068f10ed127a85b380ecb6d84f1c1ee0045848295b100d781f48762b0204d738530cccdfbd3578ef1927ff87bbe8f6c55349c61a
6
+ metadata.gz: ecc2b6ce1188088007009498183016919b3b99a471a7b2746d8ec1bac4a5c0cf0aa221c38da2997fd223be68fa5a1275b3470938376131f90e92953409e8a0c2
7
+ data.tar.gz: 4a56d0949e659f6faf0595a56bed8e057ee2e194b651d0eb3957d0cff37419b441a799e620fe64af25a41a193fc1cbe715c25766b829a4404856260bf35ee1a1
data/README.md CHANGED
@@ -8,9 +8,10 @@ GeoBlacklight Admin is a [GeoBlacklight](https://github.com/geoblacklight/geobla
8
8
 
9
9
  ## Requirements
10
10
 
11
- * Rails v6.1 (not v7 yet)
11
+ * Rails v7
12
12
  * Blacklight v7 (not v8)
13
- * GeoBlacklight v4 (not v3)
13
+ * GeoBlacklight v4.4+ (Vite.js)
14
+ * @geoblacklight/frontend v4 (NPM package)
14
15
  * Solr v8.4+
15
16
  * PostgreSQL (not MySQL-based DBs)
16
17
  * Redis (for Sidekiq)
@@ -27,10 +28,10 @@ You need a PostgreSQL database to use this project.
27
28
 
28
29
  ### Install Template
29
30
 
30
- Use Ruby v3.2 and Rails v6.1.7.4 to bootstrap a new GeoBlacklight + GBL Admin application using the template script:
31
+ Use Ruby v3.3 and Rails v7.0.8.1 to bootstrap a new GeoBlacklight + GBL Admin application using the template script:
31
32
 
32
33
  ```bash
33
- rails _6.1.7.4_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/template.rb
34
+ rails _7.0.8.1_ new gbl_admin -m https://raw.githubusercontent.com/geobtaa/geoblacklight_admin/develop/template.rb
34
35
  cd gbl_admin
35
36
  bundle exec rake gbl_admin:server
36
37
  ```
@@ -47,62 +48,16 @@ You have now generated the .internal_test_app and populated the Elements / FormE
47
48
 
48
49
  -----
49
50
 
50
- ## Run Project for Local Development
51
- Drop and recreate databases (or engine_cart:generate will fail)
51
+ ## Contributing
52
52
 
53
- ### Drop/Create application PG database
54
- ```bash
55
- psql postgres
56
- DROP DATABASE geoblacklight_development;
57
- CREATE DATABASE geoblacklight_development;
58
- ```
59
-
60
- ```bash
61
- cd project root
62
- bundle install
63
- bundle exec rake engine_cart:regenerate
64
- ```
53
+ For Developer documentation see [doc/developer.md](./docs/development.md)
65
54
 
66
- ### Run Solr
67
- ```bash
68
- bin/rails geoblacklight:solr
69
- ```
55
+ ## License
56
+ The gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
70
57
 
71
- ### Run App
72
- ```bash
73
- cd .internal_test_app
74
- bundle exec rails server
75
- ```
76
-
77
- ### Lint App
78
- ```bash
79
- standardrb .
80
- standardrb --fix
81
- ```
82
-
83
- ### Test App
84
- ```bash
85
- RAILS_ENV=test bundle exec rails test
86
- ```
87
58
 
88
59
  ## TODOs
89
- * ~~SolrWrapper - Add persist option~~
90
- * ~~BlacklightApi returns not auth'd message (not requiring auth for now (not sensitive data))~~
91
- * ~~Facet links need /admin nesting~~
92
- * ~~Imports#new -- undefined method `imports_path'~~
93
- * ~~Elements#index -- undefined method `element_path'~~
94
- * ~~Imports#new -- cannot upload files~~
95
- * ~~Import#run -- doesn't fire~~
96
- * ~~Documents - JS actions not working~~
97
- * ~~GBL needs to honor publication state~~
98
- * ~~Add GBL Admin link to nav~~
99
- * ~~Routes - Get devise user~~
100
- * ~~No route matches [GET] "/users/sign_out"~~
101
- * ~~Bookmarks need to be Admin::Bookmarks~~
102
- * ~~GitHub Actions / CI integration~~
103
- * ~~Port the GEOMG test suite~~
104
- * ~~Project gem dependency injection redundancy...~~
60
+ * ~~Send GBLADMIN JavaScript pack to NPM like Blacklight~~
105
61
  * DRY up Engine routing
106
62
  * Remove legacy GEOMG / B1G everywhere...
107
- * Send GBLADMIN JavaScript pack to NPM like Blacklight
108
63
  * Likely some more polish to be uncovered...
data/Rakefile CHANGED
@@ -25,6 +25,8 @@ require "solr_wrapper/rake_task"
25
25
  require "engine_cart/rake_task"
26
26
  require "geoblacklight_admin/version"
27
27
  require "rake/testtask"
28
+ require "geoblacklight_admin/rake_task"
29
+ require "simple_form"
28
30
 
29
31
  # Searches for files ending in _test.rb in the test directory
30
32
  Rake::TestTask.new do |t|
@@ -40,6 +42,7 @@ task default: :test
40
42
  desc "Run test suite"
41
43
  task ci: ["geoblacklight:generate"] do
42
44
  within_test_app do
45
+ require "simple_form"
43
46
  system "RAILS_ENV=test bin/rails db:migrate"
44
47
  system "RAILS_ENV=test rake db:seed"
45
48
  system "RAILS_ENV=test rails webpacker:compile"
@@ -1,4 +1,8 @@
1
- // jQuery Ready
2
- $(document).on('ready turbolinks:load', function() {
3
- $('.chosen-select').chosen();
1
+ // VanillaJS Ready
2
+ document.addEventListener('DOMContentLoaded', function() {
3
+ var elements = document.querySelectorAll('.chosen-select');
4
+ Array.prototype.forEach.call(elements, function(el, i){
5
+ console.log("Vanilla JS Chosen Select");
6
+ $('.chosen-select').chosen();
7
+ });
4
8
  });
@@ -1,5 +1,5 @@
1
- // jQuery Ready
2
- $(document).on('ready turbolinks:load', function() {
1
+ // VanillaJS Ready
2
+ document.addEventListener('DOMContentLoaded', function() {
3
3
  // Datepickers - YYYY-MM-DD
4
4
  if($("input[data-js='datepicker']").length > 0) {
5
5
  $("input[data-js='datepicker']").datepicker({
@@ -1,4 +1,4 @@
1
- // jQuery Ready
2
- $(document).on('ready turbolinks:load', function() {
1
+ // VanillaJS Ready
2
+ document.addEventListener('DOMContentLoaded', function() {
3
3
  $("input[data-inputmask]").inputmask();
4
4
  });
@@ -1,4 +1,4 @@
1
- // jQuery Ready
2
- $(document).on('ready turbolinks:load', function() {
1
+ // VanillaJS Ready
2
+ document.addEventListener('DOMContentLoaded', function() {
3
3
  $('.js-truncate').shave(32);
4
4
  });
@@ -11,12 +11,9 @@
11
11
  // about supported directives.
12
12
  //
13
13
 
14
- //= require jquery3
15
- //= require rails-ujs
14
+ // VENDOR
16
15
  //= require @nathanvda/cocoon/cocoon.js
17
16
  //= require chosen-jquery/lib/chosen.jquery.js
18
-
19
- // VENDOR
20
17
  //= require bootstrap-datepicker/js/bootstrap-datepicker.js
21
18
  //= require inputmask/dist/jquery.inputmask
22
19
  //= require shave/dist/jquery.shave.js
@@ -25,7 +25,9 @@
25
25
  @import "modules/elements";
26
26
  @import "modules/forms";
27
27
  @import "modules/icons";
28
+ @import "modules/images";
28
29
  @import "modules/nav";
30
+ @import "modules/results";
29
31
  @import "modules/tables";
30
32
  @import "modules/toasts";
31
33
  @import "modules/visibility";
@@ -43,7 +45,7 @@ footer.gbl-admin {
43
45
  box-shadow: inset 0 0 0 50vw rgba(0, 0, 0, 0.8);
44
46
  }
45
47
 
46
- div.container-fluid {
48
+ main.container-fluid {
47
49
  margin-top: 5rem;
48
50
  }
49
51
 
@@ -0,0 +1,4 @@
1
+ .thumbnail {
2
+ max-height: 65px;
3
+ max-width: 65px;
4
+ }
@@ -7,3 +7,7 @@
7
7
  .make-me-sticky {
8
8
  top:8rem;
9
9
  }
10
+
11
+ .navbar a {
12
+ text-decoration: none;
13
+ }
@@ -0,0 +1,5 @@
1
+ ol#results {
2
+ li {
3
+ margin-bottom: 1rem;
4
+ }
5
+ }
@@ -3,7 +3,7 @@
3
3
  module Admin
4
4
  class AdminController < ApplicationController
5
5
  include Devise::Controllers::Helpers
6
- include Pagy::Backend
6
+ include ::Pagy::Backend
7
7
  layout "admin/layouts/application"
8
8
 
9
9
  before_action :authenticate_admin!
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "blacklight/catalog"
4
3
  require "blacklight_range_limit/controller_override"
5
4
 
6
5
  module Admin
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Admin::AssetsController
4
+ module Admin
5
+ class AssetsController < Admin::AdminController
6
+ before_action :set_asset, only: %i[show edit update destroy]
7
+
8
+ # GET /assets or /assets.json
9
+ def index
10
+ scope = Asset
11
+ search_query = params[:q].strip if params[:q].present?
12
+
13
+ # Basic search functionality
14
+ if search_query.present?
15
+ scope = if date_check?(search_query)
16
+ Asset.where("created_at BETWEEN ? AND ?", search_query.to_date.beginning_of_day, search_query.to_date.end_of_day)
17
+ else
18
+ scope.where(id: search_query).or(
19
+ Asset.where(friendlier_id: search_query)
20
+ ).or(
21
+ Asset.where("title like ?", "%" + Asset.sanitize_sql_like(search_query) + "%")
22
+ ).or(
23
+ Asset.where(parent_id: search_query)
24
+ )
25
+ end
26
+ end
27
+
28
+ @pagy, @assets = pagy(scope, items: 20)
29
+ end
30
+
31
+ # GET /assets/1 or /assets/1.json
32
+ def show
33
+ end
34
+
35
+ # GET /assets/new
36
+ def new
37
+ @asset = Asset.new
38
+ end
39
+
40
+ # GET /assets/1/edit
41
+ def edit
42
+ end
43
+
44
+ # POST /assets or /assets.json
45
+ def create
46
+ @asset = Asset.new(asset_params)
47
+
48
+ respond_to do |format|
49
+ if @asset.save
50
+ format.html { redirect_to admin_asset_url(@asset), notice: "Asset was successfully created." }
51
+ format.json { render :show, status: :created, location: @asset }
52
+ else
53
+ format.html { render :new, status: :unprocessable_entity }
54
+ format.json { render json: @asset.errors, status: :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PATCH/PUT /assets/1 or /assets/1.json
60
+ def update
61
+ respond_to do |format|
62
+ if @asset.update(asset_params)
63
+ format.html { redirect_to admin_asset_url(@asset.id), notice: "Asset was successfully updated." }
64
+ format.json { render :show, status: :ok, location: @asset }
65
+ else
66
+ format.html { render :edit, status: :unprocessable_entity }
67
+ format.json { render json: @asset.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /assets/1 or /assets/1.json
73
+ def destroy
74
+ @asset.destroy
75
+
76
+ respond_to do |format|
77
+ format.html { redirect_to admin_assets_url, notice: "Asset was successfully destroyed." }
78
+ format.json { head :no_content }
79
+ end
80
+ end
81
+
82
+ # /assets/display_attach_form
83
+ def display_attach_form
84
+ end
85
+
86
+ # Receives json hashes for direct uploaded files in params[:files],
87
+ # and id in params[:id] (friendlier_id)
88
+ # creates filesets for them and attach.
89
+ #
90
+ # POST /assets/ingest
91
+ def attach_files
92
+ # @parent = Document.find_by_friendlier_id!(params[:id])
93
+
94
+ # current_position = @parent.members.maximum(:position) || 0
95
+
96
+ files_params = (params[:cached_files] || [])
97
+ .collect { |s| JSON.parse(s) }
98
+ .sort_by { |h| h&.dig("metadata", "filename") }
99
+
100
+ files_params.each do |file_data|
101
+ asset = Asset.new
102
+
103
+ # if derivative_storage_type = params.dig(:storage_type_for, file_data["id"])
104
+ # asset.derivative_storage_type = derivative_storage_type
105
+ # end
106
+
107
+ # asset.position = (current_position += 1)
108
+ # asset.parent_id = @parent.id
109
+ asset.file = file_data
110
+ asset.title = (asset.file&.original_filename || "Untitled")
111
+ asset.save!
112
+ end
113
+
114
+ # @parent.update(representative: @parent.members.order(:position).first) if @parent.representative_id.nil?
115
+
116
+ redirect_to admin_assets_url, notice: "Files attached successfully."
117
+ end
118
+
119
+ def sort
120
+ Asset.sort_assets(params[:id_list])
121
+ render body: nil
122
+ end
123
+
124
+ private
125
+
126
+ # Use callbacks to share common setup or constraints between actions.
127
+ def set_asset
128
+ @asset = Asset.find(params[:id])
129
+ end
130
+
131
+ # Only allow a list of trusted parameters through.
132
+ def asset_params
133
+ params.require(:asset)
134
+ end
135
+
136
+ def date_check?(val)
137
+ val.to_date
138
+ rescue Date::Error
139
+ false
140
+ end
141
+ end
142
+ end
@@ -73,7 +73,7 @@ module Admin
73
73
 
74
74
  def run
75
75
  @bulk_action.run!
76
- @bulk_action.state_machine.transition_to!(:queued)
76
+ # @bulk_action.state_machine.transition_to!(:queued)
77
77
  redirect_to admin_bulk_action_url(@bulk_action), notice: "Bulk action is running. Check back soon for results."
78
78
  end
79
79
 
@@ -84,12 +84,12 @@ module Admin
84
84
 
85
85
  respond_to do |format|
86
86
  if DocumentAccess.destroy_all(params.dig(:document_access, :assets, :file))
87
- format.html { redirect_to document_accesses_path, notice: "Document Access Links were created destroyed." }
87
+ format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links were created destroyed." }
88
88
  else
89
- format.html { redirect_to document_accesses_path, notice: "Document Access Links could not be destroyed." }
89
+ format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links could not be destroyed." }
90
90
  end
91
91
  rescue => e
92
- format.html { redirect_to document_accesses_path, notice: "Document Access Links could not be destroyed. #{e}" }
92
+ format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links could not be destroyed. #{e}" }
93
93
  end
94
94
  end
95
95
 
@@ -4,9 +4,10 @@
4
4
  module Admin
5
5
  class DocumentAssetsController < Admin::AdminController
6
6
  before_action :set_document
7
+ before_action :set_document_asset, only: %i[show edit update destroy]
7
8
 
8
9
  def index
9
- scope = Kithe::Asset
10
+ scope = Asset
10
11
 
11
12
  # simple simple search on a few simple attributes with OR combo.
12
13
  if params[:document_id].present?
@@ -21,8 +22,7 @@ module Admin
21
22
  end
22
23
 
23
24
  def show
24
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
25
- authorize! :read, @asset
25
+ @asset = Asset.find_by_friendlier_id!(params[:id])
26
26
 
27
27
  return unless @asset.stored?
28
28
 
@@ -32,34 +32,31 @@ module Admin
32
32
  end
33
33
 
34
34
  def edit
35
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
36
- authorize! :update, @asset
37
35
  end
38
36
 
39
37
  # PATCH/PUT /works/1
40
38
  # PATCH/PUT /works/1.json
41
39
  def update
42
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
43
- authorize! :update, @asset
40
+ @document_asset = DocumentAsset.find_by_friendlier_id!(params[:id])
44
41
 
45
42
  respond_to do |format|
46
- if @asset.update(asset_params)
47
- format.html { redirect_to admin_asset_url(@asset), notice: "Asset was successfully updated." }
48
- format.json { render :show, status: :ok, location: @asset }
43
+ if @document_asset.update(document_asset_params)
44
+ format.html { redirect_to admin_document_document_assets_path(@document, @document_asset.parent), notice: "Asset was successfully updated." }
45
+ format.json { render :show, status: :ok, location: @document_asset }
49
46
  else
50
47
  format.html { render :edit }
51
- format.json { render json: @asset.errors, status: :unprocessable_entity }
48
+ format.json { render json: @document_asset.errors, status: :unprocessable_entity }
52
49
  end
53
50
  end
54
51
  end
55
52
 
56
53
  def destroy
57
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
54
+ @asset = Asset.find_by_friendlier_id!(params[:id])
58
55
  @asset.destroy
59
56
 
60
57
  respond_to do |format|
61
58
  format.html do
62
- redirect_to document_document_assets_path(@document),
59
+ redirect_to admin_document_document_assets_path(@document),
63
60
  notice: "Asset '#{@asset.title}' was successfully destroyed."
64
61
  end
65
62
  format.json { head :no_content }
@@ -67,7 +64,7 @@ module Admin
67
64
  end
68
65
 
69
66
  def check_fixity
70
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:asset_id])
67
+ @asset = Asset.find_by_friendlier_id!(params[:asset_id])
71
68
  SingleAssetCheckerJob.perform_later(@asset)
72
69
  redirect_to admin_asset_url(@asset), notice: "This file will be checked shortly."
73
70
  end
@@ -95,12 +92,16 @@ module Admin
95
92
  .sort_by { |h| h&.dig("metadata", "filename") }
96
93
 
97
94
  files_params.each do |file_data|
98
- asset = Kithe::Asset.new
95
+ asset = Asset.new
99
96
 
100
97
  # if derivative_storage_type = params.dig(:storage_type_for, file_data["id"])
101
98
  # asset.derivative_storage_type = derivative_storage_type
102
99
  # end
103
100
 
101
+ # References
102
+ references = params.dig(:dct_references_for, file_data["id"])
103
+ asset.dct_references_uri_key = references if references
104
+
104
105
  asset.position = (current_position += 1)
105
106
  asset.parent_id = @parent.id
106
107
  asset.file = file_data
@@ -110,11 +111,11 @@ module Admin
110
111
 
111
112
  @parent.update(representative: @parent.members.order(:position).first) if @parent.representative_id.nil?
112
113
 
113
- redirect_to admin_document_path(@parent.friendlier_id, anchor: "nav-members")
114
+ redirect_to admin_document_document_assets_path(@parent.friendlier_id, anchor: "nav-members")
114
115
  end
115
116
 
116
117
  def convert_to_child_work
117
- @asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
118
+ @asset = Asset.find_by_friendlier_id!(params[:id])
118
119
 
119
120
  parent = @asset.parent
120
121
 
@@ -184,18 +185,27 @@ module Admin
184
185
 
185
186
  private
186
187
 
188
+ def asset_params
189
+ allowed_params = [:title, :derivative_storage_type, :alt_text, :caption,
190
+ :transcription, :english_translation,
191
+ :role, {admin_note_attributes: []}, :dct_references_for]
192
+ allowed_params << :published if can?(:publish, @asset)
193
+ params.require(:asset).permit(*allowed_params)
194
+ end
195
+
187
196
  def set_document
188
197
  return unless params[:document_id] # If not nested
189
198
 
190
199
  @document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:document_id])
191
200
  end
192
201
 
193
- def asset_params
194
- allowed_params = [:title, :derivative_storage_type, :alt_text, :caption,
195
- :transcription, :english_translation,
196
- :role, {admin_note_attributes: []}]
197
- allowed_params << :published if can?(:publish, @asset)
198
- params.require(:asset).permit(*allowed_params)
202
+ def set_document_asset
203
+ @document_asset = DocumentAsset.find_by_friendlier_id(params[:id])
204
+ end
205
+
206
+ # Only allow a list of trusted parameters through.
207
+ def document_asset_params
208
+ params.require(:asset).permit(:title, :label, :dct_references_uri_key)
199
209
  end
200
210
  end
201
211
  end
@@ -5,7 +5,7 @@ module Admin
5
5
  class DocumentsController < Admin::AdminController
6
6
  ActionController::Parameters.permit_all_parameters = true
7
7
  before_action :set_document,
8
- only: %i[show edit update destroy versions]
8
+ only: %i[show edit update destroy admin versions]
9
9
 
10
10
  # GET /documents
11
11
  # GET /documents.json
@@ -134,6 +134,10 @@ module Admin
134
134
  def edit
135
135
  end
136
136
 
137
+ # GET /documents/1/admin
138
+ def admin
139
+ end
140
+
137
141
  # GET /documents/1/versions
138
142
  def versions
139
143
  end
@@ -145,7 +149,7 @@ module Admin
145
149
  @document.friendlier_id = @document.send(GeoblacklightAdmin::Schema.instance.solr_fields[:id])
146
150
  respond_to do |format|
147
151
  if @document.save
148
- format.html { redirect_to admin_documents_path, notice: "Document was successfully created." }
152
+ format.html { redirect_to edit_admin_document_path(@document), notice: "Document was successfully created." }
149
153
  format.json { render :show, status: :created, location: @document }
150
154
  else
151
155
  format.html { render :edit }
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "blacklight/catalog"
4
3
  require "blacklight_range_limit/controller_override"
5
4
 
6
5
  # Admin::IdsController
@@ -14,8 +14,8 @@ module Admin
14
14
  # GET /imports/1
15
15
  # GET /imports/1.json
16
16
  def show
17
- @pagy_failed, @import_failed_documents = pagy(@import.import_documents.not_in_state(:success), items: 50)
18
- @pagy_success, @import_success_documents = pagy(@import.import_documents.in_state(:success), items: 50)
17
+ @pagy_failed, @import_failed_documents = pagy(@import.import_documents.not_in_state(:success), items: 50, page_param: :failed_page)
18
+ @pagy_success, @import_success_documents = pagy(@import.import_documents.in_state(:success), items: 50, page_param: :success_page)
19
19
  end
20
20
 
21
21
  # GET /imports/new
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AssetHelper
4
+ module AssetHelper
5
+ def asset_thumb_to_render?(asset)
6
+ asset&.file_url&.present? && asset&.file_derivatives&.present?
7
+ end
8
+ end
@@ -57,4 +57,8 @@ module DocumentHelper
57
57
  def blacklight_link(document)
58
58
  "#{BLACKLIGHT_URL}/catalog/#{document.friendlier_id}"
59
59
  end
60
+
61
+ def thumb_to_render?(document)
62
+ document&.thumbnail&.file_url&.present? && document&.thumbnail&.file_derivatives&.present?
63
+ end
60
64
  end
@@ -53,10 +53,16 @@ module GeoblacklightAdminHelper
53
53
  "11" => "The Ohio State University",
54
54
  "12" => "University of Chicago",
55
55
  "13" => "University of Nebraska-Lincoln",
56
- "14" => "Rutgers University-New Brunswick"
56
+ "14" => "Rutgers University-New Brunswick",
57
+ "15" => "Northwestern University"
57
58
  }
58
59
  end
59
60
 
61
+ def bookmarks_badge
62
+ bookmarks_classes = ["badge", "badge-dark"]
63
+ "<span class='#{bookmarks_classes.join(" ")}' id='bookmarks-count'>#{current_user.bookmarks.size}</span>"
64
+ end
65
+
60
66
  def notifications_badge
61
67
  notifications_classes = ["badge"]
62
68
  notifications_classes << "badge-dark" if current_user.notifications.unread.empty?
@@ -145,4 +151,8 @@ module GeoblacklightAdminHelper
145
151
 
146
152
  link_to(label, path)
147
153
  end
154
+
155
+ def assets_dct_references_options
156
+ escape_javascript(options_for_select(I18n.t("activemodel.enum_values.document/reference.category").invert.sort.insert(0, ["Choose Reference Type", nil]))).to_s
157
+ end
148
158
  end