mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Database table view supports synchronizing column width to other table views https://github.com/siyuan-note/siyuan/issues/11022
This commit is contained in:
parent
1bb0c983e8
commit
43d533ce1d
2 changed files with 56 additions and 1 deletions
|
|
@ -44,6 +44,59 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doSyncAttrViewTableColWidth(operation *Operation) (ret *TxErr) {
|
||||
err := syncAttrViewTableColWidth(operation)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func syncAttrViewTableColWidth(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
view := attrView.GetView(operation.ID)
|
||||
if nil == view {
|
||||
err = av.ErrViewNotFound
|
||||
logging.LogErrorf("view [%s] not found in attribute view [%s]", operation.ID, operation.AvID)
|
||||
return
|
||||
}
|
||||
|
||||
var width string
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
if column.ID == operation.KeyID {
|
||||
width = operation.Data.(string)
|
||||
break
|
||||
}
|
||||
}
|
||||
case av.LayoutTypeGallery:
|
||||
return
|
||||
}
|
||||
|
||||
if "" == width {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range attrView.Views {
|
||||
if av.LayoutTypeTable == v.LayoutType {
|
||||
for _, column := range v.Table.Columns {
|
||||
if column.ID == operation.KeyID {
|
||||
column.Width = width
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetGroupHideEmpty(operation *Operation) (ret *TxErr) {
|
||||
if err := SetGroupHideEmpty(operation.AvID, operation.BlockID, operation.Data.(bool)); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue