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; } }