diff --git a/assets/controllers/delete_record_controller.js b/assets/controllers/delete_record_controller.js new file mode 100644 index 0000000..9b504b9 --- /dev/null +++ b/assets/controllers/delete_record_controller.js @@ -0,0 +1,36 @@ +import { Controller } from '@hotwired/stimulus'; + +/** + * Show warning before deleting record + * [template: {entity}/index.html.twig] + */ +export default class extends Controller { + static targets = ['modal', 'path']; + + /** + * @todo Refactor with actions for modal + * @param {object} event + */ + show(event) { + event.preventDefault(); + const modal = this.modalTarget; + + modal.classList.add('is-active'); + modal.querySelector('.delete').addEventListener('click', () => { + modal.classList.remove('is-active'); + }); + modal.querySelector('.modal-background').addEventListener('click', () => { + modal.classList.remove('is-active'); + }); + modal.querySelector('#cancel').addEventListener('click', () => { + modal.classList.remove('is-active'); + }); + + } + // Proceed with deletion... + delete(event) { + const delPath = this.pathTarget.href; + location.href = delPath; + } +} + diff --git a/templates/bibliography/index.html.twig b/templates/bibliography/index.html.twig index effa97c..403df21 100644 --- a/templates/bibliography/index.html.twig +++ b/templates/bibliography/index.html.twig @@ -3,7 +3,7 @@ {% block title %}Bibliography - {{ record.citation }} | ArCOA{% endblock %} {% block rightpanel %} -
Delete record?
+ +This record will be permanently deleted. Proceed?
+Delete record?
- -This record will be permanently deleted. Proceed?
-Delete record?
+ +This record will be permanently deleted. Proceed?
+Delete record?
+ +This record will be permanently deleted. Proceed?
+