Skip to content

Commit fb96934

Browse files
Iurii Karpovclaude
andcommitted
Daily Routines: drag&drop, unscheduled toggle, date picker, ics import fix
- Long-press drag&drop to move routines across day/time/all-day buckets - Unscheduled toggle in edit modal (NONE-frequency only) preserves null date/time - Date picker in modal for non-recurring scheduled routines - updateDailyTask omits scheduled_date/scheduled_time when not provided - Fix .ics import: drop manual multipart Content-Type so axios sets boundary - Surface import errors in alert Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 904688d commit fb96934

11 files changed

Lines changed: 483 additions & 45 deletions

File tree

‎src/actions/tmgr/daily-tasks.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ export const updateDailyTask = async (
8585
settings: data.settings || null,
8686
is_daily_routine: true,
8787
is_recurring: data.is_recurring || false,
88-
scheduled_date: data.scheduled_date || null,
89-
scheduled_time: data.scheduled_time || null
9088
};
89+
if ('routine_category' in data) payload.routine_category = data.routine_category;
90+
if ('scheduled_date' in data) payload.scheduled_date = data.scheduled_date;
91+
if ('scheduled_time' in data) payload.scheduled_time = data.scheduled_time;
9192

9293
// Only include recurrence if is_recurring is true
9394
if (data.is_recurring && data.recurrence) {
@@ -214,9 +215,7 @@ export const importRoutinesIcs = async (
214215
const fd = new FormData();
215216
fd.append('file', file);
216217
fd.append('mode', mode);
217-
const { data } = await $axios.post('daily-routines/ics/import', fd, {
218-
headers: { 'Content-Type': 'multipart/form-data' },
219-
});
218+
const { data } = await $axios.post('daily-routines/ics/import', fd);
220219
return data as IcsImportResult;
221220
};
222221

‎src/components/dailyRoutine/EditRoutineModal.vue‎

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,35 @@
8080
</div>
8181
</ERSection>
8282

83+
<!-- Schedule mode (only for non-recurring) -->
84+
<ERSection v-if="draft.frequency === 'NONE'" label="Schedule">
85+
<label class="flex items-center gap-2 rounded-card border border-line bg-surface-sunken px-3 py-2.5 text-sm text-ink cursor-pointer">
86+
<input
87+
v-model="draft.unscheduled"
88+
type="checkbox"
89+
class="h-4 w-4 accent-brand"
90+
/>
91+
<span class="flex-1">Unscheduled (no specific date/time)</span>
92+
</label>
93+
</ERSection>
94+
95+
<!-- Date (non-recurring + scheduled) -->
96+
<ERSection
97+
v-if="draft.frequency === 'NONE' && !draft.unscheduled"
98+
label="Date"
99+
>
100+
<input
101+
v-model="draft.scheduledDate"
102+
type="date"
103+
class="w-full rounded-card border border-line bg-surface-sunken px-3.5 py-2.5 text-sm text-ink outline-none focus:border-line-strong"
104+
/>
105+
</ERSection>
106+
83107
<!-- Time + Duration -->
84-
<div class="grid grid-cols-2 gap-2.5">
108+
<div
109+
v-if="!(draft.frequency === 'NONE' && draft.unscheduled)"
110+
class="grid grid-cols-2 gap-2.5"
111+
>
85112
<ERSection label="Time">
86113
<div class="flex items-center gap-1.5 rounded-card border border-line bg-surface-sunken px-3 py-2.5">
87114
<DRIcon name="clock" :size="13" :stroke="catColor" />
@@ -283,6 +310,8 @@
283310
dayOfMonth: number;
284311
month: number;
285312
reminderMin: number | null;
313+
unscheduled: boolean;
314+
scheduledDate: string;
286315
}
287316
288317
const props = defineProps<{
@@ -297,20 +326,50 @@
297326
298327
const titleRef = ref<HTMLInputElement | null>(null);
299328
329+
function todayIso(): string {
330+
const d = new Date();
331+
const y = d.getFullYear();
332+
const m = String(d.getMonth() + 1).padStart(2, '0');
333+
const day = String(d.getDate()).padStart(2, '0');
334+
return `${y}-${m}-${day}`;
335+
}
336+
337+
function parseTimeStr(s: any): { h: number; m: number } | null {
338+
if (typeof s !== 'string') return null;
339+
const parts = s.split(':');
340+
if (parts.length < 2) return null;
341+
const h = parseInt(parts[0], 10);
342+
const m = parseInt(parts[1], 10);
343+
if (isNaN(h) || isNaN(m)) return null;
344+
return { h, m };
345+
}
346+
347+
const r = props.routine ?? {};
348+
const initialFreq = (r.recurrence?.frequency ?? r.frequency ?? 'NONE') as RoutineFrequency;
349+
const taskTime = parseTimeStr(r.scheduled_time);
350+
const hasTime =
351+
r.time?.h != null ||
352+
r.recurrence?.time?.hours != null ||
353+
taskTime !== null;
354+
const hasDate = !!(r.scheduled_date || r._draftDate);
355+
const isExistingNone = r.id != null && initialFreq === 'NONE';
356+
300357
const initial: RoutineDraft = {
301-
id: props.routine?.id ?? null,
302-
title: props.routine?.title ?? '',
303-
description: props.routine?.description ?? '',
304-
cat: (props.routine?.routine_category?.id ?? props.routine?.cat ?? 'none') as RoutineCategoryId,
305-
timeH: props.routine?.time?.h ?? props.routine?.recurrence?.time?.hours ?? 9,
306-
timeM: props.routine?.time?.m ?? props.routine?.recurrence?.time?.minutes ?? 0,
307-
durationMin: props.routine?.recurrence?.duration_min ?? props.routine?.durationMin ?? 30,
308-
frequency: (props.routine?.recurrence?.frequency ?? props.routine?.frequency ?? 'NONE') as RoutineFrequency,
309-
interval: props.routine?.recurrence?.interval ?? 1,
310-
daysOfWeek: dowsToIndices(props.routine?.recurrence?.days_of_week ?? []),
311-
dayOfMonth: props.routine?.recurrence?.day_of_frequency ?? new Date().getDate(),
312-
month: props.routine?.recurrence?.month ?? 0,
313-
reminderMin: props.routine?.recurrence?.reminder_min ?? null,
358+
id: r.id ?? null,
359+
title: r.title ?? '',
360+
description: r.description ?? '',
361+
cat: (r.routine_category?.id ?? r.cat ?? 'none') as RoutineCategoryId,
362+
timeH: r.time?.h ?? r.recurrence?.time?.hours ?? taskTime?.h ?? 9,
363+
timeM: r.time?.m ?? r.recurrence?.time?.minutes ?? taskTime?.m ?? 0,
364+
durationMin: r.recurrence?.duration_min ?? r.durationMin ?? 30,
365+
frequency: initialFreq,
366+
interval: r.recurrence?.interval ?? 1,
367+
daysOfWeek: dowsToIndices(r.recurrence?.days_of_week ?? []),
368+
dayOfMonth: r.recurrence?.day_of_frequency ?? new Date().getDate(),
369+
month: r.recurrence?.month ?? 0,
370+
reminderMin: r.recurrence?.reminder_min ?? null,
371+
unscheduled: isExistingNone ? !hasTime && !hasDate : false,
372+
scheduledDate: r.scheduled_date ?? r._draftDate ?? r.date ?? todayIso(),
314373
};
315374
316375
const draft = reactive<RoutineDraft>(initial);

‎src/components/dailyRoutine/EventBlock.vue‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<template>
22
<div
3-
class="dr-week-chip absolute cursor-pointer overflow-hidden rounded-md transition-opacity"
4-
:class="entry.completed ? 'opacity-50' : 'opacity-100'"
3+
class="dr-week-chip absolute cursor-pointer overflow-hidden rounded-md transition-opacity touch-none"
4+
:class="[
5+
entry.completed ? 'opacity-50' : 'opacity-100',
6+
isBeingDragged ? 'opacity-30' : '',
7+
]"
58
:style="blockStyle"
69
:title="`${entry.title} · ${entry.time} – ${endTimeStr}`"
7-
@click="$emit('toggle', entry)"
10+
@click="onClick"
11+
@pointerdown="onPointerDown($event, entry)"
812
>
913
<div
1014
v-if="!isShort"
@@ -48,18 +52,33 @@
4852
4953
const HOUR_PX = 56;
5054
55+
import { useRoutineDrag } from '@/composable/useRoutineDrag';
56+
5157
const props = defineProps<{
5258
entry: RoutineEntry;
5359
startMin: number;
5460
endMin: number;
5561
mode: 'full' | 'compact';
5662
}>();
5763
58-
defineEmits<{
64+
const emit = defineEmits<{
5965
(e: 'toggle', entry: RoutineEntry): void;
6066
(e: 'edit', entry: RoutineEntry): void;
6167
}>();
6268
69+
const { active, onPointerDown } = useRoutineDrag();
70+
const isBeingDragged = computed(
71+
() =>
72+
active.value &&
73+
active.value.task_id === props.entry.task_id &&
74+
active.value.date === props.entry.date,
75+
);
76+
77+
function onClick() {
78+
if (active.value) return;
79+
emit('toggle', props.entry);
80+
}
81+
6382
const top = computed(() => (props.startMin / 60) * HOUR_PX);
6483
const height = computed(() => Math.max(24, ((props.endMin - props.startMin) / 60) * HOUR_PX - 2));
6584
const isShort = computed(() => height.value < 38);

‎src/components/dailyRoutine/RoutineRow.vue‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<template>
22
<div
3-
class="group relative flex items-center gap-3 overflow-hidden rounded-card border bg-surface px-3.5 py-3 shadow-tmgr-xs transition-all"
3+
class="group relative flex items-center gap-3 overflow-hidden rounded-card border bg-surface px-3.5 py-3 shadow-tmgr-xs transition-all touch-none"
44
:class="[
55
selected
66
? 'border-brand bg-brand-bg shadow-tmgr-md'
77
: 'border-line hover:border-line-strong hover:shadow-tmgr-md cursor-pointer',
8+
isBeingDragged ? 'opacity-30' : '',
89
]"
9-
@click="$emit('select', entry)"
10+
@click="onClick"
11+
@pointerdown="onPointerDown($event, entry)"
1012
>
1113
<span
1214
class="absolute left-0 top-0 bottom-0 w-[3px]"
@@ -88,13 +90,14 @@
8890
import DRIcon from './DRIcon.vue';
8991
import type { RoutineEntry } from '@/types/dailyRoutine';
9092
import { entryRecurrenceLabel } from '@/utils/dailyRoutines/recurrenceLabel';
93+
import { useRoutineDrag } from '@/composable/useRoutineDrag';
9194
9295
const props = defineProps<{
9396
entry: RoutineEntry;
9497
selected?: boolean;
9598
}>();
9699
97-
defineEmits<{
100+
const emit = defineEmits<{
98101
(e: 'toggle', entry: RoutineEntry): void;
99102
(e: 'edit', entry: RoutineEntry): void;
100103
(e: 'delete', entry: RoutineEntry): void;
@@ -103,4 +106,17 @@
103106
}>();
104107
105108
const frequencyLabel = computed(() => entryRecurrenceLabel(props.entry));
109+
110+
const { active, onPointerDown } = useRoutineDrag();
111+
const isBeingDragged = computed(
112+
() =>
113+
active.value &&
114+
active.value.task_id === props.entry.task_id &&
115+
active.value.date === props.entry.date,
116+
);
117+
118+
function onClick() {
119+
if (active.value) return;
120+
emit('select', props.entry);
121+
}
106122
</script>

‎src/components/dailyRoutine/views/DayView.vue‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<template>
22
<div class="flex flex-1 flex-col gap-3 min-h-0">
33
<div
4-
v-if="unscheduled.length"
5-
class="flex shrink-0 flex-col gap-1.5 max-h-[220px] overflow-y-auto"
4+
v-if="unscheduled.length || dragActive"
5+
class="flex shrink-0 flex-col gap-1.5 max-h-[220px] overflow-y-auto rounded-card transition-colors"
6+
:class="hoverKey === unschedHoverKey ? 'bg-brand/10 ring-1 ring-brand/40' : ''"
7+
data-dr-drop
8+
data-dr-kind="unscheduled"
9+
:data-dr-date="dateIso"
610
>
711
<div class="flex items-center justify-between gap-2 px-1">
812
<div class="text-[10px] font-bold uppercase tracking-wider text-ink-subtle">
@@ -34,7 +38,14 @@
3438
ref="scrollRef"
3539
class="flex-1 overflow-auto rounded-card border border-line bg-surface"
3640
>
37-
<div class="relative cursor-pointer pl-14" :style="{ height: `${24 * HOUR_PX}px` }" @click="onCellClick($event)">
41+
<div
42+
class="relative cursor-pointer pl-14"
43+
:style="{ height: `${24 * HOUR_PX}px` }"
44+
data-dr-drop
45+
data-dr-kind="hour-grid"
46+
:data-dr-date="dateIso"
47+
@click="onCellClick($event)"
48+
>
3849
<div
3950
v-for="h in 24"
4051
:key="h"
@@ -103,6 +114,10 @@
103114
import { clusterEvents } from '@/utils/dailyRoutines/lanePacking';
104115
import { isSameDay, parseTime } from '@/utils/dailyRoutines/dateHelpers';
105116
import type { RoutineEntry } from '@/types/dailyRoutine';
117+
import { useRoutineDrag } from '@/composable/useRoutineDrag';
118+
119+
const { active, hoverKey } = useRoutineDrag();
120+
const dragActive = computed(() => !!active.value);
106121
107122
const props = defineProps<{
108123
entries: RoutineEntry[];
@@ -143,6 +158,9 @@
143158
const HOUR_PX = 56;
144159
const scrollRef = ref<HTMLElement | null>(null);
145160
161+
const dateIso = computed(() => fmtIso(props.date));
162+
const unschedHoverKey = computed(() => `unsched:${dateIso.value}`);
163+
146164
const isToday = computed(() => isSameDay(props.date, new Date()));
147165
const nowOffset = computed(() => {
148166
if (!isToday.value) return null;

‎src/components/dailyRoutine/views/ListView.vue‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<template>
22
<div class="flex flex-1 flex-col gap-4 overflow-auto">
3-
<section v-if="unscheduled.length">
3+
<section
4+
v-if="unscheduled.length || dragActive"
5+
class="rounded-card transition-colors"
6+
:class="hoverKey === `unsched:${todayIso}` ? 'bg-brand/10 ring-1 ring-brand/40' : ''"
7+
data-dr-drop
8+
data-dr-kind="unscheduled"
9+
:data-dr-date="todayIso"
10+
>
411
<header class="flex items-center justify-between gap-2 px-1 pb-2">
512
<div class="text-[10px] font-bold uppercase tracking-wider text-ink-subtle">
613
Unscheduled <span class="text-ink-subtle">{{ unscheduled.length }}</span>
@@ -27,7 +34,13 @@
2734
/>
2835
</div>
2936
</section>
30-
<section>
37+
<section
38+
class="rounded-card transition-colors"
39+
:class="hoverKey === `day:${todayIso}` ? 'bg-brand/10 ring-1 ring-brand/40' : ''"
40+
data-dr-drop
41+
data-dr-kind="day-cell"
42+
:data-dr-date="todayIso"
43+
>
3144
<header class="px-1 pb-2 text-[10px] font-bold uppercase tracking-wider text-brand">
3245
Today <span class="text-ink-subtle">{{ scheduled.length }}</span>
3346
</header>
@@ -51,6 +64,16 @@
5164
import { computed } from 'vue';
5265
import RoutineRow from '../RoutineRow.vue';
5366
import type { RoutineEntry } from '@/types/dailyRoutine';
67+
import { useRoutineDrag } from '@/composable/useRoutineDrag';
68+
69+
const { active, hoverKey } = useRoutineDrag();
70+
const dragActive = computed(() => !!active.value);
71+
72+
function isoToday(): string {
73+
const d = new Date();
74+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
75+
}
76+
const todayIso = isoToday();
5477
5578
const props = defineProps<{
5679
entries: RoutineEntry[];

‎src/components/dailyRoutine/views/MonthView.vue‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@
2020
<div
2121
v-for="(d, i) in days"
2222
:key="i"
23-
class="flex min-h-0 cursor-pointer flex-col gap-0.5 overflow-hidden p-1.5"
23+
class="flex min-h-0 cursor-pointer flex-col gap-0.5 overflow-hidden p-1.5 transition-colors"
2424
:class="[
2525
i % 7 === 0 ? '' : 'border-l border-line',
2626
i < 7 ? '' : 'border-t border-line',
27+
hoverKey === `day:${fmtIso(d)}` ? 'bg-brand/15 ring-1 ring-brand/40 ring-inset' : '',
2728
]"
2829
:style="cellStyle(d)"
30+
data-dr-drop
31+
data-dr-kind="day-cell"
32+
:data-dr-date="fmtIso(d)"
2933
@click="onCellClick($event, d)"
3034
>
3135
<div class="flex items-center justify-end text-xs tabular-nums" :style="dayLabelStyle(d)">
@@ -66,6 +70,9 @@
6670
import { addDays, isSameDay, startOfMonth, startOfWeek } from '@/utils/dailyRoutines/dateHelpers';
6771
import { hexAlpha } from '@/utils/dailyRoutines/categoryMap';
6872
import type { RoutineEntry } from '@/types/dailyRoutine';
73+
import { useRoutineDrag } from '@/composable/useRoutineDrag';
74+
75+
const { hoverKey } = useRoutineDrag();
6976
7077
const today = new Date();
7178

0 commit comments

Comments
 (0)