🎨 Add Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9958

This commit is contained in:
Daniel 2023-12-24 22:27:38 +08:00
parent 93dc9f5c22
commit 0ce8b58a79
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 110 additions and 13 deletions

View file

@ -49,6 +49,16 @@ type KeyValues struct {
Values []*Value `json:"values,omitempty"` // 属性视图属性列值
}
func (kValues *KeyValues) GetValue(blockID string) (ret *Value) {
for _, v := range kValues.Values {
if v.BlockID == blockID {
ret = v
return
}
}
return
}
type KeyType string
const (
@ -306,6 +316,20 @@ func (av *AttributeView) GetCurrentView() (ret *View, err error) {
return
}
func (av *AttributeView) GetValue(keyID, blockID string) (ret *Value) {
for _, kv := range av.KeyValues {
if kv.Key.ID == keyID {
for _, v := range kv.Values {
if v.BlockID == blockID {
ret = v
return
}
}
}
}
return
}
func (av *AttributeView) GetKey(keyID string) (ret *Key, err error) {
for _, kv := range av.KeyValues {
if kv.Key.ID == keyID {