Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Update av

Danielf31807a50034
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 8c14839b16..808ac2a515 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,8 @@
{
+ "hideCol": "Hide column",
+ "hideAll": "Hide all",
+ "showAll": "Show all",
+ "showCol": "Show column",
"number": "Number",
"date": "Date",
"select": "Select",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 6cd9d0418f..ff8bd30110 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,8 @@
{
+ "hideCol": "Ocultar columna",
+ "hideAll": "Ocultar todo",
+ "showAll": "Mostrar todo",
+ "showCol": "Mostrar columna",
"número": "Número",
"fecha": "Fecha",
"seleccionar": "Seleccionar",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 54fd5a3961..98f686c336 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -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",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index ff5808f483..2de4bf41b5 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,8 @@
{
+ "hideCol": "隱藏列",
+ "hideAll": "隱藏全部",
+ "showAll": "顯示全部",
+ "showCol": "顯示列",
"number": "數字",
"date": "日期",
"select": "單選",
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index cea48ab60e..1911a590af 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -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 {