added search/filter and fixed horizontal fit for mobile.
This commit is contained in:
@@ -25,6 +25,15 @@ export interface Task {
|
||||
deletedAt?: number; // Timestamp of soft delete
|
||||
}
|
||||
|
||||
export interface Filter {
|
||||
query: string;
|
||||
tags: string[];
|
||||
priorityMin: number;
|
||||
priorityMax: number;
|
||||
urgencyMin: number;
|
||||
urgencyMax: number;
|
||||
}
|
||||
|
||||
interface TaskStore {
|
||||
tasks: Task[];
|
||||
pWeight: number;
|
||||
@@ -32,6 +41,7 @@ interface TaskStore {
|
||||
matrixScaleDays: number;
|
||||
prefId?: string; // ID of the user_preferences record
|
||||
tagDefinitions?: Record<string, number>;
|
||||
filter: Filter;
|
||||
}
|
||||
|
||||
// Initial empty state
|
||||
@@ -41,8 +51,43 @@ export const [store, setStore] = createStore<TaskStore>({
|
||||
uWeight: 1.0,
|
||||
matrixScaleDays: 30,
|
||||
tagDefinitions: {}, // Map<Name, Value 0-10>
|
||||
filter: {
|
||||
query: "",
|
||||
tags: [],
|
||||
priorityMin: 1,
|
||||
priorityMax: 10,
|
||||
urgencyMin: 1,
|
||||
urgencyMax: 10
|
||||
}
|
||||
});
|
||||
|
||||
export const matchesFilter = (task: Task) => {
|
||||
const f = store.filter;
|
||||
|
||||
// Query search (title or content)
|
||||
if (f.query) {
|
||||
const q = f.query.toLowerCase();
|
||||
const inTitle = task.title.toLowerCase().includes(q);
|
||||
const inContent = task.content?.toLowerCase().includes(q);
|
||||
if (!inTitle && !inContent) return false;
|
||||
}
|
||||
|
||||
// Tags (OR logic if multiple selected?)
|
||||
if (f.tags.length > 0) {
|
||||
const hasTag = f.tags.some(tag => task.tags?.includes(tag));
|
||||
if (!hasTag) return false;
|
||||
}
|
||||
|
||||
// Priority
|
||||
if (task.priority < f.priorityMin || task.priority > f.priorityMax) return false;
|
||||
|
||||
// Urgency (calculated)
|
||||
const urgency = calculateUrgencyFromDate(task.dueDate);
|
||||
if (urgency < f.urgencyMin || urgency > f.urgencyMax) return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Auto-persist changes to localStorage (wrapped in root to avoid console warning)
|
||||
createRoot(() => {
|
||||
createEffect(() => {
|
||||
@@ -527,6 +572,21 @@ export const renameTagDefinition = async (oldName: string, newName: string) => {
|
||||
};
|
||||
|
||||
|
||||
export const setFilter = (update: Partial<Filter>) => {
|
||||
setStore("filter", (f) => ({ ...f, ...update }));
|
||||
};
|
||||
|
||||
export const clearFilter = () => {
|
||||
setStore("filter", {
|
||||
query: "",
|
||||
tags: [],
|
||||
priorityMin: 1,
|
||||
priorityMax: 10,
|
||||
urgencyMin: 1,
|
||||
urgencyMax: 10
|
||||
});
|
||||
};
|
||||
|
||||
// Legacy cleanup - We don't need local storage persistence setup anymore
|
||||
export const setupPersistence = () => {
|
||||
// Moved logic to initStore which is called on auth.
|
||||
|
||||
Reference in New Issue
Block a user