From 6afd48aa6ea48f5e665ee57275a9d24fcec64f31 Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Mon, 7 Oct 2024 14:03:38 +0300 Subject: [PATCH] allow for editing of vendor in one line, just front end --- app/static/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/static/index.js b/app/static/index.js index a932b77..cfc963f 100644 --- a/app/static/index.js +++ b/app/static/index.js @@ -10,12 +10,31 @@ function startEditMode(id){ for(let i = 0; i < reassignButtons.length; i++){ reassignButtons[i].disabled = true; } - document.addEventListener('') + + const handleKeydown = (e) => { + if (e.key === 'Enter') { + document.removeEventListener('keydown', handleKeydown); + const vendor = document.getElementById(`vendor-line-${id}`); + const vendorInput = document.getElementById(`vendor-input-${id}`); + vendor.innerText = vendorInput.value; + if (vendorInput.parentNode) { + vendorInput.parentNode.removeChild(vendorInput); + } + + for(let i = 0; i < reassignButtons.length; i++){ + reassignButtons[i].disabled = false; + } + } + }; + + document.addEventListener('keydown', handleKeydown); + const vendor = document.getElementById(`vendor-line-${id}`); var placeholderText = vendor.innerText vendor.innerText = '' var inputElem = document.createElement("input"); inputElem.value = placeholderText; + inputElem.id = `vendor-input-${id}` vendor.appendChild(inputElem); }