mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
fix(quick-capture): initialize default filename when input is empty
This commit is contained in:
parent
438785444e
commit
d2845e687b
2 changed files with 25 additions and 4 deletions
|
|
@ -37,7 +37,11 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
|
|||
private targetFileEl: HTMLDivElement | null = null;
|
||||
private editorContainer: HTMLElement | null = null;
|
||||
|
||||
constructor(app: App, plugin: TaskProgressBarPlugin, metadata?: TaskMetadata) {
|
||||
constructor(
|
||||
app: App,
|
||||
plugin: TaskProgressBarPlugin,
|
||||
metadata?: TaskMetadata,
|
||||
) {
|
||||
// Default to checkbox mode for task creation
|
||||
super(app, plugin, "checkbox", metadata);
|
||||
|
||||
|
|
@ -228,6 +232,10 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
|
|||
},
|
||||
});
|
||||
|
||||
// Initialize customFileName with resolved path so file-mode saves work
|
||||
// even when user doesn't edit the input
|
||||
this.taskMetadata.customFileName = resolvedPath;
|
||||
|
||||
// Update the customFileName when input changes
|
||||
this.fileNameInput.addEventListener("input", () => {
|
||||
if (this.fileNameInput) {
|
||||
|
|
@ -660,9 +668,11 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
|
|||
|
||||
// Add tags (ensure they start with # but don't double-add)
|
||||
if (this.taskMetadata.tags && this.taskMetadata.tags.length > 0) {
|
||||
metadata.push(...this.taskMetadata.tags.map((tag) =>
|
||||
tag.startsWith("#") ? tag : `#${tag}`
|
||||
));
|
||||
metadata.push(
|
||||
...this.taskMetadata.tags.map((tag) =>
|
||||
tag.startsWith("#") ? tag : `#${tag}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Add metadata to content
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import {
|
|||
} from "./BaseQuickCaptureModal";
|
||||
import { FileNameInput } from "../components/FileNameInput";
|
||||
import { formatDate as formatDateSmart } from "@/utils/date/date-utils";
|
||||
import { processDateTemplates } from "@/utils/file/file-operations";
|
||||
|
||||
const LAST_USED_MODE_KEY = "task-genius.lastUsedQuickCaptureMode";
|
||||
|
||||
|
|
@ -295,6 +296,16 @@ export class QuickCaptureModal extends BaseQuickCaptureModal {
|
|||
},
|
||||
);
|
||||
|
||||
// Initialize customFileName with default value if not already set
|
||||
// This ensures the file mode save logic works even when user doesn't modify the input
|
||||
if (!this.taskMetadata.customFileName) {
|
||||
const defaultTemplate =
|
||||
this.plugin.settings.quickCapture.defaultFileNameTemplate ||
|
||||
"{{DATE:YYYY-MM-DD}} - Task";
|
||||
this.taskMetadata.customFileName =
|
||||
processDateTemplates(defaultTemplate);
|
||||
}
|
||||
|
||||
// Set initial value if exists
|
||||
if (this.taskMetadata.customFileName) {
|
||||
this.fileNameInput.setValue(this.taskMetadata.customFileName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue