diff --git a/crates/iz-web/src/detail.rs b/crates/iz-web/src/detail.rs index 0353e30..66fc7e8 100644 --- a/crates/iz-web/src/detail.rs +++ b/crates/iz-web/src/detail.rs @@ -666,40 +666,58 @@ async fn set_task_tag(cx: &Cx, Form(input): Form) -> Redirect { redirect(cx, None) } -/// Puts someone on a task. A Viewer can neither do this nor be the target. +/// Puts people on a task. A Viewer can neither do this nor be a target. +/// Repeated `user_id` pairs assign several people in one post โ€” the create +/// picker and the task picker's multi-select both land here. #[route(POST "/api/assign")] -async fn assign(cx: &Cx, Form(input): Form) -> Redirect { +async fn assign(cx: &Cx, Form(pairs): Form>) -> Redirect { use iz_core::detail::ActivityKind; use time::OffsetDateTime; - let (actor, _) = match writer_and_task(cx, &input.task_id).await { + let field = |name: &str| { + pairs + .iter() + .find(|(key, _)| key == name) + .map(|(_, value)| value.as_str()) + }; + let task_id = field("task_id").unwrap_or_default(); + let (actor, _) = match writer_and_task(cx, task_id).await { Ok(pair) => pair, Err(refusal) => return redirect(cx, Some(refusal)), }; let store = store(cx).clone(); - - let Some(person) = store.user(&input.user_id).await? else { - return redirect(cx, Some(Refusal::NotFound)); - }; - if person.workspace_id != actor.workspace_id { - return redirect(cx, Some(Refusal::NotFound)); - } - if !person.role.can_be_assigned() { - return redirect(cx, Some(Refusal::Forbidden)); + let mut seen: Vec<&str> = Vec::new(); + for user_id in pairs + .iter() + .filter(|(key, _)| key == "user_id") + .map(|(_, value)| value.as_str()) + { + if user_id.is_empty() || seen.iter().any(|id| *id == user_id) { + continue; + } + seen.push(user_id); + let Some(person) = store.user(user_id).await? else { + return redirect(cx, Some(Refusal::NotFound)); + }; + if person.workspace_id != actor.workspace_id { + return redirect(cx, Some(Refusal::NotFound)); + } + if !person.role.can_be_assigned() { + return redirect(cx, Some(Refusal::Forbidden)); + } + store.assign_task(task_id, &person.id).await?; + let activity_id = store + .record_activity( + task_id, + Some(&actor.id), + Some(&person.id), + &ActivityKind::Assigned, + &person.display_name, + OffsetDateTime::now_utc(), + ) + .await?; + mail(cx).after_activity(store.clone(), activity_id); } - - store.assign_task(&input.task_id, &person.id).await?; - let activity_id = store - .record_activity( - &input.task_id, - Some(&actor.id), - Some(&person.id), - &ActivityKind::Assigned, - &person.display_name, - OffsetDateTime::now_utc(), - ) - .await?; - mail(cx).after_activity(store, activity_id); redirect(cx, None) } @@ -1598,6 +1616,49 @@ pub(crate) async fn datepicker_script<'a>(cx: &'a Cx, lang: Lang) -> Result }.boxed()) } +/// Type-to-filter inside an assignee popover. Reuses `.dd-search` and the +/// dropdown's `tr`+`en` match, as a repair on `iz:wire` so a morph does not +/// leave a typed query sitting over unfiltered rows. Enter does not submit +/// the wrapping create form. +async fn assignee_search_script<'a>(cx: &'a Cx) -> Result { + use topcoat::view::Unescaped; + const JS: &str = "\ + (function () {\ + if (window.__izAssigneeSearch) { return; }\ + window.__izAssigneeSearch = true;\ + function filterPanel(panel) {\ + var search = panel.querySelector('.dd-search');\ + if (!search) { return; }\ + var q = search.value;\ + var qTr = q.toLocaleLowerCase('tr');\ + var qEn = q.toLowerCase();\ + panel.querySelectorAll('.pop-row').forEach(function (r) {\ + var t = r.textContent;\ + var miss = t.toLocaleLowerCase('tr').indexOf(qTr) === -1 && t.toLowerCase().indexOf(qEn) === -1;\ + r.classList.toggle('dd-option-hidden', qEn !== '' && miss);\ + });\ + }\ + function wire() {\ + document.querySelectorAll('.assignee-pop .pop-panel').forEach(filterPanel);\ + }\ + document.addEventListener('input', function (e) {\ + var search = e.target && e.target.closest && e.target.closest('.assignee-pop .dd-search');\ + if (!search) { return; }\ + window.__izOwn(search, [], ['value']);\ + var panel = search.closest('.pop-panel');\ + if (panel) { filterPanel(panel); }\ + });\ + document.addEventListener('keydown', function (e) {\ + if (e.key !== 'Enter') { return; }\ + if (!e.target || !e.target.closest || !e.target.closest('.assignee-pop .dd-search')) { return; }\ + e.preventDefault();\ + });\ + document.addEventListener('iz:wire', wire);\ + wire();\ + })();"; + Ok(view! { cx => }.boxed()) +} + async fn assignee_chip<'a>( cx: &'a Cx, task_id: &'a str, @@ -1635,24 +1696,30 @@ async fn assignee_picker<'a>( } let toggle = format!("assign-{task_id}"); let put_aria = t(lang, Key::PutSomeoneOnThisTask); + let search_aria = t(lang, Key::Search); Ok(view! { cx =>
-
- for person in people { -
- - - -
- } -
+ + } +
+
+ + +
+ (topcoat::view::Child::new(refused(cx, "assign", lang).await?))
@@ -2438,6 +2505,7 @@ pub async fn task_modal<'a>( (topcoat::view::Child::new(datepicker_script(cx, lang).await?)) + (topcoat::view::Child::new(assignee_search_script(cx).await?)) (topcoat::view::Child::new(escape_closes(cx).await?)) }.boxed()) } @@ -2890,6 +2958,7 @@ pub async fn new_task_modal<'a>( ) -> Result { let columns = columns.to_vec(); let put_on_aria = t(lang, Key::PutSomeoneOnThisTask); + let search_aria = t(lang, Key::Search); let link_aria = t(lang, Key::LinkAnotherTask); Ok(view! { cx => @@ -2964,6 +3033,7 @@ pub async fn new_task_modal<'a>(
+
for person in people {
(topcoat::view::Child::new(datepicker_script(cx, lang).await?)) + (topcoat::view::Child::new(assignee_search_script(cx).await?)) (topcoat::view::Child::new(escape_closes(cx).await?)) }.boxed()) } diff --git a/crates/iz-web/tests/http.rs b/crates/iz-web/tests/http.rs index 367c8b4..1c6cef7 100644 --- a/crates/iz-web/tests/http.rs +++ b/crates/iz-web/tests/http.rs @@ -5723,16 +5723,18 @@ async fn the_new_task_modal_carries_the_task_tab_fields() { // Anchor at the modal div itself โ€” the page's scripts quote `modal-scrim` // too โ€” and stop at the first script after it: what sits between is the // modal's own markup. - let start = html - .find("modal modal-new-task") - .expect("no modal scrim"); + let start = html.find("modal modal-new-task").expect("no modal scrim"); let modal = &html[start..]; let modal = &modal[..modal.find("im"), "the dark sibling renders: {html}"); - assert!(!html.contains("ok dev"), "the flyout carries dots only: {html}"); + assert!( + !html.contains("ok dev"), + "the flyout carries dots only: {html}" + ); } /// The marks are pinned without a router, a bundle or a live sibling: a @@ -10240,18 +10305,30 @@ fn the_switcher_marks_render_from_resolved_probes_alone() { marks.contains("health-dot health-on"), "the ok sibling reads on: {marks}" ); - assert!(marks.contains(">in"), "the live sibling renders: {marks}"); + assert!( + marks.contains(">in"), + "the live sibling renders: {marks}" + ); assert!( marks.contains("health-dot health-off"), "the dark sibling reads off: {marks}" ); - assert!(marks.contains(">im"), "the dark sibling renders: {marks}"); - assert!(!marks.contains(">iz"), "iz's own row stays out: {marks}"); + assert!( + marks.contains(">im"), + "the dark sibling renders: {marks}" + ); + assert!( + !marks.contains(">iz"), + "iz's own row stays out: {marks}" + ); assert!( marks.contains("title=\"Files\""), "the mark keeps its human name: {marks}" ); - assert!(marks.contains("data-hard"), "the links leave this origin: {marks}"); + assert!( + marks.contains("data-hard"), + "the links leave this origin: {marks}" + ); assert!( marks.contains(r#"ยท"#), "middots between: {marks}" diff --git a/style/main.scss b/style/main.scss index 2ac35fa..d3df2df 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1817,7 +1817,13 @@ img.avatar { transition: background-color var(--dur-fast) var(--ease); &:hover { background: var(--row-hover); } - &:has(:checked) { background: var(--row-hover); } + &:has(:checked) { + background: color-mix(in srgb, var(--accent) 32%, var(--surface)); + color: var(--accent-ink); + } + &:has(:checked):hover { + background: color-mix(in srgb, var(--accent) 32%, var(--surface)); + } } .pop-row-name { font-size: 12px; }