Update ProfileSelectionModal to change button text and remove folder creation functionality
- Changed the button text from "Pick…" to "Anpassen" for better localization. - Removed the folder creation button and its associated functionality to streamline the modal interface.
This commit is contained in:
parent
ae0e699602
commit
556145e76d
|
|
@ -95,7 +95,7 @@ export class ProfileSelectionModal extends Modal {
|
|||
folderButtonContainer.style.marginTop = "0.5em";
|
||||
|
||||
const pickFolderBtn = folderButtonContainer.createEl("button", {
|
||||
text: "Pick…",
|
||||
text: "Anpassen",
|
||||
});
|
||||
pickFolderBtn.onclick = async () => {
|
||||
const folderModal = new FolderTreeModal(this.app, this.noteIndex, folderPath);
|
||||
|
|
@ -106,31 +106,6 @@ export class ProfileSelectionModal extends Modal {
|
|||
}
|
||||
};
|
||||
|
||||
const newFolderBtn = folderButtonContainer.createEl("button", {
|
||||
text: "New folder…",
|
||||
});
|
||||
newFolderBtn.onclick = async () => {
|
||||
const folderName = await this.promptForFolderName();
|
||||
if (folderName && folderName.trim()) {
|
||||
const newFolderPath = folderPath
|
||||
? `${folderPath}/${folderName.trim()}`
|
||||
: folderName.trim();
|
||||
|
||||
try {
|
||||
await this.app.vault.createFolder(newFolderPath);
|
||||
folderPath = newFolderPath;
|
||||
folderPathSpan.textContent = folderPath || "(root)";
|
||||
new Notice(`Folder created: ${newFolderPath}`);
|
||||
|
||||
// Refresh note index to include new folder
|
||||
this.noteIndex.refresh();
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
new Notice(`Failed to create folder: ${msg}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Profile selection (grouped)
|
||||
for (const [groupName, profiles] of grouped.entries()) {
|
||||
contentEl.createEl("h3", { text: groupName });
|
||||
|
|
@ -235,53 +210,6 @@ export class ProfileSelectionModal extends Modal {
|
|||
});
|
||||
}
|
||||
|
||||
private async promptForFolderName(): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
const modal = new Modal(this.app);
|
||||
modal.titleEl.textContent = "New folder name";
|
||||
|
||||
const inputContainer = modal.contentEl.createEl("div");
|
||||
const input = inputContainer.createEl("input", {
|
||||
type: "text",
|
||||
placeholder: "Folder name",
|
||||
});
|
||||
input.style.width = "100%";
|
||||
input.style.marginBottom = "1em";
|
||||
|
||||
const buttonContainer = modal.contentEl.createEl("div");
|
||||
buttonContainer.style.display = "flex";
|
||||
buttonContainer.style.gap = "0.5em";
|
||||
buttonContainer.style.justifyContent = "flex-end";
|
||||
|
||||
const cancelBtn = buttonContainer.createEl("button", { text: "Cancel" });
|
||||
cancelBtn.onclick = () => {
|
||||
modal.close();
|
||||
resolve(null);
|
||||
};
|
||||
|
||||
const createBtn = buttonContainer.createEl("button", {
|
||||
text: "Create",
|
||||
cls: "mod-cta",
|
||||
});
|
||||
createBtn.onclick = () => {
|
||||
const value = input.value.trim();
|
||||
modal.close();
|
||||
resolve(value || null);
|
||||
};
|
||||
|
||||
input.onkeydown = (evt) => {
|
||||
if (evt.key === "Enter") {
|
||||
createBtn.click();
|
||||
} else if (evt.key === "Escape") {
|
||||
cancelBtn.click();
|
||||
}
|
||||
};
|
||||
|
||||
modal.open();
|
||||
input.focus();
|
||||
input.select();
|
||||
});
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
const { contentEl } = this;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user