From 777a7c9f51da20a2ed868cbde3f32f87659ffe18 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 2 Nov 2024 16:07:56 +0800 Subject: [PATCH] :art: Improve av api setAttributeViewBlockAttr https://github.com/siyuan-note/siyuan/issues/12996 --- app/src/protyle/render/av/blockAttr.ts | 1 - kernel/api/av.go | 3 +-- kernel/model/attribute_view.go | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts index 8f79686a0..41629db78 100644 --- a/app/src/protyle/render/av/blockAttr.ts +++ b/app/src/protyle/render/av/blockAttr.ts @@ -352,7 +352,6 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"] avID: item.parentElement.dataset.avId, keyID: item.parentElement.dataset.colId, rowID: item.parentElement.dataset.blockId, - cellID: item.parentElement.dataset.id, value }, (setResponse) => { if (type === "number") { diff --git a/kernel/api/av.go b/kernel/api/av.go index de1ae7f35..3d2d468fa 100644 --- a/kernel/api/av.go +++ b/kernel/api/av.go @@ -614,9 +614,8 @@ func setAttributeViewBlockAttr(c *gin.Context) { avID := arg["avID"].(string) keyID := arg["keyID"].(string) rowID := arg["rowID"].(string) - cellID := arg["cellID"].(string) value := arg["value"].(interface{}) - updatedVal, err := model.UpdateAttributeViewCell(nil, avID, keyID, rowID, cellID, value) + updatedVal, err := model.UpdateAttributeViewCell(nil, avID, keyID, rowID, value) if err != nil { ret.Code = -1 ret.Msg = err.Error() diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 538df4ae5..6cd1c9aa6 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -2974,11 +2974,11 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) { } func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error) { - _, err = UpdateAttributeViewCell(tx, operation.AvID, operation.KeyID, operation.RowID, operation.ID, operation.Data) + _, err = UpdateAttributeViewCell(tx, operation.AvID, operation.KeyID, operation.RowID, operation.Data) return } -func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string, valueData interface{}) (val *av.Value, err error) { +func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID string, valueData interface{}) (val *av.Value, err error) { attrView, err := av.ParseAttributeView(avID) if err != nil { return @@ -3008,7 +3008,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string, } for _, value := range keyValues.Values { - if cellID == value.ID || rowID == value.BlockID { + if rowID == value.BlockID { val = value val.Type = keyValues.Key.Type break @@ -3016,7 +3016,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string, } if nil == val { - val = &av.Value{ID: cellID, KeyID: keyID, BlockID: rowID, Type: keyValues.Key.Type, CreatedAt: now, UpdatedAt: now} + val = &av.Value{ID: ast.NewNodeID(), KeyID: keyID, BlockID: rowID, Type: keyValues.Key.Type, CreatedAt: now, UpdatedAt: now} keyValues.Values = append(keyValues.Values, val) } break