diff --git a/src/utils/search.ts b/src/utils/search.ts index c9a89784..a891e919 100644 --- a/src/utils/search.ts +++ b/src/utils/search.ts @@ -22,6 +22,7 @@ interface StoredRecentItem { route?: string; schemaName?: string; reportName?: string; + initData?: RawValueMap; timestamp: number; } @@ -102,6 +103,7 @@ function getCreateList(fyo: Fyo): SearchItem[] { label: fyo.schemaMap[schemaName]?.label, group: 'Create', action: getCreateAction(fyo, schemaName), + schemaName, } as SearchItem) ); @@ -151,6 +153,8 @@ function getCreateList(fyo: Fyo): SearchItem[] { label, group: 'Create', action: getCreateAction(fyo, schemaName, create), + schemaName, + initData: create, } as SearchItem; }); @@ -430,6 +434,9 @@ export class Search { recentItem.route = item.route; } else if (item.group === 'Docs') { recentItem.schemaName = item.schemaLabel; + } else if (item.group === 'Create') { + recentItem.schemaName = item.schemaName; + recentItem.initData = item.initData; } const updatedRecents = [ @@ -470,6 +477,9 @@ export class Search { private _executeRecentAction(item: StoredRecentItem) { if (item.route) { void routeTo(item.route); + } else if (item.schemaName && item.group === 'Create') { + const action = getCreateAction(this.fyo, item.schemaName, item.initData); + void action(); } else if (item.schemaName) { this._openDocList(item.schemaName); } else if (item.reportName) { diff --git a/utils/types.ts b/utils/types.ts index 34fbde0b..10679859 100644 --- a/utils/types.ts +++ b/utils/types.ts @@ -1,4 +1,4 @@ -import type { ConfigFile } from 'fyo/core/types'; +import type { ConfigFile, RawValueMap } from 'fyo/core/types'; export type UnknownMap = Record; export type Translation = { translation: string; context?: string }; @@ -96,4 +96,6 @@ export interface SearchItem { group: Exclude; route?: string; action?: () => void | Promise; + schemaName?: string; + initData?: RawValueMap; }