mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 The database rollup field supports using the template field https://github.com/siyuan-note/siyuan/issues/12384
This commit is contained in:
parent
f6694810e2
commit
d67a041633
4 changed files with 22 additions and 6 deletions
|
@ -188,6 +188,9 @@ type Collection interface {
|
|||
// GetField 返回指定 ID 的字段。
|
||||
GetField(id string) (ret Field, fieldIndex int)
|
||||
|
||||
// GetValue 返回指定项目 ID 和键 ID 的字段值。
|
||||
GetValue(itemID, keyID string) (ret *Value)
|
||||
|
||||
// GetSorts 返回集合的排序规则。
|
||||
GetSorts() []*ViewSort
|
||||
|
||||
|
|
|
@ -184,6 +184,15 @@ func (gallery *Gallery) GetField(id string) (ret Field, fieldIndex int) {
|
|||
return nil, -1
|
||||
}
|
||||
|
||||
func (gallery *Gallery) GetValue(itemID, keyID string) (ret *Value) {
|
||||
for _, card := range gallery.Cards {
|
||||
if card.ID == itemID {
|
||||
return card.GetValue(keyID)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gallery *Gallery) GetType() LayoutType {
|
||||
return LayoutTypeGallery
|
||||
}
|
||||
|
|
|
@ -158,6 +158,15 @@ func (table *Table) GetField(id string) (ret Field, fieldIndex int) {
|
|||
return nil, -1
|
||||
}
|
||||
|
||||
func (table *Table) GetValue(itemID, keyID string) (ret *Value) {
|
||||
for _, row := range table.Rows {
|
||||
if row.ID == itemID {
|
||||
return row.GetValue(keyID)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*Table) GetType() LayoutType {
|
||||
return LayoutTypeTable
|
||||
}
|
||||
|
|
|
@ -342,12 +342,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
for _, blockID := range relVal.Relation.BlockIDs {
|
||||
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
|
||||
if nil == destVal && av.KeyTypeTemplate == destKey.Type && nil != viewable {
|
||||
for _, destItem := range viewable.(av.Collection).GetItems() {
|
||||
if blockID == destItem.GetID() {
|
||||
destVal = destItem.GetValue(destKey.ID)
|
||||
break
|
||||
}
|
||||
}
|
||||
destVal = viewable.(av.Collection).GetValue(blockID, destKey.ID)
|
||||
}
|
||||
|
||||
if nil == destVal {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue