mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
0d5320f08b
commit
cbddce4d25
2 changed files with 32 additions and 2 deletions
|
@ -44,6 +44,34 @@ import (
|
||||||
"github.com/xrash/smetrics"
|
"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) {
|
func (tx *Transaction) doSyncAttrViewTableColWidth(operation *Operation) (ret *TxErr) {
|
||||||
err := syncAttrViewTableColWidth(operation)
|
err := syncAttrViewTableColWidth(operation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -94,13 +122,13 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) {
|
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 &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||||
}
|
}
|
||||||
return
|
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)
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -303,6 +303,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
ret = tx.doHideAttrViewGroup(op)
|
ret = tx.doHideAttrViewGroup(op)
|
||||||
case "syncAttrViewTableColWidth":
|
case "syncAttrViewTableColWidth":
|
||||||
ret = tx.doSyncAttrViewTableColWidth(op)
|
ret = tx.doSyncAttrViewTableColWidth(op)
|
||||||
|
case "removeAttrViewGroup":
|
||||||
|
ret = tx.doRemoveAttrViewGroup(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != ret {
|
if nil != ret {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue