Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/app-showcase/src/objects/category.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const Category = ObjectSchema.create({

fields: {
name: Field.text({ label: 'Name', required: true, searchable: true, maxLength: 120 }),
parent: Field.lookup('showcase_category', { label: 'Parent Category' }),
parent: Field.lookup('showcase_category', { label: 'Parent Category', allowCreate: true }),
color: Field.color({ label: 'Color' }),
sort_order: Field.number({ label: 'Sort Order', min: 0, defaultValue: 0 }),
},
Expand Down
4 changes: 4 additions & 0 deletions packages/spec/liveness/field.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
"status": "live",
"note": "objectui LookupField — dependent/cascading lookup; restricts candidates by another field's value (reads dependsOn || depends_on)."
},
"allowCreate": {
"status": "live",
"note": "objectui LookupField — opt-in inline quick-create (dataSource.create from typed text) (reads allowCreate || allow_create)."
},
"maxRating": {
"status": "dead",
"evidence": "RatingField reads `max` (RatingField.tsx:13) — dead + redundant with max",
Expand Down
2 changes: 2 additions & 0 deletions packages/spec/src/data/field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ describe('FieldSchema', () => {
lookupPageSize: 20,
lookupFilters: [{ field: 'status', operator: 'eq', value: 'active' }],
dependsOn: ['region', { field: 'country', param: 'country_code' }],
allowCreate: true,
};

const result = FieldSchema.parse(lookupField);
Expand All @@ -318,6 +319,7 @@ describe('FieldSchema', () => {
expect(result.lookupPageSize).toBe(20);
expect(result.lookupFilters?.[0]).toEqual({ field: 'status', operator: 'eq', value: 'active' });
expect(result.dependsOn).toHaveLength(2);
expect(result.allowCreate).toBe(true);
});

it('builds a lookup with picker config via Field.lookup', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/spec/src/data/field.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ export const FieldSchema = lazySchema(() => z.object({
field: z.string(),
param: z.string().optional(),
})])).optional().describe('Dependent lookup: restrict candidates by the value of other field(s) on the same record. String = same local/remote key; {field,param} when the remote filter key differs.'),
allowCreate: z.boolean().optional().describe('Allow inline quick-create from the record picker: when no match exists the user can create a record from the typed text (optimistic dataSource.create with the display field). Best for simple objects whose only required field is the display field.'),

/** Calculation — CEL formula. Plain string accepted for back-compat; build emits canonical envelope. */
expression: ExpressionInputSchema.optional().describe('Formula expression (CEL). e.g. F`record.amount * 0.1`'),
Expand Down
Loading