mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +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
|
||||
}
|
||||
|
||||
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) {
|
||||
err := addAttributeViewColumn(operation.Name, operation.Typ, operation.ParentID)
|
||||
if nil != err {
|
||||
|
|
@ -291,6 +299,32 @@ func updateAttributeViewColumn(id, name string, typ string, avID string) (err er
|
|||
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) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue