From 12284d91b18697bc87c122dc4ebe192b7bdb0b4d Mon Sep 17 00:00:00 2001 From: DanS Date: Thu, 19 Nov 2026 15:04:00 -0600 Subject: [PATCH] =?UTF-8?q?feat(transactions):=20export=20dialog=20?= =?UTF-8?q?=E2=80=94=20disabled-with-reason,=20no=20silent=20overwrite,=20?= =?UTF-8?q?folder=20link=20(F034/F073/F085)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UX audit, Export transactions dialog: - F034: the Export button is disabled when the scope is stale/invalid or no rows match, with the reason spelled out inline next to the count (was: always enabled, reason only shown as a toast after clicking). - F073: a persistent "Open folder" link (not only on the success screen), and an existing file is auto-suffixed (-2, -3, …) instead of being silently overwritten. - F085: the error line uses the themed ErrorVec4() instead of a raw literal. F096 (export shield legs as one merged row) deferred — needs a shared shield-merge helper with the History list. Build + tests green. Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/export_transactions_dialog.cpp | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ui/windows/export_transactions_dialog.cpp b/src/ui/windows/export_transactions_dialog.cpp index 761ce28..5f31c12 100644 --- a/src/ui/windows/export_transactions_dialog.cpp +++ b/src/ui/windows/export_transactions_dialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace dragonx { namespace ui { @@ -158,6 +159,15 @@ void ExportTransactionsDialog::render(App* app) ImGui::Spacing(); ImGui::Text(TR("export_tx_count"), scopeOk ? subsetIdx.size() : (size_t)0); + // Spell out why Export is unavailable, inline, instead of only reacting on click. (F034) + const bool canExport = scopeOk && !subsetIdx.empty(); + if (!canExport) { + const char* why = !scopeOk ? (s_scope == 1 ? TR("export_tx_scope_stale") : TR("export_tx_range_invalid")) + : TR("export_tx_none"); + ImGui::PushTextWrapPos(0.0f); + ImGui::TextColored(m::WarningVec4(), "%s", why); + ImGui::PopTextWrapPos(); + } ImGui::Spacing(); // Filename + save-location hint. @@ -166,6 +176,9 @@ void ExportTransactionsDialog::render(App* app) // Show the real, resolved config directory (the old hardcoded ~/.config path was wrong on Windows/macOS). ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceDisabled()), "%s %s", TR("file_save_location"), util::Platform::getConfigDir().c_str()); + // Persistent "Open folder" — reachable before an export too, not only on the success screen. (F073) + if (m::TactileButton(TR("export_tx_open_folder"), ImVec2(0, 0))) + util::Platform::openFolder(util::Platform::getConfigDir()); // Result — success shows the saved path as a copy field; failure shows a red line. if (!s_saved_path.empty()) { @@ -176,19 +189,17 @@ void ExportTransactionsDialog::render(App* app) ImGui::SameLine(0, 4.0f * Layout::dpiScale()); ImGui::TextColored(m::SuccessVec4(), "%s", TR("export_tx_success")); widgets::AddressCopyField("##exportedpath", s_saved_path); - if (m::TactileButton(TR("export_tx_open_folder"), ImVec2(0, 0))) - util::Platform::openFolder(util::Platform::getConfigDir()); } else if (!s_error.empty()) { ImGui::Spacing(); ImGui::PushTextWrapPos(0.0f); - ImGui::TextColored(ImVec4(0.8f, 0.3f, 0.3f, 1.0f), "%s", s_error.c_str()); + ImGui::TextColored(m::ErrorVec4(), "%s", s_error.c_str()); // follow the active skin (F085) ImGui::PopTextWrapPos(); } ImGui::Spacing(); bool doExport = false, doClose = false; - m::DialogActionFooter(TR("export"), true, TR("close"), doExport, doClose); + m::DialogActionFooter(TR("export"), canExport, TR("close"), doExport, doClose); if (doClose) s_open = false; if (doExport) { s_saved_path.clear(); @@ -203,8 +214,16 @@ void ExportTransactionsDialog::render(App* app) // Sanitize in-buffer so the user sees exactly what was written (and we can't be pointed outside // the config dir by a pasted path). std::string safeName = util::sanitizeExportFilename(s_filename, ".csv", "dragonx_transactions.csv"); - snprintf(s_filename, sizeof(s_filename), "%s", safeName.c_str()); std::string filepath = configDir + "/" + safeName; + // Don't silently overwrite an existing export — suffix the name (-2, -3, …). (F073) + if (std::filesystem::exists(filepath)) { + const std::string stem = safeName.substr(0, safeName.size() - 4); // strip ".csv" + for (int k = 2; k < 1000; ++k) { + std::string cand = stem + "-" + std::to_string(k) + ".csv"; + if (!std::filesystem::exists(configDir + "/" + cand)) { safeName = cand; filepath = configDir + "/" + cand; break; } + } + } + snprintf(s_filename, sizeof(s_filename), "%s", safeName.c_str()); // Build the chosen subset (scope 0 exports the whole list with no copy), then write atomically // (temp + fsync + rename) so a disk-full failure is reported instead of a truncated CSV. std::string csv;