🎨 Update av

This commit is contained in:
Daniel 2023-07-02 22:26:36 +08:00
parent 739bdc22b9
commit f31807a500
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 43 additions and 9 deletions

View file

@ -1,4 +1,8 @@
{
"hideCol": "Hide column",
"hideAll": "Hide all",
"showAll": "Show all",
"showCol": "Show column",
"number": "Number",
"date": "Date",
"select": "Select",

View file

@ -1,4 +1,8 @@
{
"hideCol": "Ocultar columna",
"hideAll": "Ocultar todo",
"showAll": "Mostrar todo",
"showCol": "Mostrar columna",
"número": "Número",
"fecha": "Fecha",
"seleccionar": "Seleccionar",

View file

@ -1,4 +1,8 @@
{
"hideCol": "Masquer la colonne",
"hideAll": "Masquer tout",
"showAll": "Afficher tout",
"showCol": "Afficher la colonne",
"numéro": "Numéro",
"date": "Date",
"select": "Sélectionner",

View file

@ -1,4 +1,8 @@
{
"hideCol": "隱藏列",
"hideAll": "隱藏全部",
"showAll": "顯示全部",
"showCol": "顯示列",
"number": "數字",
"date": "日期",
"select": "單選",

View file

@ -341,9 +341,7 @@ func sortAttributeViewColumn(columnID, previousColumnID, avID string) (err error
if column.ID == columnID {
col = column
index = i
}
if column.ID == previousColumnID {
previousIndex = i
break
}
}
if nil == col {
@ -351,12 +349,18 @@ func sortAttributeViewColumn(columnID, previousColumnID, avID string) (err error
}
attrView.Columns = append(attrView.Columns[:index], attrView.Columns[index+1:]...)
attrView.Columns = append(attrView.Columns[:previousIndex], append([]*av.Column{col}, attrView.Columns[previousIndex:]...)...)
for i, column := range attrView.Columns {
if column.ID == previousColumnID {
previousIndex = i + 1
break
}
}
attrView.Columns = insertElement(attrView.Columns, previousIndex, col)
for _, row := range attrView.Rows {
cel := row.Cells[index]
row.Cells = append(row.Cells[:index], row.Cells[index+1:]...)
row.Cells = append(row.Cells[:previousIndex], append([]*av.Cell{cel}, row.Cells[previousIndex:]...)...)
row.Cells = insertElement(row.Cells, previousIndex, cel)
}
err = av.SaveAttributeView(attrView)
@ -375,9 +379,7 @@ func sortAttributeViewRow(rowID, previousRowID, avID string) (err error) {
if r.ID == rowID {
row = r
index = i
}
if r.ID == previousRowID {
previousIndex = i
break
}
}
if nil == row {
@ -385,12 +387,28 @@ func sortAttributeViewRow(rowID, previousRowID, avID string) (err error) {
}
attrView.Rows = append(attrView.Rows[:index], attrView.Rows[index+1:]...)
attrView.Rows = append(attrView.Rows[:previousIndex], append([]*av.Row{row}, attrView.Rows[previousIndex:]...)...)
for i, r := range attrView.Rows {
if r.ID == previousRowID {
previousIndex = i + 1
break
}
}
attrView.Rows = insertElement(attrView.Rows, previousIndex, row)
err = av.SaveAttributeView(attrView)
return
}
// 0 <= index <= len(a)
func insertElement[T any](rows []T, index int, value T) []T {
if len(rows) == index { // nil or empty slice or after last element
return append(rows, value)
}
rows = append(rows[:index+1], rows[index:]...) // index < len(a)
rows[index] = value
return rows
}
func setAttributeViewColHidden(hidden bool, columnID, avID string) (err error) {
attrView, err := av.ParseAttributeView(avID)
if nil != err {