feat(market): discard uncommitted group edits when switching away
Switching to another group in the Manage-portfolio list (or adding/deleting a group) now discards the current group's uncommitted working edits instead of auto-saving them — only the Save button (and closing the modal) persists. This matches the explicit-save model signalled by the Revert/Save buttons and the unsaved-changes dot: navigating between drafts is ephemeral until saved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -628,7 +628,7 @@ static void RenderPortfolioEditor(App* app)
|
|||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
if (delRow >= 0) {
|
if (delRow >= 0) {
|
||||||
commitIfNeeded(); // persist edits to the current group first
|
// Operates on the stored entries; any uncommitted working edits are discarded.
|
||||||
auto es = settings->getPortfolioEntries();
|
auto es = settings->getPortfolioEntries();
|
||||||
if (delRow < (int)es.size()) {
|
if (delRow < (int)es.size()) {
|
||||||
es.erase(es.begin() + delRow);
|
es.erase(es.begin() + delRow);
|
||||||
@@ -638,13 +638,15 @@ static void RenderPortfolioEditor(App* app)
|
|||||||
else if (delRow == s_pf_sel) s_pf_sel = std::min(delRow, (int)es.size() - 1);
|
else if (delRow == s_pf_sel) s_pf_sel = std::min(delRow, (int)es.size() - 1);
|
||||||
PortfolioBeginEdit(app, s_pf_sel);
|
PortfolioBeginEdit(app, s_pf_sel);
|
||||||
}
|
}
|
||||||
} else if (clickedSel != -999) { commitIfNeeded(); PortfolioBeginEdit(app, clickedSel); }
|
} else if (clickedSel != -999) {
|
||||||
|
PortfolioBeginEdit(app, clickedSel); // switching groups discards uncommitted edits
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::Dummy(ImVec2(0, Layout::spacingSm()));
|
ImGui::Dummy(ImVec2(0, Layout::spacingSm()));
|
||||||
// Add immediately creates a persisted "Untitled" group and selects it for editing.
|
// Add immediately creates a persisted "Untitled" group and selects it for editing.
|
||||||
if (ImGui::Button(TR("portfolio_add_entry"), ImVec2(masterW, addH))) {
|
if (ImGui::Button(TR("portfolio_add_entry"), ImVec2(masterW, addH))) {
|
||||||
commitIfNeeded();
|
// Adding switches to a new group; uncommitted edits to the current one are discarded.
|
||||||
auto es = settings->getPortfolioEntries();
|
auto es = settings->getPortfolioEntries();
|
||||||
config::Settings::PortfolioEntry ne;
|
config::Settings::PortfolioEntry ne;
|
||||||
ne.label = TR("portfolio_untitled");
|
ne.label = TR("portfolio_untitled");
|
||||||
|
|||||||
Reference in New Issue
Block a user