mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-27 11:58:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
c9a68c7b1d
5 changed files with 37 additions and 22 deletions
|
|
@ -106,7 +106,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
|
|||
|
||||
fixDev := false
|
||||
for _, groupView := range view.Groups {
|
||||
if "" == groupView.GetGroupValue() && !fixDev {
|
||||
if ("" == groupView.GetGroupValue() || nil == groupView.GroupKey) && !fixDev {
|
||||
// TODO 分组上线后删除,预计 2025 年 9 月后可以删除
|
||||
regenAttrViewGroups(attrView, "force")
|
||||
av.SaveAttributeView(attrView)
|
||||
|
|
|
|||
|
|
@ -3442,7 +3442,7 @@ func getAttrViewTable(attrView *av.AttributeView, view *av.View, query string) (
|
|||
}
|
||||
|
||||
depth := 1
|
||||
ret = sql.RenderAttributeViewTable(attrView, view, query, &depth)
|
||||
ret = sql.RenderAttributeViewTable(attrView, view, query, &depth, map[string]*av.AttributeView{}, map[string]av.Collection{})
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,10 +72,15 @@ func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, query
|
|||
|
||||
func RenderView(attrView *av.AttributeView, view *av.View, query string) (ret av.Viewable) {
|
||||
depth := 1
|
||||
return renderView(attrView, view, query, &depth)
|
||||
renderedAttrViews := map[string]*av.AttributeView{}
|
||||
renderedTemplateKeyCollections := map[string]av.Collection{}
|
||||
renderedAttrViews[attrView.ID] = attrView
|
||||
ret = renderView(attrView, view, query, &depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
return
|
||||
}
|
||||
|
||||
func renderView(attrView *av.AttributeView, view *av.View, query string, depth *int) (ret av.Viewable) {
|
||||
func renderView(attrView *av.AttributeView, view *av.View, query string,
|
||||
depth *int, renderedAttrViews map[string]*av.AttributeView, renderedTemplateKeyCollections map[string]av.Collection) (ret av.Viewable) {
|
||||
if 7 < *depth {
|
||||
return
|
||||
}
|
||||
|
|
@ -83,9 +88,9 @@ func renderView(attrView *av.AttributeView, view *av.View, query string, depth *
|
|||
*depth++
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
ret = RenderAttributeViewTable(attrView, view, query, depth)
|
||||
ret = RenderAttributeViewTable(attrView, view, query, depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
case av.LayoutTypeGallery:
|
||||
ret = RenderAttributeViewGallery(attrView, view, query, depth)
|
||||
ret = RenderAttributeViewGallery(attrView, view, query, depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -321,9 +326,8 @@ func fillAttributeViewBaseValue(baseValue *av.BaseValue, fieldID, itemID string,
|
|||
}
|
||||
}
|
||||
|
||||
func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues, depth *int) {
|
||||
avCache := map[string]*av.AttributeView{}
|
||||
avCache[attrView.ID] = attrView
|
||||
func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues,
|
||||
depth *int, renderedAttrViews map[string]*av.AttributeView, renderedTemplateKeyCollections map[string]av.Collection) {
|
||||
for _, item := range collection.GetItems() {
|
||||
for _, value := range item.GetValues() {
|
||||
itemID := item.GetID()
|
||||
|
|
@ -354,11 +358,11 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
break
|
||||
}
|
||||
|
||||
destAv := avCache[relKey.Relation.AvID]
|
||||
destAv := renderedAttrViews[relKey.Relation.AvID]
|
||||
if nil == destAv {
|
||||
destAv, _ = av.ParseAttributeView(relKey.Relation.AvID)
|
||||
if nil != destAv {
|
||||
avCache[relKey.Relation.AvID] = destAv
|
||||
renderedAttrViews[relKey.Relation.AvID] = destAv
|
||||
}
|
||||
}
|
||||
if nil == destAv {
|
||||
|
|
@ -370,16 +374,25 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
return
|
||||
}
|
||||
|
||||
var viewable av.Viewable
|
||||
var furtherCollection av.Collection
|
||||
var ok bool
|
||||
if av.KeyTypeTemplate == destKey.Type {
|
||||
// 渲染目标视图,这样才能汇总渲染后的模板字段值
|
||||
viewable = renderView(destAv, destAv.Views[0], "", depth)
|
||||
if furtherCollection, ok = renderedTemplateKeyCollections[destKey.ID]; !ok {
|
||||
renderedTemplateKeyCollections[destKey.ID] = collection
|
||||
|
||||
// 渲染目标视图,这样才能汇总渲染后的模板字段值
|
||||
viewable := renderView(destAv, destAv.Views[0], "", depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
if nil != viewable {
|
||||
furtherCollection = viewable.(av.Collection)
|
||||
renderedTemplateKeyCollections[destKey.ID] = furtherCollection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, blockID := range relVal.Relation.BlockIDs {
|
||||
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
|
||||
if nil != viewable && av.KeyTypeTemplate == destKey.Type {
|
||||
destVal = viewable.(av.Collection).GetValue(blockID, destKey.ID)
|
||||
if nil != furtherCollection && av.KeyTypeTemplate == destKey.Type {
|
||||
destVal = furtherCollection.GetValue(blockID, destKey.ID)
|
||||
}
|
||||
|
||||
if nil == destVal {
|
||||
|
|
@ -409,11 +422,11 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
value.Relation.Contents = nil
|
||||
relKey, _ := attrView.GetKey(value.KeyID)
|
||||
if nil != relKey && nil != relKey.Relation {
|
||||
destAv := avCache[relKey.Relation.AvID]
|
||||
destAv := renderedAttrViews[relKey.Relation.AvID]
|
||||
if nil == destAv {
|
||||
destAv, _ = av.ParseAttributeView(relKey.Relation.AvID)
|
||||
if nil != destAv {
|
||||
avCache[relKey.Relation.AvID] = destAv
|
||||
renderedAttrViews[relKey.Relation.AvID] = destAv
|
||||
}
|
||||
}
|
||||
if nil != destAv {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query string, depth *int) (ret *av.Gallery) {
|
||||
func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query string,
|
||||
depth *int, renderedAttrViews map[string]*av.AttributeView, renderedTemplateKeyCollections map[string]av.Collection) (ret *av.Gallery) {
|
||||
ret = &av.Gallery{
|
||||
BaseInstance: av.NewViewBaseInstance(view),
|
||||
CoverFrom: view.Gallery.CoverFrom,
|
||||
|
|
@ -114,7 +115,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
ials := BatchGetBlockAttrsWitTrees(ialIDs, boundTrees)
|
||||
|
||||
// 渲染自动生成的字段值,比如关联、汇总、创建时间和更新时间
|
||||
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, cardsValues, depth)
|
||||
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, cardsValues, depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
|
||||
// 最后单独渲染模板字段,这样模板就可以使用汇总、关联、创建时间和更新时间的值了
|
||||
renderTemplateErr := fillAttributeViewTemplateValues(attrView, ret, ials, cardsValues)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query string, depth *int) (ret *av.Table) {
|
||||
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) {
|
||||
ret = &av.Table{
|
||||
BaseInstance: av.NewViewBaseInstance(view),
|
||||
Columns: []*av.TableColumn{},
|
||||
|
|
@ -107,7 +108,7 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
|
|||
ials := BatchGetBlockAttrs(ialIDs)
|
||||
|
||||
// 渲染自动生成的字段值,比如关联、汇总、创建时间和更新时间
|
||||
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, rowsValues, depth)
|
||||
fillAttributeViewAutoGeneratedValues(attrView, ret, ials, rowsValues, depth, renderedAttrViews, renderedTemplateKeyCollections)
|
||||
|
||||
// 最后单独渲染模板字段,这样模板就可以使用汇总、关联、创建时间和更新时间的值了
|
||||
renderTemplateErr := fillAttributeViewTemplateValues(attrView, ret, ials, rowsValues)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue