@@ -29,7 +26,7 @@
-
+
@@ -98,11 +95,14 @@
/>
-
diff --git a/src/utils/types.ts b/src/utils/types.ts
index 598a908a..19041ae8 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -38,13 +38,10 @@ export type SettingsTab =
| ModelNameEnum.SystemSettings;
export interface QuickEditOptions {
- doc?: Doc;
- schemaName?: string;
- name?: string;
+ doc: Doc;
hideFields?: string[];
showFields?: string[];
defaults?: Record
;
- listFilters?: QueryFilter;
}
export type SidebarConfig = SidebarRoot[];
diff --git a/src/utils/ui.ts b/src/utils/ui.ts
index 6409bdca..7b659f9f 100644
--- a/src/utils/ui.ts
+++ b/src/utils/ui.ts
@@ -35,63 +35,26 @@ export const toastDurationMap = { short: 2_500, long: 5_000 } as const;
export async function openQuickEdit({
doc,
- schemaName,
- name,
hideFields = [],
showFields = [],
- defaults = {},
- listFilters = {},
}: QuickEditOptions) {
- if (doc) {
- schemaName = doc.schemaName;
- name = doc.name;
+ const { schemaName, name } = doc;
+ if (!name) {
+ throw new ValueError(t`Quick edit error: ${schemaName} entry has no name.`);
}
- if (!doc && (!schemaName || !name)) {
- throw new ValueError(t`Schema Name or Name not passed to Open Quick Edit`);
- }
-
- const currentRoute = router.currentRoute.value;
- const query = currentRoute.query;
- let method: 'push' | 'replace' = 'push';
-
- if (query.edit && query.schemaName === schemaName) {
- method = 'replace';
- }
-
- if (query.name === name) {
+ if (router.currentRoute.value.query.name === name) {
return;
}
- const forWhat = (defaults?.for ?? []) as string[];
- if (forWhat[0] === 'not in') {
- const purpose = forWhat[1]?.[0];
-
- defaults = Object.assign({
- for:
- purpose === 'Sales'
- ? 'Purchases'
- : purpose === 'Purchases'
- ? 'Sales'
- : 'Both',
- });
- }
-
- if (forWhat[0] === 'not in' && forWhat[1] === 'Sales') {
- defaults = Object.assign({ for: 'Purchases' });
- }
-
- router[method]({
- query: {
- edit: 1,
- schemaName,
- name,
- showFields,
- hideFields,
- defaults: stringifyCircular(defaults),
- filters: JSON.stringify(listFilters),
- },
- });
+ const query = {
+ edit: 1,
+ name,
+ schemaName,
+ showFields,
+ hideFields,
+ };
+ router.push({ query });
}
export async function openSettings(tab: SettingsTab) {