mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
34f1f6a3d4
3 changed files with 57 additions and 4 deletions
|
@ -630,6 +630,20 @@ func (av *AttributeView) GetBlockKeyValues() (ret *KeyValues) {
|
|||
return
|
||||
}
|
||||
|
||||
func (av *AttributeView) GetBlockValue(itemID string) (ret *Value) {
|
||||
for _, kv := range av.KeyValues {
|
||||
if KeyTypeBlock == kv.Key.Type && 0 < len(kv.Values) {
|
||||
for _, v := range kv.Values {
|
||||
if v.BlockID == itemID {
|
||||
ret = v
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (av *AttributeView) GetKeyValues(keyID string) (ret *KeyValues, err error) {
|
||||
for _, kv := range av.KeyValues {
|
||||
if kv.Key.ID == keyID {
|
||||
|
|
|
@ -1648,6 +1648,11 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
return
|
||||
}
|
||||
|
||||
var relationDestAv *av.AttributeView
|
||||
if av.KeyTypeRelation == groupKey.Type && nil != groupKey.Relation {
|
||||
relationDestAv, _ = av.ParseAttributeView(groupKey.Relation.AvID)
|
||||
}
|
||||
|
||||
var rangeStart, rangeEnd float64
|
||||
switch group.Method {
|
||||
case av.GroupMethodValue:
|
||||
|
@ -1695,11 +1700,20 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
var groupVal string
|
||||
switch group.Method {
|
||||
case av.GroupMethodValue:
|
||||
if av.KeyTypeMSelect == groupKey.Type {
|
||||
if av.KeyTypeSelect == groupKey.Type || av.KeyTypeMSelect == groupKey.Type {
|
||||
for _, s := range value.MSelect {
|
||||
groupItemsMap[s.Content] = append(groupItemsMap[s.Content], item)
|
||||
}
|
||||
continue
|
||||
} else if av.KeyTypeRelation == groupKey.Type {
|
||||
if nil == relationDestAv {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, bID := range value.Relation.BlockIDs {
|
||||
groupItemsMap[bID] = append(groupItemsMap[bID], item)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
groupVal = value.String(false)
|
||||
|
@ -1801,6 +1815,16 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
v.GroupVal.Type = av.KeyTypeSelect
|
||||
v.GroupVal.MSelect = []*av.ValueSelect{{Content: opt.Name, Color: opt.Color}}
|
||||
}
|
||||
} else if av.KeyTypeRelation == groupKey.Type {
|
||||
if relationDestAv != nil && groupValueDefault != groupValue {
|
||||
v.GroupVal.Text = nil
|
||||
v.GroupVal.Type = av.KeyTypeRelation
|
||||
v.GroupVal.Relation = &av.ValueRelation{BlockIDs: []string{groupValue}}
|
||||
|
||||
if destBlock := relationDestAv.GetBlockValue(groupValue); nil != destBlock {
|
||||
v.GroupVal.Relation.Contents = []*av.Value{destBlock}
|
||||
}
|
||||
}
|
||||
}
|
||||
v.GroupSort = -1
|
||||
view.Groups = append(view.Groups, v)
|
||||
|
@ -3525,7 +3549,7 @@ func sortAttributeViewRow(operation *Operation) (err error) {
|
|||
if groupView := view.GetGroupByID(operation.GroupID); nil != groupView {
|
||||
groupKey := view.GetGroupKey(attrView)
|
||||
isAcrossGroup := operation.GroupID != operation.TargetGroupID
|
||||
if isAcrossGroup && (av.KeyTypeTemplate == groupKey.Type || av.KeyTypeRollup == groupKey.Type || av.KeyTypeCreated == groupKey.Type || av.KeyTypeUpdated == groupKey.Type) {
|
||||
if isAcrossGroup && (av.KeyTypeTemplate == groupKey.Type || av.KeyTypeCreated == groupKey.Type || av.KeyTypeUpdated == groupKey.Type) {
|
||||
// 这些字段类型不支持跨分组移动,因为它们的值是自动计算生成的
|
||||
return
|
||||
}
|
||||
|
@ -3556,7 +3580,7 @@ func sortAttributeViewRow(operation *Operation) (err error) {
|
|||
}
|
||||
targetGroupView.GroupItemIDs = util.InsertElem(targetGroupView.GroupItemIDs, previousIndex, itemID)
|
||||
|
||||
if av.KeyTypeMSelect == groupKey.Type {
|
||||
if av.KeyTypeMSelect == groupKey.Type || av.KeyTypeRelation == groupKey.Type {
|
||||
// 跨多选分组时一个项目可能会同时存在于多个分组中,需要重新生成分组
|
||||
regenAttrViewGroups(attrView, "force")
|
||||
}
|
||||
|
|
|
@ -434,7 +434,19 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
keyValues = append(keyValues, &av.KeyValues{Key: relKey, Values: []*av.Value{{ID: value.ID, KeyID: relKey.ID, BlockID: itemID, Type: av.KeyTypeRelation, Relation: value.Relation}}})
|
||||
items[itemID] = keyValues
|
||||
case av.KeyTypeCreated: // 渲染创建时间
|
||||
createdStr := itemID[:len("20060102150405")]
|
||||
ial := map[string]string{}
|
||||
block := item.GetBlockValue()
|
||||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
id := itemID
|
||||
if "" != ial["id"] {
|
||||
id = ial["id"]
|
||||
}
|
||||
createdStr := id[:len("20060102150405")]
|
||||
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
||||
if nil == parseErr {
|
||||
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
|
||||
|
@ -453,6 +465,9 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
|||
if nil != block {
|
||||
ial = ials[block.Block.ID]
|
||||
}
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
updatedStr := ial["updated"]
|
||||
if "" == updatedStr && nil != block {
|
||||
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue