Mutations stop turning the page
Browse files at this commit39ad0ed4a66c1cbb50e8a38390d33adeedb4a639Parent: d28fea9- feat
- mutations stop turning the page
6 changed files +248 -140
- crates/izlek-web/src/board.rs +44 -76
- crates/izlek-web/src/detail.rs +46 -49
- crates/izlek-web/src/dropdown.rs +6 -2
- crates/izlek-web/src/layout.rs +148 -2
- crates/izlek-web/src/pages.rs +3 -3
- crates/izlek-web/src/settings.rs +1 -8
crates/izlek-web/src/board.rsmodified+44 -76
| @@ -1,10 +1,10 @@ | |||
| 1 | //! The board, from the Main artboard. | 1 | //! The board, from the Main artboard. |
| 2 | //! | 2 | //! |
| 3 | -//! The whole column list is one shard: the server renders every column and | 3 | +//! The server renders every column and card; a drop posts `/api/move_card` |
| 4 | -//! card, and a drop re-runs it in place. There is no client board state to | 4 | +//! over `fetch` and swaps the redirected page in via `layout.rs`'s |
| 5 | -//! keep in sync with the server — a drag's only client-side memory is the | 5 | +//! `soft_nav_script`. There is no client board state to keep in sync with |
| 6 | -//! browser's own drag session (`dataTransfer`), read back by the column that | 6 | +//! the server — a drag's only client-side memory is the browser's own drag |
| 7 | -//! catches the drop. | 7 | +//! session (`dataTransfer`), read back by the column that catches the drop. |
| 8 | 8 | ||
| 9 | use izlek_core::board::{DeadlineState, Moved, Person, TaskCard}; | 9 | use izlek_core::board::{DeadlineState, Moved, Person, TaskCard}; |
| 10 | use izlek_core::store::{NewTask, User}; | 10 | use izlek_core::store::{NewTask, User}; |
| @@ -14,7 +14,6 @@ use topcoat::context::Cx; | |||
| 14 | use topcoat::router::content::Form; | 14 | use topcoat::router::content::Form; |
| 15 | use topcoat::router::request::headers; | 15 | use topcoat::router::request::headers; |
| 16 | use topcoat::router::{HeaderName, StatusCode, header, query_params, route}; | 16 | use topcoat::router::{HeaderName, StatusCode, header, query_params, route}; |
| 17 | -use topcoat::runtime::{Event, procedure, shard}; | ||
| 18 | use topcoat::view::view; | 17 | use topcoat::view::view; |
| 19 | 18 | ||
| 20 | use crate::i18n::{Key, Lang, t}; | 19 | use crate::i18n::{Key, Lang, t}; |
| @@ -170,7 +169,8 @@ struct MoveCardForm { | |||
| 170 | to_column_id: String, | 169 | to_column_id: String, |
| 171 | } | 170 | } |
| 172 | 171 | ||
| 173 | -/// The same move the drop procedure performs, reachable without script. | 172 | +/// The one move path: the modal's status form, a card menu's "Move" rows |
| 173 | +/// and the drop handler in `card_menu_script` all post here. | ||
| 174 | #[route(POST "/api/move_card")] | 174 | #[route(POST "/api/move_card")] |
| 175 | async fn move_card(cx: &Cx, Form(input): Form<MoveCardForm>) -> Redirect { | 175 | async fn move_card(cx: &Cx, Form(input): Form<MoveCardForm>) -> Redirect { |
| 176 | match move_card_shared(cx, &input.task_id, &input.from_column_id, &input.to_column_id).await? { | 176 | match move_card_shared(cx, &input.task_id, &input.from_column_id, &input.to_column_id).await? { |
| @@ -179,22 +179,6 @@ async fn move_card(cx: &Cx, Form(input): Form<MoveCardForm>) -> Redirect { | |||
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | -/// What a drop calls: performs the move and hands back a refusal code, if | ||
| 183 | -/// any, for the drop handler to leave alone. Callable with any arguments — | ||
| 184 | -/// the checks above are what actually guard it. | ||
| 185 | -#[procedure] | ||
| 186 | -async fn move_card_procedure( | ||
| 187 | - cx: &Cx, | ||
| 188 | - task_id: String, | ||
| 189 | - from_column_id: String, | ||
| 190 | - to_column_id: String, | ||
| 191 | -) -> Result<Result<bool, String>> { | ||
| 192 | - match move_card_shared(cx, &task_id, &from_column_id, &to_column_id).await? { | ||
| 193 | - Some(refusal) => Ok(Err(refusal.code().to_string())), | ||
| 194 | - None => Ok(Ok(true)), | ||
| 195 | - } | ||
| 196 | -} | ||
| 197 | - | ||
| 198 | /// `deadline`, `created` or `title` — the "Sort" control in the filter bar. | 182 | /// `deadline`, `created` or `title` — the "Sort" control in the filter bar. |
| 199 | /// Anything else (a hand-edited or stale query string) falls back to | 183 | /// Anything else (a hand-edited or stale query string) falls back to |
| 200 | /// `deadline` silently. | 184 | /// `deadline` silently. |
| @@ -220,11 +204,8 @@ fn sort_column_cards(cards: &mut [TaskCard], sort: &str) { | |||
| 220 | } | 204 | } |
| 221 | } | 205 | } |
| 222 | 206 | ||
| 223 | -/// The whole column list. `version` carries no meaning of its own — bumping | 207 | +/// The whole column list. |
| 224 | -/// it is what tells the browser to ask for this again after a drop lands. | 208 | +async fn board_columns(cx: &Cx, sort: String) -> Result { |
| 225 | -#[shard] | ||
| 226 | -async fn board_columns(cx: &Cx, version: f64, sort: String) -> Result { | ||
| 227 | - let _ = version; | ||
| 228 | let user = match require_user(cx).await { | 209 | let user = match require_user(cx).await { |
| 229 | Ok(user) => user, | 210 | Ok(user) => user, |
| 230 | Err(refusal) => { | 211 | Err(refusal) => { |
| @@ -297,11 +278,9 @@ async fn render_column( | |||
| 297 | } | 278 | } |
| 298 | } | 279 | } |
| 299 | 280 | ||
| 300 | -// The `@dragstart`/`@contextmenu` handlers below never read `e` as ordinary | 281 | +// Drag and the context menu are delegated document listeners in |
| 301 | -// Rust — the `raw!` macro resolves `${e}` through its own name table, keyed | 282 | +// `card_menu_script`, reading the card's `data-task-id`/`data-from-column` |
| 302 | -// on the closure param's identifier text, not through the generated closure | 283 | +// — per-element handlers would die when a soft submit swaps the board in. |
| 303 | -// body. | ||
| 304 | -#[allow(unused_variables)] | ||
| 305 | async fn render_card( | 284 | async fn render_card( |
| 306 | cx: &Cx, | 285 | cx: &Cx, |
| 307 | card: TaskCard, | 286 | card: TaskCard, |
| @@ -337,27 +316,13 @@ async fn render_card( | |||
| 337 | let menu_id = format!("card-menu-{}", card.id); | 316 | let menu_id = format!("card-menu-{}", card.id); |
| 338 | let move_targets: Vec<(String, String)> = | 317 | let move_targets: Vec<(String, String)> = |
| 339 | all_columns.iter().filter(|(id, _)| id != column_id).cloned().collect(); | 318 | all_columns.iter().filter(|(id, _)| id != column_id).cloned().collect(); |
| 340 | - // `raw!` interpolation only takes a bare identifier, and it moves what it | ||
| 341 | - // takes — one clone per site that also needs the value afterward. | ||
| 342 | - let drag_task_id = task_id.clone(); | ||
| 343 | - let drag_from_column = from_column.clone(); | ||
| 344 | - let open_menu_id = menu_id.clone(); | ||
| 345 | - | ||
| 346 | view! { | 319 | view! { |
| 347 | cx => | 320 | cx => |
| 348 | <a class="card" class:card-done=(done_column) href=(href.clone()) | 321 | <a class="card" class:card-done=(done_column) href=(href.clone()) |
| 349 | draggable=(if may_write { "true" } else { "false" }) | 322 | draggable=(if may_write { "true" } else { "false" }) |
| 350 | - @dragstart=$(|e: Event| raw!( | 323 | + data-task-id=(task_id.clone()) |
| 351 | - "(() => { ${e}.inner.dataTransfer.setData('izlek-task', ${drag_task_id}); ${e}.inner.dataTransfer.setData('izlek-from', ${drag_from_column}); })()", | 324 | + data-from-column=(from_column.clone()) |
| 352 | - () | 325 | + data-menu-id=(menu_id.clone()) |
| 353 | - )) | ||
| 354 | - @contextmenu=$(|e: Event| { | ||
| 355 | - e.prevent_default(); | ||
| 356 | - raw!( | ||
| 357 | - "(() => { window.__izlekOpenCardMenu(${e}.inner, ${open_menu_id}); })()", | ||
| 358 | - () | ||
| 359 | - ) | ||
| 360 | - }) | ||
| 361 | > | 326 | > |
| 362 | <div class="card-keys"> | 327 | <div class="card-keys"> |
| 363 | <span class="card-key">(card.task_key.clone())</span> | 328 | <span class="card-key">(card.task_key.clone())</span> |
| @@ -439,7 +404,32 @@ async fn card_menu_script(cx: &Cx) -> Result { | |||
| 439 | if (datepick) { datepick.checked = false; e.stopImmediatePropagation(); return; } \ | 404 | if (datepick) { datepick.checked = false; e.stopImmediatePropagation(); return; } \ |
| 440 | var menu = document.querySelector('.card-menu-open'); \ | 405 | var menu = document.querySelector('.card-menu-open'); \ |
| 441 | if (menu) { closeCardMenus(); e.stopImmediatePropagation(); return; } \ | 406 | if (menu) { closeCardMenus(); e.stopImmediatePropagation(); return; } \ |
| 442 | - }, true)"; | 407 | + }, true); \ |
| 408 | + document.addEventListener('contextmenu', function (e) { \ | ||
| 409 | + var card = e.target.closest ? e.target.closest('.card[data-menu-id]') : null; \ | ||
| 410 | + if (!card) { return; } \ | ||
| 411 | + e.preventDefault(); \ | ||
| 412 | + window.__izlekOpenCardMenu(e, card.dataset.menuId); \ | ||
| 413 | + }); \ | ||
| 414 | + document.addEventListener('dragstart', function (e) { \ | ||
| 415 | + var card = e.target.closest ? e.target.closest('.card[data-task-id]') : null; \ | ||
| 416 | + if (!card) { return; } \ | ||
| 417 | + e.dataTransfer.setData('izlek-task', card.dataset.taskId); \ | ||
| 418 | + e.dataTransfer.setData('izlek-from', card.dataset.fromColumn); \ | ||
| 419 | + }); \ | ||
| 420 | + document.addEventListener('dragover', function (e) { \ | ||
| 421 | + if (e.target.closest && e.target.closest('.board-columns')) { e.preventDefault(); } \ | ||
| 422 | + }); \ | ||
| 423 | + document.addEventListener('drop', function (e) { \ | ||
| 424 | + var column = e.target.closest ? e.target.closest('.column-cards') : null; \ | ||
| 425 | + if (!column) { return; } \ | ||
| 426 | + e.preventDefault(); \ | ||
| 427 | + var task = e.dataTransfer.getData('izlek-task'); \ | ||
| 428 | + var from = e.dataTransfer.getData('izlek-from'); \ | ||
| 429 | + if (task && window.__izlekPost) { \ | ||
| 430 | + window.__izlekPost('/api/move_card', { task_id: task, from_column_id: from, to_column_id: column.id }); \ | ||
| 431 | + } \ | ||
| 432 | + })"; | ||
| 443 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 433 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } |
| 444 | } | 434 | } |
| 445 | 435 | ||
| @@ -532,9 +522,7 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { | |||
| 532 | } | 522 | } |
| 533 | <form class="field-box field-box-sort" method="get" action="/"> | 523 | <form class="field-box field-box-sort" method="get" action="/"> |
| 534 | <span class="field-text">(t(lang, Key::Sort))</span> | 524 | <span class="field-text">(t(lang, Key::Sort))</span> |
| 535 | - <select class="status-select" name="sort" | 525 | + <select class="status-select" name="sort" data-autosubmit=""> |
| 536 | - @change=$(|e: Event| raw!("${e}.inner.target.form.requestSubmit()", ())) | ||
| 537 | - > | ||
| 538 | for key in SORT_KEYS { | 526 | for key in SORT_KEYS { |
| 539 | <option value=(key) selected=(key == sort)>(sort_label(key, lang))</option> | 527 | <option value=(key) selected=(key == sort)>(sort_label(key, lang))</option> |
| 540 | } | 528 | } |
| @@ -553,28 +541,8 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { | |||
| 553 | <p class="field-error">(refusal.message_in(lang))</p> | 541 | <p class="field-error">(refusal.message_in(lang))</p> |
| 554 | } | 542 | } |
| 555 | <main class="board-stage"> | 543 | <main class="board-stage"> |
| 556 | - signal version = 0.0; | 544 | + <div class="board-columns"> |
| 557 | - <div class="board-columns" | 545 | + (board_columns(cx, sort.clone()).await?) |
| 558 | - @dragover=$(|e: Event| e.prevent_default()) | ||
| 559 | - @drop=$(async move |e: Event| { | ||
| 560 | - e.prevent_default(); | ||
| 561 | - // The drop can land on a card's inner text or icon, not | ||
| 562 | - // just the column's own surface — walk up to the column | ||
| 563 | - // that actually owns the id, rather than trusting the | ||
| 564 | - // exact element under the pointer to carry one. | ||
| 565 | - let to = raw!( | ||
| 566 | - "cx.hydrate((() => { var col = ${e}.inner.target.closest('.column-cards'); return col ? col.id : ''; })())", | ||
| 567 | - "".to_owned() | ||
| 568 | - ); | ||
| 569 | - let task_id = raw!("cx.hydrate(${e}.inner.dataTransfer.getData('izlek-task'))", "".to_owned()); | ||
| 570 | - let from = raw!("cx.hydrate(${e}.inner.dataTransfer.getData('izlek-from'))", "".to_owned()); | ||
| 571 | - if !task_id.is_empty() { | ||
| 572 | - let _result = move_card_procedure(task_id, from, to).await; | ||
| 573 | - version.set(version.get() + 1.0); | ||
| 574 | - } | ||
| 575 | - }) | ||
| 576 | - > | ||
| 577 | - board_columns(version: $(version.get()), sort: $(sort)) | ||
| 578 | </div> | 546 | </div> |
| 579 | </main> | 547 | </main> |
| 580 | if let Some(task_id) = &open_task { | 548 | if let Some(task_id) = &open_task { |
crates/izlek-web/src/detail.rsmodified+46 -49
| @@ -26,7 +26,6 @@ use topcoat::context::Cx; | |||
| 26 | use topcoat::router::content::{Form, Json}; | 26 | use topcoat::router::content::{Form, Json}; |
| 27 | use topcoat::router::request::headers; | 27 | use topcoat::router::request::headers; |
| 28 | use topcoat::router::{HeaderName, StatusCode, header, route}; | 28 | use topcoat::router::{HeaderName, StatusCode, header, route}; |
| 29 | -use topcoat::runtime::Event; | ||
| 30 | use topcoat::view::{class, view}; | 29 | use topcoat::view::{class, view}; |
| 31 | 30 | ||
| 32 | use crate::i18n::{Key, Lang, t}; | 31 | use crate::i18n::{Key, Lang, t}; |
| @@ -535,20 +534,17 @@ async fn delete_file(cx: &Cx, Form(input): Form<FileIdForm>) -> Redirect { | |||
| 535 | // Wasm-escapes from the old version, each simplified to a plain form post | 534 | // Wasm-escapes from the old version, each simplified to a plain form post |
| 536 | // rather than ported to a runtime signal (noted at each site below): | 535 | // rather than ported to a runtime signal (noted at each site below): |
| 537 | // | 536 | // |
| 538 | -// - StatusControl's and the file input's `on:change` auto-submit are back as | 537 | +// - StatusControl's and the file input's `on:change` auto-submit are the |
| 539 | -// a one-line `@change=$(|e: Event| raw!("${e}.inner.target.form.requestSubmit()", ()))` | 538 | +// `data-autosubmit` attribute (and the file input's own class), read by |
| 540 | -// — a literal `@change="this.form.requestSubmit()"` runs immediately at | 539 | +// `layout.rs`'s `soft_nav_script` through one delegated `change` |
| 541 | -// attribute-scan time rather than on the event (topcoat's `data-topcoat-on:` | 540 | +// listener — a per-element handler would die when a soft submit swaps |
| 542 | -// handlers always call through the compiled-closure/`raw!` path; a bare JS | 541 | +// the page in — and the "Move"/"Attach" buttons stay for a browser |
| 543 | -// string is evaluated once with no event or `this` bound) — and the | 542 | +// without script. |
| 544 | -// "Move"/"Attach" buttons stay for a browser without script. | 543 | +// - The modal scrim's click-to-close is `soft_nav_script`'s delegated |
| 545 | -// - The modal scrim's click-to-close is back the same way: the scrim's own | 544 | +// click listener (a click whose target is the scrim itself closes; a |
| 546 | -// `@click` is a closure calling `raw!("window.location.href='/'", ())`, | 545 | +// click inside `.modal` never has the scrim as target, so no |
| 547 | -// its inner `.modal` stops propagation with | 546 | +// stop-propagation is needed). The X glyph and the footer "Close" link |
| 548 | -// `@click=$(|e: Event| e.stop_propagation())`. The window `Escape` | 547 | +// route through the same soft close. |
| 549 | -// listener lives only in `board.rs`'s `card_menu_script` — this modal is | ||
| 550 | -// always rendered alongside it. The X glyph and the footer "Close" button | ||
| 551 | -// (plain links/buttons, no script) still work on their own. | ||
| 552 | // - DeadlineControl's hand-built calendar grid (`js_sys::Date` for "today", | 548 | // - DeadlineControl's hand-built calendar grid (`js_sys::Date` for "today", |
| 553 | // month navigation, per-day buttons) is replaced with a native | 549 | // month navigation, per-day buttons) is replaced with a native |
| 554 | // `<input type="date">` inside the same CSS-only edit-toggle popover — | 550 | // `<input type="date">` inside the same CSS-only edit-toggle popover — |
| @@ -681,33 +677,32 @@ async fn avatar(cx: &Cx, person: &Person, extra: &str) -> Result { | |||
| 681 | /// `Escape` for everything the task modal renders, topmost first: viewer → | 677 | /// `Escape` for everything the task modal renders, topmost first: viewer → |
| 682 | /// delete confirm (`confirm=delete` in URL) → open edit popovers → modal | 678 | /// delete confirm (`confirm=delete` in URL) → open edit popovers → modal |
| 683 | /// itself; datepick and card menu stay `board.rs`'s — this capture listener | 679 | /// itself; datepick and card menu stay `board.rs`'s — this capture listener |
| 684 | -/// registers first (inline in modal markup) and stops the key, and | 680 | +/// registers first (inline in modal markup) and stops the key. Closing |
| 685 | -/// `__izlekLeaving` is one navigation per document, `pageshow` releases it. | 681 | +/// never navigates: `layout.rs`'s `__izlekCloseViewer`/`__izlekCloseModal` |
| 686 | -/// Focused native media controls swallow `Escape` before the page ever | 682 | +/// drop the overlay's DOM and rewrite the URL, the board underneath is |
| 687 | -/// sees the key, so focus landing on the viewer's audio/video is moved | 683 | +/// already rendered. Focused native media controls swallow `Escape` before |
| 688 | -/// straight back to the panel. Every branch that navigates must | 684 | +/// the page ever sees the key, so focus landing on the viewer's |
| 689 | -/// `preventDefault()` first: a real Escape's browser default is | 685 | +/// audio/video is moved straight back to the panel. Every closing branch |
| 690 | -/// stop-loading, which cancels the navigation the handler just started | 686 | +/// still calls `preventDefault()`: a real Escape's browser default is |
| 691 | -/// (and would leave `__izlekLeaving` latched true, deadening every | 687 | +/// stop-loading (it once cancelled the navigation these branches used to |
| 692 | -/// later press). Synthetic keys carry no default, so only a live | 688 | +/// start; synthetic keys carry no default, so only a live keyboard ever |
| 693 | -/// keyboard ever showed it. | 689 | +/// showed it). |
| 694 | async fn escape_closes(cx: &Cx) -> Result { | 690 | async fn escape_closes(cx: &Cx) -> Result { |
| 695 | use topcoat::view::Unescaped; | 691 | use topcoat::view::Unescaped; |
| 696 | const JS: &str = "\ | 692 | const JS: &str = "\ |
| 697 | document.addEventListener('keydown', function (e) { \ | 693 | document.addEventListener('keydown', function (e) { \ |
| 698 | if (e.key !== 'Escape') { return; } \ | 694 | if (e.key !== 'Escape') { return; } \ |
| 699 | if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return; } \ | 695 | if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return; } \ |
| 700 | - var viewer = document.querySelector('.viewer-scrim'); \ | 696 | + if (document.querySelector('.viewer-scrim')) { \ |
| 701 | - if (viewer) { \ | ||
| 702 | e.preventDefault(); \ | 697 | e.preventDefault(); \ |
| 703 | - if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = viewer.querySelector('.viewer-close').getAttribute('href'); } \ | 698 | + window.__izlekCloseViewer(); \ |
| 704 | e.stopImmediatePropagation(); \ | 699 | e.stopImmediatePropagation(); \ |
| 705 | return; \ | 700 | return; \ |
| 706 | } \ | 701 | } \ |
| 707 | var confirm = document.querySelector('details.confirm-details[open]'); \ | 702 | var confirm = document.querySelector('details.confirm-details[open]'); \ |
| 708 | if (confirm && window.location.search.indexOf('confirm=delete') !== -1) { \ | 703 | if (confirm && window.location.search.indexOf('confirm=delete') !== -1) { \ |
| 709 | e.preventDefault(); \ | 704 | e.preventDefault(); \ |
| 710 | - if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = '/'; } \ | 705 | + window.__izlekCloseModal(); \ |
| 711 | e.stopImmediatePropagation(); \ | 706 | e.stopImmediatePropagation(); \ |
| 712 | return; \ | 707 | return; \ |
| 713 | } \ | 708 | } \ |
| @@ -724,18 +719,17 @@ async fn escape_closes(cx: &Cx) -> Result { | |||
| 724 | } \ | 719 | } \ |
| 725 | if (document.querySelector('.modal-scrim')) { \ | 720 | if (document.querySelector('.modal-scrim')) { \ |
| 726 | e.preventDefault(); \ | 721 | e.preventDefault(); \ |
| 727 | - if (!window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = '/'; } \ | 722 | + window.__izlekCloseModal(); \ |
| 728 | e.stopImmediatePropagation(); \ | 723 | e.stopImmediatePropagation(); \ |
| 729 | } \ | 724 | } \ |
| 730 | }, true); \ | 725 | }, true); \ |
| 731 | - document.addEventListener('pageshow', function () { window.__izlekLeaving = false; }); \ | ||
| 732 | document.addEventListener('focusin', function (e) { \ | 726 | document.addEventListener('focusin', function (e) { \ |
| 733 | var media = e.target; \ | 727 | var media = e.target; \ |
| 734 | if (media.tagName !== 'AUDIO' && media.tagName !== 'VIDEO') { return; } \ | 728 | if (media.tagName !== 'AUDIO' && media.tagName !== 'VIDEO') { return; } \ |
| 735 | var panel = media.closest('.viewer'); \ | 729 | var panel = media.closest('.viewer'); \ |
| 736 | if (panel) { panel.focus(); } \ | 730 | if (panel) { panel.focus(); } \ |
| 737 | }, true); \ | 731 | }, true); \ |
| 738 | - document.addEventListener('click', function (e) { var confirm = document.querySelector('details.confirm-details[open]'); if (!confirm) { return; } var panel = confirm.querySelector('.confirm'); if (panel && !panel.contains(e.target) && !e.target.closest('summary')) { if (window.location.search.indexOf('confirm=delete') !== -1 && !window.__izlekLeaving) { window.__izlekLeaving = true; window.location.href = '/'; } else { confirm.removeAttribute('open'); } } }, true); \ | 732 | + document.addEventListener('click', function (e) { var confirm = document.querySelector('details.confirm-details[open]'); if (!confirm) { return; } var panel = confirm.querySelector('.confirm'); if (panel && !panel.contains(e.target) && !e.target.closest('summary')) { if (window.location.search.indexOf('confirm=delete') !== -1) { window.__izlekCloseModal(); } else { confirm.removeAttribute('open'); } } }, true); \ |
| 739 | document.addEventListener('click', function (e) { \ | 733 | document.addEventListener('click', function (e) { \ |
| 740 | document.querySelectorAll('.edit-toggle:checked').forEach(function (toggle) { \ | 734 | document.querySelectorAll('.edit-toggle:checked').forEach(function (toggle) { \ |
| 741 | if (toggle.closest('.datepick-pop')) { return; } \ | 735 | if (toggle.closest('.datepick-pop')) { return; } \ |
| @@ -1152,10 +1146,6 @@ async fn comment_row(cx: &Cx, comment: &Comment, zone: UtcOffset) -> Result { | |||
| 1152 | /// dependencies, files, comments, activity and delete, exactly as the | 1146 | /// dependencies, files, comments, activity and delete, exactly as the |
| 1153 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later | 1147 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later |
| 1154 | /// integration slice — this only renders the fragment. | 1148 | /// integration slice — this only renders the fragment. |
| 1155 | -// Two `@change` handlers below never read `e` as ordinary Rust — the | ||
| 1156 | -// `raw!` macro resolves `${e}` through its own name table, keyed on the | ||
| 1157 | -// closure param's identifier text, not through the generated closure body. | ||
| 1158 | -#[allow(unused_variables)] | ||
| 1159 | pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result { | 1149 | pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result { |
| 1160 | let snapshot = match load_snapshot(cx, task_id).await? { | 1150 | let snapshot = match load_snapshot(cx, task_id).await? { |
| 1161 | Ok(snapshot) => snapshot, | 1151 | Ok(snapshot) => snapshot, |
| @@ -1167,8 +1157,8 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1167 | let lang = require_user(cx).await.map(|user| Lang::from_code(&user.language)).unwrap_or(Lang::En); | 1157 | let lang = require_user(cx).await.map(|user| Lang::from_code(&user.language)).unwrap_or(Lang::En); |
| 1168 | return view! { | 1158 | return view! { |
| 1169 | cx => | 1159 | cx => |
| 1170 | - <div class="modal-scrim" @click=$(|_e: Event| raw!("window.location.href='/'", ()))> | 1160 | + <div class="modal-scrim"> |
| 1171 | - <div class="modal" @click=$(|e: Event| e.stop_propagation())><p class="modal-note">(refusal.message_in(lang))</p></div> | 1161 | + <div class="modal"><p class="modal-note">(refusal.message_in(lang))</p></div> |
| 1172 | </div> | 1162 | </div> |
| 1173 | (escape_closes(cx).await?) | 1163 | (escape_closes(cx).await?) |
| 1174 | }; | 1164 | }; |
| @@ -1202,8 +1192,8 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1202 | 1192 | ||
| 1203 | view! { | 1193 | view! { |
| 1204 | cx => | 1194 | cx => |
| 1205 | - <div class="modal-scrim" @click=$(|_e: Event| raw!("window.location.href='/'", ()))> | 1195 | + <div class="modal-scrim"> |
| 1206 | - <div class="modal" tabindex="-1" @click=$(|e: Event| e.stop_propagation())> | 1196 | + <div class="modal" tabindex="-1"> |
| 1207 | <header class="detail-head"> | 1197 | <header class="detail-head"> |
| 1208 | <div class="detail-headline"> | 1198 | <div class="detail-headline"> |
| 1209 | <span class="detail-key">(detail.task_key.clone())</span> | 1199 | <span class="detail-key">(detail.task_key.clone())</span> |
| @@ -1221,7 +1211,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1221 | <input type="hidden" name="task_id" value=(detail.id.clone())> | 1211 | <input type="hidden" name="task_id" value=(detail.id.clone())> |
| 1222 | <input type="hidden" name="from_column_id" value=(detail.column.id.clone())> | 1212 | <input type="hidden" name="from_column_id" value=(detail.column.id.clone())> |
| 1223 | <span class=(class!("status-dot", "status-dot-done" if detail.column.is_done))></span> | 1213 | <span class=(class!("status-dot", "status-dot-done" if detail.column.is_done))></span> |
| 1224 | - <select class="status-select" name="to_column_id" @change=$(|e: Event| raw!("${e}.inner.target.form.requestSubmit()", ()))> | 1214 | + <select class="status-select" name="to_column_id" data-autosubmit=""> |
| 1225 | for column in &detail.columns { | 1215 | for column in &detail.columns { |
| 1226 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> | 1216 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> |
| 1227 | } | 1217 | } |
| @@ -1301,10 +1291,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1301 | <label class="field-box file-upload-box"> | 1291 | <label class="field-box file-upload-box"> |
| 1302 | (glyph::plus(cx).await?) | 1292 | (glyph::plus(cx).await?) |
| 1303 | <span class="field-text file-upload-name">(t(lang, Key::File))</span> | 1293 | <span class="field-text file-upload-name">(t(lang, Key::File))</span> |
| 1304 | - <input class="file-upload-input" type="file" name="file" accept=(accept) required="" @change=$(|e: Event| raw!( | 1294 | + <input class="file-upload-input" type="file" name="file" accept=(accept) required=""> |
| 1305 | - "(() => { var input = ${e}.inner.target; var name = input.closest('label').querySelector('.file-upload-name'); if (input.files && input.files[0]) { name.textContent = input.files[0].name; } input.form.requestSubmit(); })()", | ||
| 1306 | - () | ||
| 1307 | - ))> | ||
| 1308 | </label> | 1295 | </label> |
| 1309 | </form> | 1296 | </form> |
| 1310 | (refused(cx, "upload_file", lang).await?) | 1297 | (refused(cx, "upload_file", lang).await?) |
| @@ -1392,12 +1379,19 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1392 | /// The house audio player: play toggle, clock, seek bar over a hidden | 1379 | /// The house audio player: play toggle, clock, seek bar over a hidden |
| 1393 | /// `<audio>` — native controls live in the browser's own chrome, ignore the | 1380 | /// `<audio>` — native controls live in the browser's own chrome, ignore the |
| 1394 | /// theme, and swallow `Escape` while focused, so the viewer draws its own. | 1381 | /// theme, and swallow `Escape` while focused, so the viewer draws its own. |
| 1382 | +/// Wiring is per-player and idempotent (`data-wired`), re-run on | ||
| 1383 | +/// `izlek:wire` so a player arriving in a soft page swap — where inline | ||
| 1384 | +/// scripts never execute — still gets its controls. | ||
| 1395 | async fn audio_player_script(cx: &Cx) -> Result { | 1385 | async fn audio_player_script(cx: &Cx) -> Result { |
| 1396 | use topcoat::view::Unescaped; | 1386 | use topcoat::view::Unescaped; |
| 1397 | const JS: &str = "\ | 1387 | const JS: &str = "\ |
| 1398 | (function () { \ | 1388 | (function () { \ |
| 1399 | - var player = document.querySelector('.audio-player'); \ | 1389 | + if (window.__izlekAudioWired) { return; } \ |
| 1400 | - if (!player) { return; } \ | 1390 | + window.__izlekAudioWired = true; \ |
| 1391 | + function wireAll() { document.querySelectorAll('.audio-player').forEach(wirePlayer); } \ | ||
| 1392 | + function wirePlayer(player) { \ | ||
| 1393 | + if (player.dataset.wired) { return; } \ | ||
| 1394 | + player.dataset.wired = '1'; \ | ||
| 1401 | var audio = player.querySelector('.audio-el'); \ | 1395 | var audio = player.querySelector('.audio-el'); \ |
| 1402 | var play = player.querySelector('.audio-play'); \ | 1396 | var play = player.querySelector('.audio-play'); \ |
| 1403 | var seek = player.querySelector('.audio-seek'); \ | 1397 | var seek = player.querySelector('.audio-seek'); \ |
| @@ -1428,6 +1422,9 @@ async fn audio_player_script(cx: &Cx) -> Result { | |||
| 1428 | seek.addEventListener('input', function () { \ | 1422 | seek.addEventListener('input', function () { \ |
| 1429 | if (audio.duration) { audio.currentTime = seek.value / 1000 * audio.duration; } \ | 1423 | if (audio.duration) { audio.currentTime = seek.value / 1000 * audio.duration; } \ |
| 1430 | }); \ | 1424 | }); \ |
| 1425 | + } \ | ||
| 1426 | + wireAll(); \ | ||
| 1427 | + document.addEventListener('izlek:wire', wireAll); \ | ||
| 1431 | })();"; | 1428 | })();"; |
| 1432 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 1429 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } |
| 1433 | } | 1430 | } |
| @@ -1504,8 +1501,8 @@ pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result | |||
| 1504 | pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result { | 1501 | pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result { |
| 1505 | view! { | 1502 | view! { |
| 1506 | cx => | 1503 | cx => |
| 1507 | - <div class="modal-scrim" @click=$(|_e: Event| raw!("window.location.href='/'", ()))> | 1504 | + <div class="modal-scrim"> |
| 1508 | - <div class="modal modal-new-task" tabindex="-1" @click=$(|e: Event| e.stop_propagation())> | 1505 | + <div class="modal modal-new-task" tabindex="-1"> |
| 1509 | <header class="detail-head"> | 1506 | <header class="detail-head"> |
| 1510 | <span class="detail-headline">(t(lang, Key::NewTask))</span> | 1507 | <span class="detail-headline">(t(lang, Key::NewTask))</span> |
| 1511 | <span class="detail-esc">(t(lang, Key::Esc))</span> | 1508 | <span class="detail-esc">(t(lang, Key::Esc))</span> |
crates/izlek-web/src/dropdown.rsmodified+6 -2
| @@ -15,7 +15,9 @@ use topcoat::Result; | |||
| 15 | use topcoat::context::Cx; | 15 | use topcoat::context::Cx; |
| 16 | use topcoat::view::{Unescaped, view}; | 16 | use topcoat::view::{Unescaped, view}; |
| 17 | 17 | ||
| 18 | -/// Emitted once per page that renders a `<select>`. Owns its own `Escape` | 18 | +/// Emitted once per page that renders a `<select>`; the enhancement is |
| 19 | +/// per-element and idempotent (`data-dd-done`), re-run on `izlek:wire` so | ||
| 20 | +/// selects arriving in a soft page swap get theirs too. Owns its own `Escape` | ||
| 19 | /// handling (capture-phase, `stopImmediatePropagation` on an open panel) | 21 | /// handling (capture-phase, `stopImmediatePropagation` on an open panel) |
| 20 | /// rather than routing through `board.rs`'s `card_menu_script` — on any | 22 | /// rather than routing through `board.rs`'s `card_menu_script` — on any |
| 21 | /// page carrying both, this script must be emitted *before* that one so its | 23 | /// page carrying both, this script must be emitted *before* that one so its |
| @@ -126,7 +128,9 @@ pub async fn dropdown_script(cx: &Cx) -> Result { | |||
| 126 | }, true);\ | 128 | }, true);\ |
| 127 | document.addEventListener('click', closeAll);\ | 129 | document.addEventListener('click', closeAll);\ |
| 128 | window.addEventListener('scroll', closeAll, true);\ | 130 | window.addEventListener('scroll', closeAll, true);\ |
| 129 | - document.querySelectorAll('select.status-select, select.field-input').forEach(enhance);\ | 131 | + function enhanceAll() { document.querySelectorAll('select.status-select, select.field-input').forEach(enhance); }\ |
| 132 | + enhanceAll();\ | ||
| 133 | + document.addEventListener('izlek:wire', enhanceAll);\ | ||
| 130 | })();"; | 134 | })();"; |
| 131 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 135 | view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } |
| 132 | } | 136 | } |
crates/izlek-web/src/layout.rsmodified+148 -2
| @@ -35,7 +35,7 @@ pub async fn user_menu(cx: &Cx, display_name: &str, email: &str, role: izlek_cor | |||
| 35 | <div class="user-menu-role">(t(lang, role_key))</div> | 35 | <div class="user-menu-role">(t(lang, role_key))</div> |
| 36 | <div class="user-menu-divider"></div> | 36 | <div class="user-menu-divider"></div> |
| 37 | <a class="user-menu-item" href="/settings">(t(lang, Key::Settings))</a> | 37 | <a class="user-menu-item" href="/settings">(t(lang, Key::Settings))</a> |
| 38 | - <form class="user-menu-item-form" method="post" action="/api/sign_out"> | 38 | + <form class="user-menu-item-form" method="post" action="/api/sign_out" data-hard=""> |
| 39 | <button class="user-menu-item" type="submit">(t(lang, Key::SignOut))</button> | 39 | <button class="user-menu-item" type="submit">(t(lang, Key::SignOut))</button> |
| 40 | </form> | 40 | </form> |
| 41 | </div> | 41 | </div> |
| @@ -43,6 +43,151 @@ pub async fn user_menu(cx: &Cx, display_name: &str, email: &str, role: izlek_cor | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | +/// The page-swap machinery that keeps every mutation on the same document. | ||
| 47 | +/// | ||
| 48 | +/// Every `/api/*` mutation is a plain form post answered with a 303 — sound | ||
| 49 | +/// without script, but a full navigation repaints the whole page for a | ||
| 50 | +/// one-field change. This script, emitted first in `<body>` on every page, | ||
| 51 | +/// intercepts those submits (capture-phase, so `requestSubmit()` from any | ||
| 52 | +/// auto-submit control lands here too), replays them over `fetch`, and swaps | ||
| 53 | +/// the redirected page's `<body>` children in place — same bytes the hard | ||
| 54 | +/// navigation would have shown, no reload. Refusal banners and saved chips | ||
| 55 | +/// arrive with the swap because the redirect URL's query params rendered | ||
| 56 | +/// them server-side; `history.replaceState` keeps the address bar honest. | ||
| 57 | +/// | ||
| 58 | +/// Swapped-in nodes carry no live `<script>` (parser-inserted only) and no | ||
| 59 | +/// topcoat hydration — the runtime walks the document once at load and | ||
| 60 | +/// exposes no re-hydrate entry — so every behavior on this app is a | ||
| 61 | +/// document-level delegated listener that survives the swap, and the | ||
| 62 | +/// `izlek:wire` event re-runs the idempotent per-element enhancers | ||
| 63 | +/// (`dropdown.rs`, the audio player) over the new nodes. | ||
| 64 | +/// | ||
| 65 | +/// Forms that must really navigate (sign-in/out, claim, redeem: the session | ||
| 66 | +/// cookie and the whole page identity change) opt out with `data-hard`. | ||
| 67 | +/// Overlay closes never hit the server at all: the board is already | ||
| 68 | +/// rendered under the modal, so `__izlekCloseModal`/`__izlekCloseViewer` | ||
| 69 | +/// drop the overlay's DOM and rewrite the URL. | ||
| 70 | +/// | ||
| 71 | +/// The click-forwarder at the end is the repo-wide fix for the dead-zone | ||
| 72 | +/// class the member-role select first showed: any click inside a | ||
| 73 | +/// `.field-box`/`.status-form`/`.member-role` that misses the `.dd-trigger` | ||
| 74 | +/// (label, chevron glyph, box padding) is forwarded to the trigger. | ||
| 75 | +pub async fn soft_nav_script(cx: &Cx) -> Result { | ||
| 76 | + const JS: &str = "\ | ||
| 77 | + (function () { \ | ||
| 78 | + if (window.__izlekSoft) { return; } \ | ||
| 79 | + window.__izlekSoft = true; \ | ||
| 80 | + function wire() { document.dispatchEvent(new Event('izlek:wire')); } \ | ||
| 81 | + function swap(html, url) { \ | ||
| 82 | + var doc = new DOMParser().parseFromString(html, 'text/html'); \ | ||
| 83 | + var x = window.scrollX, y = window.scrollY; \ | ||
| 84 | + document.body.replaceChildren(); \ | ||
| 85 | + while (doc.body.firstChild) { document.body.appendChild(doc.body.firstChild); } \ | ||
| 86 | + var root = doc.documentElement; \ | ||
| 87 | + if (root.getAttribute('lang')) { document.documentElement.setAttribute('lang', root.getAttribute('lang')); } \ | ||
| 88 | + if (root.hasAttribute('data-theme')) { document.documentElement.setAttribute('data-theme', root.getAttribute('data-theme')); } \ | ||
| 89 | + else { document.documentElement.removeAttribute('data-theme'); } \ | ||
| 90 | + if (url) { history.replaceState(null, '', url); } \ | ||
| 91 | + window.scrollTo(x, y); \ | ||
| 92 | + wire(); \ | ||
| 93 | + } \ | ||
| 94 | + function sweepPanels() { \ | ||
| 95 | + document.querySelectorAll('.dd-panel').forEach(function (panel) { \ | ||
| 96 | + if (panel.__ddTrigger && !document.contains(panel.__ddTrigger)) { panel.remove(); } \ | ||
| 97 | + }); \ | ||
| 98 | + } \ | ||
| 99 | + window.__izlekGo = function (url) { \ | ||
| 100 | + fetch(url).then( \ | ||
| 101 | + function (r) { return r.text().then(function (t) { swap(t, r.url); }); }, \ | ||
| 102 | + function () { window.location.href = url; } \ | ||
| 103 | + ); \ | ||
| 104 | + }; \ | ||
| 105 | + window.__izlekPost = function (action, fields) { \ | ||
| 106 | + fetch(action, { method: 'POST', body: new URLSearchParams(fields) }).then( \ | ||
| 107 | + function (r) { return r.text().then(function (t) { swap(t, r.url); }); }, \ | ||
| 108 | + function () {} \ | ||
| 109 | + ); \ | ||
| 110 | + }; \ | ||
| 111 | + window.__izlekCloseViewer = function () { \ | ||
| 112 | + var scrim = document.querySelector('.viewer-scrim'); \ | ||
| 113 | + if (!scrim) { return false; } \ | ||
| 114 | + var back = scrim.querySelector('.viewer-close').getAttribute('href'); \ | ||
| 115 | + scrim.remove(); \ | ||
| 116 | + sweepPanels(); \ | ||
| 117 | + history.replaceState(null, '', back); \ | ||
| 118 | + var modal = document.querySelector('.modal'); \ | ||
| 119 | + if (modal) { modal.focus(); } \ | ||
| 120 | + return true; \ | ||
| 121 | + }; \ | ||
| 122 | + window.__izlekCloseModal = function () { \ | ||
| 123 | + var scrims = document.querySelectorAll('.modal-scrim'); \ | ||
| 124 | + if (!scrims.length) { return false; } \ | ||
| 125 | + scrims.forEach(function (el) { el.remove(); }); \ | ||
| 126 | + sweepPanels(); \ | ||
| 127 | + var u = new URL(window.location.href); \ | ||
| 128 | + ['task', 'file', 'confirm', 'new', 'refusal', 'on'].forEach(function (k) { u.searchParams.delete(k); }); \ | ||
| 129 | + var q = u.searchParams.toString(); \ | ||
| 130 | + history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \ | ||
| 131 | + return true; \ | ||
| 132 | + }; \ | ||
| 133 | + document.addEventListener('submit', function (e) { \ | ||
| 134 | + var form = e.target; \ | ||
| 135 | + if (!form || form.hasAttribute('data-hard')) { return; } \ | ||
| 136 | + var method = (form.getAttribute('method') || 'get').toLowerCase(); \ | ||
| 137 | + if (method !== 'post') { \ | ||
| 138 | + e.preventDefault(); \ | ||
| 139 | + var q = new URLSearchParams(new FormData(form)).toString(); \ | ||
| 140 | + window.__izlekGo((form.getAttribute('action') || window.location.pathname) + (q ? '?' + q : '')); \ | ||
| 141 | + return; \ | ||
| 142 | + } \ | ||
| 143 | + e.preventDefault(); \ | ||
| 144 | + var data = e.submitter ? new FormData(form, e.submitter) : new FormData(form); \ | ||
| 145 | + var multipart = (form.getAttribute('enctype') || '').indexOf('multipart') !== -1; \ | ||
| 146 | + fetch(form.getAttribute('action'), { method: 'POST', body: multipart ? data : new URLSearchParams(data) }).then( \ | ||
| 147 | + function (r) { return r.text().then(function (t) { swap(t, r.url); }); }, \ | ||
| 148 | + function () { form.submit(); } \ | ||
| 149 | + ); \ | ||
| 150 | + }, true); \ | ||
| 151 | + document.addEventListener('change', function (e) { \ | ||
| 152 | + var control = e.target; \ | ||
| 153 | + if (control.classList && control.classList.contains('file-upload-input')) { \ | ||
| 154 | + var name = control.closest('label').querySelector('.file-upload-name'); \ | ||
| 155 | + if (control.files && control.files[0]) { name.textContent = control.files[0].name; } \ | ||
| 156 | + control.form.requestSubmit(); \ | ||
| 157 | + return; \ | ||
| 158 | + } \ | ||
| 159 | + if (control.hasAttribute && control.hasAttribute('data-autosubmit')) { control.form.requestSubmit(); } \ | ||
| 160 | + }); \ | ||
| 161 | + document.addEventListener('click', function (e) { \ | ||
| 162 | + var link = e.target.closest ? e.target.closest('a') : null; \ | ||
| 163 | + if (link) { \ | ||
| 164 | + if (link.classList.contains('viewer-close') || (link.classList.contains('detail-close') && link.closest('.viewer-scrim'))) { \ | ||
| 165 | + e.preventDefault(); \ | ||
| 166 | + window.__izlekCloseViewer(); \ | ||
| 167 | + return; \ | ||
| 168 | + } \ | ||
| 169 | + if (link.getAttribute('href') === '/' && link.closest('.modal-scrim')) { \ | ||
| 170 | + e.preventDefault(); \ | ||
| 171 | + window.__izlekCloseModal(); \ | ||
| 172 | + return; \ | ||
| 173 | + } \ | ||
| 174 | + } \ | ||
| 175 | + if (e.target.classList && e.target.classList.contains('modal-scrim')) { \ | ||
| 176 | + if (e.target.classList.contains('viewer-scrim')) { window.__izlekCloseViewer(); } \ | ||
| 177 | + else { window.__izlekCloseModal(); } \ | ||
| 178 | + } \ | ||
| 179 | + }, true); \ | ||
| 180 | + document.addEventListener('click', function (e) { \ | ||
| 181 | + if (e.target.closest && e.target.closest('.dd-trigger, .dd-panel, button, a, input, select, textarea')) { return; } \ | ||
| 182 | + var box = e.target.closest ? e.target.closest('.field-box, .status-form, .member-role') : null; \ | ||
| 183 | + if (!box) { return; } \ | ||
| 184 | + var trigger = box.querySelector('.dd-trigger'); \ | ||
| 185 | + if (trigger) { e.stopImmediatePropagation(); trigger.click(); } \ | ||
| 186 | + }); \ | ||
| 187 | + })();"; | ||
| 188 | + view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | ||
| 189 | +} | ||
| 190 | + | ||
| 46 | /// The one `Escape` path shared by every page that has no `board.rs` | 191 | /// The one `Escape` path shared by every page that has no `board.rs` |
| 47 | /// overlay chain of its own (settings, mail rules, logs) — plus board | 192 | /// overlay chain of its own (settings, mail rules, logs) — plus board |
| 48 | /// itself, whose `card_menu_script` never looks at `.user-menu`. Closes, | 193 | /// itself, whose `card_menu_script` never looks at `.user-menu`. Closes, |
| @@ -70,7 +215,7 @@ pub async fn escape_script(cx: &Cx) -> Result { | |||
| 70 | if (composer) { composer.removeAttribute('open'); e.stopImmediatePropagation(); return; } \ | 215 | if (composer) { composer.removeAttribute('open'); e.stopImmediatePropagation(); return; } \ |
| 71 | if (document.querySelector('.rule-new-body[action=\"/api/update_rule\"]')) { \ | 216 | if (document.querySelector('.rule-new-body[action=\"/api/update_rule\"]')) { \ |
| 72 | e.preventDefault(); \ | 217 | e.preventDefault(); \ |
| 73 | - window.location.href = '/rules'; \ | 218 | + if (window.__izlekGo) { window.__izlekGo('/rules'); } else { window.location.href = '/rules'; } \ |
| 74 | e.stopImmediatePropagation(); \ | 219 | e.stopImmediatePropagation(); \ |
| 75 | } \ | 220 | } \ |
| 76 | }, true); \ | 221 | }, true); \ |
| @@ -132,6 +277,7 @@ async fn root_layout(cx: &Cx, slot: Result) -> Result { | |||
| 132 | topcoat::dev::script() | 277 | topcoat::dev::script() |
| 133 | </head> | 278 | </head> |
| 134 | <body> | 279 | <body> |
| 280 | + (soft_nav_script(cx).await?) | ||
| 135 | (content) | 281 | (content) |
| 136 | </body> | 282 | </body> |
| 137 | </html> | 283 | </html> |
crates/izlek-web/src/pages.rsmodified+3 -3
| @@ -88,7 +88,7 @@ async fn setup_card(cx: &Cx) -> Result { | |||
| 88 | <div class="auth-title">(t(lang, Key::SetupTitle))</div> | 88 | <div class="auth-title">(t(lang, Key::SetupTitle))</div> |
| 89 | <div class="auth-sub">(t(lang, Key::SetupSub))</div> | 89 | <div class="auth-sub">(t(lang, Key::SetupSub))</div> |
| 90 | </div> | 90 | </div> |
| 91 | - <form method="post" action="/api/claim_workspace"> | 91 | + <form method="post" action="/api/claim_workspace" data-hard=""> |
| 92 | <label class="auth-field"> | 92 | <label class="auth-field"> |
| 93 | <span class="auth-label">(t(lang, Key::YourNameLabel))</span> | 93 | <span class="auth-label">(t(lang, Key::YourNameLabel))</span> |
| 94 | <input | 94 | <input |
| @@ -150,7 +150,7 @@ async fn sign_in_card(cx: &Cx) -> Result { | |||
| 150 | <div class="auth-title">(t(lang, Key::SignInTitle))</div> | 150 | <div class="auth-title">(t(lang, Key::SignInTitle))</div> |
| 151 | <div class="auth-sub">(t(lang, Key::SignInSub))</div> | 151 | <div class="auth-sub">(t(lang, Key::SignInSub))</div> |
| 152 | </div> | 152 | </div> |
| 153 | - <form method="post" action="/api/sign_in"> | 153 | + <form method="post" action="/api/sign_in" data-hard=""> |
| 154 | <label class="auth-field"> | 154 | <label class="auth-field"> |
| 155 | <span class="auth-label">(t(lang, Key::EmailLabel))</span> | 155 | <span class="auth-label">(t(lang, Key::EmailLabel))</span> |
| 156 | <input | 156 | <input |
| @@ -212,7 +212,7 @@ async fn join_card(cx: &Cx, token: &str, person: Invited) -> Result { | |||
| 212 | <span class="auth-locked-value">(person.email)</span> | 212 | <span class="auth-locked-value">(person.email)</span> |
| 213 | </div> | 213 | </div> |
| 214 | </div> | 214 | </div> |
| 215 | - <form method="post" action="/api/redeem_link"> | 215 | + <form method="post" action="/api/redeem_link" data-hard=""> |
| 216 | <input type="hidden" name="token" value=(token)> | 216 | <input type="hidden" name="token" value=(token)> |
| 217 | <label class="auth-field"> | 217 | <label class="auth-field"> |
| 218 | <span class="auth-label">(t(lang, Key::NewPasswordLabel))</span> | 218 | <span class="auth-label">(t(lang, Key::NewPasswordLabel))</span> |
crates/izlek-web/src/settings.rsmodified+1 -8
| @@ -23,7 +23,6 @@ use topcoat::Result; | |||
| 23 | use topcoat::context::Cx; | 23 | use topcoat::context::Cx; |
| 24 | use topcoat::router::content::Form; | 24 | use topcoat::router::content::Form; |
| 25 | use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, page, route}; | 25 | use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, page, route}; |
| 26 | -use topcoat::runtime::Event; | ||
| 27 | use topcoat::view::view; | 26 | use topcoat::view::view; |
| 28 | 27 | ||
| 29 | use izlek_core::store::{NewSender, SenderTest, User}; | 28 | use izlek_core::store::{NewSender, SenderTest, User}; |
| @@ -1058,13 +1057,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1058 | } else { | 1057 | } else { |
| 1059 | <form method="post" action="/api/set_role" class="member-role status-form"> | 1058 | <form method="post" action="/api/set_role" class="member-role status-form"> |
| 1060 | <input type="hidden" name="user_id" value=(member.id.clone())> | 1059 | <input type="hidden" name="user_id" value=(member.id.clone())> |
| 1061 | - <select class="status-select" name="role" | 1060 | + <select class="status-select" name="role" data-autosubmit=""> |
| 1062 | - // Saved in the background: nothing else on the page changes | ||
| 1063 | - // on success, so a full reload would only flash. A refusal | ||
| 1064 | - // still needs the redirect's banner, and a network error | ||
| 1065 | - // falls back to the plain submit. | ||
| 1066 | - @change=$(|e: Event| raw!("{ var f = ${e}.inner.target.form; fetch(f.action, { method: 'POST', body: new URLSearchParams(new FormData(f)) }).then(function (r) { if (!r.ok || r.url.indexOf('refusal=') !== -1) { window.location.href = r.url; } }, function () { f.requestSubmit(); }); }", ())) | ||
| 1067 | - > | ||
| 1068 | <option value="member" selected=(member.role == izlek_core::Role::Member)>(t(lang, Key::RoleMemberOption))</option> | 1061 | <option value="member" selected=(member.role == izlek_core::Role::Member)>(t(lang, Key::RoleMemberOption))</option> |
| 1069 | <option value="viewer" selected=(member.role == izlek_core::Role::Viewer)>(t(lang, Key::RoleViewerOption))</option> | 1062 | <option value="viewer" selected=(member.role == izlek_core::Role::Viewer)>(t(lang, Key::RoleViewerOption))</option> |
| 1070 | <option value="admin" selected=(member.role == izlek_core::Role::Admin)>(t(lang, Key::RoleAdminOption))</option> | 1063 | <option value="admin" selected=(member.role == izlek_core::Role::Admin)>(t(lang, Key::RoleAdminOption))</option> |