fix: edits to existing deals not saving
Hidden input was named "id", which collided with form.id
(standard DOM property returning the form element's id attribute,
not the named control). FormData.get("id") returned empty,
so submit always created a new deal instead of updating.
Renamed field to "dealId" and updated all references.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
94f5d6a56b
commit
c726bf9d36
@ -149,7 +149,7 @@ function openDealModal(id){
|
||||
if(id){
|
||||
const d = window.Store.get(id);
|
||||
if(!d) return;
|
||||
form.id.value = d.id;
|
||||
form.dealId.value = d.id;
|
||||
form.company.value = d.company;
|
||||
form.product.value = d.product || "";
|
||||
form.manager.value = d.manager;
|
||||
@ -190,7 +190,7 @@ function bindEvents(){
|
||||
$("#deal-form").addEventListener("submit", e => {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(e.target);
|
||||
const id = fd.get("id") || null;
|
||||
const id = fd.get("dealId") || null;
|
||||
const existing = id ? window.Store.get(id) : null;
|
||||
const statusText = (fd.get("currentStatus") || "").trim();
|
||||
const oldStatus = existing ? (existing.currentStatus || "") : "";
|
||||
@ -224,7 +224,7 @@ function bindEvents(){
|
||||
});
|
||||
|
||||
$("#delete-deal").addEventListener("click", () => {
|
||||
const id = $("#deal-form").id.value;
|
||||
const id = $("#deal-form").dealId.value;
|
||||
if(!id) return;
|
||||
if(!confirm("Удалить сделку?")) return;
|
||||
window.Store.remove(id);
|
||||
|
||||
@ -134,7 +134,7 @@ td.status-cell textarea:focus{background:#fff;outline:2px solid var(--primary)}
|
||||
<button class="modal-close" id="modal-close" type="button">✕</button>
|
||||
<h3 id="modal-title">Сделка</h3>
|
||||
<form id="deal-form">
|
||||
<input type="hidden" name="id">
|
||||
<input type="hidden" name="dealId">
|
||||
<label>Компания <input name="company" required></label>
|
||||
<label>Название продукта/услуги <input name="product" placeholder="например: CRM-внедрение"></label>
|
||||
<label>Менеджер
|
||||
|
||||
Reference in New Issue
Block a user