Three defects the browser found that the compiler could not
Browse files at this commit7fd5ec2cebf01d678ef766cb16308e3b78e9b88eParent: 9b4b86e- fix
- three defects the browser found that the compiler could not
4 changed files +60 -36
- crates/dizey-core/src/store/mod.rs +2 -2
- crates/dizey-web/src/board.rs +13 -3
- crates/dizey-web/src/detail.rs +42 -28
- style/main.scss +3 -3
crates/dizey-core/src/store/mod.rsmodified+2 -2
| @@ -341,12 +341,12 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 341 | 341 | at: OffsetDateTime, |
| 342 | 342 | ) -> Result<Vec<String>>; |
| 343 | 343 | |
| 344 | - /// Appends one line to a task's activity trail. `actor_id` is `None` when | |
| 345 | - /// the system did it rather than a person. | |
| 346 | 344 | /// What a delete would take with it, for the confirmation step. Reads |
| 347 | 345 | /// only; nothing here writes. |
| 348 | 346 | async fn deletion_cost(&self, task_id: &str) -> Result<Option<DeletionCost>>; |
| 349 | 347 | |
| 348 | + /// Appends one line to a task's activity trail. `actor_id` is `None` when | |
| 349 | + /// the system did it rather than a person. | |
| 350 | 350 | async fn record_activity( |
| 351 | 351 | &self, |
| 352 | 352 | task_id: &str, |
crates/dizey-web/src/board.rsmodified+13 -3
| @@ -120,6 +120,11 @@ impl Filter { | ||
| 120 | 120 | #[component] |
| 121 | 121 | pub fn Board() -> impl IntoView { |
| 122 | 122 | let board = Resource::new(|| (), |_| async move { current_board().await }); |
| 123 | + // Which card is open in the detail modal, if any. It lives out here, above | |
| 124 | + // the suspense boundary: a refetch rebuilds `BoardScreen` from scratch, and | |
| 125 | + // a signal owned by that component would be born empty again — closing the | |
| 126 | + // modal every time something inside it saved. | |
| 127 | + let opened = RwSignal::new(None::<String>); | |
| 123 | 128 | |
| 124 | 129 | view! { |
| 125 | 130 | <Suspense fallback=|| { |
| @@ -128,7 +133,13 @@ pub fn Board() -> impl IntoView { | ||
| 128 | 133 | {move || Suspend::new(async move { |
| 129 | 134 | match board.await { |
| 130 | 135 | Ok(Ok(snapshot)) => { |
| 131 | - view! { <BoardScreen snapshot=snapshot on_change=move || board.refetch()/> } | |
| 136 | + view! { | |
| 137 | + <BoardScreen | |
| 138 | + snapshot=snapshot | |
| 139 | + opened=opened | |
| 140 | + on_change=move || board.refetch() | |
| 141 | + /> | |
| 142 | + } | |
| 132 | 143 | .into_any() |
| 133 | 144 | } |
| 134 | 145 | Ok(Err(refusal)) => { |
| @@ -156,14 +167,13 @@ pub fn Board() -> impl IntoView { | ||
| 156 | 167 | #[component] |
| 157 | 168 | fn BoardScreen( |
| 158 | 169 | snapshot: BoardSnapshot, |
| 170 | + opened: RwSignal<Option<String>>, | |
| 159 | 171 | on_change: impl Fn() + Copy + Send + Sync + 'static, |
| 160 | 172 | ) -> impl IntoView { |
| 161 | 173 | let BoardSnapshot { view, me, today } = snapshot; |
| 162 | 174 | let filter = RwSignal::new(Filter::All); |
| 163 | 175 | // Which column has its composer open, if any. |
| 164 | 176 | let composing = RwSignal::new(None::<String>); |
| 165 | - // Which card is open in the detail modal, if any. | |
| 166 | - let opened = RwSignal::new(None::<String>); | |
| 167 | 177 | let may_write = me.role.can_write_tasks(); |
| 168 | 178 | let my_id = StoredValue::new(me.id.clone()); |
| 169 | 179 |
crates/dizey-web/src/detail.rsmodified+42 -28
| @@ -432,6 +432,29 @@ pub async fn delete_task(task_id: String) -> Result<Option<Refusal>, ServerFnErr | ||
| 432 | 432 | |
| 433 | 433 | // -- the screen ------------------------------------------------------------- |
| 434 | 434 | |
| 435 | +/// Whatever a refused call said, rendered where the form that asked for it is. | |
| 436 | +/// A refusal shown at the far end of a scrolling modal is a refusal nobody | |
| 437 | +/// reads: the person clicked "Link a task" and the sentence has to land under | |
| 438 | +/// that button, not under the activity trail. | |
| 439 | +fn refused<S>(action: ServerAction<S>) -> impl IntoView | |
| 440 | +where | |
| 441 | + S: leptos::server_fn::ServerFn<Output = Option<Refusal>> + Send + Sync + Clone + 'static, | |
| 442 | + S::Error: Clone + Send + Sync + 'static, | |
| 443 | +{ | |
| 444 | + move || { | |
| 445 | + action | |
| 446 | + .value() | |
| 447 | + .get() | |
| 448 | + .and_then(|answer| match answer { | |
| 449 | + Ok(refusal) => refusal, | |
| 450 | + // The call never arrived, which is not the person's mistake and | |
| 451 | + // is not a sentence about their task. | |
| 452 | + Err(_) => Some(Refusal::Unavailable), | |
| 453 | + }) | |
| 454 | + .map(|refusal| view! { <p class="modal-problem">{refusal.message()}</p> }) | |
| 455 | + } | |
| 456 | +} | |
| 457 | + | |
| 435 | 458 | /// The modal. `esc` closes it, as the artboard's chip says. |
| 436 | 459 | #[component] |
| 437 | 460 | pub fn TaskDetailModal( |
| @@ -451,27 +474,22 @@ pub fn TaskDetailModal( | ||
| 451 | 474 | on_change(); |
| 452 | 475 | }; |
| 453 | 476 | |
| 454 | - view! { | |
| 455 | - <div | |
| 456 | - class="modal-scrim" | |
| 457 | - on:click=move |_| on_close() | |
| 458 | - on:keydown=move |event| { | |
| 459 | - if event.key() == "Escape" { | |
| 460 | - on_close(); | |
| 461 | - } | |
| 477 | + // Escape listens on the window, not on the modal. The modal is inserted | |
| 478 | + // after the click that opened it, so focus is still on the card behind the | |
| 479 | + // scrim and a listener bound to this element would never hear the key. | |
| 480 | + #[cfg(feature = "hydrate")] | |
| 481 | + { | |
| 482 | + let handle = window_event_listener(leptos::ev::keydown, move |event| { | |
| 483 | + if event.key() == "Escape" { | |
| 484 | + on_close(); | |
| 462 | 485 | } |
| 463 | - > | |
| 464 | - <div | |
| 465 | - class="modal" | |
| 466 | - tabindex="-1" | |
| 467 | - autofocus | |
| 468 | - on:click=move |event| event.stop_propagation() | |
| 469 | - on:keydown=move |event| { | |
| 470 | - if event.key() == "Escape" { | |
| 471 | - on_close(); | |
| 472 | - } | |
| 473 | - } | |
| 474 | - > | |
| 486 | + }); | |
| 487 | + on_cleanup(move || handle.remove()); | |
| 488 | + } | |
| 489 | + | |
| 490 | + view! { | |
| 491 | + <div class="modal-scrim" on:click=move |_| on_close()> | |
| 492 | + <div class="modal" tabindex="-1" on:click=move |event| event.stop_propagation()> | |
| 475 | 493 | <Suspense fallback=|| { |
| 476 | 494 | view! { <div class="modal-loading"></div> } |
| 477 | 495 | }> |
| @@ -557,13 +575,6 @@ fn DetailScreen( | ||
| 557 | 575 | } |
| 558 | 576 | }); |
| 559 | 577 | |
| 560 | - let problem = move || { | |
| 561 | - [save.value(), comment.value(), link.value(), remove.value()] | |
| 562 | - .into_iter() | |
| 563 | - .find_map(|value| value.get().and_then(|answer| answer.ok().flatten())) | |
| 564 | - .map(|refusal| view! { <p class="modal-problem">{refusal.message()}</p> }) | |
| 565 | - }; | |
| 566 | - | |
| 567 | 578 | view! { |
| 568 | 579 | <header class="detail-head"> |
| 569 | 580 | <span class="detail-key">{task_key}</span> |
| @@ -656,6 +667,7 @@ fn DetailScreen( | ||
| 656 | 667 | "Save" |
| 657 | 668 | </button> |
| 658 | 669 | </div> |
| 670 | + {refused(save)} | |
| 659 | 671 | } |
| 660 | 672 | })} |
| 661 | 673 | </ActionForm> |
| @@ -735,6 +747,7 @@ fn DetailScreen( | ||
| 735 | 747 | "Link a task" |
| 736 | 748 | </button> |
| 737 | 749 | </ActionForm> |
| 750 | + {refused(link)} | |
| 738 | 751 | } |
| 739 | 752 | })} |
| 740 | 753 | </section> |
| @@ -770,6 +783,7 @@ fn DetailScreen( | ||
| 770 | 783 | </button> |
| 771 | 784 | </div> |
| 772 | 785 | </ActionForm> |
| 786 | + {refused(comment)} | |
| 773 | 787 | } |
| 774 | 788 | })} |
| 775 | 789 | </section> |
| @@ -796,7 +810,7 @@ fn DetailScreen( | ||
| 796 | 810 | .collect_view()} |
| 797 | 811 | </section> |
| 798 | 812 | |
| 799 | - {problem} | |
| 813 | + {refused(remove)} | |
| 800 | 814 | |
| 801 | 815 | {move || { |
| 802 | 816 | ask.value() |
style/main.scssmodified+3 -3
| @@ -712,8 +712,8 @@ a { | ||
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | .detail-label { |
| 715 | + font-family: var(--font-mono); | |
| 715 | 716 | font-size: 10px; |
| 716 | - font-weight: 600; | |
| 717 | 717 | letter-spacing: 0.08em; |
| 718 | 718 | color: var(--muted-soft); |
| 719 | 719 | } |
| @@ -852,9 +852,9 @@ a { | ||
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | .dep-heading { |
| 855 | + font-family: var(--font-mono); | |
| 855 | 856 | font-size: 10px; |
| 856 | - font-weight: 600; | |
| 857 | - letter-spacing: 0.08em; | |
| 857 | + letter-spacing: 0.06em; | |
| 858 | 858 | color: var(--muted-soft); |
| 859 | 859 | } |
| 860 | 860 |