From d1494eb0bfd4004bcf0aefb775b71227f372938d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Wed, 29 May 2024 21:33:02 +0200 Subject: [PATCH] Assets: repair inline edit --- assets/plugins/features/inline.ts | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/assets/plugins/features/inline.ts b/assets/plugins/features/inline.ts index d3e4a72a..d59ebb38 100644 --- a/assets/plugins/features/inline.ts +++ b/assets/plugins/features/inline.ts @@ -4,11 +4,10 @@ import { Datagrid, Datagrids } from "../.."; export class InlinePlugin implements DatagridPlugin { onInit(datagrids: Datagrids) { - } onDatagridInit(datagrid: Datagrid): boolean { - datagrid.ajax.addEventListener('success', ({detail: {payload}}) => { + datagrid.ajax.addEventListener('success', ({ detail: { payload } }) => { if (!payload._datagrid_name || payload._datagrid_name !== datagrid.name) return; if (payload._datagrid_inline_edited || payload._datagrid_inline_edit_cancel) { @@ -43,34 +42,34 @@ export class InlinePlugin implements DatagridPlugin { datagrid.el.querySelector(".datagrid-inline-edit-trigger") ?.classList.add("hidden"); } - }) - datagrid.el.querySelectorAll(".datagrid-inline-edit input").forEach(inputEl => { - inputEl.addEventListener("keydown", e => { - if (!isEnter(e)) return; + datagrid.el.querySelectorAll(".datagrid-inline-edit input").forEach(inputEl => { + inputEl.addEventListener("keydown", e => { + if (!isEnter(e)) return; - e.stopPropagation(); - e.preventDefault(); + e.stopPropagation(); + e.preventDefault(); - return inputEl - .closest("tr") - ?.querySelector(".col-action-inline-edit [name='inline_edit[submit]']") - ?.click(); + return inputEl + .closest("tr") + ?.querySelector(".col-action-inline-edit [name='inline_edit[submit]']") + ?.click(); + }); }); - }); - datagrid.el.querySelectorAll("[data-datagrid-cancel-inline-add]").forEach(cancel => { - cancel.addEventListener("mouseup", e => { - if (e.button === 0) { - e.stopPropagation(); - e.preventDefault(); - const inlineAdd = cancel.closest(".datagrid-row-inline-add"); - if (inlineAdd) { - inlineAdd.classList.add("datagrid-row-inline-add-hidden"); + datagrid.el.querySelectorAll("[data-datagrid-cancel-inline-add]").forEach(cancel => { + cancel.addEventListener("mouseup", e => { + if (e.button === 0) { + e.stopPropagation(); + e.preventDefault(); + const inlineAdd = cancel.closest(".datagrid-row-inline-add"); + if (inlineAdd) { + inlineAdd.classList.add("datagrid-row-inline-add-hidden"); + } } - } + }); }); - }); + }) return true; }