mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
🎨 The database template field supports using other template fields https://github.com/siyuan-note/siyuan/issues/15517
This commit is contained in:
parent
aabb85d895
commit
752457b888
2 changed files with 17 additions and 8 deletions
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
|
|
@ -38,6 +39,7 @@ type AttributeView struct {
|
||||||
ID string `json:"id"` // 属性视图 ID
|
ID string `json:"id"` // 属性视图 ID
|
||||||
Name string `json:"name"` // 属性视图名称
|
Name string `json:"name"` // 属性视图名称
|
||||||
KeyValues []*KeyValues `json:"keyValues"` // 属性视图属性键值
|
KeyValues []*KeyValues `json:"keyValues"` // 属性视图属性键值
|
||||||
|
OriginalKeyValues []*KeyValues `json:"-"` // 原始属性视图属性键值
|
||||||
KeyIDs []string `json:"keyIDs"` // 属性视图属性键 ID,用于排序
|
KeyIDs []string `json:"keyIDs"` // 属性视图属性键 ID,用于排序
|
||||||
ViewID string `json:"viewID"` // 当前视图 ID
|
ViewID string `json:"viewID"` // 当前视图 ID
|
||||||
Views []*View `json:"views"` // 视图
|
Views []*View `json:"views"` // 视图
|
||||||
|
|
@ -470,6 +472,13 @@ func ParseAttributeView(avID string) (ret *AttributeView, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret.OriginalKeyValues = []*KeyValues{}
|
||||||
|
for _, keyValues := range ret.KeyValues {
|
||||||
|
cloned := &KeyValues{}
|
||||||
|
copier.CopyWithOption(cloned, keyValues, copier.Option{DeepCopy: true})
|
||||||
|
ret.OriginalKeyValues = append(ret.OriginalKeyValues, cloned)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ func RenderTemplateField(ial map[string]string, keyValues []*av.KeyValues, tplCo
|
||||||
|
|
||||||
func generateAttrViewItems(attrView *av.AttributeView, view *av.View) (ret map[string][]*av.KeyValues) {
|
func generateAttrViewItems(attrView *av.AttributeView, view *av.View) (ret map[string][]*av.KeyValues) {
|
||||||
ret = map[string][]*av.KeyValues{}
|
ret = map[string][]*av.KeyValues{}
|
||||||
for _, keyValues := range attrView.KeyValues {
|
for _, keyValues := range attrView.OriginalKeyValues {
|
||||||
for _, val := range keyValues.Values {
|
for _, val := range keyValues.Values {
|
||||||
values := ret[val.BlockID]
|
values := ret[val.BlockID]
|
||||||
if nil == values {
|
if nil == values {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue