Fix RecordList field selection export
This commit is contained in:
@@ -262,19 +262,14 @@ func (c *composePageBlock) cleanupModuleFields(opt map[string]interface{}) {
|
||||
|
||||
retFF := make([]interface{}, 0, len(ff))
|
||||
for _, rawF := range ff {
|
||||
f, ok := rawF.(map[string]interface{})
|
||||
if !ok {
|
||||
switch c := rawF.(type) {
|
||||
case string:
|
||||
retFF = append(retFF, map[string]interface{}{"name": c})
|
||||
case map[string]interface{}, map[string]string:
|
||||
retFF = append(retFF, c)
|
||||
default:
|
||||
retFF = append(retFF, rawF)
|
||||
continue
|
||||
}
|
||||
|
||||
fn, has := f["name"]
|
||||
if !has {
|
||||
retFF = append(retFF, rawF)
|
||||
continue
|
||||
}
|
||||
|
||||
retFF = append(retFF, fn)
|
||||
}
|
||||
|
||||
opt["fields"] = retFF
|
||||
|
||||
@@ -2,6 +2,7 @@ package envoy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
@@ -322,6 +323,10 @@ func TestStoreYaml_pageRefs(t *testing.T) {
|
||||
Kind: "RecordList",
|
||||
Options: map[string]interface{}{
|
||||
"module": strconv.FormatUint(mod.ID, 10),
|
||||
"fields": []map[string]interface{}{
|
||||
{"name": "f1"},
|
||||
{"name": "f2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -329,6 +334,10 @@ func TestStoreYaml_pageRefs(t *testing.T) {
|
||||
Kind: "RecordList",
|
||||
Options: map[string]interface{}{
|
||||
"moduleID": strconv.FormatUint(mod.ID, 10),
|
||||
"fields": []map[string]interface{}{
|
||||
{"name": "f1"},
|
||||
{"name": "f2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -363,10 +372,20 @@ func TestStoreYaml_pageRefs(t *testing.T) {
|
||||
// provided as module
|
||||
b := pg.Blocks[0]
|
||||
req.Equal(strconv.FormatUint(mod.ID, 10), b.Options["moduleID"])
|
||||
casted := b.Options["fields"].([]interface{})
|
||||
for i, c := range casted {
|
||||
cc := c.(map[string]interface{})
|
||||
req.Equal(fmt.Sprintf("f%d", i+1), cc["name"].(string))
|
||||
}
|
||||
|
||||
// provided as moduleID
|
||||
b = pg.Blocks[1]
|
||||
req.Equal(strconv.FormatUint(mod.ID, 10), b.Options["moduleID"])
|
||||
casted = b.Options["fields"].([]interface{})
|
||||
for i, c := range casted {
|
||||
cc := c.(map[string]interface{})
|
||||
req.Equal(fmt.Sprintf("f%d", i+1), cc["name"].(string))
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user