mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-05 04:10:16 +01:00
🎨 Supports multiple views for the database https://github.com/siyuan-note/siyuan/issues/9751
This commit is contained in:
parent
4928e8e2fb
commit
d7d4f4d0de
1 changed files with 47 additions and 0 deletions
|
|
@ -242,6 +242,10 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
ret = tx.doReplaceAttrViewBlock(op)
|
ret = tx.doReplaceAttrViewBlock(op)
|
||||||
case "updateAttrViewColTemplate":
|
case "updateAttrViewColTemplate":
|
||||||
ret = tx.doUpdateAttrViewColTemplate(op)
|
ret = tx.doUpdateAttrViewColTemplate(op)
|
||||||
|
case "addAttrViewView":
|
||||||
|
ret = tx.doAddAttrViewView(op)
|
||||||
|
case "removeAttrViewView":
|
||||||
|
ret = tx.doRemoveAttrViewView(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != ret {
|
if nil != ret {
|
||||||
|
|
@ -257,6 +261,49 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
|
var err error
|
||||||
|
avID := operation.AvID
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||||
|
return &TxErr{code: TxErrCodeBlockNotFound, id: avID}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewID := operation.ID
|
||||||
|
for i, view := range attrView.Views {
|
||||||
|
if viewID == view.ID {
|
||||||
|
attrView.Views = append(attrView.Views[:i], attrView.Views[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = av.SaveAttributeView(attrView); nil != err {
|
||||||
|
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
|
||||||
|
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: avID}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) doAddAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
|
var err error
|
||||||
|
avID := operation.AvID
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||||
|
return &TxErr{code: TxErrCodeBlockNotFound, id: avID}
|
||||||
|
}
|
||||||
|
|
||||||
|
view := av.NewView()
|
||||||
|
attrView.Views = append(attrView.Views, view)
|
||||||
|
attrView.ViewID = view.ID
|
||||||
|
if err = av.SaveAttributeView(attrView); nil != err {
|
||||||
|
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
|
||||||
|
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: avID}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||||
var err error
|
var err error
|
||||||
id := operation.ID
|
id := operation.ID
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue