mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
♻️ Refactor av data structure
This commit is contained in:
parent
cb73513941
commit
36f7083529
3 changed files with 32 additions and 32 deletions
|
|
@ -44,9 +44,9 @@ func RenderAttributeView(avID string) (viewable av.Viewable, attrView *av.Attrib
|
|||
}
|
||||
|
||||
var view *av.View
|
||||
if "" != attrView.CurrentViewID {
|
||||
if "" != attrView.ViewID {
|
||||
for _, v := range attrView.Views {
|
||||
if v.ID == attrView.CurrentViewID {
|
||||
if v.ID == attrView.ViewID {
|
||||
view = v
|
||||
break
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ func RenderAttributeView(avID string) (viewable av.Viewable, attrView *av.Attrib
|
|||
view = attrView.Views[0]
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
viewable, err = renderAttributeViewTable(attrView, view)
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ func setAttributeViewFilters(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &view.Table.Filters); nil != err {
|
||||
return
|
||||
|
|
@ -221,7 +221,7 @@ func setAttributeViewSorts(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &view.Table.Sorts); nil != err {
|
||||
return
|
||||
|
|
@ -311,7 +311,7 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
if "" != operation.PreviousID {
|
||||
for i, id := range view.Table.RowIDs {
|
||||
|
|
@ -375,7 +375,7 @@ func setAttributeViewColWidth(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
if column.ID == operation.ID {
|
||||
|
|
@ -408,7 +408,7 @@ func setAttributeViewColWrap(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
if column.ID == operation.ID {
|
||||
|
|
@ -441,7 +441,7 @@ func setAttributeViewColHidden(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
if column.ID == operation.ID {
|
||||
|
|
@ -487,7 +487,7 @@ func sortAttributeViewRow(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
view.Table.RowIDs = append(view.Table.RowIDs[:index], view.Table.RowIDs[index+1:]...)
|
||||
for i, r := range view.Table.RowIDs {
|
||||
|
|
@ -522,7 +522,7 @@ func sortAttributeViewColumn(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
var col *av.ViewTableColumn
|
||||
var index, previousIndex int
|
||||
|
|
@ -576,7 +576,7 @@ func addAttributeViewColumn(operation *Operation) (err error) {
|
|||
key := av.NewKey(operation.Name, keyType)
|
||||
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})
|
||||
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{ID: key.ID})
|
||||
}
|
||||
|
|
@ -638,7 +638,7 @@ func removeAttributeViewColumn(operation *Operation) (err error) {
|
|||
}
|
||||
|
||||
for _, view := range attrView.Views {
|
||||
switch view.CurrentLayoutType {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for i, column := range view.Table.Columns {
|
||||
if column.ID == operation.ID {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue