⭐
Log in to mark this repository.
fmtttt
fe0a522 · gmorell · 2026-01-18 23:04
Files changed
modified
src/do_tui.rs
+60
−46
@@ -232,52 +232,68 @@ pub async fn run_tui(
| 232 | 232 | Tabs::Calendar => {} |
| 233 | 233 | _ => {} |
| 234 | 234 | }, |
| 235 | − KeyCode::Char('d') => if app.current_tab == Tabs::Ppl { app.ppl_show_dates = !app.ppl_show_dates }, | |
| 236 | − KeyCode::Char('r') => if app.current_tab == Tabs::Ppl { app.ppl_show_traits = !app.ppl_show_traits }, | |
| 237 | − KeyCode::Char('i') => if app.current_tab == Tabs::Ppl { app.ppl_show_tiers = !app.ppl_show_tiers }, | |
| 238 | − KeyCode::Char('l') => if app.current_tab == Tabs::Ppl { app.ppl_show_relations = !app.ppl_show_relations }, | |
| 235 | + KeyCode::Char('d') => { | |
| 236 | + if app.current_tab == Tabs::Ppl { | |
| 237 | + app.ppl_show_dates = !app.ppl_show_dates | |
| 238 | + } | |
| 239 | + } | |
| 240 | + KeyCode::Char('r') => { | |
| 241 | + if app.current_tab == Tabs::Ppl { | |
| 242 | + app.ppl_show_traits = !app.ppl_show_traits | |
| 243 | + } | |
| 244 | + } | |
| 245 | + KeyCode::Char('i') => { | |
| 246 | + if app.current_tab == Tabs::Ppl { | |
| 247 | + app.ppl_show_tiers = !app.ppl_show_tiers | |
| 248 | + } | |
| 249 | + } | |
| 250 | + KeyCode::Char('l') => { | |
| 251 | + if app.current_tab == Tabs::Ppl { | |
| 252 | + app.ppl_show_relations = !app.ppl_show_relations | |
| 253 | + } | |
| 254 | + } | |
| 239 | 255 | KeyCode::Enter => { |
| 240 | 256 | if app.current_tab == Tabs::Ppl |
| 241 | − && app.ppl_editing && app.ppl_detail_state.selected().is_some() { | |
| 242 | − let idx = &app.ppl_detail_state.selected().unwrap(); | |
| 243 | − let e = app.ppl_editables.get(*idx).unwrap(); | |
| 244 | − if !app.ppl_field_editing { | |
| 245 | − // let k | |
| 246 | − app.ppl_input_a = e.first.clone().into(); | |
| 247 | − app.ppl_input_b = | |
| 248 | − e.second.clone().unwrap_or("".to_string()).into(); | |
| 249 | − app.ppl_input_c = | |
| 250 | − e.third.clone().unwrap_or("".to_string()).into(); | |
| 251 | − } else { | |
| 252 | − let new_editable = Editable { | |
| 253 | − tgt: e.tgt.clone(), | |
| 254 | − id: e.id, | |
| 255 | − first: app.ppl_input_a.value().parse().unwrap(), | |
| 256 | − second: Option::from(app.ppl_input_b.value().to_string()), | |
| 257 | − third: Option::from(app.ppl_input_c.value().to_string()), | |
| 258 | − }; | |
| 259 | − | |
| 260 | − match e.tgt { | |
| 261 | − Editablez::Trait => { | |
| 262 | − TraitOps::updatee(&db, new_editable).await; | |
| 263 | − } | |
| 264 | − Editablez::Tier => { | |
| 265 | − TierOps::updatee(&db, new_editable).await; | |
| 266 | − } | |
| 267 | − Editablez::Contact => { | |
| 268 | − ContactOps::updatee(&db, new_editable).await; | |
| 269 | − } | |
| 270 | − Editablez::Relation => { | |
| 271 | − RelationOps::updatee(&db, new_editable).await; | |
| 272 | − } | |
| 273 | − Editablez::SigDate => { | |
| 274 | − SigDateOps::updatee(&db, new_editable).await; | |
| 275 | − } | |
| 276 | − }; | |
| 277 | − app.reload(&db).await?; | |
| 278 | − } | |
| 279 | − app.ppl_field_editing = !app.ppl_field_editing; | |
| 257 | + && app.ppl_editing | |
| 258 | + && app.ppl_detail_state.selected().is_some() | |
| 259 | + { | |
| 260 | + let idx = &app.ppl_detail_state.selected().unwrap(); | |
| 261 | + let e = app.ppl_editables.get(*idx).unwrap(); | |
| 262 | + if !app.ppl_field_editing { | |
| 263 | + // let k | |
| 264 | + app.ppl_input_a = e.first.clone().into(); | |
| 265 | + app.ppl_input_b = e.second.clone().unwrap_or("".to_string()).into(); | |
| 266 | + app.ppl_input_c = e.third.clone().unwrap_or("".to_string()).into(); | |
| 267 | + } else { | |
| 268 | + let new_editable = Editable { | |
| 269 | + tgt: e.tgt.clone(), | |
| 270 | + id: e.id, | |
| 271 | + first: app.ppl_input_a.value().parse().unwrap(), | |
| 272 | + second: Option::from(app.ppl_input_b.value().to_string()), | |
| 273 | + third: Option::from(app.ppl_input_c.value().to_string()), | |
| 274 | + }; | |
| 275 | + | |
| 276 | + match e.tgt { | |
| 277 | + Editablez::Trait => { | |
| 278 | + TraitOps::updatee(&db, new_editable).await; | |
| 279 | + } | |
| 280 | + Editablez::Tier => { | |
| 281 | + TierOps::updatee(&db, new_editable).await; | |
| 282 | + } | |
| 283 | + Editablez::Contact => { | |
| 284 | + ContactOps::updatee(&db, new_editable).await; | |
| 285 | + } | |
| 286 | + Editablez::Relation => { | |
| 287 | + RelationOps::updatee(&db, new_editable).await; | |
| 288 | + } | |
| 289 | + Editablez::SigDate => { | |
| 290 | + SigDateOps::updatee(&db, new_editable).await; | |
| 291 | + } | |
| 292 | + }; | |
| 293 | + app.reload(&db).await?; | |
| 280 | 294 | } |
| 295 | + app.ppl_field_editing = !app.ppl_field_editing; | |
| 296 | + } | |
| 281 | 297 | } |
| 282 | 298 | _ => { |
| 283 | 299 | default_editing_handler(&mut app, &key_event); |
@@ -935,9 +951,7 @@ fn render(f: &mut Frame, app: &mut Tui) {
| 935 | 951 | }, |
| 936 | 952 | false => { |
| 937 | 953 | let title = match &curr.nick { |
| 938 | − None => { | |
| 939 | − curr.name.clone().to_string() | |
| 940 | − } | |
| 954 | + None => curr.name.clone().to_string(), | |
| 941 | 955 | Some(n) => { |
| 942 | 956 | format!("{} ({})", curr.name.clone(), n) |
| 943 | 957 | } |
Parents: fde3995