mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-18 17:31:53 +08:00
feat(in_app_help): contextual help for book types
This commit is contained in:
parent
c17d10114f
commit
e73ea36161
@ -4,9 +4,11 @@ import ListOrGridView from "../widgets/view_widgets/list_or_grid_view.js";
|
||||
import type { ViewModeArgs } from "../widgets/view_widgets/view_mode.js";
|
||||
import type ViewMode from "../widgets/view_widgets/view_mode.js";
|
||||
|
||||
export type ViewTypeOptions = "list" | "grid" | "calendar";
|
||||
|
||||
export default class NoteListRenderer {
|
||||
|
||||
private viewType: string;
|
||||
private viewType: ViewTypeOptions;
|
||||
public viewMode: ViewMode | null;
|
||||
|
||||
constructor($parent: JQuery<HTMLElement>, parentNote: FNote, noteIds: string[], showNotePath: boolean = false) {
|
||||
@ -27,14 +29,14 @@ export default class NoteListRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
#getViewType(parentNote: FNote): string {
|
||||
#getViewType(parentNote: FNote): ViewTypeOptions {
|
||||
const viewType = parentNote.getLabelValue("viewType");
|
||||
|
||||
if (!["list", "grid", "calendar"].includes(viewType || "")) {
|
||||
// when not explicitly set, decide based on the note type
|
||||
return parentNote.type === "search" ? "list" : "grid";
|
||||
} else {
|
||||
return viewType as string;
|
||||
return viewType as ViewTypeOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import appContext from "../../components/app_context.js";
|
||||
import appContext, { type EventData } from "../../components/app_context.js";
|
||||
import type { NoteType } from "../../entities/fnote.js";
|
||||
import { t } from "../../services/i18n.js";
|
||||
import type { ViewScope } from "../../services/link.js";
|
||||
import type { ViewTypeOptions } from "../../services/note_list_renderer.js";
|
||||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||
|
||||
const TPL = `
|
||||
@ -10,8 +11,7 @@ const TPL = `
|
||||
</button>
|
||||
`;
|
||||
|
||||
const byNoteType: Record<NoteType, string | null> = {
|
||||
book: null,
|
||||
const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {
|
||||
canvas: null,
|
||||
code: null,
|
||||
contentWidget: null,
|
||||
@ -30,6 +30,12 @@ const byNoteType: Record<NoteType, string | null> = {
|
||||
webView: null
|
||||
};
|
||||
|
||||
const byBookType: Record<ViewTypeOptions, string | null> = {
|
||||
list: null,
|
||||
grid: null,
|
||||
calendar: "fDGg7QcJg3Xm"
|
||||
};
|
||||
|
||||
export default class ContextualHelpButton extends NoteContextAwareWidget {
|
||||
|
||||
private helpNoteIdToOpen?: string | null;
|
||||
@ -41,8 +47,10 @@ export default class ContextualHelpButton extends NoteContextAwareWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.note && byNoteType[this.note.type]) {
|
||||
if (this.note && this.note.type !== "book" && byNoteType[this.note.type]) {
|
||||
this.helpNoteIdToOpen = byNoteType[this.note.type];
|
||||
} else if (this.note && this.note.type === "book") {
|
||||
this.helpNoteIdToOpen = byBookType[this.note.getAttributeValue("label", "viewType") as ViewTypeOptions ?? ""]
|
||||
}
|
||||
|
||||
return !!this.helpNoteIdToOpen;
|
||||
@ -73,4 +81,10 @@ export default class ContextualHelpButton extends NoteContextAwareWidget {
|
||||
});
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
||||
if (this.note?.type === "book" && loadResults.getAttributeRows().find((attr) => attr.noteId === this.noteId && attr.name === "viewType")) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,10 @@ const TPL = `
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
body.desktop .calendar-container .fc-toolbar.fc-header-toolbar {
|
||||
padding-right: 5em;
|
||||
}
|
||||
|
||||
.calendar-container .fc-toolbar-title {
|
||||
font-size: 1.3rem;
|
||||
font-weight: normal;
|
||||
|
Loading…
x
Reference in New Issue
Block a user