Skip to content

Commit 62196a2

Browse files
akoclaude
andcommitted
fix: address PR #28 review follow-ups
- Fix gallery .mxcli/widgets/gallery.def.json: FILTERSPLACEHOLDER → FILTER to match embedded def and DESCRIBE output - Fix gallery .mxcli/widgets/gallery.def.json: add missing "default": "Single" for itemSelection to match embedded def - Fix cmd_widget.go: log LoadUserDefinitions errors instead of swallowing - Fix lsp_completion.go: log LoadUserDefinitions errors instead of swallowing - Translate Chinese headers in design doc to English - Fix FILTERSPLACEHOLDER → FILTER in design doc examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bbda6bc commit 62196a2

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

.mxcli/widgets/gallery.def.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
{
1818
"propertyKey": "itemSelection",
1919
"source": "Selection",
20-
"operation": "selection"
20+
"operation": "selection",
21+
"default": "Single"
2122
},
2223
{
2324
"propertyKey": "itemSelectionMode",
@@ -78,7 +79,7 @@
7879
},
7980
{
8081
"propertyKey": "filtersPlaceholder",
81-
"mdlContainer": "FILTERSPLACEHOLDER",
82+
"mdlContainer": "FILTER",
8283
"operation": "widgets"
8384
}
8485
]

cmd/mxcli/cmd_widget.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55
import (
66
"encoding/json"
77
"fmt"
8+
"log"
89
"os"
910
"path/filepath"
1011
"strings"
@@ -195,7 +196,9 @@ func runWidgetList(cmd *cobra.Command, args []string) error {
195196
// Load user definitions if project path available
196197
projectPath, _ := cmd.Flags().GetString("project")
197198
if projectPath != "" {
198-
_ = registry.LoadUserDefinitions(projectPath)
199+
if err := registry.LoadUserDefinitions(projectPath); err != nil {
200+
log.Printf("warning: loading user widget definitions: %v", err)
201+
}
199202
}
200203

201204
defs := registry.All()

cmd/mxcli/lsp_completion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44

55
import (
66
"context"
7+
"log"
78
"strings"
89

910
"github.com/mendixlabs/mxcli/mdl/executor"
@@ -89,8 +90,7 @@ func (s *mdlServer) widgetRegistryCompletions() []protocol.CompletionItem {
8990
return
9091
}
9192
if err := registry.LoadUserDefinitions(s.mprPath); err != nil {
92-
// Non-fatal: user definitions are optional
93-
_ = err
93+
log.Printf("warning: loading user widget definitions for LSP: %v", err)
9494
}
9595
for _, def := range registry.All() {
9696
s.widgetCompletionItems = append(s.widgetCompletionItems, protocol.CompletionItem{

docs/plans/2026-03-25-pluggable-widget-engine-design.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# Pluggable Widget Engine: 声明式 Widget 构建系统
1+
# Pluggable Widget Engine: Declarative Widget Build System
22

33
**Date**: 2026-03-25
44
**Status**: Implemented
55

66
## Problem
77

8-
当前每个 pluggable widget 都需要硬编码一个 Go builder 函数(`buildComboBoxV3`, `buildGalleryV3` 等),加上 switch case 注册。新增一个 widget 需要改 4 个地方:
8+
Each pluggable widget currently requires a hardcoded Go builder function (`buildComboBoxV3`, `buildGalleryV3`, etc.) plus a switch-case registration. Adding a new widget requires changes in 4 places:
99

10-
1. `sdk/pages/pages_widgets_advanced.go`添加 WidgetID 常量
11-
2. `sdk/widgets/templates/`添加 JSON 模板
12-
3. `mdl/executor/cmd_pages_builder_v3_pluggable.go`写专属 build 函数(50-200 行)
13-
4. `mdl/executor/cmd_pages_builder_v3.go``buildWidgetV3()` switch 中添加 case
10+
1. `sdk/pages/pages_widgets_advanced.go`Add WidgetID constant
11+
2. `sdk/widgets/templates/`Add JSON template
12+
3. `mdl/executor/cmd_pages_builder_v3_pluggable.go`Write a dedicated build function (50-200 lines)
13+
4. `mdl/executor/cmd_pages_builder_v3.go`Add case in `buildWidgetV3()` switch
1414

15-
这导致:
16-
- 用户无法自行添加 pluggable widget 支持
17-
- 大量重复代码(30+ builder 函数共享 ~80% 骨架)
18-
- 维护成本随 widget 数量线性增长
15+
This causes:
16+
- Users cannot add pluggable widget support on their own
17+
- Significant code duplication (30+ builder functions sharing ~80% boilerplate)
18+
- Maintenance cost grows linearly with widget count
1919

20-
## Solution: 声明式 Widget 定义 + 通用构建引擎
20+
## Solution: Declarative Widget Definitions + Generic Build Engine
2121

2222
### Architecture
2323

@@ -126,7 +126,7 @@ Gallery (with child slots):
126126
"childSlots": [
127127
{"propertyKey": "content", "mdlContainer": "TEMPLATE", "operation": "widgets"},
128128
{"propertyKey": "emptyPlaceholder", "mdlContainer": "EMPTYPLACEHOLDER", "operation": "widgets"},
129-
{"propertyKey": "filtersPlaceholder", "mdlContainer": "FILTERSPLACEHOLDER", "operation": "widgets"}
129+
{"propertyKey": "filtersPlaceholder", "mdlContainer": "FILTER", "operation": "widgets"}
130130
]
131131
}
132132
```

0 commit comments

Comments
 (0)