!evaluateHidden(f, this.doc));
+ return (this.fields ?? []).filter(
+ (f) => !evaluateHidden(f, this.doc) && !f.meta
+ );
},
},
components: { FormControl },
diff --git a/src/utils/types.ts b/src/utils/types.ts
index 00e6c1a4..e24702ac 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -1,6 +1,7 @@
-import { Doc } from "fyo/model/doc";
-import { FieldType } from "schemas/types";
-import { QueryFilter } from "utils/db/types";
+import type { Doc } from 'fyo/model/doc';
+import type { Action } from 'fyo/model/types';
+import type { Field, FieldType } from 'schemas/types';
+import type { QueryFilter } from 'utils/db/types';
export interface MessageDialogButton {
label: string;
@@ -31,7 +32,7 @@ export interface QuickEditOptions {
hideFields?: string[];
showFields?: string[];
defaults?: Record;
- listFilters?: QueryFilter
+ listFilters?: QueryFilter;
}
export type SidebarConfig = SidebarRoot[];
@@ -44,7 +45,7 @@ export interface SidebarRoot {
iconHeight?: string;
hidden?: () => boolean;
items?: SidebarItem[];
- filters?: QueryFilter
+ filters?: QueryFilter;
}
export interface SidebarItem {
@@ -55,7 +56,6 @@ export interface SidebarItem {
hidden?: () => boolean;
}
-
export interface ExportField {
fieldname: string;
fieldtype: FieldType;
@@ -70,5 +70,13 @@ export interface ExportTableField {
fields: ExportField[];
}
+export type ActionGroup = {
+ group: string;
+ label: string;
+ type: string;
+ actions: Action[];
+};
+
+export type UIGroupedFields = Map>;
export type ExportFormat = 'csv' | 'json';
-export type PeriodKey = 'This Year' | 'This Quarter' | 'This Month'
\ No newline at end of file
+export type PeriodKey = 'This Year' | 'This Quarter' | 'This Month';
diff --git a/src/utils/ui.ts b/src/utils/ui.ts
index 38a59c55..f2b178e5 100644
--- a/src/utils/ui.ts
+++ b/src/utils/ui.ts
@@ -9,6 +9,7 @@ import { Action } from 'fyo/model/types';
import { getActions } from 'fyo/utils';
import { getDbError, LinkValidationError, ValueError } from 'fyo/utils/errors';
import { ModelNameEnum } from 'models/types';
+import { Schema } from 'schemas/types';
import { handleErrorWithDialog } from 'src/errorHandling';
import { fyo } from 'src/initFyo';
import router from 'src/router';
@@ -17,10 +18,12 @@ import { App, createApp, h, ref } from 'vue';
import { RouteLocationRaw } from 'vue-router';
import { stringifyCircular } from './';
import {
+ ActionGroup,
MessageDialogOptions,
QuickEditOptions,
SettingsTab,
ToastOptions,
+ UIGroupedFields,
} from './types';
export async function openQuickEdit({
@@ -274,14 +277,7 @@ export function getActionsForDoc(doc?: Doc): Action[] {
});
}
-export function getGroupedActionsForDoc(doc?: Doc) {
- type Group = {
- group: string;
- label: string;
- type: string;
- actions: Action[];
- };
-
+export function getGroupedActionsForDoc(doc?: Doc): ActionGroup[] {
const actions = getActionsForDoc(doc);
const actionsMap = actions.reduce((acc, ac) => {
if (!ac.group) {
@@ -297,7 +293,7 @@ export function getGroupedActionsForDoc(doc?: Doc) {
acc[ac.group].actions.push(ac);
return acc;
- }, {} as Record);
+ }, {} as Record);
const grouped = Object.keys(actionsMap)
.filter(Boolean)
@@ -393,14 +389,24 @@ function getDuplicateAction(doc: Doc): Action {
};
}
-export function getStatus(entry: { cancelled?: boolean; submitted?: boolean }) {
- if (entry.cancelled) {
- return 'Cancelled';
+export function getFieldsGroupedByTabAndSection(
+ schema: Schema
+): UIGroupedFields {
+ const grouped: UIGroupedFields = new Map();
+ for (const field of schema?.fields ?? []) {
+ const tab = field.tab ?? 'Default';
+ const section = field.section ?? 'Default';
+ if (!grouped.has(tab)) {
+ grouped.set(tab, new Map());
+ }
+
+ const tabbed = grouped.get(tab)!;
+ if (!tabbed.has(section)) {
+ tabbed.set(section, []);
+ }
+
+ tabbed.get(section)!.push(field);
}
- if (entry.submitted) {
- return 'Submitted';
- }
-
- return 'Saved';
+ return grouped;
}