geoblacklight_admin 0.0.1
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 +7 -0
- data/.editorconfig +18 -0
- data/.gitignore +75 -0
- data/.standard.yml +4 -0
- data/Gemfile +59 -0
- data/LICENSE +21 -0
- data/README.md +84 -0
- data/Rakefile +72 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/aerial_photo.jpg +0 -0
- data/app/assets/images/archive-solid.svg +1 -0
- data/app/assets/images/bookmark-regular.svg +1 -0
- data/app/assets/images/bookmark-solid.svg +1 -0
- data/app/assets/images/btaa-logo.jpg +0 -0
- data/app/assets/images/cloud-download-alt-solid.svg +1 -0
- data/app/assets/images/file-import-solid.svg +1 -0
- data/app/assets/images/trash-alt-solid.svg +1 -0
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin/date_range_picker.js +173 -0
- data/app/assets/javascripts/geoblacklight_admin/datepicker.js +22 -0
- data/app/assets/javascripts/geoblacklight_admin/elements.js +38 -0
- data/app/assets/javascripts/geoblacklight_admin/exports.js +3 -0
- data/app/assets/javascripts/geoblacklight_admin/fields.js +11 -0
- data/app/assets/javascripts/geoblacklight_admin/geoblacklight_admin.js +2 -0
- data/app/assets/javascripts/geoblacklight_admin/inputmask.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin/locale.js +5 -0
- data/app/assets/javascripts/geoblacklight_admin/sortable.js +2544 -0
- data/app/assets/javascripts/geoblacklight_admin/tooltips.js +3 -0
- data/app/assets/javascripts/geoblacklight_admin/truncate.js +4 -0
- data/app/assets/javascripts/geoblacklight_admin.js +40 -0
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +47 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_autocomplete.scss +32 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_blazer.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_code.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_datepicker.scss +477 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_elements.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_forms.scss +28 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_icons.scss +15 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +9 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +4 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_toasts.scss +7 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_visibility.scss +3 -0
- data/app/assets/stylesheets/geoblacklight_admin/settings/_variables.scss +1 -0
- data/app/channels/export_channel.rb +12 -0
- data/app/controllers/admin/admin_controller.rb +16 -0
- data/app/controllers/admin/advanced_search_controller.rb +365 -0
- data/app/controllers/admin/api_controller.rb +386 -0
- data/app/controllers/admin/bookmarks_controller.rb +68 -0
- data/app/controllers/admin/bulk_actions_controller.rb +94 -0
- data/app/controllers/admin/concerns/.keep +0 -0
- data/app/controllers/admin/concerns/upload_util.rb +8 -0
- data/app/controllers/admin/document_accesses_controller.rb +125 -0
- data/app/controllers/admin/document_assets_controller.rb +198 -0
- data/app/controllers/admin/document_downloads_controller.rb +127 -0
- data/app/controllers/admin/documents_controller.rb +219 -0
- data/app/controllers/admin/elements_controller.rb +81 -0
- data/app/controllers/admin/form_elements_controller.rb +81 -0
- data/app/controllers/admin/ids_controller.rb +379 -0
- data/app/controllers/admin/import_documents_controller.rb +18 -0
- data/app/controllers/admin/imports_controller.rb +105 -0
- data/app/controllers/admin/mappings_controller.rb +95 -0
- data/app/controllers/admin/notifications_controller.rb +51 -0
- data/app/controllers/admin/search_controller.rb +10 -0
- data/app/controllers/admin/users_controller.rb +10 -0
- data/app/helpers/bulk_actions_helper.rb +9 -0
- data/app/helpers/document_helper.rb +60 -0
- data/app/helpers/form_input_helper.rb +73 -0
- data/app/helpers/geoblacklight_admin_helper.rb +118 -0
- data/app/helpers/import_documents_helper.rb +5 -0
- data/app/helpers/mappings_helper.rb +27 -0
- data/app/indexers/document_indexer.rb +34 -0
- data/app/jobs/bulk_action_revert_document_job.rb +49 -0
- data/app/jobs/bulk_action_revert_job.rb +25 -0
- data/app/jobs/bulk_action_run_document_job.rb +42 -0
- data/app/jobs/bulk_action_run_job.rb +27 -0
- data/app/jobs/export_job.rb +72 -0
- data/app/jobs/export_json_job.rb +120 -0
- data/app/jobs/import_document_job.rb +25 -0
- data/app/jobs/import_run_job.rb +33 -0
- data/app/models/active_storage_attachment.rb +5 -0
- data/app/models/active_storage_blob.rb +5 -0
- data/app/models/api_search_builder.rb +12 -0
- data/app/models/application_record.rb +6 -0
- data/app/models/blacklight_api.rb +93 -0
- data/app/models/blacklight_api_facets.rb +15 -0
- data/app/models/blacklight_api_ids.rb +103 -0
- data/app/models/bookmark.rb +17 -0
- data/app/models/bulk_action.rb +88 -0
- data/app/models/bulk_action_document.rb +22 -0
- data/app/models/bulk_action_document_state_machine.rb +16 -0
- data/app/models/bulk_action_document_transition.rb +19 -0
- data/app/models/bulk_action_state_machine.rb +16 -0
- data/app/models/bulk_action_transition.rb +26 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/document/bbox_validator.rb +70 -0
- data/app/models/document/controlled_lists.rb +104 -0
- data/app/models/document/date_range_validator.rb +63 -0
- data/app/models/document/geom_validator.rb +117 -0
- data/app/models/document/reference.rb +107 -0
- data/app/models/document.rb +264 -0
- data/app/models/document_access.rb +35 -0
- data/app/models/document_download.rb +35 -0
- data/app/models/document_state_machine.rb +14 -0
- data/app/models/document_transition.rb +26 -0
- data/app/models/element.rb +90 -0
- data/app/models/form_control.rb +2 -0
- data/app/models/form_element.rb +19 -0
- data/app/models/form_feature.rb +2 -0
- data/app/models/form_group.rb +2 -0
- data/app/models/form_header.rb +2 -0
- data/app/models/geoblacklight_admin/field_mappings_btaa_aardvark.rb +379 -0
- data/app/models/geoblacklight_admin/field_mappings_gblv1.rb +344 -0
- data/app/models/geoblacklight_admin/iso_language_codes.rb +515 -0
- data/app/models/geoblacklight_admin/schema.rb +194 -0
- data/app/models/geoblacklight_admin.rb +3 -0
- data/app/models/import/csv_duplicates_validator.rb +36 -0
- data/app/models/import/csv_header_validator.rb +24 -0
- data/app/models/import.rb +186 -0
- data/app/models/import_btaa.rb +91 -0
- data/app/models/import_btaa_aardvark.rb +109 -0
- data/app/models/import_document.rb +34 -0
- data/app/models/import_document_state_machine.rb +12 -0
- data/app/models/import_document_transition.rb +19 -0
- data/app/models/import_gblv1.rb +92 -0
- data/app/models/import_state_machine.rb +16 -0
- data/app/models/import_transition.rb +26 -0
- data/app/models/mapping.rb +10 -0
- data/app/models/notification.rb +9 -0
- data/app/models/user.rb +26 -0
- data/app/notifications/export_notification.rb +30 -0
- data/app/services/export_csv_document_access_links_service.rb +47 -0
- data/app/services/export_csv_document_downloads_service.rb +47 -0
- data/app/services/export_csv_service.rb +44 -0
- data/app/services/export_json_service.rb +35 -0
- data/app/services/zip_file_generator.rb +56 -0
- data/app/views/admin/advanced_search/facets.json.jbuilder +80 -0
- data/app/views/admin/advanced_search/index.json.jbuilder +90 -0
- data/app/views/admin/api/_field.json.jbuilder +10 -0
- data/app/views/admin/api/fetch.json.jbuilder +86 -0
- data/app/views/admin/api/index.json.jbuilder +90 -0
- data/app/views/admin/bookmarks/_bookmark.json.jbuilder +4 -0
- data/app/views/admin/bookmarks/create.js.erb +7 -0
- data/app/views/admin/bookmarks/destroy.js.erb +7 -0
- data/app/views/admin/bookmarks/index.html.erb +21 -0
- data/app/views/admin/bookmarks/index.json.jbuilder +3 -0
- data/app/views/admin/bulk_actions/_bulk_action.json.jbuilder +4 -0
- data/app/views/admin/bulk_actions/_form.html.erb +17 -0
- data/app/views/admin/bulk_actions/edit.html.erb +6 -0
- data/app/views/admin/bulk_actions/index.html.erb +54 -0
- data/app/views/admin/bulk_actions/index.json.jbuilder +3 -0
- data/app/views/admin/bulk_actions/new.html.erb +5 -0
- data/app/views/admin/bulk_actions/show.html.erb +100 -0
- data/app/views/admin/bulk_actions/show.json.jbuilder +3 -0
- data/app/views/admin/devise/confirmations/new.html.erb +16 -0
- data/app/views/admin/devise/invitations/edit.html.erb +15 -0
- data/app/views/admin/devise/invitations/new.html.erb +15 -0
- data/app/views/admin/devise/mailer/invitation_instructions.html.erb +11 -0
- data/app/views/admin/devise/mailer/invitation_instructions.text.erb +11 -0
- data/app/views/admin/devise/passwords/edit.html.erb +26 -0
- data/app/views/admin/devise/passwords/new.html.erb +16 -0
- data/app/views/admin/devise/registrations/edit.html.erb +35 -0
- data/app/views/admin/devise/registrations/new.html.erb +30 -0
- data/app/views/admin/devise/sessions/new.html.erb +28 -0
- data/app/views/admin/devise/shared/_links.html.erb +27 -0
- data/app/views/admin/devise/unlocks/new.html.erb +16 -0
- data/app/views/admin/document_accesses/_document_access.json.jbuilder +4 -0
- data/app/views/admin/document_accesses/_form.html.erb +17 -0
- data/app/views/admin/document_accesses/destroy_all.html.erb +70 -0
- data/app/views/admin/document_accesses/edit.html.erb +5 -0
- data/app/views/admin/document_accesses/import.html.erb +70 -0
- data/app/views/admin/document_accesses/index.html.erb +74 -0
- data/app/views/admin/document_accesses/index.json.jbuilder +3 -0
- data/app/views/admin/document_accesses/new.html.erb +6 -0
- data/app/views/admin/document_accesses/show.html.erb +19 -0
- data/app/views/admin/document_accesses/show.json.jbuilder +3 -0
- data/app/views/admin/document_assets/display_attach_form.html.erb +44 -0
- data/app/views/admin/document_assets/index.html.erb +65 -0
- data/app/views/admin/document_downloads/_document_download.json.jbuilder +4 -0
- data/app/views/admin/document_downloads/_form.html.erb +15 -0
- data/app/views/admin/document_downloads/destroy_all.html.erb +70 -0
- data/app/views/admin/document_downloads/edit.html.erb +6 -0
- data/app/views/admin/document_downloads/import.html.erb +74 -0
- data/app/views/admin/document_downloads/index.html.erb +70 -0
- data/app/views/admin/document_downloads/index.json.jbuilder +3 -0
- data/app/views/admin/document_downloads/new.html.erb +5 -0
- data/app/views/admin/document_downloads/show.html.erb +24 -0
- data/app/views/admin/document_downloads/show.json.jbuilder +3 -0
- data/app/views/admin/documents/_document.html.erb +29 -0
- data/app/views/admin/documents/_document_bookmark.html.erb +17 -0
- data/app/views/admin/documents/_document_fields.html.erb +24 -0
- data/app/views/admin/documents/_form.html.erb +49 -0
- data/app/views/admin/documents/_form_control.html.erb +86 -0
- data/app/views/admin/documents/_form_group.html.erb +1 -0
- data/app/views/admin/documents/_form_header.html.erb +1 -0
- data/app/views/admin/documents/_form_nav.html.erb +21 -0
- data/app/views/admin/documents/_json_aardvark.jbuilder +47 -0
- data/app/views/admin/documents/_json_btaa_aardvark.jbuilder +16 -0
- data/app/views/admin/documents/_json_gbl_v1.jbuilder +32 -0
- data/app/views/admin/documents/_result_facets.html.erb +35 -0
- data/app/views/admin/documents/_result_pagination.html.erb +21 -0
- data/app/views/admin/documents/_result_selected_options.html.erb +54 -0
- data/app/views/admin/documents/_result_selection_options.html.erb +10 -0
- data/app/views/admin/documents/_result_toggle.html.erb +13 -0
- data/app/views/admin/documents/edit.html.erb +7 -0
- data/app/views/admin/documents/features/_assets.html.erb +3 -0
- data/app/views/admin/documents/features/_institutional_access_links.html.erb +3 -0
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +27 -0
- data/app/views/admin/documents/fetch.json_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/fetch.json_btaa_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/fetch.json_gbl_v1.jbuilder +9 -0
- data/app/views/admin/documents/index.html.erb +49 -0
- data/app/views/admin/documents/index.json_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/index.json_btaa_aardvark.jbuilder +9 -0
- data/app/views/admin/documents/index.json_gbl_v1.jbuilder +9 -0
- data/app/views/admin/documents/show.json_aardvark.jbuilder +3 -0
- data/app/views/admin/documents/show.json_btaa_aardvark.jbuilder +3 -0
- data/app/views/admin/documents/show.json_gbl_v1.jbuilder +3 -0
- data/app/views/admin/documents/versions.html.erb +110 -0
- data/app/views/admin/elements/_element.json.jbuilder +2 -0
- data/app/views/admin/elements/_form.html.erb +45 -0
- data/app/views/admin/elements/edit.html.erb +6 -0
- data/app/views/admin/elements/index.html.erb +68 -0
- data/app/views/admin/elements/index.json.jbuilder +1 -0
- data/app/views/admin/elements/new.html.erb +5 -0
- data/app/views/admin/elements/show.html.erb +121 -0
- data/app/views/admin/elements/show.json.jbuilder +1 -0
- data/app/views/admin/form_elements/_form.html.erb +46 -0
- data/app/views/admin/form_elements/_form_element.json.jbuilder +2 -0
- data/app/views/admin/form_elements/edit.html.erb +6 -0
- data/app/views/admin/form_elements/index.html.erb +49 -0
- data/app/views/admin/form_elements/index.json.jbuilder +1 -0
- data/app/views/admin/form_elements/new.html.erb +5 -0
- data/app/views/admin/form_elements/show.html.erb +19 -0
- data/app/views/admin/form_elements/show.json.jbuilder +1 -0
- data/app/views/admin/ids/fetch.json.jbuilder +86 -0
- data/app/views/admin/ids/index.json.jbuilder +41 -0
- data/app/views/admin/import_documents/show.html.haml +20 -0
- data/app/views/admin/imports/_form.html.erb +27 -0
- data/app/views/admin/imports/_import.json.jbuilder +4 -0
- data/app/views/admin/imports/_show_failed_tab.html.erb +37 -0
- data/app/views/admin/imports/_show_success_tab.html.erb +31 -0
- data/app/views/admin/imports/edit.html.erb +8 -0
- data/app/views/admin/imports/index.html.erb +56 -0
- data/app/views/admin/imports/index.json.jbuilder +3 -0
- data/app/views/admin/imports/new.html.erb +7 -0
- data/app/views/admin/imports/show.html.erb +123 -0
- data/app/views/admin/imports/show.json.jbuilder +3 -0
- data/app/views/admin/layouts/application.html.erb +30 -0
- data/app/views/admin/layouts/blazer/application.html.erb +23 -0
- data/app/views/admin/layouts/mailer.html.erb +13 -0
- data/app/views/admin/layouts/mailer.text.erb +1 -0
- data/app/views/admin/mappings/_form.html.erb +17 -0
- data/app/views/admin/mappings/_mapping.json.jbuilder +4 -0
- data/app/views/admin/mappings/edit.html.erb +6 -0
- data/app/views/admin/mappings/index.html.erb +37 -0
- data/app/views/admin/mappings/index.json.jbuilder +3 -0
- data/app/views/admin/mappings/new.html.erb +5 -0
- data/app/views/admin/mappings/show.html.erb +27 -0
- data/app/views/admin/mappings/show.json.jbuilder +3 -0
- data/app/views/admin/notifications/_notification.html.haml +31 -0
- data/app/views/admin/notifications/index.html.erb +54 -0
- data/app/views/admin/notifications/update.js.erb +7 -0
- data/app/views/admin/search/index.html.erb +38 -0
- data/app/views/admin/shared/_flash_messages.html.erb +5 -0
- data/app/views/admin/shared/_footer.html.erb +56 -0
- data/app/views/admin/shared/_js_behaviors.html.erb +147 -0
- data/app/views/admin/shared/_navbar.html.erb +78 -0
- data/app/views/admin/shared/_navbar_blazer.html.erb +42 -0
- data/app/views/admin/shared/_schema_timestamp.html.erb +16 -0
- data/app/views/admin/shared/_toast.html.erb +13 -0
- data/app/views/admin/users/index.html.erb +21 -0
- data/config/authorities/formats.yml +25 -0
- data/config/authorities/languages.yml +50 -0
- data/config/authorities/resource_type.yml +82 -0
- data/config/blazer.yml +79 -0
- data/config/gbl_v1_schema.json +118 -0
- data/config/geomg_aardvark_schema.json +211 -0
- data/config/geomg_schema.json +123 -0
- data/config/locales/devise.en.yml +65 -0
- data/config/locales/devise_invitable.en.yml +31 -0
- data/config/locales/documents.en.yml +189 -0
- data/config/locales/en.yml +51 -0
- data/config/locales/geoblacklight.en.yml +178 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +162 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin.rb +399 -0
- data/db/seeds.rb +26 -0
- data/db/seeds_elements.csv +56 -0
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_form_elements.csv +71 -0
- data/db/seeds_form_elements.numbers +0 -0
- data/db/structure.sql +816 -0
- data/geoblacklight_admin.gemspec +67 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +336 -0
- data/lib/generators/geoblacklight_admin/example_docs_generator.rb +18 -0
- data/lib/generators/geoblacklight_admin/helpers_generator.rb +18 -0
- data/lib/generators/geoblacklight_admin/install_generator.rb +60 -0
- data/lib/generators/geoblacklight_admin/jobs_generator.rb +21 -0
- data/lib/generators/geoblacklight_admin/models_generator.rb +23 -0
- data/lib/generators/geoblacklight_admin/templates/.env.development.example +28 -0
- data/lib/generators/geoblacklight_admin/templates/.solr_wrapper.yml +7 -0
- data/lib/generators/geoblacklight_admin/templates/_user_util_links.html.erb +30 -0
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +18 -0
- data/lib/generators/geoblacklight_admin/templates/config/geomg_aardvark_schema.json +211 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +25 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +31 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +158 -0
- data/lib/generators/geoblacklight_admin/templates/config/initializers/statesman.rb +7 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/consumer.js +6 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/export_channel.js +30 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/channels/index.js +5 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/application_controller.js +17 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/document_controller.js +26 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/index.js +10 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/controllers/results_controller.js +310 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/packs/application.js +23 -0
- data/lib/generators/geoblacklight_admin/templates/javascript/src/js/admin/qa_autocomplete.js +1134 -0
- data/lib/generators/geoblacklight_admin/templates/package.json +32 -0
- data/lib/generators/geoblacklight_admin/templates/solr/README-geoblacklight-solr-development.txt +3 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/_rest_managed.json +3 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/admin-extra.html +31 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/core.properties +5 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/elevate.xml +36 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/protwords.txt +21 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/schema.xml +229 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/scripts.conf +24 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/solrconfig.xml +266 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/spellings.txt +2 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords.txt +58 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords_en.txt +58 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/synonyms.txt +43 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example.xsl +132 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_atom.xsl +67 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_rss.xsl +66 -0
- data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/luke.xsl +337 -0
- data/lib/generators/geoblacklight_admin/templates/solr/snapshots/.keep +0 -0
- data/lib/generators/geoblacklight_admin/views_generator.rb +19 -0
- data/lib/geoblacklight_admin/engine.rb +20 -0
- data/lib/geoblacklight_admin/version.rb +5 -0
- data/lib/geoblacklight_admin.rb +7 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/geoblacklight_admin.rake +209 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +35 -0
- data/template.rb +16 -0
- metadata +1037 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::DocumentAssetsController
|
|
4
|
+
module Admin
|
|
5
|
+
class DocumentAssetsController < Admin::AdminController
|
|
6
|
+
before_action :set_document
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
scope = Kithe::Asset
|
|
10
|
+
|
|
11
|
+
# simple simple search on a few simple attributes with OR combo.
|
|
12
|
+
if params[:document_id].present?
|
|
13
|
+
document = Document.find_by_friendlier_id(params[:document_id])
|
|
14
|
+
scope = scope.where(parent_id: document.id)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# scope = scope.page(params[:page]).per(20).order(created_at: :desc)
|
|
18
|
+
scope = scope.includes(:parent)
|
|
19
|
+
|
|
20
|
+
@document_assets = scope
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def show
|
|
24
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
|
|
25
|
+
authorize! :read, @asset
|
|
26
|
+
|
|
27
|
+
if @asset.stored?
|
|
28
|
+
@checks = @asset.fixity_checks.order("created_at asc")
|
|
29
|
+
@latest_check = @checks.last
|
|
30
|
+
@earliest_check = @checks.first
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def edit
|
|
35
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
|
|
36
|
+
authorize! :update, @asset
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# PATCH/PUT /works/1
|
|
40
|
+
# PATCH/PUT /works/1.json
|
|
41
|
+
def update
|
|
42
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
|
|
43
|
+
authorize! :update, @asset
|
|
44
|
+
|
|
45
|
+
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 }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :edit }
|
|
51
|
+
format.json { render json: @asset.errors, status: :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def destroy
|
|
57
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
|
|
58
|
+
@asset.destroy
|
|
59
|
+
|
|
60
|
+
respond_to do |format|
|
|
61
|
+
format.html { redirect_to document_document_assets_path(@document), notice: "Asset '#{@asset.title}' was successfully destroyed." }
|
|
62
|
+
format.json { head :no_content }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def check_fixity
|
|
67
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:asset_id])
|
|
68
|
+
SingleAssetCheckerJob.perform_later(@asset)
|
|
69
|
+
redirect_to admin_asset_url(@asset), notice: "This file will be checked shortly."
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def fixity_report
|
|
73
|
+
@fixity_report = FixityReport.new
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def display_attach_form
|
|
77
|
+
@document = Document.find_by_friendlier_id!(params[:document_id])
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Receives json hashes for direct uploaded files in params[:files],
|
|
81
|
+
# and id in params[:id] (friendlier_id)
|
|
82
|
+
# creates filesets for them and attach.
|
|
83
|
+
#
|
|
84
|
+
# POST /document/:id/ingest
|
|
85
|
+
def attach_files
|
|
86
|
+
@parent = Document.find_by_friendlier_id!(params[:id])
|
|
87
|
+
|
|
88
|
+
current_position = @parent.members.maximum(:position) || 0
|
|
89
|
+
|
|
90
|
+
files_params = (params[:cached_files] || [])
|
|
91
|
+
.collect { |s| JSON.parse(s) }
|
|
92
|
+
.sort_by { |h| h&.dig("metadata", "filename") }
|
|
93
|
+
|
|
94
|
+
files_params.each do |file_data|
|
|
95
|
+
asset = Kithe::Asset.new
|
|
96
|
+
|
|
97
|
+
# if derivative_storage_type = params.dig(:storage_type_for, file_data["id"])
|
|
98
|
+
# asset.derivative_storage_type = derivative_storage_type
|
|
99
|
+
# end
|
|
100
|
+
|
|
101
|
+
asset.position = (current_position += 1)
|
|
102
|
+
asset.parent_id = @parent.id
|
|
103
|
+
asset.file = file_data
|
|
104
|
+
asset.title = (asset.file&.original_filename || "Untitled")
|
|
105
|
+
asset.save!
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
if @parent.representative_id.nil?
|
|
109
|
+
@parent.update(representative: @parent.members.order(:position).first)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
redirect_to document_path(@parent.friendlier_id, anchor: "nav-members")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def convert_to_child_work
|
|
116
|
+
@asset = Kithe::Asset.find_by_friendlier_id!(params[:id])
|
|
117
|
+
|
|
118
|
+
parent = @asset.parent
|
|
119
|
+
|
|
120
|
+
new_child = Work.new(title: @asset.title)
|
|
121
|
+
|
|
122
|
+
# Asking for permission to create a new Work,
|
|
123
|
+
# which is arguably the main thing going on in this method.
|
|
124
|
+
# authorize! :create, Work as the first line of the method
|
|
125
|
+
# would be better, but we currently aren't allowed to do that
|
|
126
|
+
# see (https://github.com/chaps-io/access-granted/pull/56).
|
|
127
|
+
authorize! :create, new_child
|
|
128
|
+
|
|
129
|
+
new_child.parent = parent
|
|
130
|
+
# collections
|
|
131
|
+
new_child.contained_by = parent.contained_by
|
|
132
|
+
new_child.position = @asset.position
|
|
133
|
+
new_child.representative = @asset
|
|
134
|
+
# we can copy _all_ the non-title metadata like this...
|
|
135
|
+
new_child.json_attributes = parent.json_attributes
|
|
136
|
+
|
|
137
|
+
@asset.parent = new_child
|
|
138
|
+
|
|
139
|
+
Kithe::Model.transaction do
|
|
140
|
+
new_child.save!
|
|
141
|
+
@asset.save! # to get new parent
|
|
142
|
+
|
|
143
|
+
if parent.representative_id == @asset.id
|
|
144
|
+
parent.representative = new_child
|
|
145
|
+
parent.save!
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
redirect_to edit_admin_work_path(new_child), notice: "Asset promoted to child work #{new_child.title}"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# requires params[:active_encode_status_id]
|
|
153
|
+
def refresh_active_encode_status
|
|
154
|
+
status = ActiveEncodeStatus.find(params[:active_encode_status_id])
|
|
155
|
+
|
|
156
|
+
RefreshActiveEncodeStatusJob.perform_later(status)
|
|
157
|
+
|
|
158
|
+
redirect_to admin_asset_url(status.asset), notice: "Started refresh for ActiveEncode job #{status.active_encode_id}"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def work_is_oral_history?
|
|
162
|
+
(@asset.parent.is_a? Work) && @asset.parent.genre && @asset.parent.genre.include?("Oral histories")
|
|
163
|
+
end
|
|
164
|
+
helper_method :work_is_oral_history?
|
|
165
|
+
|
|
166
|
+
def asset_is_collection_thumbnail?
|
|
167
|
+
@asset.parent.is_a? Collection
|
|
168
|
+
end
|
|
169
|
+
helper_method :asset_is_collection_thumbnail?
|
|
170
|
+
|
|
171
|
+
def edit_path(asset)
|
|
172
|
+
asset.parent.is_a? Collection ? edit_admin_collection_path(asset.parent) : edit_admin_asset_path(asset)
|
|
173
|
+
end
|
|
174
|
+
helper_method :edit_path
|
|
175
|
+
|
|
176
|
+
def parent_path(asset)
|
|
177
|
+
return nil if asset.parent.nil?
|
|
178
|
+
asset.parent.is_a? Collection ? collection_path(asset.parent) : admin_work_path(asset.parent)
|
|
179
|
+
end
|
|
180
|
+
helper_method :parent_path
|
|
181
|
+
|
|
182
|
+
private
|
|
183
|
+
|
|
184
|
+
def set_document
|
|
185
|
+
return unless params[:document_id] # If not nested
|
|
186
|
+
|
|
187
|
+
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:document_id])
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def asset_params
|
|
191
|
+
allowed_params = [:title, :derivative_storage_type, :alt_text, :caption,
|
|
192
|
+
:transcription, :english_translation,
|
|
193
|
+
:role, {admin_note_attributes: []}]
|
|
194
|
+
allowed_params << :published if can?(:publish, @asset)
|
|
195
|
+
params.require(:asset).permit(*allowed_params)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::DocumentDownloadsController
|
|
4
|
+
module Admin
|
|
5
|
+
class DocumentDownloadsController < Admin::AdminController
|
|
6
|
+
before_action :set_document
|
|
7
|
+
before_action :set_document_download, only: %i[show edit update destroy]
|
|
8
|
+
|
|
9
|
+
# GET /document_downloads or /document_downloads.json
|
|
10
|
+
def index
|
|
11
|
+
@document_downloads = DocumentDownload.all
|
|
12
|
+
if params[:document_id]
|
|
13
|
+
@document_downloads = DocumentDownload.where(friendlier_id: @document.friendlier_id).order(position: :asc)
|
|
14
|
+
else
|
|
15
|
+
@pagy, @document_downloads = pagy(DocumentDownload.all.order(friendlier_id: :asc, updated_at: :desc), items: 20)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# GET /document_downloads/1 or /document_downloads/1.json
|
|
20
|
+
def show
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# GET /document_downloads/new
|
|
24
|
+
def new
|
|
25
|
+
@document_download = DocumentDownload.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# GET /document_downloads/1/edit
|
|
29
|
+
def edit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# POST /document_downloads or /document_downloads.json
|
|
33
|
+
def create
|
|
34
|
+
@document_download = DocumentDownload.new(document_download_params)
|
|
35
|
+
|
|
36
|
+
logger.debug("DD Params: #{DocumentDownload.new(document_download_params).inspect}")
|
|
37
|
+
logger.debug("Document DOWNLOAD: #{@document_download.inspect}")
|
|
38
|
+
|
|
39
|
+
respond_to do |format|
|
|
40
|
+
if @document_download.save
|
|
41
|
+
format.html do
|
|
42
|
+
redirect_to document_document_downloads_path(@document_download.document), notice: "Document download was successfully created."
|
|
43
|
+
end
|
|
44
|
+
format.json { render :show, status: :created, location: @document_download }
|
|
45
|
+
else
|
|
46
|
+
format.html { render :new, status: :unprocessable_entity }
|
|
47
|
+
format.json { render json: @document_download.errors, status: :unprocessable_entity }
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# PATCH/PUT /document_downloads/1 or /document_downloads/1.json
|
|
53
|
+
def update
|
|
54
|
+
respond_to do |format|
|
|
55
|
+
if @document_download.update(document_download_params)
|
|
56
|
+
format.html do
|
|
57
|
+
redirect_to document_document_downloads_path(@document_download.document), notice: "Document download was successfully updated."
|
|
58
|
+
end
|
|
59
|
+
format.json { render :show, status: :ok, location: @document_download }
|
|
60
|
+
else
|
|
61
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
62
|
+
format.json { render json: @document_download.errors, status: :unprocessable_entity }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# DELETE /document_downloads/1 or /document_downloads/1.json
|
|
68
|
+
def destroy
|
|
69
|
+
@document_download.destroy
|
|
70
|
+
|
|
71
|
+
respond_to do |format|
|
|
72
|
+
format.html { redirect_to document_downloads_url, notice: "Document download was successfully destroyed." }
|
|
73
|
+
format.json { head :no_content }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def destroy_all
|
|
78
|
+
logger.debug("Destroy Downloads")
|
|
79
|
+
return unless params.dig(:document_download, :downloads, :file)
|
|
80
|
+
|
|
81
|
+
respond_to do |format|
|
|
82
|
+
if DocumentDownload.destroy_all(params.dig(:document_download, :downloads, :file))
|
|
83
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links were created destroyed." }
|
|
84
|
+
else
|
|
85
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links could not be destroyed." }
|
|
86
|
+
end
|
|
87
|
+
rescue => e
|
|
88
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links could not be destroyed. #{e}" }
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# GET /documents/#id/downloads/import
|
|
93
|
+
# POST /documents/#id/downloads/import
|
|
94
|
+
def import
|
|
95
|
+
logger.debug("Import Downloads")
|
|
96
|
+
return unless params.dig(:document_download, :downloads, :file)
|
|
97
|
+
|
|
98
|
+
respond_to do |format|
|
|
99
|
+
if DocumentDownload.import(params.dig(:document_download, :downloads, :file))
|
|
100
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links were created successfully." }
|
|
101
|
+
else
|
|
102
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links could not be created." }
|
|
103
|
+
end
|
|
104
|
+
rescue => e
|
|
105
|
+
format.html { redirect_to document_downloads_path, notice: "Download Links could not be created. #{e}" }
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
112
|
+
def set_document
|
|
113
|
+
return unless params[:document_id] # If not nested
|
|
114
|
+
|
|
115
|
+
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:document_id])
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def set_document_download
|
|
119
|
+
@document_download = DocumentDownload.find(params[:id])
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Only allow a list of trusted parameters through.
|
|
123
|
+
def document_download_params
|
|
124
|
+
params.require(:document_download).permit(:friendlier_id, :label, :value, :position)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::DocumentsController
|
|
4
|
+
module Admin
|
|
5
|
+
class DocumentsController < Admin::AdminController
|
|
6
|
+
ActionController::Parameters.permit_all_parameters = true
|
|
7
|
+
before_action :set_document,
|
|
8
|
+
only: %i[show edit update destroy versions]
|
|
9
|
+
|
|
10
|
+
# GET /documents
|
|
11
|
+
# GET /documents.json
|
|
12
|
+
def index
|
|
13
|
+
query_params = {
|
|
14
|
+
q: params["q"],
|
|
15
|
+
f: params["f"],
|
|
16
|
+
page: params["page"],
|
|
17
|
+
rows: params["rows"] || 20,
|
|
18
|
+
sort: params["sort"] || "score desc",
|
|
19
|
+
daterange: params["daterange"] || nil
|
|
20
|
+
}
|
|
21
|
+
@documents = BlacklightApi.new(**query_params)
|
|
22
|
+
|
|
23
|
+
respond_to do |format|
|
|
24
|
+
format.html { render :index }
|
|
25
|
+
format.json { render json: @documents.results.to_json }
|
|
26
|
+
|
|
27
|
+
# JSON - BTAA Aardvark
|
|
28
|
+
format.json_btaa_aardvark do
|
|
29
|
+
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_btaa_aardvark"}), ExportJsonService)
|
|
30
|
+
head :no_content
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# JSON - GBL Aardvark
|
|
34
|
+
format.json_aardvark do
|
|
35
|
+
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_aardvark"}), ExportJsonService)
|
|
36
|
+
head :no_content
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# JSON - GBL v1
|
|
40
|
+
format.json_gbl_v1 do
|
|
41
|
+
ExportJsonJob.perform_later(current_user, query_params.merge!({format: "json_gbl_v1"}), ExportJsonService)
|
|
42
|
+
head :no_content
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# CSV - B1G
|
|
46
|
+
format.csv do
|
|
47
|
+
ExportJob.perform_later(current_user, query_params, ExportCsvService)
|
|
48
|
+
head :no_content
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# CSV Document Downloads - B1G
|
|
52
|
+
format.csv_document_downloads do
|
|
53
|
+
ExportJob.perform_later(current_user, query_params, ExportCsvDocumentDownloadsService)
|
|
54
|
+
head :no_content
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# CSV Document Access Links - B1G
|
|
58
|
+
format.csv_document_access_links do
|
|
59
|
+
ExportJob.perform_later(current_user, query_params, ExportCsvDocumentAccessLinksService)
|
|
60
|
+
head :no_content
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Fetch documents from array of friendlier_ids
|
|
66
|
+
def fetch
|
|
67
|
+
@documents = Document.where(friendlier_id: params["ids"])
|
|
68
|
+
|
|
69
|
+
respond_to do |format|
|
|
70
|
+
format.html { render :index }
|
|
71
|
+
format.json { render json: @documents.to_json }
|
|
72
|
+
|
|
73
|
+
# JSON - BTAA Aardvark
|
|
74
|
+
format.json_btaa_aardvark do
|
|
75
|
+
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_btaa_aardvark"},
|
|
76
|
+
ExportJsonService)
|
|
77
|
+
head :no_content
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# JSON - GBL Aardvark
|
|
81
|
+
format.json_aardvark do
|
|
82
|
+
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_aardvark"}, ExportJsonService)
|
|
83
|
+
head :no_content
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# JSON - GBL v1
|
|
87
|
+
format.json_gbl_v1 do
|
|
88
|
+
ExportJsonJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "json_gbl_v1"}, ExportJsonService)
|
|
89
|
+
head :no_content
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# CSV - B1G
|
|
93
|
+
format.csv do
|
|
94
|
+
ExportJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "csv"}, ExportCsvService)
|
|
95
|
+
head :no_content
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# CSV Document Downloads - B1G
|
|
99
|
+
format.csv_document_downloads do
|
|
100
|
+
ExportJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "csv_document_downloads"}, ExportCsvDocumentDownloadsService)
|
|
101
|
+
head :no_content
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# CSV Document Downloads - B1G
|
|
105
|
+
format.csv_document_access_links do
|
|
106
|
+
ExportJob.perform_later(current_user, {ids: @documents.pluck(:friendlier_id), format: "csv_document_access_links"}, ExportCsvDocumentAccessLinksService)
|
|
107
|
+
head :no_content
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# GET /documents/new
|
|
113
|
+
def new
|
|
114
|
+
@document = Document.new
|
|
115
|
+
render :edit
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# GET /documents/1/edit
|
|
119
|
+
def edit
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# GET /documents/1/versions
|
|
123
|
+
def versions
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# POST /documents
|
|
127
|
+
# POST /documents.json
|
|
128
|
+
def create
|
|
129
|
+
@document = Document.new(document_params)
|
|
130
|
+
@document.friendlier_id = @document.send(GeoblacklightAdmin::Schema.instance.solr_fields[:id])
|
|
131
|
+
respond_to do |format|
|
|
132
|
+
if @document.save
|
|
133
|
+
format.html { redirect_to admin_documents_path, notice: "Document was successfully created." }
|
|
134
|
+
format.json { render :show, status: :created, location: @document }
|
|
135
|
+
else
|
|
136
|
+
format.html { render :edit }
|
|
137
|
+
format.json { render json: @document.errors, status: :unprocessable_entity }
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# PATCH/PUT /documents/1
|
|
143
|
+
# PATCH/PUT /documents/1.json
|
|
144
|
+
def update
|
|
145
|
+
respond_to do |format|
|
|
146
|
+
if @document.update(document_params)
|
|
147
|
+
format.html { redirect_to edit_admin_document_path(@document), notice: "Document was successfully updated." }
|
|
148
|
+
format.json { render :show, status: :ok, location: @document }
|
|
149
|
+
else
|
|
150
|
+
format.html { render :edit }
|
|
151
|
+
format.json { render json: @document.errors, status: :unprocessable_entity }
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# DELETE /documents/1
|
|
157
|
+
# DELETE /documents/1.json
|
|
158
|
+
def destroy
|
|
159
|
+
@document.destroy
|
|
160
|
+
respond_to do |format|
|
|
161
|
+
format.html { redirect_to admin_documents_url, notice: "Document '#{@document.title}' was successfully destroyed." }
|
|
162
|
+
format.json { head :no_content }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def show
|
|
167
|
+
respond_to do |format|
|
|
168
|
+
format.html { redirect_to edit_admin_document_url(@document) }
|
|
169
|
+
format.json { render json: @document.to_json } # App-style JSON
|
|
170
|
+
format.json_aardvark
|
|
171
|
+
format.json_btaa_aardvark
|
|
172
|
+
format.json_gbl_v1
|
|
173
|
+
# B1G CSV
|
|
174
|
+
format.csv { send_data collect_csv([@document]), filename: "documents-#{Time.zone.today}.csv" }
|
|
175
|
+
|
|
176
|
+
# @TODO:
|
|
177
|
+
# geoblacklight_version: 1.0 (strict)
|
|
178
|
+
# geoblacklight_version: 1.0 + B1G customizations
|
|
179
|
+
# geoblacklight_version: 2.0 (strict)
|
|
180
|
+
# geoblacklight_version: 2.0 + B1G customizations
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
private
|
|
185
|
+
|
|
186
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
187
|
+
def set_document
|
|
188
|
+
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:id] || params[:document_id])
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# only allow whitelisted params through (TODO, we're allowing all document params!)
|
|
192
|
+
# Plus sanitization or any other mutation.
|
|
193
|
+
#
|
|
194
|
+
# This could be done in a form object or otherwise abstracted, but this is good
|
|
195
|
+
# enough for now.
|
|
196
|
+
def permittable_params
|
|
197
|
+
%i[title publication_state layer_geom_type_s dct_references_s q f page sort rows daterange]
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def document_params
|
|
201
|
+
Kithe::Parameters.new(params).require(:document).permit_attr_json(Document).permit(permittable_params)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def collect_csv(documents)
|
|
205
|
+
CSV.generate(headers: true) do |csv|
|
|
206
|
+
csv << GeoblacklightAdmin::Schema.instance.exportable_fields.map { |k, _v| k.to_s }
|
|
207
|
+
if documents.instance_of?(BlacklightApi)
|
|
208
|
+
documents.load_all.map do |doc|
|
|
209
|
+
csv << doc.to_csv if doc.present?
|
|
210
|
+
end
|
|
211
|
+
else
|
|
212
|
+
documents.each do |doc|
|
|
213
|
+
csv << doc.to_csv
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::ElementsController
|
|
4
|
+
module Admin
|
|
5
|
+
class ElementsController < Admin::AdminController
|
|
6
|
+
before_action :set_element, only: %i[show edit update destroy]
|
|
7
|
+
|
|
8
|
+
# GET /elements or /elements.json
|
|
9
|
+
def index
|
|
10
|
+
@pagy, @elements = pagy(Element.all.order(position: :asc), items: 100)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /elements/1 or /elements/1.json
|
|
14
|
+
def show
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# GET /elements/new
|
|
18
|
+
def new
|
|
19
|
+
@element = Element.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# GET /elements/1/edit
|
|
23
|
+
def edit
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# POST /elements or /elements.json
|
|
27
|
+
def create
|
|
28
|
+
@element = Element.new(element_params)
|
|
29
|
+
|
|
30
|
+
respond_to do |format|
|
|
31
|
+
if @element.save
|
|
32
|
+
format.html { redirect_to element_url(@element), notice: "Element was successfully created." }
|
|
33
|
+
format.json { render :show, status: :created, location: @element }
|
|
34
|
+
else
|
|
35
|
+
format.html { render :new, status: :unprocessable_entity }
|
|
36
|
+
format.json { render json: @element.errors, status: :unprocessable_entity }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# PATCH/PUT /elements/1 or /elements/1.json
|
|
42
|
+
def update
|
|
43
|
+
respond_to do |format|
|
|
44
|
+
if @element.update(element_params)
|
|
45
|
+
format.html { redirect_to element_url(@element), notice: "Element was successfully updated." }
|
|
46
|
+
format.json { render :show, status: :ok, location: @element }
|
|
47
|
+
else
|
|
48
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
49
|
+
format.json { render json: @element.errors, status: :unprocessable_entity }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# DELETE /elements/1 or /elements/1.json
|
|
55
|
+
def destroy
|
|
56
|
+
@element.destroy
|
|
57
|
+
|
|
58
|
+
respond_to do |format|
|
|
59
|
+
format.html { redirect_to elements_url, notice: "Element was successfully destroyed." }
|
|
60
|
+
format.json { head :no_content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def sort
|
|
65
|
+
Element.sort_elements(params[:id_list])
|
|
66
|
+
render body: nil
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
72
|
+
def set_element
|
|
73
|
+
@element = Element.find(params[:id])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Only allow a list of trusted parameters through.
|
|
77
|
+
def element_params
|
|
78
|
+
params.require(:element).permit(:label, :solr_field, :field_definition, :field_type, :required, :repeatable, :formable, :placeholder_text, :data_entry_hint, :test_fixture_example, :controlled_vocabulary, :js_behaviors, :html_attributes, :display_only_on_persisted, :importable, :import_deliminated, :import_transformation_method, :exportable, :export_transformation_method, :indexable, :index_transformation_method, :validation_method, :position)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Admin::FormElementsController
|
|
4
|
+
module Admin
|
|
5
|
+
class FormElementsController < Admin::AdminController
|
|
6
|
+
before_action :set_form_element, only: %i[show edit update destroy]
|
|
7
|
+
|
|
8
|
+
# GET /form_elements or /form_elements.json
|
|
9
|
+
def index
|
|
10
|
+
@form_elements = FormElement.all
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /form_elements/1 or /form_elements/1.json
|
|
14
|
+
def show
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# GET /form_elements/new
|
|
18
|
+
def new
|
|
19
|
+
@form_element = FormElement.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# GET /form_elements/1/edit
|
|
23
|
+
def edit
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# POST /form_elements or /form_elements.json
|
|
27
|
+
def create
|
|
28
|
+
@form_element = FormElement.new(form_element_params)
|
|
29
|
+
|
|
30
|
+
respond_to do |format|
|
|
31
|
+
if @form_element.save
|
|
32
|
+
format.html { redirect_to form_elements_path, notice: "Form element was successfully created." }
|
|
33
|
+
format.json { render :show, status: :created, location: @form_element }
|
|
34
|
+
else
|
|
35
|
+
format.html { render :new, status: :unprocessable_entity }
|
|
36
|
+
format.json { render json: @form_element.errors, status: :unprocessable_entity }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# PATCH/PUT /form_elements/1 or /form_elements/1.json
|
|
42
|
+
def update
|
|
43
|
+
respond_to do |format|
|
|
44
|
+
if @form_element.update(form_element_params)
|
|
45
|
+
format.html { redirect_to form_element_url(@form_element), notice: "Form element was successfully updated." }
|
|
46
|
+
format.json { render :show, status: :ok, location: @form_element }
|
|
47
|
+
else
|
|
48
|
+
format.html { render :edit, status: :unprocessable_entity }
|
|
49
|
+
format.json { render json: @form_element.errors, status: :unprocessable_entity }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# DELETE /form_elements/1 or /form_elements/1.json
|
|
55
|
+
def destroy
|
|
56
|
+
@form_element.destroy
|
|
57
|
+
|
|
58
|
+
respond_to do |format|
|
|
59
|
+
format.html { redirect_to form_elements_url, notice: "Form element was successfully destroyed." }
|
|
60
|
+
format.json { head :no_content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def sort
|
|
65
|
+
FormElement.sort_elements(params[:id_list])
|
|
66
|
+
render body: nil
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
72
|
+
def set_form_element
|
|
73
|
+
@form_element = FormElement.find(params[:id])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Only allow a list of trusted parameters through.
|
|
77
|
+
def form_element_params
|
|
78
|
+
params.require(:form_element).permit(:type, :label, :element_solr_field)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|