Make page & layout meta non pointer for ease of use

This commit is contained in:
Tomaž Jerman
2023-04-07 12:39:27 +02:00
committed by Jože Fortun
parent a8aa759408
commit 27a32a2607
12 changed files with 39 additions and 42 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ page: {
}
meta: {
goType: "*types.PageMeta"
goType: "types.PageMeta"
dal: { type: "JSON", defaultEmptyObject: true }
omitSetter: true
omitGetter: true
+1 -1
View File
@@ -40,7 +40,7 @@ pageLayout: {
}
meta: {
goType: "*types.PageLayoutMeta"
goType: "types.PageLayoutMeta"
dal: { type: "JSON", defaultEmptyObject: true }
omitSetter: true
omitGetter: true
+4 -4
View File
@@ -345,7 +345,7 @@ endpoints:
name: config
required: false
title: Config JSON
- type: "*types.PageMeta"
- type: "types.PageMeta"
name: meta
required: false
title: Meta
@@ -416,7 +416,7 @@ endpoints:
name: config
required: false
title: Config JSON
- type: "*types.PageMeta"
- type: "types.PageMeta"
name: meta
required: false
title: Meta
@@ -696,7 +696,7 @@ endpoints:
name: primary
required: false
title: Primary
- type: "*types.PageLayoutMeta"
- type: "types.PageLayoutMeta"
name: meta
required: false
title: Meta
@@ -767,7 +767,7 @@ endpoints:
name: primary
required: false
title: Primary
- type: "*types.PageLayoutMeta"
- type: "types.PageLayoutMeta"
name: meta
required: false
title: Meta
+4 -4
View File
@@ -144,7 +144,7 @@ type (
// Meta POST parameter
//
// Meta
Meta *types.PageMeta
Meta types.PageMeta
}
PageRead struct {
@@ -230,7 +230,7 @@ type (
// Meta POST parameter
//
// Meta
Meta *types.PageMeta
Meta types.PageMeta
}
PageReorder struct {
@@ -584,7 +584,7 @@ func (r PageCreate) GetConfig() sqlxTypes.JSONText {
}
// Auditable returns all auditable/loggable parameters
func (r PageCreate) GetMeta() *types.PageMeta {
func (r PageCreate) GetMeta() types.PageMeta {
return r.Meta
}
@@ -975,7 +975,7 @@ func (r PageUpdate) GetConfig() sqlxTypes.JSONText {
}
// Auditable returns all auditable/loggable parameters
func (r PageUpdate) GetMeta() *types.PageMeta {
func (r PageUpdate) GetMeta() types.PageMeta {
return r.Meta
}
+4 -4
View File
@@ -190,7 +190,7 @@ type (
// Meta POST parameter
//
// Meta
Meta *types.PageLayoutMeta
Meta types.PageLayoutMeta
// Config POST parameter
//
@@ -274,7 +274,7 @@ type (
// Meta POST parameter
//
// Meta
Meta *types.PageLayoutMeta
Meta types.PageLayoutMeta
// Config POST parameter
//
@@ -784,7 +784,7 @@ func (r PageLayoutCreate) GetPrimary() bool {
}
// Auditable returns all auditable/loggable parameters
func (r PageLayoutCreate) GetMeta() *types.PageLayoutMeta {
func (r PageLayoutCreate) GetMeta() types.PageLayoutMeta {
return r.Meta
}
@@ -1144,7 +1144,7 @@ func (r PageLayoutUpdate) GetPrimary() bool {
}
// Auditable returns all auditable/loggable parameters
func (r PageLayoutUpdate) GetMeta() *types.PageLayoutMeta {
func (r PageLayoutUpdate) GetMeta() types.PageLayoutMeta {
return r.Meta
}
+3 -8
View File
@@ -627,14 +627,9 @@ func (svc page) handleUpdate(ctx context.Context, upd *types.Page) pageUpdateHan
}
}
if upd.Meta != nil {
if res.Meta.AllowPersonalLayouts != upd.Meta.AllowPersonalLayouts {
if res.Meta == nil {
res.Meta = &types.PageMeta{}
res.Meta.AllowPersonalLayouts = upd.Meta.AllowPersonalLayouts
changes |= pageChanged
}
}
if res.Meta.AllowPersonalLayouts != upd.Meta.AllowPersonalLayouts {
res.Meta.AllowPersonalLayouts = upd.Meta.AllowPersonalLayouts
changes |= pageChanged
}
if res.Title != upd.Title {
+2 -2
View File
@@ -504,7 +504,7 @@ func (svc pageLayout) handleUpdate(ctx context.Context, upd *types.PageLayout) p
}
}
if res.Meta != nil && res.Meta.Title != upd.Meta.Title {
if res.Meta.Title != upd.Meta.Title {
res.Meta.Title = upd.Meta.Title
changes |= pageLayoutChanged
}
@@ -514,7 +514,7 @@ func (svc pageLayout) handleUpdate(ctx context.Context, upd *types.PageLayout) p
changes |= pageLayoutChanged
}
if res.Meta != nil && res.Meta.Description != upd.Meta.Description {
if res.Meta.Description != upd.Meta.Description {
res.Meta.Description = upd.Meta.Description
changes |= pageLayoutChanged
}
+1 -1
View File
@@ -29,7 +29,7 @@ type (
Config PageConfig `json:"config"`
Blocks PageBlocks `json:"blocks"`
Meta *PageMeta `json:"meta"`
Meta PageMeta `json:"meta"`
Children PageSet `json:"children,omitempty"`
+12 -10
View File
@@ -24,7 +24,7 @@ type (
Weight int `json:"weight"`
Meta *PageLayoutMeta `json:"meta"`
Meta PageLayoutMeta `json:"meta"`
Config PageLayoutConfig `json:"config"`
Blocks PageBlocks `json:"blocks"`
@@ -82,12 +82,14 @@ type (
}
PageLayoutFilter struct {
NamespaceID uint64 `json:"namespaceID,string"`
PageID uint64 `json:"pageID,string,omitempty"`
Primary bool `json:"primary,omitempty"`
Handle string `json:"handle"`
Name string `json:"name"`
Query string `json:"query"`
PageLayoutID []uint64 `json:"pageLayoutID,string"`
NamespaceID uint64 `json:"namespaceID,string"`
PageID uint64 `json:"pageID,string,omitempty"`
ParentID uint64 `json:"ParentID,string,omitempty"`
Primary bool `json:"primary,omitempty"`
Handle string `json:"handle"`
Name string `json:"name"`
Query string `json:"query"`
LabeledIDs []uint64 `json:"-"`
Labels map[string]string `json:"labels,omitempty"`
@@ -161,8 +163,8 @@ func (set PageLayoutSet) FindByHandle(handle string) *PageLayout {
return nil
}
func (bb *PageLayoutConfig) Scan(src any) error { return sql.ParseJSON(src, bb) }
func (bb *PageLayoutConfig) Scan(src any) error { return sql.ParseJSON(src, &bb) }
func (bb PageLayoutConfig) Value() (driver.Value, error) { return json.Marshal(bb) }
func (vv *PageLayoutMeta) Scan(src any) error { return sql.ParseJSON(src, vv) }
func (vv *PageLayoutMeta) Value() (driver.Value, error) { return json.Marshal(vv) }
func (vv *PageLayoutMeta) Scan(src any) error { return sql.ParseJSON(src, &vv) }
func (vv PageLayoutMeta) Value() (driver.Value, error) { return json.Marshal(vv) }
+4 -4
View File
@@ -2,13 +2,13 @@ package types
import "encoding/json"
func ParsePageLayoutMeta(ss []string) (p *PageLayoutMeta, err error) {
p = &PageLayoutMeta{}
func ParsePageLayoutMeta(ss []string) (p PageLayoutMeta, err error) {
p = PageLayoutMeta{}
return p, parseStringsInput(ss, &p)
}
func ParsePageMeta(ss []string) (p *PageMeta, err error) {
p = &PageMeta{}
func ParsePageMeta(ss []string) (p PageMeta, err error) {
p = PageMeta{}
return p, parseStringsInput(ss, &p)
}
+2 -2
View File
@@ -293,7 +293,7 @@ type (
SelfID uint64 `db:"self_id"`
ModuleID uint64 `db:"module_id"`
NamespaceID uint64 `db:"namespace_id"`
Meta *composeType.PageMeta `db:"meta"`
Meta composeType.PageMeta `db:"meta"`
Config composeType.PageConfig `db:"config"`
Blocks composeType.PageBlocks `db:"blocks"`
Visible bool `db:"visible"`
@@ -312,7 +312,7 @@ type (
ParentID uint64 `db:"parent_id"`
NamespaceID uint64 `db:"namespace_id"`
Weight int `db:"weight"`
Meta *composeType.PageLayoutMeta `db:"meta"`
Meta composeType.PageLayoutMeta `db:"meta"`
Primary bool `db:"primary"`
Config composeType.PageLayoutConfig `db:"config"`
Blocks composeType.PageBlocks `db:"blocks"`
+1 -1
View File
@@ -24,7 +24,7 @@ func (h helper) repoMakePageLayout(ns *types.Namespace, pg *types.Page, title st
res := &types.PageLayout{
ID: id.Next(),
CreatedAt: time.Now(),
Meta: &types.PageLayoutMeta{
Meta: types.PageLayoutMeta{
Title: title,
},
NamespaceID: ns.ID,