-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfield.form.ts
More file actions
83 lines (81 loc) · 4.43 KB
/
Copy pathfield.form.ts
File metadata and controls
83 lines (81 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineForm } from '../ui/view.zod';
/**
* Field Metadata Form
*
* Form layout for creating/editing field metadata definitions.
*/
export const fieldForm = defineForm({
schemaId: 'field',
type: 'simple',
sections: [
{
name: 'basics',
label: 'Basics',
description: 'Core field identity and constraints.',
columns: 2,
fields: [
{ field: 'name', required: true, immutable: true, colSpan: 1, helpText: 'Unique identifier (snake_case, immutable after creation)' },
{ field: 'label', required: true, colSpan: 1, helpText: 'Display name for users' },
{ field: 'type', required: true, colSpan: 1, helpText: 'Data type of this field' },
{ field: 'group', colSpan: 1, helpText: 'Group name for form layout' },
{ field: 'description', widget: 'textarea', colSpan: 2, helpText: 'Help text shown to users' },
{ field: 'required', colSpan: 1, helpText: 'User must provide a value' },
{ field: 'unique', colSpan: 1, helpText: 'No two records can have the same value' },
{ field: 'multiple', colSpan: 1, helpText: 'Allow multiple values (for select/lookup)' },
],
},
{
name: 'configuration',
label: 'Configuration',
description: 'Field-type specific settings (visible blocks depend on the chosen type).',
fields: [
{ field: 'defaultValue', helpText: 'Default value for new records' },
// Text field options
{ field: 'minLength', visibleOn: "data.type == 'text' || data.type == 'textarea' || data.type == 'email'", helpText: 'Minimum character length' },
{ field: 'maxLength', visibleOn: "data.type == 'text' || data.type == 'textarea' || data.type == 'email'", helpText: 'Maximum character length' },
// Number field options
{ field: 'min', visibleOn: "data.type == 'number' || data.type == 'currency'", helpText: 'Minimum value' },
{ field: 'max', visibleOn: "data.type == 'number' || data.type == 'currency'", helpText: 'Maximum value' },
{ field: 'precision', visibleOn: "data.type == 'currency' || data.type == 'number'", helpText: 'Decimal places (e.g., 2 for $10.50)' },
{ field: 'scale', visibleOn: "data.type == 'number'", helpText: 'Number of decimal digits' },
// Select field options
{ field: 'options', type: 'repeater', visibleOn: "data.type == 'select' || data.type == 'multiselect'", helpText: 'Available options (label/value pairs)' },
// Reference field options
{ field: 'reference', widget: 'ref:object', visibleOn: "data.type == 'lookup' || data.type == 'master_detail'", helpText: 'Referenced object name' },
{ field: 'referenceFilters', widget: 'string-tags', visibleOn: "data.type == 'lookup' || data.type == 'master_detail'", helpText: 'Filter expressions (e.g., "active = true")' },
{ field: 'deleteBehavior', visibleOn: "data.type == 'lookup' || data.type == 'master_detail'", helpText: 'What happens when referenced record is deleted' },
],
},
{
name: 'formula',
label: 'Formula & Computed',
description: 'Calculated values and roll-up summaries.',
collapsible: true,
collapsed: true,
fields: [
{ field: 'expression', widget: 'textarea', helpText: 'CEL expression to calculate this field (makes it read-only)' },
{ field: 'summaryOperations', type: 'composite', helpText: 'Roll-up summary configuration (for parent-child relationships)' },
],
},
{
name: 'advanced',
label: 'Advanced',
description: 'Database, UI, audit, and security settings.',
collapsible: true,
collapsed: true,
columns: 2,
fields: [
// Database & Performance
{ field: 'columnName', colSpan: 2, helpText: 'Physical column name in database (defaults to field name)' },
{ field: 'index', colSpan: 1, helpText: 'Create database index for faster queries' },
{ field: 'externalId', colSpan: 1, helpText: 'Mark as external ID for upsert operations' },
// UI & Visibility
{ field: 'readonly', colSpan: 1, helpText: 'Field is read-only in forms' },
{ field: 'hidden', colSpan: 1, helpText: 'Hide field from default UI views' },
{ field: 'searchable', colSpan: 1, helpText: 'Include in global search results' },
{ field: 'sortable', colSpan: 1, helpText: 'Allow sorting lists by this field' },
],
},
],
});