chore(react/collections): clean up old files

This commit is contained in:
Elian Doran 2025-09-14 10:40:14 +03:00
parent 4040f8ba89
commit e77e0c54f0
No known key found for this signature in database
5 changed files with 0 additions and 207 deletions

View File

@ -1,8 +1,6 @@
import FNote from "../../entities/fnote"; import FNote from "../../entities/fnote";
import type { ViewModeArgs } from "../view_widgets/view_mode";
export const allViewTypes = ["list", "grid", "calendar", "table", "geoMap", "board"] as const; export const allViewTypes = ["list", "grid", "calendar", "table", "geoMap", "board"] as const;
export type ArgsWithoutNoteId = Omit<ViewModeArgs, "noteIds">;
export type ViewTypeOptions = typeof allViewTypes[number]; export type ViewTypeOptions = typeof allViewTypes[number];
export interface ViewModeProps<T extends object> { export interface ViewModeProps<T extends object> {

View File

@ -1,45 +0,0 @@
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 ViewMode from "../view_widgets/view_mode.js";
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);
}
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);
}
}
}

View File

@ -1,104 +0,0 @@
import type { Calendar, DateSelectArg, DatesSetArg, EventChangeArg, EventDropArg, EventInput, EventSourceFunc, EventSourceFuncArg, EventSourceInput, LocaleInput, PluginDef } from "@fullcalendar/core";
import froca from "../../services/froca.js";
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
import type FNote from "../../entities/fnote.js";
import server from "../../services/server.js";
import { t } from "../../services/i18n.js";
import options from "../../services/options.js";
import dialogService from "../../services/dialog.js";
import attributes from "../../services/attributes.js";
import type { CommandListenerData, EventData } from "../../components/app_context.js";
import utils, { hasTouchBar } from "../../services/utils.js";
import date_notes from "../../services/date_notes.js";
import appContext from "../../components/app_context.js";
import type { EventImpl } from "@fullcalendar/core/internal";
import debounce, { type DebouncedFunction } from "debounce";
import type { TouchBarItem } from "../../components/touch_bar.js";
import type { SegmentedControlSegment } from "electron";
import { LOCALE_IDS } from "@triliumnext/commons";
export default class CalendarView extends ViewMode<{}> {
private $root: JQuery<HTMLElement>;
private $calendarContainer: JQuery<HTMLElement>;
private calendar?: Calendar;
private isCalendarRoot: boolean;
constructor(args: ViewModeArgs) {
super(args, "calendar");
this.$root = $(TPL);
this.$calendarContainer = this.$root.find(".calendar-container");
args.$parent.append(this.$root);
}
#onDatesSet(e: DatesSetArg) {
if (hasTouchBar) {
appContext.triggerCommand("refreshTouchBar");
}
}
buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) {
if (!this.calendar) {
return;
}
const items: TouchBarItem[] = [];
const $toolbarItems = this.$calendarContainer.find(".fc-toolbar-chunk .fc-button-group, .fc-toolbar-chunk > button");
for (const item of $toolbarItems) {
// Button groups.
if (item.classList.contains("fc-button-group")) {
let mode: "single" | "buttons" = "single";
let selectedIndex = 0;
const segments: SegmentedControlSegment[] = [];
const subItems = item.childNodes as NodeListOf<HTMLElement>;
let index = 0;
for (const subItem of subItems) {
if (subItem.ariaPressed === "true") {
selectedIndex = index;
}
index++;
// Icon button.
const iconEl = subItem.querySelector("span.fc-icon");
let icon: string | null = null;
if (iconEl?.classList.contains("fc-icon-chevron-left")) {
icon = "NSImageNameTouchBarGoBackTemplate";
mode = "buttons";
} else if (iconEl?.classList.contains("fc-icon-chevron-right")) {
icon = "NSImageNameTouchBarGoForwardTemplate";
mode = "buttons";
}
if (icon) {
segments.push({
icon: buildIcon(icon)
});
}
}
items.push(new TouchBar.TouchBarSegmentedControl({
mode,
segments,
selectedIndex,
change: (selectedIndex, isSelected) => subItems[selectedIndex].click()
}));
continue;
}
// Standalone item.
if (item.innerText) {
items.push(new TouchBar.TouchBarButton({
label: item.innerText,
click: () => item.click()
}));
}
}
return items;
}
}

View File

@ -1,56 +0,0 @@
import type { EventData } from "../../components/app_context.js";
import appContext from "../../components/app_context.js";
import Component from "../../components/component.js";
import type FNote from "../../entities/fnote.js";
import { ViewTypeOptions } from "../collections/interface.js";
import ViewModeStorage from "./view_mode_storage.js";
export interface ViewModeArgs {
$parent: JQuery<HTMLElement>;
parentNote: FNote;
parentNotePath?: string | null;
showNotePath?: boolean;
}
export default abstract class ViewMode<T extends object> extends Component {
private _viewStorage: ViewModeStorage<T> | null;
protected parentNote: FNote;
protected viewType: ViewTypeOptions;
protected noteIds: string[];
protected args: ViewModeArgs;
constructor(args: ViewModeArgs, viewType: ViewTypeOptions) {
super();
this.parentNote = args.parentNote;
this._viewStorage = null;
// note list must be added to the DOM immediately, otherwise some functionality scripting (canvas) won't work
args.$parent.empty();
this.viewType = viewType;
this.args = args;
this.noteIds = [];
}
async beforeRender() {
await this.#refreshNoteIds();
}
abstract renderList(): Promise<JQuery<HTMLElement> | undefined>;
/**
* Called whenever an "entitiesReloaded" event has been received by the parent component.
*
* @param e the event data.
* @return {@code true} if the view should be re-rendered, a falsy value otherwise.
*/
async onEntitiesReloaded(e: EventData<"entitiesReloaded">): Promise<boolean | void> {
// Do nothing by default.
}
async entitiesReloadedEvent(e: EventData<"entitiesReloaded">) {
if (await this.onEntitiesReloaded(e)) {
appContext.triggerEvent("refreshNoteList", { noteId: this.parentNote.noteId });
}
}
}