fix: default calendar to system indicators
Use coloured system markers by default, preserve configured colours through settings migration, expose all template fields through native vault-path autocomplete, and remove the redundant Calendar heading.
This commit is contained in:
+35
-8
@@ -129,14 +129,20 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
|
|
||||||
private renderPeriodicTab(container: HTMLElement): void {
|
private renderPeriodicTab(container: HTMLElement): void {
|
||||||
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily);
|
const templateSuggestionsId = this.createTemplateSuggestions(container);
|
||||||
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly);
|
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly);
|
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Quarterly', this.settings.quarterly);
|
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Yearly', this.settings.yearly);
|
this.addPeriodNoteSettings(container, 'Quarterly', this.settings.quarterly, templateSuggestionsId);
|
||||||
|
this.addPeriodNoteSettings(container, 'Yearly', this.settings.yearly, templateSuggestionsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private addPeriodNoteSettings(container: HTMLElement, label: string, period: PeriodNoteSettings): void {
|
private addPeriodNoteSettings(
|
||||||
|
container: HTMLElement,
|
||||||
|
label: string,
|
||||||
|
period: PeriodNoteSettings,
|
||||||
|
templateSuggestionsId: string,
|
||||||
|
): void {
|
||||||
new Setting(container).setHeading().setName(label);
|
new Setting(container).setHeading().setName(label);
|
||||||
|
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
@@ -165,10 +171,11 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
.setName('Template file')
|
.setName('Template file')
|
||||||
.setDesc(`Path to the template file (without .md extension).`)
|
.setDesc('Path to the template file. The .md extension is optional.')
|
||||||
.addText((text) => {
|
.addText((text) => {
|
||||||
text.setPlaceholder('Templates/Daily note');
|
text.setPlaceholder('Templates/Daily note');
|
||||||
text.setValue(period.templateFile);
|
text.setValue(period.templateFile);
|
||||||
|
text.inputEl.setAttr('list', templateSuggestionsId);
|
||||||
text.onChange((value) => {
|
text.onChange((value) => {
|
||||||
period.templateFile = value;
|
period.templateFile = value;
|
||||||
this.saveAndRefresh();
|
this.saveAndRefresh();
|
||||||
@@ -204,6 +211,8 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
.setName('Date systems')
|
.setName('Date systems')
|
||||||
.setDesc(intro);
|
.setDesc(intro);
|
||||||
|
|
||||||
|
const templateSuggestionsId = this.createTemplateSuggestions(container);
|
||||||
|
|
||||||
this.settings.dateSystems.forEach((system, i, arr) => {
|
this.settings.dateSystems.forEach((system, i, arr) => {
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
.setHeading()
|
.setHeading()
|
||||||
@@ -270,7 +279,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
this.addSystemTextSetting(container,
|
this.addSystemTextSetting(container,
|
||||||
'Template file', 'Path to the template file. The .md extension is optional.',
|
'Template file', 'Path to the template file. The .md extension is optional.',
|
||||||
system, 'templateFile', 'resources/template/journal',
|
system, 'templateFile', 'resources/template/journal', templateSuggestionsId,
|
||||||
);
|
);
|
||||||
this.addSystemTextSetting(container,
|
this.addSystemTextSetting(container,
|
||||||
'Type property', `Fallback value for the 'type' frontmatter property, used when no template is found.`,
|
'Type property', `Fallback value for the 'type' frontmatter property, used when no template is found.`,
|
||||||
@@ -318,6 +327,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
obj: Record<K, string>,
|
obj: Record<K, string>,
|
||||||
key: K,
|
key: K,
|
||||||
placeholder: string,
|
placeholder: string,
|
||||||
|
templateSuggestionsId?: string,
|
||||||
): Setting {
|
): Setting {
|
||||||
return new Setting(container)
|
return new Setting(container)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -325,6 +335,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
.addText((text) => {
|
.addText((text) => {
|
||||||
text.setPlaceholder(placeholder);
|
text.setPlaceholder(placeholder);
|
||||||
text.setValue(obj[key]);
|
text.setValue(obj[key]);
|
||||||
|
if (templateSuggestionsId) text.inputEl.setAttr('list', templateSuggestionsId);
|
||||||
text.onChange((value) => {
|
text.onChange((value) => {
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
this.saveAndRefresh();
|
this.saveAndRefresh();
|
||||||
@@ -332,6 +343,22 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native datalist keeps template paths searchable without another custom
|
||||||
|
* modal, and accepts templates stored anywhere in the vault.
|
||||||
|
*/
|
||||||
|
private createTemplateSuggestions(container: HTMLElement): string {
|
||||||
|
const id = 'waypoint-template-suggestions';
|
||||||
|
const list = container.createEl('datalist', { attr: { id } });
|
||||||
|
const paths = this.app.vault.getMarkdownFiles()
|
||||||
|
.map(file => file.path.replace(/\.md$/, ''))
|
||||||
|
.sort((a, b) => a.localeCompare(b));
|
||||||
|
for (const path of paths) {
|
||||||
|
list.createEl('option', { value: path });
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
// Recent Files tab
|
// Recent Files tab
|
||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
|
|||||||
calendar: {
|
calendar: {
|
||||||
firstDayOfWeek: 1, // Monday
|
firstDayOfWeek: 1, // Monday
|
||||||
showNoteIndicators: true,
|
showNoteIndicators: true,
|
||||||
indicatorMode: 'any',
|
indicatorMode: 'systems',
|
||||||
dailyIndicatorColor: '#3b82f6',
|
dailyIndicatorColor: '#3b82f6',
|
||||||
},
|
},
|
||||||
daily: {
|
daily: {
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ export class WaypointView extends ItemView {
|
|||||||
|
|
||||||
private renderCalendar(): void {
|
private renderCalendar(): void {
|
||||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
||||||
section.createDiv({ cls: 'waypoint-section-header', text: 'Calendar' });
|
|
||||||
|
|
||||||
const cal = section.createDiv({ cls: 'waypoint-calendar' });
|
const cal = section.createDiv({ cls: 'waypoint-calendar' });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user