feat: add Start View On setting (Today/Yesterday) in General Settings Modal
This commit is contained in:
parent
0632e03326
commit
182e634f23
@ -676,6 +676,7 @@ export default function WeeklyView() {
|
|||||||
dayHeaderGap?: string;
|
dayHeaderGap?: string;
|
||||||
showTaskCheckboxes?: boolean;
|
showTaskCheckboxes?: boolean;
|
||||||
quoteSourceUrls?: string[];
|
quoteSourceUrls?: string[];
|
||||||
|
startDayOffset?: number;
|
||||||
}>({
|
}>({
|
||||||
name: session?.user?.name || "",
|
name: session?.user?.name || "",
|
||||||
email: session?.user?.email || "",
|
email: session?.user?.email || "",
|
||||||
@ -2150,6 +2151,7 @@ export default function WeeklyView() {
|
|||||||
const goToToday = () => {
|
const goToToday = () => {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
d.setHours(0, 0, 0, 0);
|
d.setHours(0, 0, 0, 0);
|
||||||
|
d.setDate(d.getDate() + (profile?.startDayOffset || 0));
|
||||||
setCurrentWeekStart(d);
|
setCurrentWeekStart(d);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5827,6 +5829,7 @@ export default function WeeklyView() {
|
|||||||
somedayLists={somedayLists}
|
somedayLists={somedayLists}
|
||||||
handleToggleTaskList={handleToggleTaskList}
|
handleToggleTaskList={handleToggleTaskList}
|
||||||
fetchAvailableTaskLists={fetchAvailableTaskLists}
|
fetchAvailableTaskLists={fetchAvailableTaskLists}
|
||||||
|
setCurrentWeekStart={setCurrentWeekStart}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -6843,8 +6846,10 @@ interface SettingsSidebarProps {
|
|||||||
yearColor?: string;
|
yearColor?: string;
|
||||||
dayHeaderGap?: string;
|
dayHeaderGap?: string;
|
||||||
showTaskCheckboxes?: boolean;
|
showTaskCheckboxes?: boolean;
|
||||||
|
startDayOffset?: number;
|
||||||
quoteSourceUrls: string[];
|
quoteSourceUrls: string[];
|
||||||
}) => void;
|
}) => void;
|
||||||
|
setCurrentWeekStart: (d: Date) => void;
|
||||||
quoteSourceUrls?: string[];
|
quoteSourceUrls?: string[];
|
||||||
goal: string;
|
goal: string;
|
||||||
setGoal: (goal: string) => void;
|
setGoal: (goal: string) => void;
|
||||||
@ -7090,6 +7095,7 @@ function SettingsSidebar({
|
|||||||
handleToggleTaskList,
|
handleToggleTaskList,
|
||||||
fetchAvailableTaskLists,
|
fetchAvailableTaskLists,
|
||||||
initialTab,
|
initialTab,
|
||||||
|
setCurrentWeekStart,
|
||||||
}: SettingsSidebarProps) {
|
}: SettingsSidebarProps) {
|
||||||
const [activeTab, setActiveTab] = useState<
|
const [activeTab, setActiveTab] = useState<
|
||||||
"calendar" | "general" | "account" | "styling" | "motivation" | "about"
|
"calendar" | "general" | "account" | "styling" | "motivation" | "about"
|
||||||
@ -7202,6 +7208,7 @@ function SettingsSidebar({
|
|||||||
dayHeaderGap?: string;
|
dayHeaderGap?: string;
|
||||||
showTaskCheckboxes?: boolean;
|
showTaskCheckboxes?: boolean;
|
||||||
quoteSourceUrls?: string[];
|
quoteSourceUrls?: string[];
|
||||||
|
startDayOffset?: number;
|
||||||
}>({
|
}>({
|
||||||
name: "",
|
name: "",
|
||||||
email: "",
|
email: "",
|
||||||
@ -7361,6 +7368,7 @@ function SettingsSidebar({
|
|||||||
yearFontWeight: profile.yearFontWeight,
|
yearFontWeight: profile.yearFontWeight,
|
||||||
dayHeaderGap: profile.dayHeaderGap,
|
dayHeaderGap: profile.dayHeaderGap,
|
||||||
showTaskCheckboxes: profile.showTaskCheckboxes,
|
showTaskCheckboxes: profile.showTaskCheckboxes,
|
||||||
|
startDayOffset: profile.startDayOffset,
|
||||||
} as any);
|
} as any);
|
||||||
}, [profile, showTimeGrid, cellDuration, viewStyle, fontSize, showNextTask, showSomeday, showAllDay, showSchedule]);
|
}, [profile, showTimeGrid, cellDuration, viewStyle, fontSize, showNextTask, showSomeday, showAllDay, showSchedule]);
|
||||||
|
|
||||||
@ -7436,6 +7444,7 @@ function SettingsSidebar({
|
|||||||
showSubHourSlots: data.user.showSubHourSlots !== undefined ? data.user.showSubHourSlots : true,
|
showSubHourSlots: data.user.showSubHourSlots !== undefined ? data.user.showSubHourSlots : true,
|
||||||
allDayPosition: data.user.allDayPosition || "below",
|
allDayPosition: data.user.allDayPosition || "below",
|
||||||
showTaskCheckboxes: data.user.showTaskCheckboxes || false,
|
showTaskCheckboxes: data.user.showTaskCheckboxes || false,
|
||||||
|
startDayOffset: data.user.startDayOffset !== undefined ? data.user.startDayOffset : 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.user.showTimeGrid !== undefined)
|
if (data.user.showTimeGrid !== undefined)
|
||||||
@ -7452,6 +7461,14 @@ function SettingsSidebar({
|
|||||||
setShowSchedule(data.user.showSchedule);
|
setShowSchedule(data.user.showSchedule);
|
||||||
if (data.user.focusBreakDuration)
|
if (data.user.focusBreakDuration)
|
||||||
setFocusBreakDuration(data.user.focusBreakDuration);
|
setFocusBreakDuration(data.user.focusBreakDuration);
|
||||||
|
|
||||||
|
// Apply the initial start date offset if set
|
||||||
|
if (data.user.startDayOffset !== undefined && data.user.startDayOffset !== 0) {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(0, 0, 0, 0);
|
||||||
|
d.setDate(d.getDate() + data.user.startDayOffset);
|
||||||
|
setCurrentWeekStart(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -7647,6 +7664,7 @@ function SettingsSidebar({
|
|||||||
goalScope: profile.goalScope,
|
goalScope: profile.goalScope,
|
||||||
dateLayout: profile.dateLayout,
|
dateLayout: profile.dateLayout,
|
||||||
dateAlignment: profile.dateAlignment,
|
dateAlignment: profile.dateAlignment,
|
||||||
|
startDayOffset: profile.startDayOffset,
|
||||||
} as any);
|
} as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7774,6 +7792,29 @@ function SettingsSidebar({
|
|||||||
>
|
>
|
||||||
|
|
||||||
{/* Visibility Toggles */}
|
{/* Visibility Toggles */}
|
||||||
|
<div style={{ display: "flex", flexDirection: "column", gap: "8px", marginBottom: "8px" }}>
|
||||||
|
<label style={{ fontSize: "0.9rem", fontWeight: 600 }}>Start View On</label>
|
||||||
|
<select
|
||||||
|
value={profile.startDayOffset === -1 ? "-1" : "0"}
|
||||||
|
onChange={(e) => {
|
||||||
|
const offset = parseInt(e.target.value);
|
||||||
|
setProfile({ ...profile, startDayOffset: offset });
|
||||||
|
saveSetting("startDayOffset", offset);
|
||||||
|
}}
|
||||||
|
className="weekly-input"
|
||||||
|
style={{
|
||||||
|
padding: "8px",
|
||||||
|
border: "1px solid var(--weekly-border, #ddd)",
|
||||||
|
borderRadius: "4px",
|
||||||
|
background: "var(--weekly-settings-input-bg, white)",
|
||||||
|
color: "var(--weekly-settings-text, #333)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="0">Today</option>
|
||||||
|
<option value="-1">Yesterday</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{ display: "flex", alignItems: "center", gap: "8px" }}
|
style={{ display: "flex", alignItems: "center", gap: "8px" }}
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user