feat: init
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
import { PluginSettingTab, Setting } from "obsidian";
|
||||
import type { App } from "obsidian";
|
||||
import type BeaverCalendarPlugin from "./main";
|
||||
|
||||
export type ViewMode = "list" | "calendar";
|
||||
export type GroupBy = "sphere" | "project" | "status" | "due";
|
||||
export type SortBy = "manual" | "priority" | "due";
|
||||
|
||||
export interface BeaverCalendarSettings {
|
||||
boardsFolder: string;
|
||||
archiveHeading: string;
|
||||
view: ViewMode;
|
||||
groupBy: GroupBy;
|
||||
listSort: SortBy;
|
||||
calendarSort: SortBy;
|
||||
showDone: boolean;
|
||||
includeArchive: boolean;
|
||||
railCollapsed: boolean;
|
||||
undatedCollapsed: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: BeaverCalendarSettings = {
|
||||
boardsFolder: "Boards",
|
||||
archiveHeading: "Archive",
|
||||
view: "list",
|
||||
groupBy: "sphere",
|
||||
listSort: "due",
|
||||
calendarSort: "priority",
|
||||
showDone: false,
|
||||
includeArchive: false,
|
||||
railCollapsed: false,
|
||||
undatedCollapsed: false,
|
||||
};
|
||||
|
||||
export function normalizeFolder(value: string): string {
|
||||
return value.trim().replace(/^\/+/u, "").replace(/\/+$/u, "");
|
||||
}
|
||||
|
||||
export class BeaverCalendarSettingsTab extends PluginSettingTab {
|
||||
constructor(
|
||||
app: App,
|
||||
private readonly plugin: BeaverCalendarPlugin,
|
||||
) {
|
||||
super(app, plugin);
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Boards folder")
|
||||
.setDesc(
|
||||
"Every markdown file in this folder is a sphere, and every second-level heading inside it is a project.",
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Boards")
|
||||
.setValue(this.plugin.settings.boardsFolder)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.boardsFolder = normalizeFolder(value);
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.store.reloadAll();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Archive heading")
|
||||
.setDesc("The lane completed tasks are moved to by the archive command.")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Archive")
|
||||
.setValue(this.plugin.settings.archiveHeading)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.archiveHeading = value.trim() || "Archive";
|
||||
await this.plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Include the archive")
|
||||
.setDesc(
|
||||
"Widen the show-completed toggle to reach tasks below the archive " +
|
||||
"separator. With this off, show-completed only reveals completed " +
|
||||
"tasks still sitting in their lanes. Archived tasks carry an " +
|
||||
"Archive badge instead of a project one.",
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.includeArchive)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.includeArchive = value;
|
||||
this.plugin.store.includeArchive = value;
|
||||
await this.plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Show completed")
|
||||
.setDesc("Completed tasks are hidden from the list and the calendar by default.")
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.showDone)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showDone = value;
|
||||
this.plugin.store.showDone = value;
|
||||
await this.plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user