diff --git a/assets/controllers/delete_record_controller.js b/assets/controllers/delete_record_controller.js index 82ef548..6a5f8e6 100644 --- a/assets/controllers/delete_record_controller.js +++ b/assets/controllers/delete_record_controller.js @@ -5,17 +5,22 @@ import { Controller } from '@hotwired/stimulus'; * [template: {entity}/index.html.twig] */ export default class extends Controller { - static targets = ['modal', 'path']; + static targets = ['modal', 'path', 'name', 'message']; /** * @todo Refactor with actions for modal * @param {object} event */ - show(event) { + warn(event) { event.preventDefault(); + const id = event.currentTarget.getAttribute('data-url').match(/\d+$/)[0]; const modal = this.modalTarget; + const name = this.nameTargets.find(a => a.href.includes(id)).textContent; + + const message = `The record '${name.trim()}' will be permanently deleted. Proceed?`; modal.classList.add('is-active'); + this.messageTarget.innerHTML = message; modal.querySelector('.delete').addEventListener('click', () => { modal.classList.remove('is-active'); }); @@ -28,8 +33,8 @@ export default class extends Controller { } // Proceed with deletion... - delete(event) { - const delPath = this.pathTarget.href; + delete() { + const delPath = this.pathTarget.getAttribute('data-url'); location.href = delPath; } } diff --git a/assets/controllers/map_controller.js b/assets/controllers/map_controller.js new file mode 100644 index 0000000..13d80fe --- /dev/null +++ b/assets/controllers/map_controller.js @@ -0,0 +1,13 @@ +import { Controller } from '@hotwired/stimulus'; + +/** + */ +export default class extends Controller { + static targets = [ 'map',]; + static values = { + state: Number, + }; + + initialize() { + } +} diff --git a/templates/bibliography/landing.html.twig b/templates/bibliography/landing.html.twig index 945dd25..c417ccb 100644 --- a/templates/bibliography/landing.html.twig +++ b/templates/bibliography/landing.html.twig @@ -54,7 +54,11 @@ {% for record in records %} {{ record.id }} - {{ record.citation }} + + + {{ record.citation }} + + {{ record.status }} {{ record.owner }} {{ record.reference }} @@ -69,13 +73,13 @@ - + data-delete-record-target="path" data-action="click->delete-record#warn"> - + @@ -92,7 +96,7 @@