Fix compose page YAML marshal for unconfigured page blocks

This commit is contained in:
Tomaž Jerman
2021-11-05 08:57:05 +01:00
parent accc9ceb1f
commit 032566d902
2 changed files with 23 additions and 11 deletions
+7 -7
View File
@@ -245,7 +245,7 @@ func (r *ComposePage) optString(opt map[string]interface{}, kk ...string) string
func (r *ComposePage) pbRecordList(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "module", "moduleID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -254,7 +254,7 @@ func (r *ComposePage) pbRecordList(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbComment(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "module", "moduleID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -263,7 +263,7 @@ func (r *ComposePage) pbComment(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbAutomation(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "workflow", "workflowID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -272,7 +272,7 @@ func (r *ComposePage) pbAutomation(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbRecordOrganizer(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "module", "moduleID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -281,7 +281,7 @@ func (r *ComposePage) pbRecordOrganizer(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbChart(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "chart", "chartID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -290,7 +290,7 @@ func (r *ComposePage) pbChart(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbCalendar(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "module", "moduleID")
if id == "" {
if id == "" || id == "0" {
return
}
@@ -299,7 +299,7 @@ func (r *ComposePage) pbCalendar(opt map[string]interface{}) (out *Ref) {
func (r *ComposePage) pbMetric(opt map[string]interface{}) (out *Ref) {
id := r.optString(opt, "module", "moduleID")
if id == "" {
if id == "" || id == "0" {
return
}
+16 -4
View File
@@ -188,17 +188,26 @@ func (c *composePageBlock) MarshalYAML() (interface{}, error) {
opt := c.res.Options
switch c.res.Kind {
case "RecordList":
opt["moduleID"] = c.refMod[0]
delete(opt, "moduleID")
if len(c.refMod) > 0 {
opt["moduleID"] = c.refMod[0]
}
delete(opt, "module")
break
case "RecordOrganizer":
opt["moduleID"] = c.refMod[0]
delete(opt, "moduleID")
if len(c.refMod) > 0 {
opt["moduleID"] = c.refMod[0]
}
delete(opt, "module")
break
case "Chart":
opt["chartID"] = c.refChart[0]
delete(opt, "chartID")
if len(c.refChart) > 0 {
opt["chartID"] = c.refChart[0]
}
delete(opt, "chart")
break
@@ -237,7 +246,10 @@ func (c *composePageBlock) MarshalYAML() (interface{}, error) {
break
case "Comment":
opt["moduleID"] = c.refMod[0]
delete(opt, "moduleID")
if len(c.refMod) > 0 {
opt["moduleID"] = c.refMod[0]
}
delete(opt, "module")
break