tag prefixing via @ and #
This commit is contained in:
@@ -81,7 +81,7 @@ export const NotesSidebar: Component<{
|
|||||||
<For each={note.tags.slice(0, 3)}>
|
<For each={note.tags.slice(0, 3)}>
|
||||||
{(t) => (
|
{(t) => (
|
||||||
<span class="text-[0.6rem] px-1.5 py-0.5 bg-muted rounded-md text-muted-foreground whitespace-nowrap border border-border/50">
|
<span class="text-[0.6rem] px-1.5 py-0.5 bg-muted rounded-md text-muted-foreground whitespace-nowrap border border-border/50">
|
||||||
#{t}
|
{t}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
|||||||
|
|
||||||
const allTagNames = () => {
|
const allTagNames = () => {
|
||||||
const definedTags = store.tagDefinitions.map(d => d.name);
|
const definedTags = store.tagDefinitions.map(d => d.name);
|
||||||
const bucketTags = store.buckets.map(b => b.name);
|
const bucketTags = store.buckets.map(b => `@${b.name}`);
|
||||||
const noteTags = store.notes.map(n => n.title);
|
const noteTags = store.notes.map(n => `#${n.title}`);
|
||||||
return [...new Set([...definedTags, ...bucketTags, ...noteTags])].sort();
|
return [...new Set([...definedTags, ...bucketTags, ...noteTags])].sort();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
|||||||
if (!name) return;
|
if (!name) return;
|
||||||
|
|
||||||
// update global definition
|
// update global definition
|
||||||
const bucket = store.buckets.find(b => b.name === name);
|
const bucket = store.buckets.find(b => b.name === name || `@${b.name}` === name);
|
||||||
const color = bucket ? bucket.color : undefined;
|
const color = bucket ? bucket.color : undefined;
|
||||||
upsertTagDefinition(name, valueScore(), color, resolvedTheme());
|
upsertTagDefinition(name, valueScore(), color, resolvedTheme());
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ export const TaskCard: Component<{ task: Task }> = (props) => {
|
|||||||
|
|
||||||
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
||||||
// We are in a bucket view. Hide the tag that matches this bucket's name.
|
// We are in a bucket view. Hide the tag that matches this bucket's name.
|
||||||
const bucketName = (ctx as { name: string }).name.toLowerCase();
|
// Buckets are now tagged with '@' + name.
|
||||||
return tags.filter(t => t.toLowerCase() !== bucketName);
|
const bucketTagName = `@${(ctx as { name: string }).name.toLowerCase()}`;
|
||||||
|
return tags.filter(t => t.toLowerCase() !== bucketTagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags;
|
return tags;
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ export const TaskDetail: Component<TaskDetailProps> = (props) => {
|
|||||||
|
|
||||||
// If in a bucket view, ensure the bucket tag is preserved (it was hidden from the UI so it's missing from 'tags')
|
// If in a bucket view, ensure the bucket tag is preserved (it was hidden from the UI so it's missing from 'tags')
|
||||||
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
||||||
const bucketName = (ctx as { name: string }).name;
|
const bucketTagName = `@${(ctx as { name: string }).name}`;
|
||||||
// Check case-insensitive existence
|
// Check case-insensitive existence
|
||||||
if (!newTags.some(t => t.toLowerCase() === bucketName.toLowerCase())) {
|
if (!newTags.some(t => t.toLowerCase() === bucketTagName.toLowerCase())) {
|
||||||
newTags.push(bucketName);
|
newTags.push(bucketTagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +129,9 @@ export const TaskDetail: Component<TaskDetailProps> = (props) => {
|
|||||||
|
|
||||||
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
||||||
// We are in a bucket view. Hide the tag that matches this bucket's name.
|
// We are in a bucket view. Hide the tag that matches this bucket's name.
|
||||||
const bucketName = (ctx as { name: string }).name.toLowerCase();
|
// Buckets are now tagged with '@' + name.
|
||||||
return tags.filter(t => t.toLowerCase() !== bucketName);
|
const bucketTagName = `@${(ctx as { name: string }).name.toLowerCase()}`;
|
||||||
|
return tags.filter(t => t.toLowerCase() !== bucketTagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags;
|
return tags;
|
||||||
|
|||||||
+21
-57
@@ -260,28 +260,16 @@ export const matchesFilter = (task: Task) => {
|
|||||||
task.tags?.includes(r.tagName || "");
|
task.tags?.includes(r.tagName || "");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bucket visibility logic for "My Bucket":
|
// Bucket tasks are now tagged with '@' + name.
|
||||||
// Users requested: "Any user who adds that bucket to their workspaces list can view the workspace and see tasks in that bucket from all users."
|
|
||||||
// AND "In settings a user should be able to see and edit all buckets... They should be able to add any bucket to their workspaces list."
|
|
||||||
// When in 'mine', do we show bucket tasks?
|
|
||||||
// Typically 'My Bucket' is just MY stuff + stuff shared explicitly with me.
|
|
||||||
// Buckets seem to be separate "Contexts" in the sidebar.
|
|
||||||
// However, if the user wants them mixed in, they didn't explicitly say "mix into my main list",
|
|
||||||
// they said "add that bucket to their workspaces list". This usually implies a separate view.
|
|
||||||
// BUT, if I create a task and tag it "Shop", I expect to see it.
|
|
||||||
|
|
||||||
// If I own the task, I see it.
|
|
||||||
// If it's shared with me, I see it.
|
|
||||||
|
|
||||||
if (!isOwner && !isExplicitlyShared && !isTagRuleShared) return false;
|
if (!isOwner && !isExplicitlyShared && !isTagRuleShared) return false;
|
||||||
} else if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
} else if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
||||||
// Bucket View
|
// Bucket View
|
||||||
const bucketProxy = store.buckets.find(b => b.id === (ctx as { bucketId: string }).bucketId);
|
const bucketProxy = store.buckets.find(b => b.id === (ctx as { bucketId: string }).bucketId);
|
||||||
if (!bucketProxy) return false;
|
if (!bucketProxy) return false;
|
||||||
|
|
||||||
// Show tasks that have the bucket name as a tag
|
// Show tasks that have the bucket name (prefixed with @) as a tag
|
||||||
// The requirement: "if any user adds a tag that is the name of a bucket to a task that task is then made public and moved to the bucket."
|
const bucketTagName = `@${bucketProxy.name}`;
|
||||||
if (!task.tags?.includes(bucketProxy.name)) return false;
|
if (!task.tags?.includes(bucketTagName)) return false;
|
||||||
} else {
|
} else {
|
||||||
// Context is Oversight for specific user
|
// Context is Oversight for specific user
|
||||||
// Show ONLY tasks owned by that user
|
// Show ONLY tasks owned by that user
|
||||||
@@ -545,13 +533,9 @@ const isTaskInSubscribedBucket = (task: any): boolean => {
|
|||||||
if (taskTags.length === 0) return false;
|
if (taskTags.length === 0) return false;
|
||||||
|
|
||||||
// Check if any of the task's tags match a bucket we are subscribed to
|
// Check if any of the task's tags match a bucket we are subscribed to
|
||||||
// We need to look up bucket names from our subscribed bucket IDs
|
|
||||||
// This is slightly expensive if we iterate.
|
|
||||||
// Optimization: Pre-calculate subscribed bucket names?
|
|
||||||
// For now, simple find.
|
|
||||||
return store.subscribedBuckets.some(subId => {
|
return store.subscribedBuckets.some(subId => {
|
||||||
const bucket = store.buckets.find(b => b.id === subId);
|
const bucket = store.buckets.find(b => b.id === subId);
|
||||||
return bucket && taskTags.includes(bucket.name);
|
return bucket && taskTags.includes(`@${bucket.name}`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1315,17 +1299,18 @@ const checkForHandoffs = (task: Task, updates: Partial<Task>): Partial<Task> =>
|
|||||||
|
|
||||||
// Check for any tag that triggers a SEND_TASK rule
|
// Check for any tag that triggers a SEND_TASK rule
|
||||||
for (const tag of updates.tags) {
|
for (const tag of updates.tags) {
|
||||||
|
// Handle @ prefix in rule matching
|
||||||
const rule = store.shareRules.find(r =>
|
const rule = store.shareRules.find(r =>
|
||||||
r.ownerId === currentUserId &&
|
r.ownerId === currentUserId &&
|
||||||
r.type === 'tag' &&
|
r.type === 'tag' &&
|
||||||
r.tagName === tag &&
|
(r.tagName === tag || `@${r.tagName}` === tag) &&
|
||||||
r.share_mode === 'SEND_TASK'
|
r.share_mode === 'SEND_TASK'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rule) {
|
if (rule) {
|
||||||
console.log(`Handoff triggered by tag "${tag}" -> Transferring to ${rule.targetUserId}`);
|
console.log(`Handoff triggered by tag "${tag}" -> Transferring to ${rule.targetUserId}`);
|
||||||
|
|
||||||
// Check if it's a bucket tag (target is self, but tag is a bucket)
|
// Check if it's a bucket tag
|
||||||
const isBucketRule = rule.targetUserId === currentUserId && store.tagDefinitions.find(t => t.name === tag)?.isBucket;
|
const isBucketRule = rule.targetUserId === currentUserId && store.tagDefinitions.find(t => t.name === tag)?.isBucket;
|
||||||
|
|
||||||
if (isBucketRule) {
|
if (isBucketRule) {
|
||||||
@@ -1633,12 +1618,13 @@ export const syncSystemTagsAndRules = async () => {
|
|||||||
|
|
||||||
// --- Sync Bucket Tags ---
|
// --- Sync Bucket Tags ---
|
||||||
for (const bucket of store.buckets) {
|
for (const bucket of store.buckets) {
|
||||||
const tagExists = tagDefinitions.find(t => t.name === bucket.name);
|
const bucketTagName = `@${bucket.name}`;
|
||||||
|
const tagExists = tagDefinitions.find(t => t.name === bucketTagName);
|
||||||
if (!tagExists) {
|
if (!tagExists) {
|
||||||
try {
|
try {
|
||||||
const record = await pb.collection(TAGS_COLLECTION).create({
|
const record = await pb.collection(TAGS_COLLECTION).create({
|
||||||
user: currentUserId,
|
user: currentUserId,
|
||||||
name: bucket.name,
|
name: bucketTagName,
|
||||||
value: 5,
|
value: 5,
|
||||||
color: bucket.color || "#64748b",
|
color: bucket.color || "#64748b",
|
||||||
theme: "dark",
|
theme: "dark",
|
||||||
@@ -1653,23 +1639,22 @@ export const syncSystemTagsAndRules = async () => {
|
|||||||
isBucket: true
|
isBucket: true
|
||||||
}]);
|
}]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to create bucket tag ${bucket.name}`, e);
|
console.error(`Failed to create bucket tag ${bucketTagName}`, e);
|
||||||
}
|
}
|
||||||
} else if (!tagExists.isBucket) {
|
} else if (!tagExists.isBucket) {
|
||||||
try {
|
try {
|
||||||
await pb.collection(TAGS_COLLECTION).update(tagExists.id, { isBucket: true });
|
await pb.collection(TAGS_COLLECTION).update(tagExists.id, { isBucket: true });
|
||||||
setStore("tagDefinitions", d => d.id === tagExists.id, { isBucket: true });
|
setStore("tagDefinitions", d => d.id === tagExists.id, { isBucket: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to flag tag ${bucket.name} as bucket`, e);
|
console.error(`Failed to flag tag ${bucketTagName} as bucket`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- Sync Bucket System Rule ---
|
// --- Sync Bucket System Rule ---
|
||||||
// Ensure a ShareRule exists for this bucket so it appears in "System Rules"
|
|
||||||
const bucketRuleExists = normalizedRules.some(r =>
|
const bucketRuleExists = normalizedRules.some(r =>
|
||||||
r.ownerId === currentUserId &&
|
r.ownerId === currentUserId &&
|
||||||
r.targetUserId === currentUserId &&
|
r.targetUserId === currentUserId &&
|
||||||
r.type === 'tag' &&
|
r.type === 'tag' &&
|
||||||
r.tagName === bucket.name
|
(r.tagName === bucket.name || r.tagName === bucketTagName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!bucketRuleExists) {
|
if (!bucketRuleExists) {
|
||||||
@@ -1678,19 +1663,20 @@ export const syncSystemTagsAndRules = async () => {
|
|||||||
ownerId: currentUserId,
|
ownerId: currentUserId,
|
||||||
targetUserId: currentUserId,
|
targetUserId: currentUserId,
|
||||||
type: 'tag',
|
type: 'tag',
|
||||||
tagName: bucket.name,
|
tagName: bucketTagName,
|
||||||
share_mode: 'SEND_TASK'
|
share_mode: 'SEND_TASK'
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to ensure system rule for bucket ${bucket.name}`, e);
|
console.error(`Failed to ensure system rule for bucket ${bucketTagName}`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Sync User Tags ---
|
// --- Sync User Tags ---
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
const userName = user.name || user.email;
|
const originalName = user.name || user.email;
|
||||||
if (!userName) continue;
|
if (!originalName) continue;
|
||||||
|
const userName = `@${originalName}`;
|
||||||
|
|
||||||
const tagExists = tagDefinitions.find(t => t.name === userName);
|
const tagExists = tagDefinitions.find(t => t.name === userName);
|
||||||
if (!tagExists) {
|
if (!tagExists) {
|
||||||
@@ -1723,34 +1709,13 @@ export const syncSystemTagsAndRules = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- User Share Rule Sync ---
|
|
||||||
// OPTIMIZATION: We no longer create individual share rules for every user-pair.
|
|
||||||
// Instead, we rely on the "Global Rule" (Self-Rule) created above for the user's own name.
|
|
||||||
// When User A tags a task "Bob", the Global Rule for Bob (Owner=Bob, Target=Bob, Tag=Bob)
|
|
||||||
// will pick it up via the updated `shouldTaskBeVisible` logic.
|
|
||||||
|
|
||||||
// If we want to support "Collab" (Edit access), we might still need specific rules or specific shares,
|
|
||||||
// but for "View" access (Handoff), the Global Rule is sufficient.
|
|
||||||
|
|
||||||
// We do NOT delete existing rules here to avoid data loss during transition,
|
|
||||||
// unless strictly requested. The user said "I want to optimize share rules... make them ownerless".
|
|
||||||
// So we stop creating new ones.
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (user.id !== currentUserId) {
|
|
||||||
// Legacy loop removed to prevent exponential growth
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// --- Ensure Self-Rule for Current User (Global Subscription) ---
|
// --- Ensure Self-Rule for Current User (Global Subscription) ---
|
||||||
// This is the critical piece for "Global Sharing".
|
|
||||||
// We must ensure the user has a rule: Owner=Me, Target=Me, Tag=Me.
|
|
||||||
if (user.id === currentUserId) {
|
if (user.id === currentUserId) {
|
||||||
const selfRuleExists = normalizedRules.some(r =>
|
const selfRuleExists = normalizedRules.some(r =>
|
||||||
r.ownerId === currentUserId &&
|
r.ownerId === currentUserId &&
|
||||||
r.targetUserId === currentUserId &&
|
r.targetUserId === currentUserId &&
|
||||||
r.type === 'tag' &&
|
r.type === 'tag' &&
|
||||||
r.tagName === userName
|
(r.tagName === originalName || r.tagName === userName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!selfRuleExists) {
|
if (!selfRuleExists) {
|
||||||
@@ -1760,10 +1725,9 @@ export const syncSystemTagsAndRules = async () => {
|
|||||||
targetUserId: currentUserId,
|
targetUserId: currentUserId,
|
||||||
type: 'tag',
|
type: 'tag',
|
||||||
tagName: userName,
|
tagName: userName,
|
||||||
share_mode: 'ADD_USER' // Mode doesn't strictly matter for self-rule visibility, but ADD_USER is safe default
|
share_mode: 'ADD_USER'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update local store immediately to ensure loadAllHistory sees it
|
|
||||||
const newRule: ShareRule = {
|
const newRule: ShareRule = {
|
||||||
id: record.id,
|
id: record.id,
|
||||||
ownerId: currentUserId,
|
ownerId: currentUserId,
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ export const NotepadView: Component<{
|
|||||||
await handleUpdateNote(id, { title: newTitle });
|
await handleUpdateNote(id, { title: newTitle });
|
||||||
|
|
||||||
// 2. Rename the TagDefinition (preserves color) and propagate to all tagged tasks
|
// 2. Rename the TagDefinition (preserves color) and propagate to all tagged tasks
|
||||||
await renameTagDefinition(oldTitle, newTitle);
|
// Use '#' prefix for note tags
|
||||||
|
await renameTagDefinition(`#${oldTitle}`, `#${newTitle}`);
|
||||||
};
|
};
|
||||||
const handleDeleteNote = async (id: string) => {
|
const handleDeleteNote = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
@@ -86,11 +87,12 @@ export const NotepadView: Component<{
|
|||||||
const linkedTasks = createMemo(() => {
|
const linkedTasks = createMemo(() => {
|
||||||
const note = activeNote();
|
const note = activeNote();
|
||||||
if (!note) return [];
|
if (!note) return [];
|
||||||
|
const noteTagName = `#${note.title}`;
|
||||||
return store.tasks.filter(t => {
|
return store.tasks.filter(t => {
|
||||||
// Explicit relation
|
// Explicit relation
|
||||||
if (note.tasks && note.tasks.includes(t.id)) return true;
|
if (note.tasks && note.tasks.includes(t.id)) return true;
|
||||||
// Tag relation (case-insensitive title match)
|
// Tag relation (case-insensitive title match with # prefix)
|
||||||
if (t.tags && t.tags.some(tag => tag.toLowerCase() === note.title.toLowerCase())) return true;
|
if (t.tags && t.tags.some(tag => tag.toLowerCase() === noteTagName.toLowerCase())) return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -206,7 +208,6 @@ export const NotepadView: Component<{
|
|||||||
<For each={note().tags}>
|
<For each={note().tags}>
|
||||||
{(tag) => (
|
{(tag) => (
|
||||||
<Badge variant="secondary" class="h-6 px-2 text-xs bg-muted/30 border border-border/50 text-foreground shadow-sm">
|
<Badge variant="secondary" class="h-6 px-2 text-xs bg-muted/30 border border-border/50 text-foreground shadow-sm">
|
||||||
<Hash size={10} class="mr-1 opacity-50" />
|
|
||||||
{tag}
|
{tag}
|
||||||
<Show when={canEdit}>
|
<Show when={canEdit}>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user