diff --git a/src/settings/GeneralSettings.ts b/src/settings/GeneralSettings.ts index facb408..113bb40 100644 --- a/src/settings/GeneralSettings.ts +++ b/src/settings/GeneralSettings.ts @@ -7,6 +7,7 @@ import ConfirmationModal from './modals/CreateFnForEveryFolder'; import { TemplateSuggest } from '../suggesters/TemplateSuggester'; import { loadFileClasses } from '../functions/styleFunctions'; import BackupWarningModal from './modals/BackupWarning'; +import RenameFolderNotesModal from './modals/RenameFns'; export async function renderGeneral(settingsTab: SettingsTab) { const containerEl = settingsTab.settingsPage; @@ -27,7 +28,7 @@ export async function renderGeneral(settingsTab: SettingsTab) { .setButtonText('Rename existing folder notes') .setCta() .onClick(async () => { - new BackupWarningModal( + new RenameFolderNotesModal( settingsTab.plugin, 'Rename all existing folder notes', 'When you click on "Confirm" all existing folder notes will be renamed to the new folder note name.', diff --git a/src/settings/modals/BackupWarning.ts b/src/settings/modals/BackupWarning.ts index 03ec594..3fe1af1 100644 --- a/src/settings/modals/BackupWarning.ts +++ b/src/settings/modals/BackupWarning.ts @@ -25,6 +25,8 @@ export default class BackupWarningModal extends Modal { contentEl.createEl('p', { text: this.desc }); + this.insertCustomHtml(); + contentEl.createEl('p', { text: 'Make sure to backup your vault before using this feature.' }).style.color = '#fb464c'; const buttonContainer = contentEl.createDiv({ cls: 'fn-modal-button-container' }); @@ -43,6 +45,10 @@ export default class BackupWarningModal extends Modal { }); } + insertCustomHtml(): void { + + } + onClose() { const { contentEl } = this; contentEl.empty(); diff --git a/src/settings/modals/RenameFns.ts b/src/settings/modals/RenameFns.ts new file mode 100644 index 0000000..8677a66 --- /dev/null +++ b/src/settings/modals/RenameFns.ts @@ -0,0 +1,35 @@ +import BackupWarningModal from "./BackupWarning"; +import FolderNotesPlugin from "src/main"; +import { Setting } from "obsidian"; + +export default class RenameFolderNotesModal extends BackupWarningModal { + constructor(plugin: FolderNotesPlugin, title: string, description: string, callback: (...args: any[]) => void, args: any[] = []) { + super(plugin, title, description, callback, args); + } + + insertCustomHtml(): void { + const { contentEl } = this; + new Setting(contentEl) + .setName('Old Folder Note Name') + .setDesc('Every folder note that matches this name will be renamed to the new folder note name.') + .addText(text => text + .setPlaceholder('Enter the old folder note name') + .setValue(this.plugin.settings.oldFolderNoteName || '') + .onChange(async (value) => { + this.plugin.settings.oldFolderNoteName = value; + }) + ); + + new Setting(contentEl) + .setName('New Folder Note Name') + .setDesc('Every folder note that matches the old folder note name will be renamed to this name.') + .addText(text => text + .setPlaceholder('Enter the new folder note name') + .setValue(this.plugin.settings.folderNoteName || '') + .onChange(async (value) => { + this.plugin.settings.folderNoteName = value; + this.plugin.settingsTab.display(); + }) + ); + } +} \ No newline at end of file