mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
3c0933beac
commit
f1f363d77b
2 changed files with 39 additions and 0 deletions
|
|
@ -206,6 +206,43 @@ func hideAttributeViewGroup(avID, blockID, groupID string, hidden int) (err erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (tx *Transaction) doFoldAttrViewGroup(operation *Operation) (ret *TxErr) {
|
||||
if err := foldAttrViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func foldAttrViewGroup(avID, blockID, groupID string, folded bool) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, blockID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if nil == view.Group {
|
||||
return
|
||||
}
|
||||
|
||||
for _, group := range view.Groups {
|
||||
if group.ID == groupID {
|
||||
group.GroupFolded = folded
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
if err != nil {
|
||||
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewGroup(operation *Operation) (ret *TxErr) {
|
||||
data, err := gulu.JSON.MarshalJSON(operation.Data)
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -301,6 +301,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewGroup(op)
|
||||
case "hideAttrViewGroup":
|
||||
ret = tx.doHideAttrViewGroup(op)
|
||||
case "foldAttrViewGroup":
|
||||
ret = tx.doFoldAttrViewGroup(op)
|
||||
case "syncAttrViewTableColWidth":
|
||||
ret = tx.doSyncAttrViewTableColWidth(op)
|
||||
case "removeAttrViewGroup":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue