diff --git a/server/internal/adapter/gql/gqlmodel/convert_scene_align.go b/server/internal/adapter/gql/gqlmodel/convert_scene_align.go index b074dfaff0..7d079d9aed 100644 --- a/server/internal/adapter/gql/gqlmodel/convert_scene_align.go +++ b/server/internal/adapter/gql/gqlmodel/convert_scene_align.go @@ -37,6 +37,18 @@ func ToWidgetSection(s *scene.WidgetSection) *WidgetSection { Bottom: ToWidgetArea(s.Area(scene.WidgetAreaBottom)), } } +func ToWidgetAreaPadding(p *scene.WidgetAreaPadding) *WidgetAreaPadding { + if p == nil { + return &WidgetAreaPadding{} + } + + return &WidgetAreaPadding{ + Top: p.Top(), + Bottom: p.Bottom(), + Left: p.Left(), + Right: p.Right(), + } +} func ToWidgetArea(a *scene.WidgetArea) *WidgetArea { if a == nil { @@ -44,8 +56,12 @@ func ToWidgetArea(a *scene.WidgetArea) *WidgetArea { } return &WidgetArea{ - WidgetIds: util.Map(a.WidgetIDs(), IDFrom[id.Widget]), - Align: ToWidgetAlignType(a.Alignment()), + WidgetIds: util.Map(a.WidgetIDs(), IDFrom[id.Widget]), + Align: ToWidgetAlignType(a.Alignment()), + Padding: ToWidgetAreaPadding(a.Padding()), + Gap: a.Gap(), + Centered: a.Centered(), + Background: a.Background(), } } diff --git a/server/internal/usecase/interactor/scene.go b/server/internal/usecase/interactor/scene.go index a898743a2b..48a4894ac5 100644 --- a/server/internal/usecase/interactor/scene.go +++ b/server/internal/usecase/interactor/scene.go @@ -358,7 +358,9 @@ func (i *Scene) UpdateWidgetAlignSystem(ctx context.Context, param interfaces.Up if param.Centered != nil { area.SetCentered(*param.Centered) } - area.SetBackground(param.Background) + if param.Background != nil { + area.SetBackground(param.Background) + } if err = i.sceneRepo.Save(ctx, s); err != nil { return nil, err diff --git a/server/pkg/scene/builder/encoder.go b/server/pkg/scene/builder/encoder.go index 47c57dc3f1..50610ded6b 100644 --- a/server/pkg/scene/builder/encoder.go +++ b/server/pkg/scene/builder/encoder.go @@ -163,8 +163,19 @@ type widgetSectionJSON struct { } type widgetAreaJSON struct { - WidgetIDs []string `json:"widgetIds"` - Align string `json:"align"` + WidgetIDs []string `json:"widgetIds"` + Align string `json:"align"` + Padding *widgetAreaPaddingJSON `json:"padding"` + Gap int `json:"gap"` + Centered bool `json:"centered"` + Background *string `json:"background"` +} + +type widgetAreaPaddingJSON struct { + Top int `json:"top"` + Bottom int `json:"bottom"` + Left int `json:"left"` + Right int `json:"right"` } type widgetJSON struct { diff --git a/server/pkg/scene/builder/scene.go b/server/pkg/scene/builder/scene.go index 9cdd98ebf7..0fbee04000 100644 --- a/server/pkg/scene/builder/scene.go +++ b/server/pkg/scene/builder/scene.go @@ -200,7 +200,22 @@ func buildWidgetArea(a *scene.WidgetArea) *widgetAreaJSON { return nil } return &widgetAreaJSON{ - WidgetIDs: toString(a.WidgetIDs()), - Align: string(a.Alignment()), + WidgetIDs: toString(a.WidgetIDs()), + Align: string(a.Alignment()), + Padding: buildWidgetAreaPadding(a.Padding()), + Gap: a.Gap(), + Centered: a.Centered(), + Background: a.Background(), + } +} +func buildWidgetAreaPadding(p *scene.WidgetAreaPadding) *widgetAreaPaddingJSON { + if p == nil { + return &widgetAreaPaddingJSON{} + } + return &widgetAreaPaddingJSON{ + Top: p.Top(), + Bottom: p.Bottom(), + Left: p.Left(), + Right: p.Right(), } } diff --git a/server/pkg/scene/builder/scene_test.go b/server/pkg/scene/builder/scene_test.go index 4b7de2abf4..a27e2c1c5b 100644 --- a/server/pkg/scene/builder/scene_test.go +++ b/server/pkg/scene/builder/scene_test.go @@ -107,6 +107,15 @@ func TestBuildWidgetAlignSystem(t *testing.T) { Top: &widgetAreaJSON{ WidgetIDs: []string{wid.String()}, Align: "start", + Padding: &widgetAreaPaddingJSON{ + Top: 0, + Bottom: 0, + Left: 0, + Right: 0, + }, + Gap: 0, + Centered: false, + Background: nil, }, }, },