mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve db tv relation render
This commit is contained in:
parent
5bcfdcbf8c
commit
5700a9f18a
4 changed files with 11 additions and 11 deletions
|
|
@ -300,7 +300,7 @@ func (filter *ViewFilter) GetAffectValue(key *Key, defaultVal *Value) (ret *Valu
|
||||||
}
|
}
|
||||||
case FilterOperatorDoesNotContain:
|
case FilterOperatorDoesNotContain:
|
||||||
case FilterOperatorIsEmpty:
|
case FilterOperatorIsEmpty:
|
||||||
ret.Relation = &ValueRelation{Contents: []string{}}
|
ret.Relation = &ValueRelation{Contents: []*Value{}}
|
||||||
case FilterOperatorIsNotEmpty:
|
case FilterOperatorIsNotEmpty:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,16 +141,16 @@ func (value *Value) String() string {
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
case KeyTypeRelation:
|
case KeyTypeRelation:
|
||||||
if 1 > len(value.Relation.Contents) {
|
if nil == value.Relation || 1 > len(value.Relation.Contents) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var ret []string
|
var ret []string
|
||||||
for _, v := range value.Relation.Contents {
|
for _, v := range value.Relation.Contents {
|
||||||
ret = append(ret, v)
|
ret = append(ret, v.String())
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(strings.Join(ret, ", "))
|
return strings.TrimSpace(strings.Join(ret, ", "))
|
||||||
case KeyTypeRollup:
|
case KeyTypeRollup:
|
||||||
if nil == value.Rollup || nil == value.Rollup.Contents {
|
if nil == value.Rollup || 1 > len(value.Rollup.Contents) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var ret []string
|
var ret []string
|
||||||
|
|
@ -648,8 +648,8 @@ type ValueCheckbox struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValueRelation struct {
|
type ValueRelation struct {
|
||||||
Contents []string `json:"contents"`
|
|
||||||
BlockIDs []string `json:"blockIDs"`
|
BlockIDs []string `json:"blockIDs"`
|
||||||
|
Contents []*Value `json:"contents"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValueRollup struct {
|
type ValueRollup struct {
|
||||||
|
|
|
||||||
|
|
@ -403,9 +403,9 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks := map[string]string{}
|
blocks := map[string]*av.Value{}
|
||||||
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
||||||
blocks[blockValue.BlockID] = blockValue.Block.Content
|
blocks[blockValue.BlockID] = blockValue
|
||||||
}
|
}
|
||||||
for _, bID := range kv.Values[0].Relation.BlockIDs {
|
for _, bID := range kv.Values[0].Relation.BlockIDs {
|
||||||
kv.Values[0].Relation.Contents = append(kv.Values[0].Relation.Contents, blocks[bID])
|
kv.Values[0].Relation.Contents = append(kv.Values[0].Relation.Contents, blocks[bID])
|
||||||
|
|
@ -1029,9 +1029,9 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
||||||
if nil != relKey && nil != relKey.Relation {
|
if nil != relKey && nil != relKey.Relation {
|
||||||
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
|
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
|
||||||
if nil != destAv {
|
if nil != destAv {
|
||||||
blocks := map[string]string{}
|
blocks := map[string]*av.Value{}
|
||||||
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
||||||
blocks[blockValue.BlockID] = blockValue.Block.Content
|
blocks[blockValue.BlockID] = blockValue
|
||||||
}
|
}
|
||||||
for _, blockID := range cell.Value.Relation.BlockIDs {
|
for _, blockID := range cell.Value.Relation.BlockIDs {
|
||||||
cell.Value.Relation.Contents = append(cell.Value.Relation.Contents, blocks[blockID])
|
cell.Value.Relation.Contents = append(cell.Value.Relation.Contents, blocks[blockID])
|
||||||
|
|
|
||||||
|
|
@ -827,9 +827,9 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
||||||
if nil != relKey && nil != relKey.Relation {
|
if nil != relKey && nil != relKey.Relation {
|
||||||
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
|
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
|
||||||
if nil != destAv {
|
if nil != destAv {
|
||||||
blocks := map[string]string{}
|
blocks := map[string]*av.Value{}
|
||||||
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
for _, blockValue := range destAv.GetBlockKeyValues().Values {
|
||||||
blocks[blockValue.BlockID] = blockValue.Block.Content
|
blocks[blockValue.BlockID] = blockValue
|
||||||
}
|
}
|
||||||
for _, blockID := range cell.Value.Relation.BlockIDs {
|
for _, blockID := range cell.Value.Relation.BlockIDs {
|
||||||
cell.Value.Relation.Contents = append(cell.Value.Relation.Contents, blocks[blockID])
|
cell.Value.Relation.Contents = append(cell.Value.Relation.Contents, blocks[blockID])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue