🎨 The database template field supports using other template fields https://github.com/siyuan-note/siyuan/issues/15517

This commit is contained in:
Daniel 2025-08-20 18:18:32 +08:00
parent f0f5b6a824
commit 6e6522d56a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 50 additions and 47 deletions

View file

@ -23,7 +23,7 @@ import (
)
func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query string,
depth *int, renderedAttrViews map[string]*av.AttributeView, renderedTemplateKeyCollections map[string]av.Collection) (ret *av.Table) {
depth *int, renderedAttrViews map[string]*av.AttributeView) (ret *av.Table) {
ret = &av.Table{
BaseInstance: av.NewViewBaseInstance(view),
Columns: []*av.TableColumn{},
@ -97,6 +97,9 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
ret.Rows = append(ret.Rows, &tableRow)
}
// 回填补全数据
fillAttributeViewKeyValues(attrView, ret)
// 批量获取块属性以提升性能
var ialIDs []string
for _, row := range ret.Rows {
@ -108,10 +111,10 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
ials := BatchGetBlockAttrs(ialIDs)
// 渲染自动生成的字段值,比如关联、汇总、创建时间和更新时间
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, rowsValues, depth, renderedAttrViews, renderedTemplateKeyCollections)
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, depth, renderedAttrViews)
// 最后单独渲染模板字段,这样模板就可以使用汇总、关联、创建时间和更新时间的值了
renderTemplateErr := fillAttributeViewTemplateValues(attrView, ret, ials, rowsValues)
renderTemplateErr := fillAttributeViewTemplateValues(attrView, view, ret, ials)
if nil != renderTemplateErr {
util.PushErrMsg(fmt.Sprintf(util.Langs[util.Lang][44], util.EscapeHTML(renderTemplateErr.Error())), 30000)
}