🎨 Candidate values of the database relation fields are no longer subject to view filtering https://github.com/siyuan-note/siyuan/issues/10411

This commit is contained in:
Daniel 2024-02-23 23:32:23 +08:00
parent bc6d6b17f7
commit 0dc8f1752d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 28 additions and 1 deletions

View file

@ -305,6 +305,27 @@ func SaveAttributeView(av *AttributeView) (err error) {
}
// 数据订正
// 值去重
blockValues := av.GetBlockKeyValues()
blockIDs := map[string]bool{}
var duplicatedValueIDs []string
for _, blockValue := range blockValues.Values {
if !blockIDs[blockValue.BlockID] {
blockIDs[blockValue.BlockID] = true
} else {
duplicatedValueIDs = append(duplicatedValueIDs, blockValue.ID)
}
}
var tmp []*Value
for _, blockValue := range blockValues.Values {
if !gulu.Str.Contains(blockValue.ID, duplicatedValueIDs) {
tmp = append(tmp, blockValue)
}
}
blockValues.Values = tmp
// 视图值去重
for _, view := range av.Views {
if nil != view.Table {
// 行去重

View file

@ -49,12 +49,18 @@ func GetAttributeViewPrimaryKeyValues(avID string, page, pageSize int) (attribut
attributeViewName = attrView.Name
keyValues = attrView.GetBlockKeyValues()
// 不在视图中的值要过滤掉
// 过滤掉不在视图中的值
tmp := map[string]*av.Value{}
for _, kv := range keyValues.Values {
for _, view := range attrView.Views {
switch view.LayoutType {
case av.LayoutTypeTable:
if !kv.IsDetached {
if nil == treenode.GetBlockTree(kv.BlockID) {
break
}
}
if gulu.Str.Contains(kv.Block.ID, view.Table.RowIDs) {
tmp[kv.Block.ID] = kv
}