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.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +18 -0
  3. data/.gitignore +75 -0
  4. data/.standard.yml +4 -0
  5. data/Gemfile +59 -0
  6. data/LICENSE +21 -0
  7. data/README.md +84 -0
  8. data/Rakefile +72 -0
  9. data/app/assets/images/.keep +0 -0
  10. data/app/assets/images/aerial_photo.jpg +0 -0
  11. data/app/assets/images/archive-solid.svg +1 -0
  12. data/app/assets/images/bookmark-regular.svg +1 -0
  13. data/app/assets/images/bookmark-solid.svg +1 -0
  14. data/app/assets/images/btaa-logo.jpg +0 -0
  15. data/app/assets/images/cloud-download-alt-solid.svg +1 -0
  16. data/app/assets/images/file-import-solid.svg +1 -0
  17. data/app/assets/images/trash-alt-solid.svg +1 -0
  18. data/app/assets/javascripts/geoblacklight_admin/chosen.js +4 -0
  19. data/app/assets/javascripts/geoblacklight_admin/date_range_picker.js +173 -0
  20. data/app/assets/javascripts/geoblacklight_admin/datepicker.js +22 -0
  21. data/app/assets/javascripts/geoblacklight_admin/elements.js +38 -0
  22. data/app/assets/javascripts/geoblacklight_admin/exports.js +3 -0
  23. data/app/assets/javascripts/geoblacklight_admin/fields.js +11 -0
  24. data/app/assets/javascripts/geoblacklight_admin/geoblacklight_admin.js +2 -0
  25. data/app/assets/javascripts/geoblacklight_admin/inputmask.js +4 -0
  26. data/app/assets/javascripts/geoblacklight_admin/locale.js +5 -0
  27. data/app/assets/javascripts/geoblacklight_admin/sortable.js +2544 -0
  28. data/app/assets/javascripts/geoblacklight_admin/tooltips.js +3 -0
  29. data/app/assets/javascripts/geoblacklight_admin/truncate.js +4 -0
  30. data/app/assets/javascripts/geoblacklight_admin.js +40 -0
  31. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +47 -0
  32. data/app/assets/stylesheets/geoblacklight_admin/modules/_autocomplete.scss +32 -0
  33. data/app/assets/stylesheets/geoblacklight_admin/modules/_blazer.scss +3 -0
  34. data/app/assets/stylesheets/geoblacklight_admin/modules/_code.scss +3 -0
  35. data/app/assets/stylesheets/geoblacklight_admin/modules/_datepicker.scss +477 -0
  36. data/app/assets/stylesheets/geoblacklight_admin/modules/_elements.scss +3 -0
  37. data/app/assets/stylesheets/geoblacklight_admin/modules/_forms.scss +28 -0
  38. data/app/assets/stylesheets/geoblacklight_admin/modules/_icons.scss +15 -0
  39. data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +9 -0
  40. data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +4 -0
  41. data/app/assets/stylesheets/geoblacklight_admin/modules/_toasts.scss +7 -0
  42. data/app/assets/stylesheets/geoblacklight_admin/modules/_visibility.scss +3 -0
  43. data/app/assets/stylesheets/geoblacklight_admin/settings/_variables.scss +1 -0
  44. data/app/channels/export_channel.rb +12 -0
  45. data/app/controllers/admin/admin_controller.rb +16 -0
  46. data/app/controllers/admin/advanced_search_controller.rb +365 -0
  47. data/app/controllers/admin/api_controller.rb +386 -0
  48. data/app/controllers/admin/bookmarks_controller.rb +68 -0
  49. data/app/controllers/admin/bulk_actions_controller.rb +94 -0
  50. data/app/controllers/admin/concerns/.keep +0 -0
  51. data/app/controllers/admin/concerns/upload_util.rb +8 -0
  52. data/app/controllers/admin/document_accesses_controller.rb +125 -0
  53. data/app/controllers/admin/document_assets_controller.rb +198 -0
  54. data/app/controllers/admin/document_downloads_controller.rb +127 -0
  55. data/app/controllers/admin/documents_controller.rb +219 -0
  56. data/app/controllers/admin/elements_controller.rb +81 -0
  57. data/app/controllers/admin/form_elements_controller.rb +81 -0
  58. data/app/controllers/admin/ids_controller.rb +379 -0
  59. data/app/controllers/admin/import_documents_controller.rb +18 -0
  60. data/app/controllers/admin/imports_controller.rb +105 -0
  61. data/app/controllers/admin/mappings_controller.rb +95 -0
  62. data/app/controllers/admin/notifications_controller.rb +51 -0
  63. data/app/controllers/admin/search_controller.rb +10 -0
  64. data/app/controllers/admin/users_controller.rb +10 -0
  65. data/app/helpers/bulk_actions_helper.rb +9 -0
  66. data/app/helpers/document_helper.rb +60 -0
  67. data/app/helpers/form_input_helper.rb +73 -0
  68. data/app/helpers/geoblacklight_admin_helper.rb +118 -0
  69. data/app/helpers/import_documents_helper.rb +5 -0
  70. data/app/helpers/mappings_helper.rb +27 -0
  71. data/app/indexers/document_indexer.rb +34 -0
  72. data/app/jobs/bulk_action_revert_document_job.rb +49 -0
  73. data/app/jobs/bulk_action_revert_job.rb +25 -0
  74. data/app/jobs/bulk_action_run_document_job.rb +42 -0
  75. data/app/jobs/bulk_action_run_job.rb +27 -0
  76. data/app/jobs/export_job.rb +72 -0
  77. data/app/jobs/export_json_job.rb +120 -0
  78. data/app/jobs/import_document_job.rb +25 -0
  79. data/app/jobs/import_run_job.rb +33 -0
  80. data/app/models/active_storage_attachment.rb +5 -0
  81. data/app/models/active_storage_blob.rb +5 -0
  82. data/app/models/api_search_builder.rb +12 -0
  83. data/app/models/application_record.rb +6 -0
  84. data/app/models/blacklight_api.rb +93 -0
  85. data/app/models/blacklight_api_facets.rb +15 -0
  86. data/app/models/blacklight_api_ids.rb +103 -0
  87. data/app/models/bookmark.rb +17 -0
  88. data/app/models/bulk_action.rb +88 -0
  89. data/app/models/bulk_action_document.rb +22 -0
  90. data/app/models/bulk_action_document_state_machine.rb +16 -0
  91. data/app/models/bulk_action_document_transition.rb +19 -0
  92. data/app/models/bulk_action_state_machine.rb +16 -0
  93. data/app/models/bulk_action_transition.rb +26 -0
  94. data/app/models/concerns/.keep +0 -0
  95. data/app/models/document/bbox_validator.rb +70 -0
  96. data/app/models/document/controlled_lists.rb +104 -0
  97. data/app/models/document/date_range_validator.rb +63 -0
  98. data/app/models/document/geom_validator.rb +117 -0
  99. data/app/models/document/reference.rb +107 -0
  100. data/app/models/document.rb +264 -0
  101. data/app/models/document_access.rb +35 -0
  102. data/app/models/document_download.rb +35 -0
  103. data/app/models/document_state_machine.rb +14 -0
  104. data/app/models/document_transition.rb +26 -0
  105. data/app/models/element.rb +90 -0
  106. data/app/models/form_control.rb +2 -0
  107. data/app/models/form_element.rb +19 -0
  108. data/app/models/form_feature.rb +2 -0
  109. data/app/models/form_group.rb +2 -0
  110. data/app/models/form_header.rb +2 -0
  111. data/app/models/geoblacklight_admin/field_mappings_btaa_aardvark.rb +379 -0
  112. data/app/models/geoblacklight_admin/field_mappings_gblv1.rb +344 -0
  113. data/app/models/geoblacklight_admin/iso_language_codes.rb +515 -0
  114. data/app/models/geoblacklight_admin/schema.rb +194 -0
  115. data/app/models/geoblacklight_admin.rb +3 -0
  116. data/app/models/import/csv_duplicates_validator.rb +36 -0
  117. data/app/models/import/csv_header_validator.rb +24 -0
  118. data/app/models/import.rb +186 -0
  119. data/app/models/import_btaa.rb +91 -0
  120. data/app/models/import_btaa_aardvark.rb +109 -0
  121. data/app/models/import_document.rb +34 -0
  122. data/app/models/import_document_state_machine.rb +12 -0
  123. data/app/models/import_document_transition.rb +19 -0
  124. data/app/models/import_gblv1.rb +92 -0
  125. data/app/models/import_state_machine.rb +16 -0
  126. data/app/models/import_transition.rb +26 -0
  127. data/app/models/mapping.rb +10 -0
  128. data/app/models/notification.rb +9 -0
  129. data/app/models/user.rb +26 -0
  130. data/app/notifications/export_notification.rb +30 -0
  131. data/app/services/export_csv_document_access_links_service.rb +47 -0
  132. data/app/services/export_csv_document_downloads_service.rb +47 -0
  133. data/app/services/export_csv_service.rb +44 -0
  134. data/app/services/export_json_service.rb +35 -0
  135. data/app/services/zip_file_generator.rb +56 -0
  136. data/app/views/admin/advanced_search/facets.json.jbuilder +80 -0
  137. data/app/views/admin/advanced_search/index.json.jbuilder +90 -0
  138. data/app/views/admin/api/_field.json.jbuilder +10 -0
  139. data/app/views/admin/api/fetch.json.jbuilder +86 -0
  140. data/app/views/admin/api/index.json.jbuilder +90 -0
  141. data/app/views/admin/bookmarks/_bookmark.json.jbuilder +4 -0
  142. data/app/views/admin/bookmarks/create.js.erb +7 -0
  143. data/app/views/admin/bookmarks/destroy.js.erb +7 -0
  144. data/app/views/admin/bookmarks/index.html.erb +21 -0
  145. data/app/views/admin/bookmarks/index.json.jbuilder +3 -0
  146. data/app/views/admin/bulk_actions/_bulk_action.json.jbuilder +4 -0
  147. data/app/views/admin/bulk_actions/_form.html.erb +17 -0
  148. data/app/views/admin/bulk_actions/edit.html.erb +6 -0
  149. data/app/views/admin/bulk_actions/index.html.erb +54 -0
  150. data/app/views/admin/bulk_actions/index.json.jbuilder +3 -0
  151. data/app/views/admin/bulk_actions/new.html.erb +5 -0
  152. data/app/views/admin/bulk_actions/show.html.erb +100 -0
  153. data/app/views/admin/bulk_actions/show.json.jbuilder +3 -0
  154. data/app/views/admin/devise/confirmations/new.html.erb +16 -0
  155. data/app/views/admin/devise/invitations/edit.html.erb +15 -0
  156. data/app/views/admin/devise/invitations/new.html.erb +15 -0
  157. data/app/views/admin/devise/mailer/invitation_instructions.html.erb +11 -0
  158. data/app/views/admin/devise/mailer/invitation_instructions.text.erb +11 -0
  159. data/app/views/admin/devise/passwords/edit.html.erb +26 -0
  160. data/app/views/admin/devise/passwords/new.html.erb +16 -0
  161. data/app/views/admin/devise/registrations/edit.html.erb +35 -0
  162. data/app/views/admin/devise/registrations/new.html.erb +30 -0
  163. data/app/views/admin/devise/sessions/new.html.erb +28 -0
  164. data/app/views/admin/devise/shared/_links.html.erb +27 -0
  165. data/app/views/admin/devise/unlocks/new.html.erb +16 -0
  166. data/app/views/admin/document_accesses/_document_access.json.jbuilder +4 -0
  167. data/app/views/admin/document_accesses/_form.html.erb +17 -0
  168. data/app/views/admin/document_accesses/destroy_all.html.erb +70 -0
  169. data/app/views/admin/document_accesses/edit.html.erb +5 -0
  170. data/app/views/admin/document_accesses/import.html.erb +70 -0
  171. data/app/views/admin/document_accesses/index.html.erb +74 -0
  172. data/app/views/admin/document_accesses/index.json.jbuilder +3 -0
  173. data/app/views/admin/document_accesses/new.html.erb +6 -0
  174. data/app/views/admin/document_accesses/show.html.erb +19 -0
  175. data/app/views/admin/document_accesses/show.json.jbuilder +3 -0
  176. data/app/views/admin/document_assets/display_attach_form.html.erb +44 -0
  177. data/app/views/admin/document_assets/index.html.erb +65 -0
  178. data/app/views/admin/document_downloads/_document_download.json.jbuilder +4 -0
  179. data/app/views/admin/document_downloads/_form.html.erb +15 -0
  180. data/app/views/admin/document_downloads/destroy_all.html.erb +70 -0
  181. data/app/views/admin/document_downloads/edit.html.erb +6 -0
  182. data/app/views/admin/document_downloads/import.html.erb +74 -0
  183. data/app/views/admin/document_downloads/index.html.erb +70 -0
  184. data/app/views/admin/document_downloads/index.json.jbuilder +3 -0
  185. data/app/views/admin/document_downloads/new.html.erb +5 -0
  186. data/app/views/admin/document_downloads/show.html.erb +24 -0
  187. data/app/views/admin/document_downloads/show.json.jbuilder +3 -0
  188. data/app/views/admin/documents/_document.html.erb +29 -0
  189. data/app/views/admin/documents/_document_bookmark.html.erb +17 -0
  190. data/app/views/admin/documents/_document_fields.html.erb +24 -0
  191. data/app/views/admin/documents/_form.html.erb +49 -0
  192. data/app/views/admin/documents/_form_control.html.erb +86 -0
  193. data/app/views/admin/documents/_form_group.html.erb +1 -0
  194. data/app/views/admin/documents/_form_header.html.erb +1 -0
  195. data/app/views/admin/documents/_form_nav.html.erb +21 -0
  196. data/app/views/admin/documents/_json_aardvark.jbuilder +47 -0
  197. data/app/views/admin/documents/_json_btaa_aardvark.jbuilder +16 -0
  198. data/app/views/admin/documents/_json_gbl_v1.jbuilder +32 -0
  199. data/app/views/admin/documents/_result_facets.html.erb +35 -0
  200. data/app/views/admin/documents/_result_pagination.html.erb +21 -0
  201. data/app/views/admin/documents/_result_selected_options.html.erb +54 -0
  202. data/app/views/admin/documents/_result_selection_options.html.erb +10 -0
  203. data/app/views/admin/documents/_result_toggle.html.erb +13 -0
  204. data/app/views/admin/documents/edit.html.erb +7 -0
  205. data/app/views/admin/documents/features/_assets.html.erb +3 -0
  206. data/app/views/admin/documents/features/_institutional_access_links.html.erb +3 -0
  207. data/app/views/admin/documents/features/_multiple_download_links.html.erb +27 -0
  208. data/app/views/admin/documents/fetch.json_aardvark.jbuilder +9 -0
  209. data/app/views/admin/documents/fetch.json_btaa_aardvark.jbuilder +9 -0
  210. data/app/views/admin/documents/fetch.json_gbl_v1.jbuilder +9 -0
  211. data/app/views/admin/documents/index.html.erb +49 -0
  212. data/app/views/admin/documents/index.json_aardvark.jbuilder +9 -0
  213. data/app/views/admin/documents/index.json_btaa_aardvark.jbuilder +9 -0
  214. data/app/views/admin/documents/index.json_gbl_v1.jbuilder +9 -0
  215. data/app/views/admin/documents/show.json_aardvark.jbuilder +3 -0
  216. data/app/views/admin/documents/show.json_btaa_aardvark.jbuilder +3 -0
  217. data/app/views/admin/documents/show.json_gbl_v1.jbuilder +3 -0
  218. data/app/views/admin/documents/versions.html.erb +110 -0
  219. data/app/views/admin/elements/_element.json.jbuilder +2 -0
  220. data/app/views/admin/elements/_form.html.erb +45 -0
  221. data/app/views/admin/elements/edit.html.erb +6 -0
  222. data/app/views/admin/elements/index.html.erb +68 -0
  223. data/app/views/admin/elements/index.json.jbuilder +1 -0
  224. data/app/views/admin/elements/new.html.erb +5 -0
  225. data/app/views/admin/elements/show.html.erb +121 -0
  226. data/app/views/admin/elements/show.json.jbuilder +1 -0
  227. data/app/views/admin/form_elements/_form.html.erb +46 -0
  228. data/app/views/admin/form_elements/_form_element.json.jbuilder +2 -0
  229. data/app/views/admin/form_elements/edit.html.erb +6 -0
  230. data/app/views/admin/form_elements/index.html.erb +49 -0
  231. data/app/views/admin/form_elements/index.json.jbuilder +1 -0
  232. data/app/views/admin/form_elements/new.html.erb +5 -0
  233. data/app/views/admin/form_elements/show.html.erb +19 -0
  234. data/app/views/admin/form_elements/show.json.jbuilder +1 -0
  235. data/app/views/admin/ids/fetch.json.jbuilder +86 -0
  236. data/app/views/admin/ids/index.json.jbuilder +41 -0
  237. data/app/views/admin/import_documents/show.html.haml +20 -0
  238. data/app/views/admin/imports/_form.html.erb +27 -0
  239. data/app/views/admin/imports/_import.json.jbuilder +4 -0
  240. data/app/views/admin/imports/_show_failed_tab.html.erb +37 -0
  241. data/app/views/admin/imports/_show_success_tab.html.erb +31 -0
  242. data/app/views/admin/imports/edit.html.erb +8 -0
  243. data/app/views/admin/imports/index.html.erb +56 -0
  244. data/app/views/admin/imports/index.json.jbuilder +3 -0
  245. data/app/views/admin/imports/new.html.erb +7 -0
  246. data/app/views/admin/imports/show.html.erb +123 -0
  247. data/app/views/admin/imports/show.json.jbuilder +3 -0
  248. data/app/views/admin/layouts/application.html.erb +30 -0
  249. data/app/views/admin/layouts/blazer/application.html.erb +23 -0
  250. data/app/views/admin/layouts/mailer.html.erb +13 -0
  251. data/app/views/admin/layouts/mailer.text.erb +1 -0
  252. data/app/views/admin/mappings/_form.html.erb +17 -0
  253. data/app/views/admin/mappings/_mapping.json.jbuilder +4 -0
  254. data/app/views/admin/mappings/edit.html.erb +6 -0
  255. data/app/views/admin/mappings/index.html.erb +37 -0
  256. data/app/views/admin/mappings/index.json.jbuilder +3 -0
  257. data/app/views/admin/mappings/new.html.erb +5 -0
  258. data/app/views/admin/mappings/show.html.erb +27 -0
  259. data/app/views/admin/mappings/show.json.jbuilder +3 -0
  260. data/app/views/admin/notifications/_notification.html.haml +31 -0
  261. data/app/views/admin/notifications/index.html.erb +54 -0
  262. data/app/views/admin/notifications/update.js.erb +7 -0
  263. data/app/views/admin/search/index.html.erb +38 -0
  264. data/app/views/admin/shared/_flash_messages.html.erb +5 -0
  265. data/app/views/admin/shared/_footer.html.erb +56 -0
  266. data/app/views/admin/shared/_js_behaviors.html.erb +147 -0
  267. data/app/views/admin/shared/_navbar.html.erb +78 -0
  268. data/app/views/admin/shared/_navbar_blazer.html.erb +42 -0
  269. data/app/views/admin/shared/_schema_timestamp.html.erb +16 -0
  270. data/app/views/admin/shared/_toast.html.erb +13 -0
  271. data/app/views/admin/users/index.html.erb +21 -0
  272. data/config/authorities/formats.yml +25 -0
  273. data/config/authorities/languages.yml +50 -0
  274. data/config/authorities/resource_type.yml +82 -0
  275. data/config/blazer.yml +79 -0
  276. data/config/gbl_v1_schema.json +118 -0
  277. data/config/geomg_aardvark_schema.json +211 -0
  278. data/config/geomg_schema.json +123 -0
  279. data/config/locales/devise.en.yml +65 -0
  280. data/config/locales/devise_invitable.en.yml +31 -0
  281. data/config/locales/documents.en.yml +189 -0
  282. data/config/locales/en.yml +51 -0
  283. data/config/locales/geoblacklight.en.yml +178 -0
  284. data/config/locales/simple_form.en.yml +31 -0
  285. data/config/routes.rb +162 -0
  286. data/db/migrate/20230316183001_add_geoblacklight_admin.rb +399 -0
  287. data/db/seeds.rb +26 -0
  288. data/db/seeds_elements.csv +56 -0
  289. data/db/seeds_elements.numbers +0 -0
  290. data/db/seeds_form_elements.csv +71 -0
  291. data/db/seeds_form_elements.numbers +0 -0
  292. data/db/structure.sql +816 -0
  293. data/geoblacklight_admin.gemspec +67 -0
  294. data/lib/generators/geoblacklight_admin/config_generator.rb +336 -0
  295. data/lib/generators/geoblacklight_admin/example_docs_generator.rb +18 -0
  296. data/lib/generators/geoblacklight_admin/helpers_generator.rb +18 -0
  297. data/lib/generators/geoblacklight_admin/install_generator.rb +60 -0
  298. data/lib/generators/geoblacklight_admin/jobs_generator.rb +21 -0
  299. data/lib/generators/geoblacklight_admin/models_generator.rb +23 -0
  300. data/lib/generators/geoblacklight_admin/templates/.env.development.example +28 -0
  301. data/lib/generators/geoblacklight_admin/templates/.solr_wrapper.yml +7 -0
  302. data/lib/generators/geoblacklight_admin/templates/_user_util_links.html.erb +30 -0
  303. data/lib/generators/geoblacklight_admin/templates/config/database.yml +18 -0
  304. data/lib/generators/geoblacklight_admin/templates/config/geomg_aardvark_schema.json +211 -0
  305. data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +25 -0
  306. data/lib/generators/geoblacklight_admin/templates/config/initializers/kithe.rb +31 -0
  307. data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +158 -0
  308. data/lib/generators/geoblacklight_admin/templates/config/initializers/statesman.rb +7 -0
  309. data/lib/generators/geoblacklight_admin/templates/javascript/channels/consumer.js +6 -0
  310. data/lib/generators/geoblacklight_admin/templates/javascript/channels/export_channel.js +30 -0
  311. data/lib/generators/geoblacklight_admin/templates/javascript/channels/index.js +5 -0
  312. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/application_controller.js +17 -0
  313. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/document_controller.js +26 -0
  314. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/index.js +10 -0
  315. data/lib/generators/geoblacklight_admin/templates/javascript/controllers/results_controller.js +310 -0
  316. data/lib/generators/geoblacklight_admin/templates/javascript/packs/application.js +23 -0
  317. data/lib/generators/geoblacklight_admin/templates/javascript/src/js/admin/qa_autocomplete.js +1134 -0
  318. data/lib/generators/geoblacklight_admin/templates/package.json +32 -0
  319. data/lib/generators/geoblacklight_admin/templates/solr/README-geoblacklight-solr-development.txt +3 -0
  320. data/lib/generators/geoblacklight_admin/templates/solr/conf/_rest_managed.json +3 -0
  321. data/lib/generators/geoblacklight_admin/templates/solr/conf/admin-extra.html +31 -0
  322. data/lib/generators/geoblacklight_admin/templates/solr/conf/core.properties +5 -0
  323. data/lib/generators/geoblacklight_admin/templates/solr/conf/elevate.xml +36 -0
  324. data/lib/generators/geoblacklight_admin/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  325. data/lib/generators/geoblacklight_admin/templates/solr/conf/protwords.txt +21 -0
  326. data/lib/generators/geoblacklight_admin/templates/solr/conf/schema.xml +229 -0
  327. data/lib/generators/geoblacklight_admin/templates/solr/conf/scripts.conf +24 -0
  328. data/lib/generators/geoblacklight_admin/templates/solr/conf/solrconfig.xml +266 -0
  329. data/lib/generators/geoblacklight_admin/templates/solr/conf/spellings.txt +2 -0
  330. data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords.txt +58 -0
  331. data/lib/generators/geoblacklight_admin/templates/solr/conf/stopwords_en.txt +58 -0
  332. data/lib/generators/geoblacklight_admin/templates/solr/conf/synonyms.txt +43 -0
  333. data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example.xsl +132 -0
  334. data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_atom.xsl +67 -0
  335. data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/example_rss.xsl +66 -0
  336. data/lib/generators/geoblacklight_admin/templates/solr/conf/xslt/luke.xsl +337 -0
  337. data/lib/generators/geoblacklight_admin/templates/solr/snapshots/.keep +0 -0
  338. data/lib/generators/geoblacklight_admin/views_generator.rb +19 -0
  339. data/lib/geoblacklight_admin/engine.rb +20 -0
  340. data/lib/geoblacklight_admin/version.rb +5 -0
  341. data/lib/geoblacklight_admin.rb +7 -0
  342. data/lib/tasks/.keep +0 -0
  343. data/lib/tasks/geoblacklight_admin.rake +209 -0
  344. data/spec/test_app_templates/lib/generators/test_app_generator.rb +35 -0
  345. data/template.rb +16 -0
  346. 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