mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
81c7931e0f
commit
5df063fbec
2 changed files with 32 additions and 0 deletions
|
|
@ -44,6 +44,36 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCoverFromAssetKeyID(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewCoverFromAssetKeyID(operation)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttrViewCoverFromAssetKeyID(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
return
|
||||
case av.LayoutTypeGallery:
|
||||
view.Gallery.CoverFromAssetKeyID = operation.KeyID
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewCoverFrom(operation *Operation) (ret *TxErr) {
|
||||
err := setAttrViewCoverFrom(operation)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -280,6 +280,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doDuplicateAttrViewKey(op)
|
||||
case "setAttrViewCoverFrom":
|
||||
ret = tx.doSetAttrViewCoverFrom(op)
|
||||
case "setAttrViewCoverFromAssetKeyID":
|
||||
ret = tx.doSetAttrViewCoverFromAssetKeyID(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue