fix: enhance recent items functionality for create actions

This commit is contained in:
Gadha2311
2025-10-17 15:03:01 +05:30
parent 7f5e2bdefd
commit 5b9cac504e
2 changed files with 13 additions and 1 deletions
+10
View File
@@ -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) {
+3 -1
View File
@@ -1,4 +1,4 @@
import type { ConfigFile } from 'fyo/core/types';
import type { ConfigFile, RawValueMap } from 'fyo/core/types';
export type UnknownMap = Record<string, unknown>;
export type Translation = { translation: string; context?: string };
@@ -96,4 +96,6 @@ export interface SearchItem {
group: Exclude<SearchGroup, 'Docs' | 'Recent'>;
route?: string;
action?: () => void | Promise<void>;
schemaName?: string;
initData?: RawValueMap;
}