Skip to content

Commit

Permalink
🎨 Database table view supports inserting columns in the middle #9993
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 29, 2023
1 parent 1c71839 commit 76433c0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1880,10 +1880,25 @@ func addAttributeViewColumn(operation *Operation) (err error) {
key := av.NewKey(operation.ID, operation.Name, icon, keyType)
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})

for _, v := range attrView.Views {
switch v.LayoutType {
for _, view := range attrView.Views {
switch view.LayoutType {
case av.LayoutTypeTable:
v.Table.Columns = append(v.Table.Columns, &av.ViewTableColumn{ID: key.ID})
if "" == operation.PreviousID {
view.Table.Columns = append([]*av.ViewTableColumn{{ID: key.ID}}, view.Table.Columns...)
break
}

added := false
for i, column := range view.Table.Columns {
if column.ID == operation.PreviousID {
view.Table.Columns = append(view.Table.Columns[:i+1], append([]*av.ViewTableColumn{{ID: key.ID}}, view.Table.Columns[i+1:]...)...)
added = true
break
}
}
if !added {
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{ID: key.ID})
}
}
}
}
Expand Down

0 comments on commit 76433c0

Please sign in to comment.