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 %} -
+

Bibliography

{{ record.citation }}

@@ -34,7 +34,9 @@ - + Delete @@ -63,55 +65,26 @@ Some stuff...
+ - - - - {% endblock %} \ No newline at end of file diff --git a/templates/collection/index.html.twig b/templates/collection/index.html.twig index 28035ea..b1ec457 100644 --- a/templates/collection/index.html.twig +++ b/templates/collection/index.html.twig @@ -3,7 +3,7 @@ {% block title %}Collection - {{ record.title }} | ArCOA{% endblock %} {% block rightpanel %} -
+

Collection

{{ record.title }}

@@ -19,27 +19,29 @@
+
- {% endblock %} \ No newline at end of file diff --git a/templates/collector/index.html.twig b/templates/collector/index.html.twig index 531eff1..d1a1f7e 100644 --- a/templates/collector/index.html.twig +++ b/templates/collector/index.html.twig @@ -3,7 +3,7 @@ {% block title %}Collector - {{ record.name }} | ArCOA{% endblock %} {% block rightpanel %} -
+

Collector

{{ record.name }}

@@ -33,12 +33,14 @@ - +
{% endif %} @@ -83,7 +85,28 @@ {% endif %}
- + + {% endblock %} \ No newline at end of file