Skip to content

Commit f7afab7

Browse files
authored
Merge pull request #53 from objectstack-ai/copilot/update-filter-documentation
2 parents 1c22142 + 9dc055e commit f7afab7

File tree

10 files changed

+172
-187
lines changed

10 files changed

+172
-187
lines changed

content/docs/references/ui/analytics/Report.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ description: Report Schema Reference
1515
| **columns** | `object[]` || Columns to display |
1616
| **groupingsDown** | `object[]` | optional | Row groupings |
1717
| **groupingsAcross** | `object[]` | optional | Column groupings (Matrix only) |
18-
| **filter** | `string` | optional | Filter logic (e.g. "1 AND (2 OR 3)") |
19-
| **filterItems** | `object[]` | optional | Filter criteria lines |
18+
| **filter** | `any` | optional | Filter criteria |
2019
| **chart** | `object` | optional | Embedded chart configuration |

examples/crm/src/ui/dashboards.ts

Lines changed: 59 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ export const SalesDashboard: Dashboard = {
1212
title: 'Total Pipeline Value',
1313
type: 'metric',
1414
object: 'opportunity',
15-
filter: [
16-
['stage', '!=', 'closed_won'],
17-
['stage', '!=', 'closed_lost'],
18-
],
15+
filter: {
16+
stage: { $nin: ['closed_won', 'closed_lost'] }
17+
},
1918
valueField: 'amount',
2019
aggregate: 'sum',
2120
layout: { x: 0, y: 0, w: 3, h: 2 },
@@ -28,10 +27,10 @@ export const SalesDashboard: Dashboard = {
2827
title: 'Closed Won This Quarter',
2928
type: 'metric',
3029
object: 'opportunity',
31-
filter: [
32-
['stage', '=', 'closed_won'],
33-
['close_date', '>=', '{current_quarter_start}'],
34-
],
30+
filter: {
31+
stage: 'closed_won',
32+
close_date: { $gte: '{current_quarter_start}' }
33+
},
3534
valueField: 'amount',
3635
aggregate: 'sum',
3736
layout: { x: 3, y: 0, w: 3, h: 2 },
@@ -44,10 +43,9 @@ export const SalesDashboard: Dashboard = {
4443
title: 'Open Opportunities',
4544
type: 'metric',
4645
object: 'opportunity',
47-
filter: [
48-
['stage', '!=', 'closed_won'],
49-
['stage', '!=', 'closed_lost'],
50-
],
46+
filter: {
47+
stage: { $nin: ['closed_won', 'closed_lost'] }
48+
},
5149
aggregate: 'count',
5250
layout: { x: 6, y: 0, w: 3, h: 2 },
5351
options: {
@@ -58,9 +56,9 @@ export const SalesDashboard: Dashboard = {
5856
title: 'Win Rate',
5957
type: 'metric',
6058
object: 'opportunity',
61-
filter: [
62-
['close_date', '>=', '{current_quarter_start}'],
63-
],
59+
filter: {
60+
close_date: { $gte: '{current_quarter_start}' }
61+
},
6462
valueField: 'stage',
6563
aggregate: 'count',
6664
layout: { x: 9, y: 0, w: 3, h: 2 },
@@ -75,10 +73,9 @@ export const SalesDashboard: Dashboard = {
7573
title: 'Pipeline by Stage',
7674
type: 'funnel',
7775
object: 'opportunity',
78-
filter: [
79-
['stage', '!=', 'closed_won'],
80-
['stage', '!=', 'closed_lost'],
81-
],
76+
filter: {
77+
stage: { $nin: ['closed_won', 'closed_lost'] }
78+
},
8279
categoryField: 'stage',
8380
valueField: 'amount',
8481
aggregate: 'sum',
@@ -91,10 +88,9 @@ export const SalesDashboard: Dashboard = {
9188
title: 'Opportunities by Owner',
9289
type: 'bar',
9390
object: 'opportunity',
94-
filter: [
95-
['stage', '!=', 'closed_won'],
96-
['stage', '!=', 'closed_lost'],
97-
],
91+
filter: {
92+
stage: { $nin: ['closed_won', 'closed_lost'] }
93+
},
9894
categoryField: 'owner',
9995
valueField: 'amount',
10096
aggregate: 'sum',
@@ -109,10 +105,10 @@ export const SalesDashboard: Dashboard = {
109105
title: 'Monthly Revenue Trend',
110106
type: 'line',
111107
object: 'opportunity',
112-
filter: [
113-
['stage', '=', 'closed_won'],
114-
['close_date', '>=', '{last_12_months}'],
115-
],
108+
filter: {
109+
stage: 'closed_won',
110+
close_date: { $gte: '{last_12_months}' }
111+
},
116112
categoryField: 'close_date',
117113
valueField: 'amount',
118114
aggregate: 'sum',
@@ -126,10 +122,9 @@ export const SalesDashboard: Dashboard = {
126122
title: 'Top Opportunities',
127123
type: 'table',
128124
object: 'opportunity',
129-
filter: [
130-
['stage', '!=', 'closed_won'],
131-
['stage', '!=', 'closed_lost'],
132-
],
125+
filter: {
126+
stage: { $nin: ['closed_won', 'closed_lost'] }
127+
},
133128
aggregate: 'count',
134129
layout: { x: 8, y: 6, w: 4, h: 4 },
135130
options: {
@@ -154,7 +149,7 @@ export const ServiceDashboard: Dashboard = {
154149
title: 'Open Cases',
155150
type: 'metric',
156151
object: 'case',
157-
filter: [['is_closed', '=', false]],
152+
filter: { is_closed: false },
158153
aggregate: 'count',
159154
layout: { x: 0, y: 0, w: 3, h: 2 },
160155
options: {
@@ -165,10 +160,10 @@ export const ServiceDashboard: Dashboard = {
165160
title: 'Critical Cases',
166161
type: 'metric',
167162
object: 'case',
168-
filter: [
169-
['priority', '=', 'critical'],
170-
['is_closed', '=', false],
171-
],
163+
filter: {
164+
priority: 'critical',
165+
is_closed: false
166+
},
172167
aggregate: 'count',
173168
layout: { x: 3, y: 0, w: 3, h: 2 },
174169
options: {
@@ -179,7 +174,7 @@ export const ServiceDashboard: Dashboard = {
179174
title: 'Avg Resolution Time (hrs)',
180175
type: 'metric',
181176
object: 'case',
182-
filter: [['is_closed', '=', true]],
177+
filter: { is_closed: true },
183178
valueField: 'resolution_time_hours',
184179
aggregate: 'avg',
185180
layout: { x: 6, y: 0, w: 3, h: 2 },
@@ -192,7 +187,7 @@ export const ServiceDashboard: Dashboard = {
192187
title: 'SLA Violations',
193188
type: 'metric',
194189
object: 'case',
195-
filter: [['is_sla_violated', '=', true]],
190+
filter: { is_sla_violated: true },
196191
aggregate: 'count',
197192
layout: { x: 9, y: 0, w: 3, h: 2 },
198193
options: {
@@ -205,7 +200,7 @@ export const ServiceDashboard: Dashboard = {
205200
title: 'Cases by Status',
206201
type: 'donut',
207202
object: 'case',
208-
filter: [['is_closed', '=', false]],
203+
filter: { is_closed: false },
209204
categoryField: 'status',
210205
aggregate: 'count',
211206
layout: { x: 0, y: 2, w: 4, h: 4 },
@@ -217,7 +212,7 @@ export const ServiceDashboard: Dashboard = {
217212
title: 'Cases by Priority',
218213
type: 'pie',
219214
object: 'case',
220-
filter: [['is_closed', '=', false]],
215+
filter: { is_closed: false },
221216
categoryField: 'priority',
222217
aggregate: 'count',
223218
layout: { x: 4, y: 2, w: 4, h: 4 },
@@ -239,9 +234,9 @@ export const ServiceDashboard: Dashboard = {
239234
title: 'Daily Case Volume',
240235
type: 'line',
241236
object: 'case',
242-
filter: [
243-
['created_date', '>=', '{last_30_days}'],
244-
],
237+
filter: {
238+
created_date: { $gte: '{last_30_days}' }
239+
},
245240
categoryField: 'created_date',
246241
aggregate: 'count',
247242
layout: { x: 0, y: 6, w: 8, h: 4 },
@@ -253,10 +248,10 @@ export const ServiceDashboard: Dashboard = {
253248
title: 'My Open Cases',
254249
type: 'table',
255250
object: 'case',
256-
filter: [
257-
['owner', '=', '{current_user}'],
258-
['is_closed', '=', false],
259-
],
251+
filter: {
252+
owner: '{current_user}',
253+
is_closed: false
254+
},
260255
aggregate: 'count',
261256
layout: { x: 8, y: 6, w: 4, h: 4 },
262257
options: {
@@ -281,10 +276,10 @@ export const ExecutiveDashboard: Dashboard = {
281276
title: 'Total Revenue (YTD)',
282277
type: 'metric',
283278
object: 'opportunity',
284-
filter: [
285-
['stage', '=', 'closed_won'],
286-
['close_date', '>=', '{current_year_start}'],
287-
],
279+
filter: {
280+
stage: 'closed_won',
281+
close_date: { $gte: '{current_year_start}' }
282+
},
288283
valueField: 'amount',
289284
aggregate: 'sum',
290285
layout: { x: 0, y: 0, w: 3, h: 2 },
@@ -297,7 +292,7 @@ export const ExecutiveDashboard: Dashboard = {
297292
title: 'Total Accounts',
298293
type: 'metric',
299294
object: 'account',
300-
filter: [['is_active', '=', true]],
295+
filter: { is_active: true },
301296
aggregate: 'count',
302297
layout: { x: 3, y: 0, w: 3, h: 2 },
303298
options: {
@@ -318,7 +313,7 @@ export const ExecutiveDashboard: Dashboard = {
318313
title: 'Total Leads',
319314
type: 'metric',
320315
object: 'lead',
321-
filter: [['is_converted', '=', false]],
316+
filter: { is_converted: false },
322317
aggregate: 'count',
323318
layout: { x: 9, y: 0, w: 3, h: 2 },
324319
options: {
@@ -331,10 +326,10 @@ export const ExecutiveDashboard: Dashboard = {
331326
title: 'Revenue by Industry',
332327
type: 'bar',
333328
object: 'opportunity',
334-
filter: [
335-
['stage', '=', 'closed_won'],
336-
['close_date', '>=', '{current_year_start}'],
337-
],
329+
filter: {
330+
stage: 'closed_won',
331+
close_date: { $gte: '{current_year_start}' }
332+
},
338333
categoryField: 'account.industry',
339334
valueField: 'amount',
340335
aggregate: 'sum',
@@ -344,10 +339,10 @@ export const ExecutiveDashboard: Dashboard = {
344339
title: 'Quarterly Revenue Trend',
345340
type: 'line',
346341
object: 'opportunity',
347-
filter: [
348-
['stage', '=', 'closed_won'],
349-
['close_date', '>=', '{last_4_quarters}'],
350-
],
342+
filter: {
343+
stage: 'closed_won',
344+
close_date: { $gte: '{last_4_quarters}' }
345+
},
351346
categoryField: 'close_date',
352347
valueField: 'amount',
353348
aggregate: 'sum',
@@ -362,9 +357,9 @@ export const ExecutiveDashboard: Dashboard = {
362357
title: 'New Accounts by Month',
363358
type: 'bar',
364359
object: 'account',
365-
filter: [
366-
['created_date', '>=', '{last_6_months}'],
367-
],
360+
filter: {
361+
created_date: { $gte: '{last_6_months}' }
362+
},
368363
categoryField: 'created_date',
369364
aggregate: 'count',
370365
layout: { x: 0, y: 6, w: 4, h: 4 },

0 commit comments

Comments
 (0)