fix: tab creation now works, use FolderPlus icon for tab assign
New tabs created via FolderPlus button are stored in localStorage as custom tabs and merged with list-derived tabs. Dissolve and rename also update custom tabs. Changed tab assign icon in list headers from Tag to FolderPlus for consistency. v1.27.2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
72eafbd63c
commit
79e4a5b287
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "my-weekly-todo-list",
|
||||
"version": "1.27.1",
|
||||
"version": "1.27.2",
|
||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -1471,19 +1471,30 @@ export default function WeeklyView() {
|
||||
const [creatingNewTab, setCreatingNewTab] = useState(false);
|
||||
const [creatingNewTabName, setCreatingNewTabName] = useState("");
|
||||
const [dragOverTab, setDragOverTab] = useState<string | null>(null);
|
||||
const [customTabs, setCustomTabs] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
const saved = localStorage.getItem("weekly_active_someday_tab");
|
||||
if (saved) setActiveSomedayTab(saved === "__all__" ? null : saved);
|
||||
try {
|
||||
const savedTabs = localStorage.getItem("weekly_custom_tabs");
|
||||
if (savedTabs) setCustomTabs(JSON.parse(savedTabs));
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}, []);
|
||||
|
||||
const saveCustomTabs = (tabs: string[]) => {
|
||||
setCustomTabs(tabs);
|
||||
localStorage.setItem("weekly_custom_tabs", JSON.stringify(tabs));
|
||||
};
|
||||
|
||||
const somedayTabs = useMemo(() => {
|
||||
const tabs = new Set<string>();
|
||||
somedayLists.forEach(l => { if (l.tab) tabs.add(l.tab); });
|
||||
customTabs.forEach(t => tabs.add(t));
|
||||
return Array.from(tabs).sort();
|
||||
}, [somedayLists]);
|
||||
}, [somedayLists, customTabs]);
|
||||
|
||||
const setSomedayTab = (tab: string | null) => {
|
||||
setActiveSomedayTab(tab);
|
||||
@ -1505,15 +1516,19 @@ export default function WeeklyView() {
|
||||
|
||||
const renameTab = async (oldName: string, newName: string) => {
|
||||
if (!newName.trim() || newName === oldName) return;
|
||||
const trimmed = newName.trim();
|
||||
const listsToUpdate = somedayLists.filter(l => l.tab === oldName);
|
||||
setSomedayLists(prev => prev.map(l => l.tab === oldName ? { ...l, tab: newName.trim() } : l));
|
||||
if (activeSomedayTab === oldName) setSomedayTab(newName.trim());
|
||||
setSomedayLists(prev => prev.map(l => l.tab === oldName ? { ...l, tab: trimmed } : l));
|
||||
if (customTabs.includes(oldName)) {
|
||||
saveCustomTabs(customTabs.map(t => t === oldName ? trimmed : t));
|
||||
}
|
||||
if (activeSomedayTab === oldName) setSomedayTab(trimmed);
|
||||
for (const list of listsToUpdate) {
|
||||
try {
|
||||
await fetch("/api/someday-lists", {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ id: list.id, tab: newName.trim() }),
|
||||
body: JSON.stringify({ id: list.id, tab: trimmed }),
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Failed to rename tab for list:", e);
|
||||
@ -1524,6 +1539,9 @@ export default function WeeklyView() {
|
||||
const dissolveTab = async (tabName: string) => {
|
||||
const listsToUpdate = somedayLists.filter(l => l.tab === tabName);
|
||||
setSomedayLists(prev => prev.map(l => l.tab === tabName ? { ...l, tab: null } : l));
|
||||
if (customTabs.includes(tabName)) {
|
||||
saveCustomTabs(customTabs.filter(t => t !== tabName));
|
||||
}
|
||||
if (activeSomedayTab === tabName) setSomedayTab(null);
|
||||
for (const list of listsToUpdate) {
|
||||
try {
|
||||
@ -6425,8 +6443,12 @@ export default function WeeklyView() {
|
||||
value={creatingNewTabName}
|
||||
onChange={(e) => setCreatingNewTabName(e.target.value)}
|
||||
onBlur={() => {
|
||||
if (creatingNewTabName.trim()) {
|
||||
setSomedayTab(creatingNewTabName.trim());
|
||||
const name = creatingNewTabName.trim();
|
||||
if (name && !somedayTabs.includes(name)) {
|
||||
saveCustomTabs([...customTabs, name]);
|
||||
setSomedayTab(name);
|
||||
} else if (name) {
|
||||
setSomedayTab(name);
|
||||
}
|
||||
setCreatingNewTab(false);
|
||||
}}
|
||||
@ -6806,7 +6828,7 @@ export default function WeeklyView() {
|
||||
) : iconContent;
|
||||
})()}
|
||||
<div className="someday-tab-assign" style={{ marginLeft: "auto", position: "relative", display: "flex", alignItems: "center" }}>
|
||||
<Tag size={13} style={{ color: list.tab ? "var(--weekly-accent, #6366f1)" : "#bbb", flexShrink: 0 }} />
|
||||
<FolderPlus size={13} style={{ color: list.tab ? "var(--weekly-accent, #6366f1)" : "#bbb", flexShrink: 0 }} />
|
||||
<select
|
||||
className="someday-tab-select"
|
||||
value={list.tab || ""}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user