mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Add select type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8694
This commit is contained in:
parent
b85d6e97cf
commit
2a8de9733e
2 changed files with 36 additions and 0 deletions
|
|
@ -167,6 +167,14 @@ func (tx *Transaction) doRemoveAttrViewBlock(operation *Operation) (ret *TxErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) doUpdateAttrViewColOptions(operation *Operation) (ret *TxErr) {
|
||||||
|
err := updateAttributeViewColumnOptions(operation.Data, operation.ID, operation.ParentID)
|
||||||
|
if nil != err {
|
||||||
|
return &TxErr{code: TxErrWriteAttributeView, id: operation.ParentID, msg: err.Error()}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doAddAttrViewColumn(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doAddAttrViewColumn(operation *Operation) (ret *TxErr) {
|
||||||
err := addAttributeViewColumn(operation.Name, operation.Typ, operation.ParentID)
|
err := addAttributeViewColumn(operation.Name, operation.Typ, operation.ParentID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
@ -291,6 +299,32 @@ func updateAttributeViewColumn(id, name string, typ string, avID string) (err er
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateAttributeViewColumnOptions(data interface{}, id, avID string) (err error) {
|
||||||
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonData, err := gulu.JSON.MarshalJSON(data)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
options := []*av.ColumnSelectOption{}
|
||||||
|
if err = gulu.JSON.UnmarshalJSON(jsonData, &options); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, col := range attrView.Columns {
|
||||||
|
if col.ID == id {
|
||||||
|
col.Options = options
|
||||||
|
err = av.SaveAttributeView(attrView)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func removeAttributeViewColumn(columnID string, avID string) (err error) {
|
func removeAttributeViewColumn(columnID string, avID string) (err error) {
|
||||||
attrView, err := av.ParseAttributeView(avID)
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
ret = tx.doSetAttrViewColumnWidth(op)
|
ret = tx.doSetAttrViewColumnWidth(op)
|
||||||
case "setAttrView":
|
case "setAttrView":
|
||||||
ret = tx.doSetAttrView(op)
|
ret = tx.doSetAttrView(op)
|
||||||
|
case "updateAttrViewColOptions":
|
||||||
|
ret = tx.doUpdateAttrViewColOptions(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != ret {
|
if nil != ret {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue