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.
- checksums.yaml +4 -4
- data/README.md +10 -55
- data/Rakefile +3 -0
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +7 -3
- data/app/assets/javascripts/geoblacklight_admin/datepicker.js +2 -2
- data/app/assets/javascripts/geoblacklight_admin/inputmask.js +2 -2
- data/app/assets/javascripts/geoblacklight_admin/truncate.js +2 -2
- data/app/assets/javascripts/geoblacklight_admin.js +1 -4
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +3 -1
- data/app/assets/stylesheets/geoblacklight_admin/modules/_images.scss +4 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +4 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_results.scss +5 -0
- data/app/controllers/admin/admin_controller.rb +1 -1
- data/app/controllers/admin/advanced_search_controller.rb +0 -1
- data/app/controllers/admin/assets_controller.rb +142 -0
- data/app/controllers/admin/bulk_actions_controller.rb +1 -1
- data/app/controllers/admin/document_accesses_controller.rb +3 -3
- data/app/controllers/admin/document_assets_controller.rb +33 -23
- data/app/controllers/admin/documents_controller.rb +6 -2
- data/app/controllers/admin/ids_controller.rb +0 -1
- data/app/controllers/admin/imports_controller.rb +2 -2
- data/app/helpers/asset_helper.rb +8 -0
- data/app/helpers/document_helper.rb +4 -0
- data/app/helpers/geoblacklight_admin_helper.rb +11 -1
- data/{lib/generators/geoblacklight_admin/templates → app}/javascript/controllers/results_controller.js +38 -0
- data/app/javascript/entrypoints/engine.js +8 -0
- data/app/javascript/index.js +8 -0
- data/app/jobs/bulk_action_revert_document_job.rb +2 -2
- data/app/jobs/bulk_action_run_document_job.rb +5 -1
- data/app/jobs/bulk_action_run_job.rb +11 -1
- data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +17 -0
- data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
- data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +19 -0
- data/app/jobs/geoblacklight_admin/store_image_job.rb +21 -2
- data/app/models/asset.rb +38 -0
- data/app/models/blacklight_api.rb +2 -2
- data/app/models/blacklight_api_facets.rb +1 -1
- data/app/models/blacklight_api_ids.rb +2 -2
- data/app/models/bulk_action_document_state_machine.rb +2 -4
- data/app/models/bulk_action_state_machine.rb +3 -3
- data/app/models/bulk_actions/change_publication_state.rb +10 -0
- data/app/models/document/reference.rb +24 -0
- data/app/models/document.rb +122 -11
- data/app/models/document_thumbnail_state_machine.rb +22 -0
- data/app/models/document_thumbnail_transition.rb +26 -0
- data/app/models/element.rb +1 -1
- data/app/models/geoblacklight_admin/field_mappings_btaa_aardvark.rb +7 -1
- data/app/models/geoblacklight_admin/schema.rb +37 -1
- data/app/models/geoblacklight_admin/solr_utils.rb +87 -0
- data/app/models/kithe/vips_cli_image_to_png.rb +114 -0
- data/app/services/geoblacklight_admin/image_service/iiif.rb +2 -2
- data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +111 -0
- data/app/services/geoblacklight_admin/image_service/tms.rb +50 -0
- data/app/services/geoblacklight_admin/image_service/wms.rb +1 -4
- data/app/services/geoblacklight_admin/image_service.rb +16 -40
- data/app/services/geoblacklight_admin/item_viewer.rb +1 -1
- data/app/uploaders/asset_uploader.rb +6 -11
- data/app/views/admin/assets/_form.html.erb +19 -0
- data/app/views/admin/assets/display_attach_form.html.erb +39 -0
- data/app/views/admin/assets/edit.html.erb +9 -0
- data/app/views/admin/assets/index.html.erb +75 -0
- data/app/views/admin/assets/show.html.erb +100 -0
- data/app/views/admin/bulk_actions/index.html.erb +50 -48
- data/app/views/admin/bulk_actions/show.html.erb +3 -2
- data/app/views/admin/document_accesses/index.html.erb +68 -64
- data/app/views/admin/document_assets/_form.html.erb +17 -0
- data/app/views/admin/document_assets/display_attach_form.html.erb +4 -9
- data/app/views/admin/document_assets/edit.html.erb +5 -0
- data/app/views/admin/document_assets/index.html.erb +88 -72
- data/app/views/admin/document_downloads/index.html.erb +64 -62
- data/app/views/admin/documents/_document.html.erb +37 -16
- data/app/views/admin/documents/_form.html.erb +21 -6
- data/app/views/admin/documents/_form_nav.html.erb +12 -3
- data/app/views/admin/documents/_result_selected_options.html.erb +6 -1
- data/app/views/admin/documents/admin.html.erb +210 -0
- data/app/views/admin/documents/index.html.erb +10 -1
- data/app/views/admin/documents/versions.html.erb +3 -3
- data/app/views/admin/elements/index.html.erb +55 -54
- data/app/views/admin/form_elements/index.html.erb +38 -35
- data/app/views/admin/imports/index.html.erb +52 -50
- data/app/views/admin/layouts/application.html.erb +7 -4
- data/app/views/admin/shared/_js_behaviors.html.erb +6 -3
- data/app/views/admin/shared/_navbar.html.erb +11 -8
- data/config/locales/documents.en.yml +6 -0
- data/config/routes.rb +1 -0
- data/config/vite.json +14 -0
- data/db/migrate/20240619171628_create_document_thumbnail_statesman.rb +18 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +63 -15
- data/lib/generators/geoblacklight_admin/install_generator.rb +1 -0
- data/lib/generators/geoblacklight_admin/templates/api_controller.rb +0 -2
- data/lib/generators/geoblacklight_admin/templates/base.html.erb +53 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +1 -0
- data/lib/generators/geoblacklight_admin/templates/config/settings.yml +15 -1
- data/lib/generators/geoblacklight_admin/templates/config/vite.json +16 -0
- data/lib/generators/geoblacklight_admin/templates/frontend/entrypoints/application.js +30 -0
- data/lib/generators/geoblacklight_admin/templates/package-test.json +10 -0
- data/lib/generators/geoblacklight_admin/templates/package.json +5 -29
- data/lib/generators/geoblacklight_admin/templates/vite.config.ts +8 -0
- data/lib/geoblacklight_admin/engine.rb +1 -0
- data/lib/geoblacklight_admin/rake_task.rb +5 -0
- data/lib/geoblacklight_admin/tasks/images.rake +33 -0
- data/lib/geoblacklight_admin/tasks/solr.rake +11 -0
- data/lib/geoblacklight_admin/version.rb +1 -1
- metadata +75 -19
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/application_controller.js +0 -17
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/document_controller.js +0 -26
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/index.js +0 -10
- data/lib/tasks/geoblacklight_admin/images.rake +0 -30
- data/lib/tasks/geoblacklight_admin.rake +0 -213
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f4725f14826124fd7393a3b7cbb37baa28b606d15cc1381186a122ef2f0a199
|
|
4
|
+
data.tar.gz: e7ba31886ae77990e504f108c8e5f9004853ee2f86266b5203490ca022dfc7ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
11
|
+
* Rails v7
|
|
12
12
|
* Blacklight v7 (not v8)
|
|
13
|
-
* GeoBlacklight v4 (
|
|
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.
|
|
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
|
|
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
|
-
##
|
|
51
|
-
Drop and recreate databases (or engine_cart:generate will fail)
|
|
51
|
+
## Contributing
|
|
52
52
|
|
|
53
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
* ~~
|
|
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
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
//
|
|
2
|
-
|
|
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({
|
|
@@ -11,12 +11,9 @@
|
|
|
11
11
|
// about supported directives.
|
|
12
12
|
//
|
|
13
13
|
|
|
14
|
-
|
|
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
|
-
|
|
48
|
+
main.container-fluid {
|
|
47
49
|
margin-top: 5rem;
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -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
|
|
87
|
+
format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links were created destroyed." }
|
|
88
88
|
else
|
|
89
|
-
format.html { redirect_to
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
-
@
|
|
43
|
-
authorize! :update, @asset
|
|
40
|
+
@document_asset = DocumentAsset.find_by_friendlier_id!(params[:id])
|
|
44
41
|
|
|
45
42
|
respond_to do |format|
|
|
46
|
-
if @
|
|
47
|
-
format.html { redirect_to
|
|
48
|
-
format.json { render :show, status: :ok, location: @
|
|
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: @
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
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 }
|
|
@@ -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
|
|
@@ -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
|