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

This commit is contained in:
Daniel 2024-11-02 16:07:56 +08:00
parent 680d637ed9
commit 777a7c9f51
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 5 additions and 7 deletions

View file

@ -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") {

View file

@ -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()

View file

@ -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