Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+140
@@ -0,0 +1,140 @@
|
||||
// AK-P4b Interim-UI (AD-28) — "Neue Aufgabe" as a modal, mirroring the automation
|
||||
// list pattern (WF-P12 "Neue Automation starten"): creating a task is trivial enough
|
||||
// that a dialog on the list beats a dedicated page. Presentational only: the form
|
||||
// posts to the create route action (`createHref`) with the exact same field contract
|
||||
// as the standalone TaskNewPage, so the action stays untouched. No useLoaderData /
|
||||
// useFetcher (DoD A.5). Final Subframe optics land as a tracked design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus, FeatherX } from "@subframe/core";
|
||||
import type { TaskPriority } from "@hivegrid/view-models";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { DateField } from "./DateField";
|
||||
import type { TaskNewPrefill, TaskPickerOption } from "./TaskNewPage";
|
||||
import { TASK_CREATOR_ASSIGNEE } from "./TaskNewPage";
|
||||
|
||||
const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"];
|
||||
|
||||
// The single assignee Select carries the kind in its value; the hidden
|
||||
// assigneeType/assigneeId inputs restore the action's field contract on submit.
|
||||
function assigneeValue(kind: "user" | "group", id: string): string {
|
||||
return `${kind}:${id}`;
|
||||
}
|
||||
|
||||
export type TaskNewDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
/** Route that owns the create action (the standalone /tasks/new route). */
|
||||
createHref: string;
|
||||
assignableUsers: readonly TaskPickerOption[];
|
||||
assignableGroups: readonly TaskPickerOption[];
|
||||
prefill?: TaskNewPrefill;
|
||||
};
|
||||
|
||||
export function TaskNewDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
createHref,
|
||||
assignableUsers,
|
||||
assignableGroups,
|
||||
prefill = null,
|
||||
}: TaskNewDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const [assignee, setAssignee] = useState<string>(TASK_CREATOR_ASSIGNEE);
|
||||
|
||||
const [assigneeType, assigneeId] = assignee === TASK_CREATOR_ASSIGNEE ? ["user", ""] : assignee.split(":");
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog.Content className="w-[560px] max-w-[92vw] p-0">
|
||||
<form method="post" action={createHref} className="flex w-full flex-col" data-ui-id="ui.tasks.new.dialog">
|
||||
<div className="flex w-full items-start justify-between gap-3 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<span className="text-heading- font-heading- text-text-neutral-primary">{t("tasks.new.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("tasks.new.subtitle")}</span>
|
||||
</div>
|
||||
<IconButton
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon={<FeatherX />}
|
||||
aria-label={t("tasks.new.actions.cancel")}
|
||||
onClick={() => onOpenChange(false)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col gap-4 px-6 py-5 max-h-[65vh] overflow-y-auto mobile:px-4">
|
||||
<TextInput label={t("tasks.detail.field.title")} showLabel>
|
||||
<TextInput.Input name="title" required autoFocus data-ui-id="ui.tasks.new.title" />
|
||||
</TextInput>
|
||||
<TextArea label={t("tasks.detail.field.description")} showLabel>
|
||||
<TextArea.Input name="description" />
|
||||
</TextArea>
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<Select className="max-w-[200px]" name="priority" label={t("tasks.detail.field.priority")} showLabel defaultValue="normal">
|
||||
{PRIORITIES.map((priority) => (
|
||||
<Select.Item key={priority} value={priority}>
|
||||
{t(`tasks.priority.${priority}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<DateField label={t("tasks.detail.field.deadline")} name="deadline" />
|
||||
</div>
|
||||
<Select
|
||||
className="w-full"
|
||||
label={t("tasks.detail.field.assignee")}
|
||||
showLabel
|
||||
value={assignee}
|
||||
onValueChange={(value: string) => setAssignee(value)}
|
||||
>
|
||||
<Select.Item value={TASK_CREATOR_ASSIGNEE}>{t("tasks.new.assignee.default")}</Select.Item>
|
||||
{assignableUsers.map((user) => (
|
||||
<Select.Item key={`u-${user.id}`} value={assigneeValue("user", user.id)}>
|
||||
{user.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
{assignableGroups.map((group) => (
|
||||
<Select.Item key={`g-${group.id}`} value={assigneeValue("group", group.id)}>
|
||||
{group.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<input type="hidden" name="assigneeType" value={assigneeType} />
|
||||
<input type="hidden" name="assigneeId" value={assigneeId} />
|
||||
|
||||
{prefill ? (
|
||||
<div data-ui-id="ui.tasks.new.dialog.prefill">
|
||||
<input type="hidden" name="entityType" value={prefill.entityType} />
|
||||
<input type="hidden" name="entityId" value={prefill.entityId} />
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t(`tasks.entity.${prefill.entityType}`)} · {prefill.entityId}
|
||||
</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="flex w-full items-center justify-end gap-2 border-t border-solid border-border-default bg-surface-neutral-secondary px-6 py-4 mobile:flex-col-reverse mobile:items-stretch mobile:px-4">
|
||||
<Button
|
||||
type="button"
|
||||
className="mobile:w-full"
|
||||
variant="tertiary"
|
||||
onClick={() => onOpenChange(false)}
|
||||
data-ui-id="ui.tasks.new.dialog.cancel"
|
||||
>
|
||||
{t("tasks.new.actions.cancel")}
|
||||
</Button>
|
||||
<Button type="submit" className="mobile:w-full" icon={<FeatherPlus />} data-ui-id="ui.tasks.new.dialog.submit">
|
||||
{t("tasks.new.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user