Skip to content

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

:art: Attribute View number column format https://github.com/siyuan-note/siyuan/issues/8764

Danielc136b71e67d1
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index c2b3db7587..bba17c2e6a 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -754,6 +754,35 @@ func addAttributeViewColumn(operation *Operation) (err error) {
return
}
+func (tx *Transaction) doUpdateAttrViewColNumberFormat(operation *Operation) (ret *TxErr) {
+ err := updateAttributeViewColNumberFormat(operation)
+ if nil != err {
+ return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
+ }
+ return
+}
+
+func updateAttributeViewColNumberFormat(operation *Operation) (err error) {
+ attrView, err := av.ParseAttributeView(operation.AvID)
+ if nil != err {
+ return
+ }
+
+ colType := av.KeyType(operation.Typ)
+ switch colType {
+ case av.KeyTypeNumber:
+ for _, keyValues := range attrView.KeyValues {
+ if keyValues.Key.ID == operation.ID && av.KeyTypeNumber == keyValues.Key.Type {
+ keyValues.Key.NumberFormat = av.NumberFormat(operation.Format)
+ break
+ }
+ }
+ }
+
+ err = av.SaveAttributeView(attrView)
+ return
+}
+
func (tx *Transaction) doUpdateAttrViewColumn(operation *Operation) (ret *TxErr) {
err := updateAttributeViewColumn(operation)
if nil != err {
@@ -775,7 +804,6 @@ func updateAttributeViewColumn(operation *Operation) (err error) {
if keyValues.Key.ID == operation.ID {
keyValues.Key.Name = operation.Name
keyValues.Key.Type = colType
- keyValues.Key.NumberFormat = av.NumberFormat(operation.Format)
break
}
}
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 041325f834..1a6f649136 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -253,6 +253,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
ret = tx.doUpdateAttrViewColOption(op)
case "setAttrViewColCalc":
ret = tx.doSetAttrViewColCalc(op)
+ case "updateAttrViewColNumberFormat":
+ ret = tx.doUpdateAttrViewColNumberFormat(op)
}
if nil != ret {