note vs tab deletion clarity
This commit is contained in:
+70
-20
@@ -23,6 +23,8 @@ export const NotepadView: Component<{
|
|||||||
const [isLinkedTasksOpen, setIsLinkedTasksOpen] = createSignal(false);
|
const [isLinkedTasksOpen, setIsLinkedTasksOpen] = createSignal(false);
|
||||||
const [isDragging, setIsDragging] = createSignal(false);
|
const [isDragging, setIsDragging] = createSignal(false);
|
||||||
const [editorInstance, setEditorInstance] = createSignal<any>(null);
|
const [editorInstance, setEditorInstance] = createSignal<any>(null);
|
||||||
|
const [noteActionsOpen, setNoteActionsOpen] = createSignal(false);
|
||||||
|
const [confirmDeleteOpen, setConfirmDeleteOpen] = createSignal(false);
|
||||||
|
|
||||||
const currentUserId = pb.authStore.model?.id;
|
const currentUserId = pb.authStore.model?.id;
|
||||||
|
|
||||||
@@ -332,13 +334,16 @@ export const NotepadView: Component<{
|
|||||||
const isOwner = note().user === currentUserId;
|
const isOwner = note().user === currentUserId;
|
||||||
const canEdit = isOwner || !note().isPrivate;
|
const canEdit = isOwner || !note().isPrivate;
|
||||||
|
|
||||||
const hasTopViewer = createMemo(() => {
|
const hasTopViewer = createMemo(() => {
|
||||||
const c = note()?.content;
|
const c = note()?.content;
|
||||||
if (!c) return false;
|
if (!c) return false;
|
||||||
const s = c.trim();
|
const s = c.trim();
|
||||||
return s.startsWith('<div data-type="file-viewer-wrapper"') ||
|
return s.startsWith('<div data-type="file-viewer-wrapper"') ||
|
||||||
(s.startsWith('<div data-type="file-attachment"') && s.includes('data-filename') && s.toLowerCase().includes('.pdf'));
|
(s.startsWith('<div data-type="file-attachment"') && s.includes('data-filename') && s.toLowerCase().includes('.pdf'));
|
||||||
});
|
});
|
||||||
|
const isChildNote = createMemo(() => {
|
||||||
|
return (note()?.tags || []).some(t => t.startsWith("child-of-"));
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -707,11 +712,17 @@ export const NotepadView: Component<{
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* Sticky Footer Actions (Match TaskDetail style) */}
|
{/* Sticky Footer Actions (Match TaskDetail style) */}
|
||||||
<div class="px-4 py-3 border-t border-border/50 md:hidden flex items-center justify-between shrink-0 bg-background/95 backdrop-blur-sm z-40 w-full sticky bottom-0">
|
<div class="px-4 py-4 border-t border-border/50 md:hidden flex items-center justify-between shrink-0 bg-background/95 backdrop-blur-sm z-40 w-full sticky bottom-0">
|
||||||
<div class="flex items-center gap-2 w-16 shrink-0">
|
<div class="flex items-center gap-2 w-16 shrink-0">
|
||||||
{/* "..." popover menu containing Public/Private toggle and Delete */}
|
{/* "..." popover menu containing Public/Private toggle and Delete */}
|
||||||
<Show when={isOwner}>
|
<Show when={isOwner}>
|
||||||
<Popover>
|
<Popover
|
||||||
|
open={noteActionsOpen()}
|
||||||
|
onOpenChange={(nextOpen) => {
|
||||||
|
setNoteActionsOpen(nextOpen);
|
||||||
|
if (!nextOpen) setConfirmDeleteOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<PopoverTrigger
|
<PopoverTrigger
|
||||||
as={Button}
|
as={Button}
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -735,18 +746,57 @@ export const NotepadView: Component<{
|
|||||||
<><Lock size={14} /> Private</>
|
<><Lock size={14} /> Private</>
|
||||||
</Show>
|
</Show>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Show
|
||||||
variant="ghost"
|
when={!confirmDeleteOpen() || isChildNote()}
|
||||||
size="sm"
|
fallback={
|
||||||
class="w-full justify-start text-[0.625rem] font-bold uppercase tracking-widest gap-2 hover:bg-destructive/10 hover:text-destructive text-muted-foreground transition-all"
|
<div class="rounded-lg border border-border/50 bg-muted/30 p-2 text-[0.625rem] uppercase tracking-widest text-muted-foreground flex flex-col gap-2">
|
||||||
onClick={(e) => {
|
<span>Delete note? This cannot be undone.</span>
|
||||||
e.stopPropagation();
|
<div class="flex gap-2">
|
||||||
handleDeleteNote(note().id);
|
<Button
|
||||||
}}
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
class="flex-1 h-7 text-[0.625rem] uppercase tracking-widest"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setConfirmDeleteOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
class="flex-1 h-7 text-[0.625rem] uppercase tracking-widest hover:bg-destructive/10 hover:text-destructive"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
handleDeleteNote(note().id);
|
||||||
|
setConfirmDeleteOpen(false);
|
||||||
|
setNoteActionsOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Trash2 size={14} />
|
<Button
|
||||||
Delete
|
variant="ghost"
|
||||||
</Button>
|
size="sm"
|
||||||
|
class="w-full justify-start text-[0.625rem] font-bold uppercase tracking-widest gap-2 hover:bg-destructive/10 hover:text-destructive text-muted-foreground transition-all"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (isChildNote()) {
|
||||||
|
handleDeleteNote(note().id);
|
||||||
|
} else {
|
||||||
|
setConfirmDeleteOpen(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
{isChildNote() ? "Delete Tab" : "Delete Note"}
|
||||||
|
</Button>
|
||||||
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|||||||
Reference in New Issue
Block a user