🎨 Update av
This commit is contained in:
parent
22ffc30245
commit
d175677042
5 changed files with 85 additions and 3 deletions
|
@ -39,6 +39,7 @@ type Column struct {
|
|||
Icon string `json:"icon"` // 列图标
|
||||
Wrap bool `json:"wrap"` // 是否换行
|
||||
Hidden bool `json:"hidden"` // 是否隐藏
|
||||
Width string `json:"width"` // 列宽度
|
||||
|
||||
// 以下是某些列类型的特有属性
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ require (
|
|||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/sashabaranov/go-openai v1.12.0
|
||||
github.com/shirou/gopsutil/v3 v3.23.5
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701095811-d5e182b6ac1b
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701164716-3bd946c2227d
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
|
||||
github.com/siyuan-note/filelock v0.0.0-20230615140405-d05a21d49524
|
||||
|
|
|
@ -287,8 +287,8 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
|
|||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701095811-d5e182b6ac1b h1:92337ju4mYbc37qTy1x+NeL3FWMs4d1hi60Nj5MAfK8=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701095811-d5e182b6ac1b/go.mod h1:iR6kmFYS3jz/yuDFg6atb0yZdDs2RvS5gf3NzTL4frI=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701164716-3bd946c2227d h1:XCAqfdZLlkxMSFecf5mEQncKZri+fFBIPAbpq1K0+wI=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230701164716-3bd946c2227d/go.mod h1:iR6kmFYS3jz/yuDFg6atb0yZdDs2RvS5gf3NzTL4frI=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b h1:828lTUW2C0uNiolODqoACu7J8sDUzswD4Xo04mUombg=
|
||||
|
|
|
@ -229,6 +229,30 @@ func (tx *Transaction) doSortAttrViewRow(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColumnHidden(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColHidden(operation.Data.(bool), operation.ID, operation.ParentID)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.ParentID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColumnWrap(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColWrap(operation.Data.(bool), operation.ID, operation.ParentID)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.ParentID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColumnWidth(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColWidth(operation.Data.(string), operation.ID, operation.ParentID)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.ParentID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func addAttributeViewColumn(name string, typ string, avID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
|
@ -367,6 +391,57 @@ func sortAttributeViewRow(rowID, previousRowID, avID string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func setAttributeViewColHidden(hidden bool, columnID, avID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for _, column := range attrView.Columns {
|
||||
if column.ID == columnID {
|
||||
column.Hidden = hidden
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func setAttributeViewColWrap(wrap bool, columnID, avID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for _, column := range attrView.Columns {
|
||||
if column.ID == columnID {
|
||||
column.Wrap = wrap
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func setAttributeViewColWidth(width, columnID, avID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for _, column := range attrView.Columns {
|
||||
if column.ID == columnID {
|
||||
column.Width = width
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func removeAttributeViewBlock(blockID, avID string) (ret *av.AttributeView, err error) {
|
||||
ret, err = av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
|
|
|
@ -232,6 +232,12 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doUpdateAttrViewCell(op)
|
||||
case "sortAttrViewRow":
|
||||
ret = tx.doSortAttrViewRow(op)
|
||||
case "setAttrViewColHidden":
|
||||
ret = tx.doSetAttrViewColumnHidden(op)
|
||||
case "setAttrViewColWrap":
|
||||
ret = tx.doSetAttrViewColumnWrap(op)
|
||||
case "setAttrViewColWidth":
|
||||
ret = tx.doSetAttrViewColumnWidth(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
Loading…
Add table
Reference in a new issue