Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const ParamsSchema = z.object({
});

const QuerySchema = z.object({
timePlanReason: z.literal("for-time-plan").optional(),
timePlanReason: z
.union([z.literal("for-time-plan"), z.literal("for-time-plan-only")])
.optional(),
timePlanRefId: z.string().optional(),
parentTimePlanActivityRefId: z.string().optional(),
});
Expand Down Expand Up @@ -96,7 +98,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const timePlanReason = query.timePlanReason || "standard";

let associatedTimePlan = null;
if (timePlanReason === "for-time-plan") {
if (
timePlanReason === "for-time-plan" ||
timePlanReason === "for-time-plan-only"
) {
if (!query.timePlanRefId) {
throw new Response("Missing Time Plan Id", { status: 500 });
}
Expand Down Expand Up @@ -132,9 +137,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
big_plan_ref_id: bigPlanId,
name: form.name,
time_plan_ref_id:
timePlanReason === "standard"
? undefined
: (query.timePlanRefId as string),
timePlanReason === "for-time-plan"
? (query.timePlanRefId as string)
: undefined,
time_plan_activity_kind: form.timePlanActivityKind,
time_plan_activity_feasability: form.timePlanActivityFeasability,
is_key: form.isKey,
Expand All @@ -156,6 +161,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
`/app/workspace/time-plans/${query.timePlanRefId}/${query.parentTimePlanActivityRefId}`,
);

case "for-time-plan-only":
return redirect(
`/app/workspace/time-plans/${query.timePlanRefId}`,
);

case "standard":
return redirect(
`/app/workspace/big-plans/${bigPlanId}/inbox-tasks/${result.new_inbox_task.ref_id}`,
Expand Down Expand Up @@ -190,7 +200,12 @@ export default function BigPlanNewInboxTask() {
key="big-plan-inbox-tasks/new"
isLeaflet
fakeKey="big-plan-inbox-tasks/new"
returnLocation={`/app/workspace/big-plans/${bigPlanId}`}
returnLocation={
loaderData.timePlanReason === "for-time-plan-only" &&
loaderData.associatedTimePlan
? `/app/workspace/time-plans/${loaderData.associatedTimePlan.ref_id}`
: `/app/workspace/big-plans/${bigPlanId}`
}
inputsEnabled={inputsEnabled}
>
<GlobalError actionResult={actionData} />
Expand Down Expand Up @@ -267,7 +282,8 @@ export default function BigPlanNewInboxTask() {
label="actionableDate"
inputsEnabled={inputsEnabled}
defaultValue={
loaderData.timePlanReason === "for-time-plan"
loaderData.timePlanReason === "for-time-plan" ||
loaderData.timePlanReason === "for-time-plan-only"
? (loaderData.associatedTimePlan as TimePlan).start_date
: (loaderData.bigPlan.actionable_date ?? undefined)
}
Expand All @@ -290,7 +306,8 @@ export default function BigPlanNewInboxTask() {
label="dueDate"
inputsEnabled={inputsEnabled}
defaultValue={
loaderData.timePlanReason === "for-time-plan"
loaderData.timePlanReason === "for-time-plan" ||
loaderData.timePlanReason === "for-time-plan-only"
? (loaderData.associatedTimePlan as TimePlan).end_date
: (loaderData.bigPlan.due_date ?? undefined)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ export default function TimePlanActivity() {
link: `/app/workspace/big-plans/${loaderData.targetBigPlan.ref_id}/inbox-tasks/new?timePlanReason=for-time-plan&timePlanRefId=${id}&parentTimePlanActivityRefId=${activityId}`,
highlight: true,
}),
NavSingle({
text: "New Inbox Task (From Time Plan, Big Plan Only)",
link: `/app/workspace/big-plans/${loaderData.targetBigPlan.ref_id}/inbox-tasks/new?timePlanReason=for-time-plan-only&timePlanRefId=${id}`,
}),
NavSingle({
text: "From Current Inbox Tasks",
link: `/app/workspace/time-plans/${id}/add-from-current-inbox-tasks?bigPlanReason=for-big-plan&bigPlanRefId=${loaderData.targetBigPlan.ref_id}&timePlanActivityRefId=${activityId}`,
Expand Down