mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
🎨 Improve database template field to use relation/rollup field Fix https://github.com/siyuan-note/siyuan/issues/11029
This commit is contained in:
parent
077944bb43
commit
1ae39777a6
1 changed files with 24 additions and 3 deletions
|
|
@ -1050,9 +1050,30 @@ func renderTemplateCol(ial map[string]string, rowValues []*av.KeyValues, tplCont
|
||||||
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
|
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
|
||||||
}
|
}
|
||||||
} else if av.KeyTypeRollup == v.Type {
|
} else if av.KeyTypeRollup == v.Type {
|
||||||
if 0 < len(v.Rollup.Contents) && av.KeyTypeNumber == v.Rollup.Contents[0].Type {
|
if 0 < len(v.Rollup.Contents) {
|
||||||
// 汇总数字时仅取第一个数字填充模板
|
var numbers []float64
|
||||||
dataModel[rowValue.Key.Name] = v.Rollup.Contents[0].Number.Content
|
var contents []string
|
||||||
|
for _, content := range v.Rollup.Contents {
|
||||||
|
if av.KeyTypeNumber == content.Type {
|
||||||
|
numbers = append(numbers, content.Number.Content)
|
||||||
|
} else {
|
||||||
|
contents = append(contents, content.String(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if 0 < len(numbers) {
|
||||||
|
dataModel[rowValue.Key.Name] = numbers
|
||||||
|
} else {
|
||||||
|
dataModel[rowValue.Key.Name] = contents
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if av.KeyTypeRelation == v.Type {
|
||||||
|
if 0 < len(v.Relation.Contents) {
|
||||||
|
var contents []string
|
||||||
|
for _, content := range v.Relation.Contents {
|
||||||
|
contents = append(contents, content.String(true))
|
||||||
|
}
|
||||||
|
dataModel[rowValue.Key.Name] = contents
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataModel[rowValue.Key.Name] = v.String(true)
|
dataModel[rowValue.Key.Name] = v.String(true)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue