🎨 Template supports numerical calculations when using rollup https://github.com/siyuan-note/siyuan/issues/10810

This commit is contained in:
Daniel 2024-03-31 23:32:00 +08:00
parent 5e7d2341f4
commit c559ac45be
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 12 additions and 0 deletions

View file

@ -811,6 +811,13 @@ func renderTemplateCol(ial map[string]string, flashcard *Flashcard, rowValues []
dataModel[rowValue.Key.Name] = v.Number.Content
} else if av.KeyTypeDate == v.Type {
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
} else if av.KeyTypeRollup == v.Type {
if 0 < len(v.Rollup.Contents) && av.KeyTypeNumber == v.Rollup.Contents[0].Type {
// 模板使用汇总时支持数字计算
// Template supports numerical calculations when using rollup https://github.com/siyuan-note/siyuan/issues/10810
// 汇总数字时仅取第一个数字填充模板
dataModel[rowValue.Key.Name] = v.Rollup.Contents[0].Number.Content
}
} else {
dataModel[rowValue.Key.Name] = v.String()
}

View file

@ -1081,6 +1081,11 @@ func renderTemplateCol(ial map[string]string, rowValues []*av.KeyValues, tplCont
dataModel[rowValue.Key.Name] = v.Number.Content
} else if av.KeyTypeDate == v.Type {
dataModel[rowValue.Key.Name] = time.UnixMilli(v.Date.Content)
} else if av.KeyTypeRollup == v.Type {
if 0 < len(v.Rollup.Contents) && av.KeyTypeNumber == v.Rollup.Contents[0].Type {
// 汇总数字时仅取第一个数字填充模板
dataModel[rowValue.Key.Name] = v.Rollup.Contents[0].Number.Content
}
} else {
dataModel[rowValue.Key.Name] = v.String()
}