fix: Preserve form content when adding/removing conclusions and actions
Sync DOM values to currentMeeting object before re-rendering when user clicks Add or Remove buttons. Previously, typed content was lost because render functions read from the data model which wasn't updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -534,23 +534,64 @@
|
|||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save current form values to currentMeeting before re-rendering
|
||||||
|
function syncConclusionsFromDOM() {
|
||||||
|
document.querySelectorAll('.conclusion-content').forEach(textarea => {
|
||||||
|
const index = parseInt(textarea.dataset.index);
|
||||||
|
if (currentMeeting.conclusions && currentMeeting.conclusions[index]) {
|
||||||
|
currentMeeting.conclusions[index].content = textarea.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncActionsFromDOM() {
|
||||||
|
document.querySelectorAll('.action-content').forEach(textarea => {
|
||||||
|
const index = parseInt(textarea.dataset.index);
|
||||||
|
if (currentMeeting.actions && currentMeeting.actions[index]) {
|
||||||
|
currentMeeting.actions[index].content = textarea.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.action-owner').forEach(input => {
|
||||||
|
const index = parseInt(input.dataset.index);
|
||||||
|
if (currentMeeting.actions && currentMeeting.actions[index]) {
|
||||||
|
currentMeeting.actions[index].owner = input.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.action-due').forEach(input => {
|
||||||
|
const index = parseInt(input.dataset.index);
|
||||||
|
if (currentMeeting.actions && currentMeeting.actions[index]) {
|
||||||
|
currentMeeting.actions[index].due_date = input.value || null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.action-status').forEach(select => {
|
||||||
|
const index = parseInt(select.dataset.index);
|
||||||
|
if (currentMeeting.actions && currentMeeting.actions[index]) {
|
||||||
|
currentMeeting.actions[index].status = select.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.removeConclusion = function(index) {
|
window.removeConclusion = function(index) {
|
||||||
|
syncConclusionsFromDOM();
|
||||||
currentMeeting.conclusions.splice(index, 1);
|
currentMeeting.conclusions.splice(index, 1);
|
||||||
renderConclusions();
|
renderConclusions();
|
||||||
};
|
};
|
||||||
|
|
||||||
window.removeAction = function(index) {
|
window.removeAction = function(index) {
|
||||||
|
syncActionsFromDOM();
|
||||||
currentMeeting.actions.splice(index, 1);
|
currentMeeting.actions.splice(index, 1);
|
||||||
renderActions();
|
renderActions();
|
||||||
};
|
};
|
||||||
|
|
||||||
addConclusionBtn.addEventListener('click', () => {
|
addConclusionBtn.addEventListener('click', () => {
|
||||||
|
syncConclusionsFromDOM();
|
||||||
if (!currentMeeting.conclusions) currentMeeting.conclusions = [];
|
if (!currentMeeting.conclusions) currentMeeting.conclusions = [];
|
||||||
currentMeeting.conclusions.push({ content: '' });
|
currentMeeting.conclusions.push({ content: '' });
|
||||||
renderConclusions();
|
renderConclusions();
|
||||||
});
|
});
|
||||||
|
|
||||||
addActionBtn.addEventListener('click', () => {
|
addActionBtn.addEventListener('click', () => {
|
||||||
|
syncActionsFromDOM();
|
||||||
if (!currentMeeting.actions) currentMeeting.actions = [];
|
if (!currentMeeting.actions) currentMeeting.actions = [];
|
||||||
currentMeeting.actions.push({ content: '', owner: '', due_date: null, status: 'Open' });
|
currentMeeting.actions.push({ content: '', owner: '', due_date: null, status: 'Open' });
|
||||||
renderActions();
|
renderActions();
|
||||||
|
|||||||
Reference in New Issue
Block a user