diff --git a/app/appearance/langs/de_DE.json b/app/appearance/langs/de_DE.json
index a7cc3f988..abeabda98 100644
--- a/app/appearance/langs/de_DE.json
+++ b/app/appearance/langs/de_DE.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Sind Sie sicher, dass Sie das Feld, das mit ${x} verknüpft ist, löschen möchten?",
+ "removeButKeepRelationField": "Entfernen, verknüpftes Feld behalten",
"exportPDFLowMemory": "Nicht genügend verfügbarer Speicher, um dieses PDF zu exportieren, bitte reduzieren Sie den Inhalt oder erhöhen Sie den verfügbaren Speicher und versuchen Sie es erneut",
"exportConf": "Export-Einstellungen",
"exportConfTip": "Konto, Zugriffscode, Synchronisation, API-Token und Daten-Repo-Schlüssel werden nicht exportiert",
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 4df3eb1f3..e605cd670 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Are you sure you want to delete the field associated with ${x}?",
+ "removeButKeepRelationField": "Remove, keep related field",
"exportPDFLowMemory": "Insufficient available memory to export this PDF, please reduce the content or increase available memory and try exporting again",
"exportConf": "Export settings",
"exportConfTip": "Account, access authorization code, synchronization, API token and data repo key will not be exported",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index abf943275..5a3c96cef 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "¿Está seguro de que desea eliminar el campo asociado a ${x}?",
+ "removeButKeepRelationField": "Eliminar, mantener el campo relacionado",
"exportPDFLowMemory": "Memoria disponible insuficiente para exportar este PDF, por favor reduzca el contenido o aumente la memoria disponible y vuelva a intentar exportar",
"exportConf": "Configuración de exportación",
"exportConfTip": "Las cuentas, los códigos de acceso, la sincronización, los tokens API y las claves del almacén de datos no se exportarán",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 2c594a956..0c48a6ead 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Êtes-vous sûr de vouloir supprimer le champ associé à ${x}?",
+ "removeButKeepRelationField": "Supprimer, conserver le champ associé",
"exportPDFLowMemory": "Mémoire disponible insuffisante pour exporter ce PDF, veuillez réduire le contenu ou augmenter la mémoire disponible et réessayer d'exporter",
"exportConf": "Exporter les paramètres",
"exportConfTip": "Les comptes, codes d'accès, synchronisation, tokens API et clés d'entrepôt de données ne seront pas exportés",
diff --git a/app/appearance/langs/he_IL.json b/app/appearance/langs/he_IL.json
index bbc3988f2..a9e5fbc3c 100644
--- a/app/appearance/langs/he_IL.json
+++ b/app/appearance/langs/he_IL.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "האם אתה בטוח שברצונך למחוק את השדה המשויך ל-${x}?",
+ "removeButKeepRelationField": "מחק, שמור על שדה הקשר",
"exportPDFLowMemory": "אין מספיק זיכרון זמין במערכת כדי לייצא את ה-PDF הזה, נא לצמצם את התוכן או להגדיל את הזיכרון הזמין ולנסות שוב לייצא",
"exportConf": "הגדרות ייצוא",
"exportConfTip": "פרטי חשבון, קוד אישור גישה, סנכרון, אסימון API ומפתח מאגר נתונים לא ייוצאו",
diff --git a/app/appearance/langs/it_IT.json b/app/appearance/langs/it_IT.json
index f679eb639..299199c9c 100644
--- a/app/appearance/langs/it_IT.json
+++ b/app/appearance/langs/it_IT.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Sei sicuro di voler eliminare il campo associato a ${x}?",
+ "removeButKeepRelationField": "Rimuovi, mantieni il campo correlato",
"exportPDFLowMemory": "Memoria disponibile insufficiente per esportare questo PDF, riduci il contenuto o aumenta la memoria disponibile e riprova a esportare",
"exportConf": "Impostazioni di esportazione",
"exportConfTip": "Account, codici di accesso, sincronizzazione, token API e chiavi di data warehouse non verranno esportati",
diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json
index edc6971e2..ee9f38b08 100644
--- a/app/appearance/langs/ja_JP.json
+++ b/app/appearance/langs/ja_JP.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "${x} に関連するフィールドを同時に削除してもよろしいですか?",
+ "removeButKeepRelationField": "削除して関連フィールドを保持",
"exportPDFLowMemory": "システムの利用可能なメモリが不足しているため、このPDFをエクスポートできません。内容を減らすか、利用可能なメモリを増やしてから再試行してください",
"exportConf": "設定のエクスポート",
"exportConfTip": "アカウント、アクセス コード、同期、API トークン、データ ウェアハウス キーはエクスポートされません",
diff --git a/app/appearance/langs/pl_PL.json b/app/appearance/langs/pl_PL.json
index 3f9f9ee2f..d87fab741 100644
--- a/app/appearance/langs/pl_PL.json
+++ b/app/appearance/langs/pl_PL.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Czy na pewno chcesz usunąć pole powiązane z ${x}?",
+ "removeButKeepRelationField": "Usuń, zachowaj powiązane pole",
"exportPDFLowMemory": "Za mało dostępnej pamięci, aby wyeksportować ten PDF, proszę zmniejszyć zawartość lub zwiększyć dostępną pamięć i spróbować ponownie",
"exportConf": "Ustawienia eksportu",
"exportConfTip": "Konto, kod autoryzacji dostępu, synchronizacja, token API i klucz repozytorium danych nie będą eksportowane",
diff --git a/app/appearance/langs/ru_RU.json b/app/appearance/langs/ru_RU.json
index 537152bc4..ae758962b 100644
--- a/app/appearance/langs/ru_RU.json
+++ b/app/appearance/langs/ru_RU.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "Вы уверены, что хотите удалить поле, связанное с ${x}?",
+ "removeButKeepRelationField": "Удалить, сохранить связанное поле",
"exportPDFLowMemory": "Недостаточно доступной памяти для экспорта этого PDF, пожалуйста, уменьшите содержимое или увеличьте доступную память и повторите попытку экспорта",
"exportConf": "Экспорт настроек",
"exportConfTip": "Учетная запись, код авторизации доступа, синхронизация, API токен и ключ репозитория данных не будут экспортированы",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 48e6811c7..89c5e2e82 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "確定同時刪除關聯至 ${x} 中的字段嗎?",
+ "removeButKeepRelationField": "刪除,保留關聯字段",
"exportPDFLowMemory": "系統可用記憶體不足,無法導出該 PDF,請減少內容或者增加可用記憶體後再嘗試導出",
"exportConf": "匯出設定",
"exportConfTip": "帳號、存取授權碼、同步、API token 和資料倉儲金鑰不會被匯出",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index df61432b3..eee1bed83 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,6 @@
{
+ "confirmRemoveRelationField": "确定同时删除关联至 ${x} 中的字段吗?",
+ "removeButKeepRelationField": "删除,保留关联字段",
"exportPDFLowMemory": "系统可用内存不足,无法导出该 PDF,请减少内容或者增加可用内存后再尝试导出",
"exportConf": "导出设置",
"exportConfTip": "账号、访问授权码、同步、API token 和数据仓库密钥不会被导出",
diff --git a/kernel/api/av.go b/kernel/api/av.go
index 08113560c..190aab120 100644
--- a/kernel/api/av.go
+++ b/kernel/api/av.go
@@ -277,8 +277,12 @@ func removeAttributeViewKey(c *gin.Context) {
avID := arg["avID"].(string)
keyID := arg["keyID"].(string)
+ removeRelationDest := false
+ if nil != arg["removeRelationDest"] {
+ removeRelationDest = arg["removeRelationDest"].(bool)
+ }
- err := model.RemoveAttributeViewKey(avID, keyID)
+ err := model.RemoveAttributeViewKey(avID, keyID, removeRelationDest)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 7231d5afc..13387a0df 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -2772,14 +2772,14 @@ func updateAttributeViewColumn(operation *Operation) (err error) {
}
func (tx *Transaction) doRemoveAttrViewColumn(operation *Operation) (ret *TxErr) {
- err := RemoveAttributeViewKey(operation.AvID, operation.ID)
+ err := RemoveAttributeViewKey(operation.AvID, operation.ID, operation.RemoveDest)
if err != nil {
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
}
return
}
-func RemoveAttributeViewKey(avID, keyID string) (err error) {
+func RemoveAttributeViewKey(avID, keyID string, removeRelationDest bool) (err error) {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
return
@@ -2796,47 +2796,47 @@ func RemoveAttributeViewKey(avID, keyID string) (err error) {
if nil != removedKey && av.KeyTypeRelation == removedKey.Type && nil != removedKey.Relation {
if removedKey.Relation.IsTwoWay {
- // 删除双向关联的目标列
-
- var destAv *av.AttributeView
- if avID == removedKey.Relation.AvID {
- destAv = attrView
- } else {
- destAv, _ = av.ParseAttributeView(removedKey.Relation.AvID)
- }
-
- if nil != destAv {
- destAvRelSrcAv := false
- for i, keyValues := range destAv.KeyValues {
- if keyValues.Key.ID == removedKey.Relation.BackKeyID {
- destAv.KeyValues = append(destAv.KeyValues[:i], destAv.KeyValues[i+1:]...)
- continue
- }
-
- if av.KeyTypeRelation == keyValues.Key.Type && keyValues.Key.Relation.AvID == attrView.ID {
- destAvRelSrcAv = true
- }
+ if removeRelationDest { // 删除双向关联的目标列
+ var destAv *av.AttributeView
+ if avID == removedKey.Relation.AvID {
+ destAv = attrView
+ } else {
+ destAv, _ = av.ParseAttributeView(removedKey.Relation.AvID)
}
- for _, view := range destAv.Views {
- switch view.LayoutType {
- case av.LayoutTypeTable:
- for i, column := range view.Table.Columns {
- if column.ID == removedKey.Relation.BackKeyID {
- view.Table.Columns = append(view.Table.Columns[:i], view.Table.Columns[i+1:]...)
- break
+ if nil != destAv {
+ destAvRelSrcAv := false
+ for i, keyValues := range destAv.KeyValues {
+ if keyValues.Key.ID == removedKey.Relation.BackKeyID {
+ destAv.KeyValues = append(destAv.KeyValues[:i], destAv.KeyValues[i+1:]...)
+ continue
+ }
+
+ if av.KeyTypeRelation == keyValues.Key.Type && keyValues.Key.Relation.AvID == attrView.ID {
+ destAvRelSrcAv = true
+ }
+ }
+
+ for _, view := range destAv.Views {
+ switch view.LayoutType {
+ case av.LayoutTypeTable:
+ for i, column := range view.Table.Columns {
+ if column.ID == removedKey.Relation.BackKeyID {
+ view.Table.Columns = append(view.Table.Columns[:i], view.Table.Columns[i+1:]...)
+ break
+ }
}
}
}
- }
- if destAv != attrView {
- av.SaveAttributeView(destAv)
- ReloadAttrView(destAv.ID)
- }
+ if destAv != attrView {
+ av.SaveAttributeView(destAv)
+ ReloadAttrView(destAv.ID)
+ }
- if !destAvRelSrcAv {
- av.RemoveAvRel(destAv.ID, attrView.ID)
+ if !destAvRelSrcAv {
+ av.RemoveAvRel(destAv.ID, attrView.ID)
+ }
}
}
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 19c05849e..c9f29da80 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1415,6 +1415,7 @@ type Operation struct {
RowID string `json:"rowID"` // 属性视图行 ID
IsTwoWay bool `json:"isTwoWay"` // 属性视图关联列是否是双向关系
BackRelationKeyID string `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID
+ RemoveDest bool `json:"removeDest"` // 属性视图删除关联目标
}
type Transaction struct {
diff --git a/kernel/util/working.go b/kernel/util/working.go
index 7ee81c031..c79278c1c 100644
--- a/kernel/util/working.go
+++ b/kernel/util/working.go
@@ -413,9 +413,10 @@ func initMime() {
// https://github.com/siyuan-note/siyuan/issues/247
// https://github.com/siyuan-note/siyuan/issues/3813
mime.AddExtensionType(".css", "text/css")
- mime.AddExtensionType(".js", "application/x-javascript")
- mime.AddExtensionType(".json", "application/json")
+ mime.AddExtensionType(".js", "text/javascript")
+ mime.AddExtensionType(".mjs", "text/javascript")
mime.AddExtensionType(".html", "text/html")
+ mime.AddExtensionType(".json", "application/json")
// 某些系统上下载资源文件后打开是 zip https://github.com/siyuan-note/siyuan/issues/6347
mime.AddExtensionType(".doc", "application/msword")