mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
fix: enhance recent items functionality for create actions
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user