From b3fcefead75ddfb7524aed1ab2ac77b9c6d0ee85 Mon Sep 17 00:00:00 2001 From: Ozan Tellioglu Date: Sat, 1 Apr 2023 22:09:29 +0200 Subject: [PATCH] New Note Default Date --- src/components/noteList.tsx | 5 ++++- src/settings/settings.ts | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/noteList.tsx b/src/components/noteList.tsx index b476b18..7f063d5 100644 --- a/src/components/noteList.tsx +++ b/src/components/noteList.tsx @@ -81,7 +81,10 @@ export default function NoteListComponent(params: NoteListComponentParams) { size={20} aria-label="Create note for today" onClick={() => { - let newFileModal = new CreateNoteModal(plugin, new Date()); + let newFileModal = new CreateNoteModal( + plugin, + plugin.settings.newNoteDate === 'current-date' ? new Date() : selectedDay + ); newFileModal.open(); }} /> diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 2a6570f..d38ac66 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -5,6 +5,7 @@ import { FolderSuggest } from 'settings/suggestor'; export type OpenFileBehaviourType = 'new-tab' | 'new-tab-group' | 'current-tab'; export type SortingOption = 'name' | 'name-rev'; export type DateSourceOption = 'filename' | 'yaml'; +export type NewNoteDateType = 'current-date' | 'active-date'; export interface OZCalendarPluginSettings { openViewOnStart: boolean; @@ -17,6 +18,7 @@ export interface OZCalendarPluginSettings { showDestinationFolderDuringCreate: boolean; openFileBehaviour: OpenFileBehaviourType; sortingOption: SortingOption; + newNoteDate: NewNoteDateType; } export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { @@ -30,6 +32,7 @@ export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { showDestinationFolderDuringCreate: true, openFileBehaviour: 'current-tab', sortingOption: 'name', + newNoteDate: 'current-date', }; export class OZCalendarPluginSettingsTab extends PluginSettingTab { @@ -194,7 +197,25 @@ export class OZCalendarPluginSettingsTab extends PluginSettingTab { cls: 'setting-item-description', }); - new Setting(this.containerEl) + new Setting(containerEl) + .setName('New Note Date') + .setDesc( + ` + Define the default behaviour for new note button if it should create under the active date or current date (today). + This setting will drive the date for the YAML Key value and File Name. + ` + ) + .addDropdown((dropdown) => { + dropdown + .addOption('active-date', 'Active Date (Selected)') + .addOption('current-date', 'Current Date (Today)') + .onChange((newValue: NewNoteDateType) => { + this.plugin.settings.newNoteDate = newValue; + this.plugin.saveSettings(); + }); + }); + + new Setting(containerEl) .setName('Default Folder Location') .setDesc('Select the default folder, under which the new files should be saved when use plugin + icon') .addSearch((cb) => {