This commit is contained in:
Daniel 2023-08-03 23:38:45 +08:00
parent c767e532df
commit c136b71e67
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 31 additions and 1 deletions

View File

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

View File

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