An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve av https://github.com/siyuan-note/siyuan/issues/15563#issuecomment-3592191959
Daniela2152fd423d7
diff --git a/kernel/av/value.go b/kernel/av/value.goindex a206b8030f..625bafe5ab 100644--- a/kernel/av/value.go+++ b/kernel/av/value.go@@ -682,6 +682,15 @@ type ValueSelect struct {Color string `json:"color"` // 1-14}+func MSelectRemoveOption(mSelect []*ValueSelect, opt string) (ret []*ValueSelect) {+ for _, s := range mSelect {+ if s.Content != opt {+ ret = append(ret, s)+ }+ }+ return+}+func MSelectExistOption(mSelect []*ValueSelect, opt string) bool {for _, s := range mSelect {if s.Content == opt {diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 701f8e8833..d3fe1fb993 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -231,8 +231,10 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group// 因为单选或多选只能按选项分组,并且可能存在空白分组(找不到临近项),所以单选或多选类型的分组字段使用分组值内容对应的选项if opt := groupKey.GetOption(groupView.GetGroupValue()); nil != opt && groupValueDefault != groupView.GetGroupValue() {if nil == newValue {- // 如果没有临近项,则尝试从过滤结果中获取- newValue = ret[groupKey.ID]+ newValue = ret[groupKey.ID] // 如果没有临近项,则尝试从过滤结果中获取+ }+ if nil == newValue {+ newValue = keyValues.GetValue(addingItemID) // 尝试从已有值中获取}if nil != newValue {@@ -3983,6 +3985,13 @@ func sortAttributeViewRow(operation *Operation) (err error) {if targetGroupView := view.GetGroupByID(operation.TargetGroupID); nil != targetGroupView && !gulu.Str.Contains(itemID, targetGroupView.GroupItemIDs) {fillDefaultValue(attrView, view, targetGroupView, operation.PreviousID, itemID, false)+ // 移除旧分组的值+ if val := attrView.GetValue(groupKey.ID, itemID); nil != val {+ if av.MSelectExistOption(val.MSelect, groupView.GetGroupValue()) {+ val.MSelect = av.MSelectRemoveOption(val.MSelect, groupView.GetGroupValue())+ }+ }+for i, r := range targetGroupView.GroupItemIDs {if r == operation.PreviousID {previousIndex = i + 1