mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Add old/folder note name for rename existing folder notes modal
This commit is contained in:
parent
d9ac3d199c
commit
416bf25a91
3 changed files with 43 additions and 1 deletions
|
|
@ -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.',
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
35
src/settings/modals/RenameFns.ts
Normal file
35
src/settings/modals/RenameFns.ts
Normal file
|
|
@ -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();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue