-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetting-tab.ts
More file actions
39 lines (33 loc) · 1.11 KB
/
setting-tab.ts
File metadata and controls
39 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { App, PluginSettingTab, Setting } from 'obsidian';
import EasyTrackerPlugin from './main';
// Plugin settings: weekStart (0 = Sunday, 1 = Monday)
export interface EasyTrackerPluginSettings {
weekStart: 0 | 1;
}
export const DEFAULT_SETTINGS: EasyTrackerPluginSettings = {
weekStart: 1,
};
export class EasyTrackerSettingTab extends PluginSettingTab {
plugin: EasyTrackerPlugin;
constructor(app: App, plugin: EasyTrackerPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
new Setting(containerEl)
.setName(this.plugin.t('setting.weekStartName'))
.setDesc(this.plugin.t('setting.weekStartDescription'))
.addDropdown(drop => {
// 1 = Monday (default); 0 = Sunday
drop.addOption('1', this.plugin.t('setting.weekStart.monday'));
drop.addOption('0', this.plugin.t('setting.weekStart.sunday'));
drop.setValue(String(this.plugin.settings.weekStart));
drop.onChange(async (value) => {
this.plugin.settings.weekStart = value === '0' ? 0 : 1;
await this.plugin.saveSettings();
});
});
}
}