proyectos: status true/false ahora muestra Activo/Inactivo via i18n

This commit is contained in:
2026-05-27 21:44:41 -05:00
parent 66b3e24fec
commit 9ae2af3ea2
10 changed files with 64 additions and 18 deletions
+30 -4
View File
@@ -11,6 +11,8 @@ pub struct Project {
pub status: String,
pub start_date: Option<String>,
pub end_date: Option<String>,
pub hus_count: Option<i64>,
pub epics_count: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -155,7 +157,7 @@ async fn get_conn(db_path: &str) -> Result<libsql::Connection, String> {
let conn = db.connect().map_err(|e| format!("Connect: {e}"))?;
conn.execute_batch(
"CREATE TABLE IF NOT EXISTS projects (
" CREATE TABLE IF NOT EXISTS projects (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
key TEXT,
@@ -163,6 +165,8 @@ async fn get_conn(db_path: &str) -> Result<libsql::Connection, String> {
status TEXT DEFAULT 'active',
start_date TEXT,
end_date TEXT,
hus_count INTEGER DEFAULT 0,
epics_count INTEGER DEFAULT 0,
created_at TEXT DEFAULT (datetime('now'))
);
@@ -325,7 +329,7 @@ pub mod commands {
let conn = get_conn(&db_path).await?;
let mut rows = conn
.query("SELECT id, name, key, description, status, start_date, end_date FROM projects ORDER BY name", ())
.query("SELECT id, name, key, description, status, start_date, end_date, hus_count, epics_count FROM projects ORDER BY name", ())
.await
.map_err(|e| format!("Query: {e}"))?;
@@ -339,6 +343,8 @@ pub mod commands {
status: row.get::<String>(4).unwrap_or_else(|_| "active".into()),
start_date: row.get::<String>(5).ok(),
end_date: row.get::<String>(6).ok(),
hus_count: row.get::<i64>(7).ok(),
epics_count: row.get::<i64>(8).ok(),
});
}
Ok(projects)
@@ -350,8 +356,8 @@ pub mod commands {
let conn = get_conn(&db_path).await?;
conn.execute(
"INSERT OR REPLACE INTO projects (id, name, key, description, status, start_date, end_date)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
"INSERT OR REPLACE INTO projects (id, name, key, description, status, start_date, end_date, hus_count, epics_count)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
libsql::params![
project.id,
project.name,
@@ -360,6 +366,8 @@ pub mod commands {
project.status,
project.start_date,
project.end_date,
project.hus_count,
project.epics_count,
],
)
.await
@@ -368,6 +376,24 @@ pub mod commands {
Ok(conn.last_insert_rowid())
}
#[tauri::command]
pub async fn update_project_counts(state: State<'_, Mutex<String>>, initiative_id: i64) -> Result<(), String> {
let db_path = state.lock().map_err(|e| e.to_string())?.clone();
let conn = get_conn(&db_path).await?;
conn.execute(
"UPDATE projects SET
hus_count = (SELECT COUNT(*) FROM user_stories WHERE initiative_id = ?1),
epics_count = (SELECT COUNT(*) FROM epics WHERE initiative_id = ?1)
WHERE id = ?1",
libsql::params![initiative_id],
)
.await
.map_err(|e| format!("Update counts: {e}"))?;
Ok(())
}
#[tauri::command]
pub async fn delete_project(state: State<'_, Mutex<String>>, id: i64) -> Result<(), String> {
let db_path = state.lock().map_err(|e| e.to_string())?.clone();
+1
View File
@@ -22,6 +22,7 @@ fn main() {
.invoke_handler(tauri::generate_handler![
commands::get_projects,
commands::save_project,
commands::update_project_counts,
commands::delete_project,
commands::get_work_items,
commands::save_work_item,