diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 9a03e86a2..ba0e94347 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -44,6 +44,34 @@ import ( "github.com/xrash/smetrics" ) +func (tx *Transaction) doRemoveAttrViewGroup(operation *Operation) (ret *TxErr) { + if err := removeAttributeViewGroup(operation.AvID, operation.BlockID); nil != err { + return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()} + } + return +} + +func removeAttributeViewGroup(avID, blockID string) (err error) { + attrView, err := av.ParseAttributeView(avID) + if err != nil { + return err + } + + view, err := getAttrViewViewByBlockID(attrView, blockID) + if err != nil { + return err + } + + view.Group, view.Groups = nil, nil + + err = av.SaveAttributeView(attrView) + if err != nil { + logging.LogErrorf("save attribute view [%s] failed: %s", avID, err) + return err + } + return nil +} + func (tx *Transaction) doSyncAttrViewTableColWidth(operation *Operation) (ret *TxErr) { err := syncAttrViewTableColWidth(operation) if err != nil { @@ -94,13 +122,13 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) { } func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) { - if err := HideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err { + if err := hideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err { return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()} } return } -func HideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) { +func hideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) { attrView, err := av.ParseAttributeView(avID) if err != nil { return err diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 28da677cd..89fec1826 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -303,6 +303,8 @@ func performTx(tx *Transaction) (ret *TxErr) { ret = tx.doHideAttrViewGroup(op) case "syncAttrViewTableColWidth": ret = tx.doSyncAttrViewTableColWidth(op) + case "removeAttrViewGroup": + ret = tx.doRemoveAttrViewGroup(op) } if nil != ret {