🎨 Attribute view support sticky layout https://github.com/siyuan-note/siyuan/pull/9617
This commit is contained in:
parent
2802efdfb3
commit
a1ac6fb867
4 changed files with 39 additions and 0 deletions
|
@ -39,6 +39,7 @@ type ViewTableColumn struct {
|
|||
|
||||
Wrap bool `json:"wrap"` // 是否换行
|
||||
Hidden bool `json:"hidden"` // 是否隐藏
|
||||
Pin bool `json:"pin"` // 是否固定
|
||||
Width string `json:"width"` // 列宽度
|
||||
Calc *ColumnCalc `json:"calc,omitempty"` // 计算
|
||||
}
|
||||
|
@ -562,6 +563,7 @@ type TableColumn struct {
|
|||
Icon string `json:"icon"` // 列图标
|
||||
Wrap bool `json:"wrap"` // 是否换行
|
||||
Hidden bool `json:"hidden"` // 是否隐藏
|
||||
Pin bool `json:"pin"` // 是否固定
|
||||
Width string `json:"width"` // 列宽度
|
||||
Calc *ColumnCalc `json:"calc"` // 计算
|
||||
|
||||
|
|
|
@ -366,6 +366,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
Wrap: col.Wrap,
|
||||
Hidden: col.Hidden,
|
||||
Width: col.Width,
|
||||
Pin: col.Pin,
|
||||
Calc: col.Calc,
|
||||
})
|
||||
}
|
||||
|
@ -947,6 +948,39 @@ func setAttributeViewColHidden(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColumnPin(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColPin(operation)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttributeViewColPin(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := attrView.GetView()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
if column.ID == operation.ID {
|
||||
column.Pin = operation.Data.(bool)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColumnIcon(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColIcon(operation)
|
||||
if nil != err {
|
||||
|
|
|
@ -208,6 +208,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewColumnWrap(op)
|
||||
case "setAttrViewColHidden":
|
||||
ret = tx.doSetAttrViewColumnHidden(op)
|
||||
case "setAttrViewColPin":
|
||||
ret = tx.doSetAttrViewColumnPin(op)
|
||||
case "setAttrViewColIcon":
|
||||
ret = tx.doSetAttrViewColumnIcon(op)
|
||||
case "insertAttrViewBlock":
|
||||
|
|
|
@ -582,6 +582,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
Wrap: col.Wrap,
|
||||
Hidden: col.Hidden,
|
||||
Width: col.Width,
|
||||
Pin: col.Pin,
|
||||
Calc: col.Calc,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue