Skip to content

fix: add spec-compliant fields to all dashboard widgets in examples#825

Merged
hotlong merged 3 commits intomainfrom
copilot/fix-dashboard-widget-metadata
Feb 24, 2026
Merged

fix: add spec-compliant fields to all dashboard widgets in examples#825
hotlong merged 3 commits intomainfrom
copilot/fix-dashboard-widget-metadata

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 24, 2026

Dashboard widgets across all examples were missing required DashboardWidgetSchema spec fields (id, title, object, categoryField, valueField, aggregate), causing empty property panels and broken config workflows.

Changes

  • examples/crm/src/dashboards/crm.dashboard.ts — 10 widgets: added id, title, object; chart widgets get categoryField/valueField/aggregate
  • examples/todo/objectstack.config.ts — 6 widgets: same treatment
  • examples/kitchen-sink/objectstack.config.ts — 7 widgets: same treatment
  • examples/crm/src/__tests__/crm-metadata.test.ts — 5 new spec compliance tests (unique ids, titles, object binding, metric title↔label consistency, chart data binding fields)
  • ROADMAP.md — Added completion entry

Before → After

// Before: metric widget missing id/title/object
{
  type: 'metric',
  layout: { x: 0, y: 0, w: 1, h: 1 },
  options: { label: 'Total Revenue', value: '$652,000', icon: 'DollarSign' }
}

// After: spec-compliant
{
  id: 'crm_total_revenue',
  title: 'Total Revenue',
  type: 'metric',
  object: 'opportunity',
  layout: { x: 0, y: 0, w: 1, h: 1 },
  options: { label: 'Total Revenue', value: '$652,000', icon: 'DollarSign' }
}

Chart widgets additionally get top-level data binding:

{
  id: 'crm_pipeline_by_stage',
  title: 'Pipeline by Stage',
  type: 'bar',
  object: 'opportunity',
  categoryField: 'stage',
  valueField: 'amount',
  aggregate: 'sum',
  // options unchanged...
}
Original prompt

This section details on the original issue you should resolve

<issue_title>examples 目录下所有 dashboard/widget 元数据不符合 spec 协议的修正清单与整改</issue_title>
<issue_description># 问题概述

目前 examples/ 目录下各演示项目(如 crmtodo)的 dashboard 和 widget 元数据存在多处与 @objectstack/spec 协议不符的情况,导致属性面板、自动表单等功能无法标准工作,极大影响定制和二次开发。

主要症状:

  • 选中 widget 后右侧属性面板 fields 空白或提示"请选择对象/字段"。
  • 部分 widget 未显示 title,也无聚合等关键参数。
  • 某些 KPI metric widget 缺失 id/title。

核心规范遗漏

所有 Dashboard Widget 必须具备 spec 标准字段(见 DashboardWidgetSchema

  • id:唯一标识(务必保证)
  • title:用于属性/工具面板的人类可读标题
  • object:数据源对象(如 chart 数据源)
  • categoryField:X 轴或分组字段(如 bar/line/pie)
  • valueField:Y 轴或数值字段
  • aggregate:聚合函数(如 sum/count/avg/min/max),适用 chart/table/pivot
  • metric/KPI widget 保证 id/title;title 应与 options.label 保持一致

实际 examples 违规清单(已排查主要 demo)

1. examples/crm/src/dashboards/crm.dashboard.ts

  • 所有 chart/table widget(如 Revenue Trends、Lead Source)均只在 options 填写 xField/yField/data,未写 object/categoryField/valueField/aggregate 等 spec 字段
  • 所有 metric widget 均未填写 id,也无 title,仅 options.label
  • "Recent Opportunities"(type: table)同样无数据绑定字段,无 id/title
  • 某些 bar/pie/table widgets 仅 options.data,无上层动态数据源描述

2. examples/todo/objectstack.config.ts 下 dashboards 字段

  • 所有 widget 均未填写 id/title/object/categoryField/valueField/aggregate(均藏在 options 内)
  • KPI metric widget 只写 options.label/value,无 id/title
  • 统计类 chart widget(Tasks by Status、Tasks by Category)缺少上面列举 spec 字段。

3. 其他 demo(如 examples/erp、examples/finance 等)[如存在暂略,建议提取脚本批量校验]

  • 检查所有 dashboard/widget 元数据是否存在相同问题。

需要修正的内容

  • 为所有 dashboard widgets 添加唯一 id 字段
  • 所有 widget 添加标准 title(title 与 options.label 对齐)
  • bar/line/area/pie/donut/table/pivot 等可绑定数据 widget,顶级添加 object/categoryField/valueField/aggregate 等绑定字段,options 仅为渲染补充
  • metric widget 也应加 object 指明来源(如有)
  • 检查 filter/measures/colorVariant 等,高级属性是否遗漏规范化

建议流程

  1. 批量 parse/validate examples/ 下所有 dashboard/widget,输出未补全字段清单
  2. 逐个修正 examples/crm、examples/todo 等源码 schema
  3. 所有字段用 spec 标准英文名、注释补充,多语言/业务自定义内容统一放 options
  4. 增加自动化测试,防止回归

参考

如需详细文件位置、需修正内容 diff,可追加提交。欢迎补充其他 example 的类似问题。</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 24, 2026 7:19am
objectui-demo Error Error Feb 24, 2026 7:19am
objectui-storybook Ready Ready Preview, Comment Feb 24, 2026 7:19am

Request Review

- Add id, title, object, categoryField, valueField, aggregate to CRM dashboard widgets
- Add id, title, object, categoryField, valueField, aggregate to Todo dashboard widgets
- Add id, title, object, categoryField, valueField, aggregate to Kitchen Sink dashboard widgets
- Add spec compliance tests to CRM metadata test suite

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix dashboard and widget metadata to comply with spec fix: add spec-compliant fields to all dashboard widgets in examples Feb 24, 2026
Copilot AI requested a review from hotlong February 24, 2026 06:52
@hotlong
Copy link
Copy Markdown
Collaborator

hotlong commented Feb 24, 2026

@copilot 仔细检查确认已经完成任务要求的所有开发内容

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 24, 2026

@copilot 仔细检查确认已经完成任务要求的所有开发内容

已逐项核查确认所有任务要求均已完成:

3 个 example 项目的 dashboard widget 修正(共 23 个 widget):

  • examples/crm — 10 widgets:4 metric + 5 chart + 1 table,全部添加 id/title/object,chart 添加 categoryField/valueField/aggregate
  • examples/todo — 6 widgets:4 metric + 2 chart,同上处理
  • examples/kitchen-sink — 7 widgets:4 metric + 3 chart,同上处理
  • examples/msw-todoexamples/hello-world 无 dashboard,无需修改

测试覆盖:

  • 新增 5 条 spec 合规测试(unique id、title、metric title↔label 一致性、object 数据绑定、chart 字段绑定)
  • CRM 元数据测试 29/29 通过,P1 spec alignment 测试 40/40 通过

ROADMAP 已更新,commit 32e153e

@hotlong hotlong marked this pull request as ready for review February 24, 2026 07:06
Copilot AI review requested due to automatic review settings February 24, 2026 07:06
@hotlong hotlong merged commit f4ed51a into main Feb 24, 2026
2 of 6 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses spec compliance issues in dashboard widgets across example projects. Dashboard widgets were missing required DashboardWidgetSchema fields (id, title, object, and for chart widgets: categoryField, valueField, aggregate), which caused empty property panels and broken configuration workflows.

Changes:

  • Added spec-compliant fields to all dashboard widgets in CRM, Todo, and Kitchen Sink examples
  • Created comprehensive spec compliance tests for dashboard widgets
  • Updated ROADMAP.md to track completion

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
examples/todo/objectstack.config.ts Added id, title, object to 4 metric widgets and id, title, object, categoryField, valueField, aggregate to 2 chart widgets
examples/kitchen-sink/objectstack.config.ts Added id, title, object to 4 metric widgets and id, title, object, categoryField, valueField, aggregate to 3 chart widgets
examples/crm/src/dashboards/crm.dashboard.ts Added id, title, object to 4 metric widgets, id, title, object, categoryField, valueField, aggregate to 5 chart widgets, and id, title, object to 1 table widget
examples/crm/src/tests/crm-metadata.test.ts Added 5 new tests validating widget spec compliance: unique IDs, titles, object binding, metric title-label consistency, and chart data binding fields
ROADMAP.md Added completion entry documenting the dashboard widget spec alignment work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples 目录下所有 dashboard/widget 元数据不符合 spec 协议的修正清单与整改

3 participants