mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-07 23:23:08 +08:00
🎨 Attribute View number column format https://github.com/siyuan-note/siyuan/issues/8764
This commit is contained in:
parent
c767e532df
commit
c136b71e67
@ -754,6 +754,35 @@ func addAttributeViewColumn(operation *Operation) (err error) {
|
|||||||
return
|
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) {
|
func (tx *Transaction) doUpdateAttrViewColumn(operation *Operation) (ret *TxErr) {
|
||||||
err := updateAttributeViewColumn(operation)
|
err := updateAttributeViewColumn(operation)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
@ -775,7 +804,6 @@ func updateAttributeViewColumn(operation *Operation) (err error) {
|
|||||||
if keyValues.Key.ID == operation.ID {
|
if keyValues.Key.ID == operation.ID {
|
||||||
keyValues.Key.Name = operation.Name
|
keyValues.Key.Name = operation.Name
|
||||||
keyValues.Key.Type = colType
|
keyValues.Key.Type = colType
|
||||||
keyValues.Key.NumberFormat = av.NumberFormat(operation.Format)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,6 +253,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||||||
ret = tx.doUpdateAttrViewColOption(op)
|
ret = tx.doUpdateAttrViewColOption(op)
|
||||||
case "setAttrViewColCalc":
|
case "setAttrViewColCalc":
|
||||||
ret = tx.doSetAttrViewColCalc(op)
|
ret = tx.doSetAttrViewColCalc(op)
|
||||||
|
case "updateAttrViewColNumberFormat":
|
||||||
|
ret = tx.doUpdateAttrViewColNumberFormat(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != ret {
|
if nil != ret {
|
||||||
|
Loading…
Reference in New Issue
Block a user