mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 09:45:52 +01:00
chore(react/collections): move files around for ease of development
This commit is contained in:
7
apps/client/src/widgets/collections/NoteList.tsx
Normal file
7
apps/client/src/widgets/collections/NoteList.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
interface NoteListProps {
|
||||
displayOnlyCollections?: boolean;
|
||||
}
|
||||
|
||||
export default function NoteList({ }: NoteListProps) {
|
||||
return <p>Hi</p>
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||
import NoteListRenderer from "../services/note_list_renderer.js";
|
||||
import type FNote from "../entities/fnote.js";
|
||||
import type { CommandListener, CommandListenerData, CommandMappings, CommandNames, EventData, EventNames } from "../components/app_context.js";
|
||||
import type ViewMode from "./view_widgets/view_mode.js";
|
||||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||
import NoteListRenderer from "./note_list_renderer.ts.bak/index.js";
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import type { CommandListener, CommandListenerData, CommandMappings, CommandNames, EventData, EventNames } from "../../components/app_context.js";
|
||||
import type ViewMode from "../view_widgets/view_mode.js";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="note-list-widget">
|
||||
@@ -0,0 +1,71 @@
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import BoardView from "../view_widgets/board_view/index.js";
|
||||
import CalendarView from "../view_widgets/calendar_view.js";
|
||||
import GeoView from "../view_widgets/geo_view/index.js";
|
||||
import ListOrGridView from "../view_widgets/list_or_grid_view.js";
|
||||
import TableView from "../view_widgets/table_view/index.js";
|
||||
import type { ViewModeArgs } from "../view_widgets/view_mode.js";
|
||||
import type ViewMode from "../view_widgets/view_mode.js";
|
||||
|
||||
const allViewTypes = ["list", "grid", "calendar", "table", "geoMap", "board"] as const;
|
||||
export type ArgsWithoutNoteId = Omit<ViewModeArgs, "noteIds">;
|
||||
export type ViewTypeOptions = typeof allViewTypes[number];
|
||||
|
||||
export default class NoteListRenderer {
|
||||
|
||||
private viewType: ViewTypeOptions;
|
||||
private args: ArgsWithoutNoteId;
|
||||
public viewMode?: ViewMode<any>;
|
||||
|
||||
constructor(args: ArgsWithoutNoteId) {
|
||||
this.args = args;
|
||||
this.viewType = this.#getViewType(args.parentNote);
|
||||
}
|
||||
|
||||
#getViewType(parentNote: FNote): ViewTypeOptions {
|
||||
const viewType = parentNote.getLabelValue("viewType");
|
||||
|
||||
if (!(allViewTypes as readonly string[]).includes(viewType || "")) {
|
||||
// when not explicitly set, decide based on the note type
|
||||
return parentNote.type === "search" ? "list" : "grid";
|
||||
} else {
|
||||
return viewType as ViewTypeOptions;
|
||||
}
|
||||
}
|
||||
|
||||
get isFullHeight() {
|
||||
switch (this.viewType) {
|
||||
case "list":
|
||||
case "grid":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
async renderList() {
|
||||
const args = this.args;
|
||||
const viewMode = this.#buildViewMode(args);
|
||||
this.viewMode = viewMode;
|
||||
await viewMode.beforeRender();
|
||||
return await viewMode.renderList();
|
||||
}
|
||||
|
||||
#buildViewMode(args: ViewModeArgs) {
|
||||
switch (this.viewType) {
|
||||
case "calendar":
|
||||
return new CalendarView(args);
|
||||
case "table":
|
||||
return new TableView(args);
|
||||
case "geoMap":
|
||||
return new GeoView(args);
|
||||
case "board":
|
||||
return new BoardView(args);
|
||||
case "list":
|
||||
case "grid":
|
||||
default:
|
||||
return new ListOrGridView(this.viewType, args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { t } from "../services/i18n";
|
||||
import Alert from "./react/Alert";
|
||||
import { useNoteContext, useNoteProperty, useTriliumEvent } from "./react/hooks";
|
||||
import "./search_result.css";
|
||||
import NoteListRenderer from "../services/note_list_renderer";
|
||||
// import NoteListRenderer from "../services/note_list_renderer";
|
||||
|
||||
enum SearchResultState {
|
||||
NO_RESULTS,
|
||||
@@ -28,12 +28,13 @@ export default function SearchResult() {
|
||||
} else if (searchContainerRef.current) {
|
||||
setState(SearchResultState.GOT_RESULTS);
|
||||
|
||||
const noteListRenderer = new NoteListRenderer({
|
||||
$parent: $(searchContainerRef.current),
|
||||
parentNote: note,
|
||||
showNotePath: true
|
||||
});
|
||||
noteListRenderer.renderList();
|
||||
// TODO: Fix me.
|
||||
// const noteListRenderer = new NoteListRenderer({
|
||||
// $parent: $(searchContainerRef.current),
|
||||
// parentNote: note,
|
||||
// showNotePath: true
|
||||
// });
|
||||
// noteListRenderer.renderList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user