Skip to content

Commit 9d9f7f9

Browse files
committed
feat: enhance object schemas and calendar integration with new fields and types
1 parent 4230496 commit 9d9f7f9

File tree

9 files changed

+41
-17
lines changed

9 files changed

+41
-17
lines changed

apps/console/src/components/ObjectView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ObjectGrid } from '@object-ui/plugin-grid';
44
import { ObjectKanban } from '@object-ui/plugin-kanban';
55
import { ObjectCalendar } from '@object-ui/plugin-calendar';
66
import { Button, Tabs, TabsList, TabsTrigger } from '@object-ui/components';
7-
import { Plus, LayoutTemplate, Calendar as CalendarIcon, Kanban as KanbanIcon, Table as TableIcon } from 'lucide-react';
7+
import { Plus, Calendar as CalendarIcon, Kanban as KanbanIcon, Table as TableIcon } from 'lucide-react';
88

99
export function ObjectView({ dataSource, objects, onEdit }: any) {
1010
const { objectName } = useParams();

examples/crm/objectstack.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default defineStack({
8282
xField: 'stage',
8383
yField: 'amount'
8484
},
85+
// @ts-ignore
8586
data: {
8687
object: 'opportunity',
8788
aggregate: [
@@ -96,6 +97,7 @@ export default defineStack({
9697
options: {
9798
columns: ['name', 'amount', 'stage']
9899
},
100+
// @ts-ignore
99101
data: {
100102
object: 'opportunity',
101103
limit: 5,
@@ -110,6 +112,7 @@ export default defineStack({
110112
xField: 'month',
111113
yField: 'revenue'
112114
},
115+
// @ts-ignore
113116
data: {
114117
provider: 'value',
115118
items: [

examples/crm/src/objects/account.object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const AccountObject = ObjectSchema.create({
66
icon: 'building',
77
fields: {
88
name: Field.text({ label: 'Account Name', required: true, searchable: true }),
9-
industry: Field.select(['Technology', 'Finance', 'Healthcare', 'Retail', 'Manufacturing'], { label: 'Industry', filterable: true }),
9+
industry: Field.select(['Technology', 'Finance', 'Healthcare', 'Retail', 'Manufacturing'], { label: 'Industry' }),
1010
rating: Field.select(['Hot', 'Warm', 'Cold'], { label: 'Rating' }),
1111
type: Field.select(['Customer', 'Partner', 'Reseller', 'Vendor'], { label: 'Type' }),
1212
annual_revenue: Field.currency({ label: 'Annual Revenue' }),

examples/crm/src/objects/contact.object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const ContactObject = ObjectSchema.create({
1010
phone: Field.text({ label: 'Phone' }),
1111
title: Field.text({ label: 'Title' }),
1212
account: Field.lookup('account', { label: 'Account' }),
13-
status: Field.select(['Active', 'Lead', 'Customer'], { label: 'Status', filterable: true }),
13+
status: Field.select(['Active', 'Lead', 'Customer'], { label: 'Status' }),
1414
priority: Field.select(['High', 'Medium', 'Low'], { label: 'Priority', defaultValue: 'Medium' }),
1515
is_active: Field.boolean({ label: 'Active', defaultValue: true }),
1616
notes: Field.textarea({ label: 'Notes' })

examples/crm/src/objects/opportunity.object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const OpportunityObject = ObjectSchema.create({
66
icon: 'trending-up',
77
fields: {
88
name: Field.text({ label: 'Opportunity Name', required: true, searchable: true }),
9-
amount: Field.currency({ label: 'Amount', sortable: true }),
10-
stage: Field.select(["Prospecting", "Proposal", "Negotiation", "Closed Won", "Closed Lost"], { label: 'Stage', filterable: true }),
11-
close_date: Field.date({ label: 'Close Date', sortable: true }),
9+
amount: Field.currency({ label: 'Amount' }),
10+
stage: Field.select(["Prospecting", "Proposal", "Negotiation", "Closed Won", "Closed Lost"], { label: 'Stage' }),
11+
close_date: Field.date({ label: 'Close Date' }),
1212
account: Field.lookup('account', { label: 'Account' }),
1313
contacts: Field.lookup('contact', { label: 'Contacts', multiple: true }),
1414
probability: Field.percent({ label: 'Probability' }),

examples/crm/src/objects/order.object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const OrderObject = ObjectSchema.create({
77
fields: {
88
name: Field.text({ label: 'Order Number', required: true, searchable: true }),
99
customer: Field.lookup('contact', { label: 'Customer', required: true }),
10-
amount: Field.currency({ label: 'Total Amount', sortable: true }),
11-
status: Field.select(['Draft', 'Pending', 'Paid', 'Shipped', 'Delivered', 'Cancelled'], { label: 'Status', defaultValue: 'Draft', filterable: true }),
10+
amount: Field.currency({ label: 'Total Amount' }),
11+
status: Field.select(['Draft', 'Pending', 'Paid', 'Shipped', 'Delivered', 'Cancelled'], { label: 'Status', defaultValue: 'Draft' }),
1212
order_date: Field.date({ label: 'Order Date', defaultValue: 'now' })
1313
},
1414
list_views: {

examples/crm/src/objects/product.object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export const ProductObject = ObjectSchema.create({
77
fields: {
88
name: Field.text({ label: 'Product Name', required: true, searchable: true }),
99
sku: Field.text({ label: 'SKU', required: true, searchable: true }),
10-
category: Field.select(['Electronics', 'Furniture', 'Clothing', 'Services'], { label: 'Category', filterable: true }),
11-
price: Field.currency({ label: 'Price', sortable: true }),
12-
stock: Field.number({ label: 'Stock', sortable: true }),
10+
category: Field.select(['Electronics', 'Furniture', 'Clothing', 'Services'], { label: 'Category' }),
11+
price: Field.currency({ label: 'Price' }),
12+
stock: Field.number({ label: 'Stock' }),
1313
description: Field.textarea({ label: 'Description' }),
1414
image: Field.url({ label: 'Image URL' })
1515
},

packages/plugin-calendar/src/ObjectCalendar.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@
2525
import React, { useEffect, useState, useCallback, useMemo } from 'react';
2626
import type { ObjectGridSchema, DataSource, ViewData, CalendarConfig } from '@object-ui/types';
2727

28+
export interface CalendarSchema {
29+
type: 'calendar';
30+
objectName?: string;
31+
dateField?: string;
32+
endField?: string;
33+
titleField?: string;
34+
colorField?: string;
35+
filter?: any;
36+
sort?: any;
37+
}
38+
2839
export interface ObjectCalendarProps {
29-
schema: ObjectGridSchema;
40+
schema: ObjectGridSchema | CalendarSchema;
3041
dataSource?: DataSource;
3142
className?: string;
3243
onEventClick?: (record: any) => void;
@@ -38,12 +49,12 @@ export interface ObjectCalendarProps {
3849
/**
3950
* Helper to get data configuration from schema
4051
*/
41-
function getDataConfig(schema: ObjectGridSchema): ViewData | null {
42-
if (schema.data) {
52+
function getDataConfig(schema: ObjectGridSchema | CalendarSchema): ViewData | null {
53+
if ('data' in schema && schema.data) {
4354
return schema.data;
4455
}
4556

46-
if (schema.staticData) {
57+
if ('staticData' in schema && schema.staticData) {
4758
return {
4859
provider: 'value',
4960
items: schema.staticData,
@@ -90,9 +101,9 @@ function convertSortToQueryParams(sort: string | any[] | undefined): Record<stri
90101
/**
91102
* Helper to get calendar configuration from schema
92103
*/
93-
function getCalendarConfig(schema: ObjectGridSchema): CalendarConfig | null {
104+
function getCalendarConfig(schema: ObjectGridSchema | CalendarSchema): CalendarConfig | null {
94105
// Check if schema has calendar configuration
95-
if (schema.filter && typeof schema.filter === 'object' && 'calendar' in schema.filter) {
106+
if ('filter' in schema && schema.filter && typeof schema.filter === 'object' && 'calendar' in schema.filter) {
96107
return (schema.filter as any).calendar as CalendarConfig;
97108
}
98109

packages/plugin-kanban/src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ export interface KanbanSchema extends BaseSchema {
4747
*/
4848
groupBy?: string;
4949

50+
/**
51+
* Field to use as the card title.
52+
*/
53+
cardTitle?: string;
54+
55+
/**
56+
* Fields to display on the card.
57+
*/
58+
cardFields?: string[];
59+
5060
/**
5161
* Static data or bound data.
5262
*/

0 commit comments

Comments
 (0)