revert works on login, now do the same for other pages as well

This commit is contained in:
Priec
2025-09-08 22:11:53 +02:00
parent 1c17d07497
commit 2cbbfd21aa
2 changed files with 29 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ use crate::ui::handlers::context::DialogPurpose;
use common::proto::komp_ac::auth::LoginResponse;
use crate::pages::login::LoginFormState;
use crate::state::pages::auth::UserRole;
use canvas::DataProvider;
use anyhow::{Context, Result, anyhow};
use tokio::spawn;
use tokio::sync::mpsc;
@@ -108,7 +109,19 @@ pub async fn revert(
login_state: &mut LoginFormState,
app_state: &mut AppState,
) -> String {
// Clear the underlying state
login_state.clear();
// Also clear values inside the editors data provider
{
let dp = login_state.editor.data_provider_mut();
dp.set_field_value(0, "".to_string());
dp.set_field_value(1, "".to_string());
dp.set_current_field(0);
dp.set_current_cursor_pos(0);
dp.set_has_unsaved_changes(false);
}
app_state.hide_dialog();
"Login reverted".to_string()
}