Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve av api setAttributeViewBlockAttr https://github.com/siyuan-note/siyuan/issues/12996

Daniel777a7c9f51da
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index 8f79686a05..41629db78e 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 de1ae7f35d..3d2d468fad 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 538df4ae56..6cd1c9aa63 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