Update
This commit is contained in:
40
main.ts
40
main.ts
@@ -1,30 +1,30 @@
|
||||
import { MarkdownView, Platform, Plugin, WorkspaceLeaf } from "obsidian";
|
||||
import {
|
||||
VIEW_TYPE_PROJECTS,
|
||||
VIEW_TYPE_OVERVIEW,
|
||||
VIEW_TYPE_DETAILS,
|
||||
VIEW_TYPE_PROJECT_VIEW,
|
||||
VIEW_TYPE_PROJECT_DETAILS_VIEW,
|
||||
VIEW_TYPE_COLLECTION_VIEW,
|
||||
RIBBON_ICON,
|
||||
} from "./src/const";
|
||||
import { ProjectsView } from "./src/views/ProjectsView";
|
||||
import { OverviewView } from "./src/views/OverviewView";
|
||||
import { DetailsView } from "./src/views/DetailsView";
|
||||
import { ProjectView } from "./src/views/ProjectView";
|
||||
import { ProjectDetailsView } from "./src/views/ProjectDetailsView";
|
||||
import { CollectionView } from "./src/views/CollectionView";
|
||||
import { parseProjectFilePath } from "./src/fs";
|
||||
import { BreadcrumbSegment, injectMobileBreadcrumb } from "./src/ui";
|
||||
|
||||
export default class ProjektkontextPlugin extends Plugin {
|
||||
async onload(): Promise<void> {
|
||||
this.registerView(VIEW_TYPE_PROJECTS, (leaf) => new ProjectsView(leaf));
|
||||
this.registerView(VIEW_TYPE_OVERVIEW, (leaf) => new OverviewView(leaf));
|
||||
this.registerView(VIEW_TYPE_DETAILS, (leaf) => new DetailsView(leaf));
|
||||
this.registerView(VIEW_TYPE_PROJECT_VIEW, (leaf) => new ProjectView(leaf));
|
||||
this.registerView(VIEW_TYPE_PROJECT_DETAILS_VIEW, (leaf) => new ProjectDetailsView(leaf));
|
||||
this.registerView(VIEW_TYPE_COLLECTION_VIEW, (leaf) => new CollectionView(leaf));
|
||||
|
||||
this.addRibbonIcon(RIBBON_ICON, "Projekte", () => {
|
||||
void this.activateProjectsView();
|
||||
void this.activateProjectView();
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "open-projects",
|
||||
name: "Projekte öffnen",
|
||||
callback: () => void this.activateProjectsView(),
|
||||
callback: () => void this.activateProjectView(),
|
||||
});
|
||||
|
||||
if (Platform.isMobile) {
|
||||
@@ -41,12 +41,12 @@ export default class ProjektkontextPlugin extends Plugin {
|
||||
|
||||
async onunload(): Promise<void> {}
|
||||
|
||||
async activateProjectsView(): Promise<void> {
|
||||
async activateProjectView(): Promise<void> {
|
||||
const { workspace } = this.app;
|
||||
let leaf: WorkspaceLeaf | null = workspace.getLeavesOfType(VIEW_TYPE_PROJECTS)[0] ?? null;
|
||||
let leaf: WorkspaceLeaf | null = workspace.getLeavesOfType(VIEW_TYPE_PROJECT_VIEW)[0] ?? null;
|
||||
if (!leaf) {
|
||||
leaf = workspace.getLeaf(false);
|
||||
await leaf.setViewState({ type: VIEW_TYPE_PROJECTS, active: true });
|
||||
await leaf.setViewState({ type: VIEW_TYPE_PROJECT_VIEW, active: true });
|
||||
}
|
||||
workspace.revealLeaf(leaf);
|
||||
}
|
||||
@@ -71,26 +71,26 @@ export default class ProjektkontextPlugin extends Plugin {
|
||||
const segments: BreadcrumbSegment[] = [
|
||||
{
|
||||
label: "Projekte",
|
||||
onClick: () => void leaf.setViewState({ type: VIEW_TYPE_PROJECTS, active: true }),
|
||||
onClick: () => void leaf.setViewState({ type: VIEW_TYPE_PROJECT_VIEW, active: true }),
|
||||
},
|
||||
{
|
||||
label: loc.project,
|
||||
onClick: () =>
|
||||
void leaf.setViewState({
|
||||
type: VIEW_TYPE_OVERVIEW,
|
||||
type: VIEW_TYPE_PROJECT_DETAILS_VIEW,
|
||||
active: true,
|
||||
state: { project: loc.project },
|
||||
}),
|
||||
},
|
||||
];
|
||||
if (loc.area) {
|
||||
if (loc.collection) {
|
||||
segments.push({
|
||||
label: loc.area,
|
||||
label: loc.collection,
|
||||
onClick: () =>
|
||||
void leaf.setViewState({
|
||||
type: VIEW_TYPE_DETAILS,
|
||||
type: VIEW_TYPE_COLLECTION_VIEW,
|
||||
active: true,
|
||||
state: { project: loc.project, area: loc.area },
|
||||
state: { project: loc.project, collection: loc.collection, zone: loc.zone },
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user