Bläddra i källkod

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 9 månader sedan
förälder
incheckning
f1b77a059d

+ 2 - 0
app/appearance/langs/de_DE.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Sind Sie sicher, dass Sie das Feld, das mit <b>${x}</b> 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",
   "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",
   "exportConf": "Export-Einstellungen",
   "exportConfTip": "Konto, Zugriffscode, Synchronisation, API-Token und Daten-Repo-Schlüssel werden nicht exportiert",
   "exportConfTip": "Konto, Zugriffscode, Synchronisation, API-Token und Daten-Repo-Schlüssel werden nicht exportiert",

+ 2 - 0
app/appearance/langs/en_US.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Are you sure you want to delete the field associated with <b>${x}</b>?",
+  "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",
   "exportPDFLowMemory": "Insufficient available memory to export this PDF, please reduce the content or increase available memory and try exporting again",
   "exportConf": "Export settings",
   "exportConf": "Export settings",
   "exportConfTip": "Account, access authorization code, synchronization, API token and data repo key will not be exported",
   "exportConfTip": "Account, access authorization code, synchronization, API token and data repo key will not be exported",

+ 2 - 0
app/appearance/langs/es_ES.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "¿Está seguro de que desea eliminar el campo asociado a <b>${x}</b>?",
+  "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",
   "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",
   "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",
   "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",

+ 2 - 0
app/appearance/langs/fr_FR.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Êtes-vous sûr de vouloir supprimer le champ associé à <b>${x}</b>?",
+  "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",
   "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",
   "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",
   "exportConfTip": "Les comptes, codes d'accès, synchronisation, tokens API et clés d'entrepôt de données ne seront pas exportés",

+ 2 - 0
app/appearance/langs/he_IL.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "האם אתה בטוח שברצונך למחוק את השדה המשויך ל-<b>${x}</b>?",
+  "removeButKeepRelationField": "מחק, שמור על שדה הקשר",
   "exportPDFLowMemory": "אין מספיק זיכרון זמין במערכת כדי לייצא את ה-PDF הזה, נא לצמצם את התוכן או להגדיל את הזיכרון הזמין ולנסות שוב לייצא",
   "exportPDFLowMemory": "אין מספיק זיכרון זמין במערכת כדי לייצא את ה-PDF הזה, נא לצמצם את התוכן או להגדיל את הזיכרון הזמין ולנסות שוב לייצא",
   "exportConf": "הגדרות ייצוא",
   "exportConf": "הגדרות ייצוא",
   "exportConfTip": "פרטי חשבון, קוד אישור גישה, סנכרון, אסימון API ומפתח מאגר נתונים לא ייוצאו",
   "exportConfTip": "פרטי חשבון, קוד אישור גישה, סנכרון, אסימון API ומפתח מאגר נתונים לא ייוצאו",

+ 2 - 0
app/appearance/langs/it_IT.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Sei sicuro di voler eliminare il campo associato a <b>${x}</b>?",
+  "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",
   "exportPDFLowMemory": "Memoria disponibile insufficiente per esportare questo PDF, riduci il contenuto o aumenta la memoria disponibile e riprova a esportare",
   "exportConf": "Impostazioni di esportazione",
   "exportConf": "Impostazioni di esportazione",
   "exportConfTip": "Account, codici di accesso, sincronizzazione, token API e chiavi di data warehouse non verranno esportati",
   "exportConfTip": "Account, codici di accesso, sincronizzazione, token API e chiavi di data warehouse non verranno esportati",

+ 2 - 0
app/appearance/langs/ja_JP.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "<b>${x}</b> に関連するフィールドを同時に削除してもよろしいですか?",
+  "removeButKeepRelationField": "削除して関連フィールドを保持",
   "exportPDFLowMemory": "システムの利用可能なメモリが不足しているため、このPDFをエクスポートできません。内容を減らすか、利用可能なメモリを増やしてから再試行してください",
   "exportPDFLowMemory": "システムの利用可能なメモリが不足しているため、このPDFをエクスポートできません。内容を減らすか、利用可能なメモリを増やしてから再試行してください",
   "exportConf": "設定のエクスポート",
   "exportConf": "設定のエクスポート",
   "exportConfTip": "アカウント、アクセス コード、同期、API トークン、データ ウェアハウス キーはエクスポートされません",
   "exportConfTip": "アカウント、アクセス コード、同期、API トークン、データ ウェアハウス キーはエクスポートされません",

+ 2 - 0
app/appearance/langs/pl_PL.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Czy na pewno chcesz usunąć pole powiązane z <b>${x}</b>?",
+  "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",
   "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",
   "exportConf": "Ustawienia eksportu",
   "exportConfTip": "Konto, kod autoryzacji dostępu, synchronizacja, token API i klucz repozytorium danych nie będą eksportowane",
   "exportConfTip": "Konto, kod autoryzacji dostępu, synchronizacja, token API i klucz repozytorium danych nie będą eksportowane",

+ 2 - 0
app/appearance/langs/ru_RU.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "Вы уверены, что хотите удалить поле, связанное с <b>${x}</b>?",
+  "removeButKeepRelationField": "Удалить, сохранить связанное поле",
   "exportPDFLowMemory": "Недостаточно доступной памяти для экспорта этого PDF, пожалуйста, уменьшите содержимое или увеличьте доступную память и повторите попытку экспорта",
   "exportPDFLowMemory": "Недостаточно доступной памяти для экспорта этого PDF, пожалуйста, уменьшите содержимое или увеличьте доступную память и повторите попытку экспорта",
   "exportConf": "Экспорт настроек",
   "exportConf": "Экспорт настроек",
   "exportConfTip": "Учетная запись, код авторизации доступа, синхронизация, API токен и ключ репозитория данных не будут экспортированы",
   "exportConfTip": "Учетная запись, код авторизации доступа, синхронизация, API токен и ключ репозитория данных не будут экспортированы",

+ 2 - 0
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "確定同時刪除關聯至 <b>${x}</b> 中的字段嗎?",
+  "removeButKeepRelationField": "刪除,保留關聯字段",
   "exportPDFLowMemory": "系統可用記憶體不足,無法導出該 PDF,請減少內容或者增加可用記憶體後再嘗試導出",
   "exportPDFLowMemory": "系統可用記憶體不足,無法導出該 PDF,請減少內容或者增加可用記憶體後再嘗試導出",
   "exportConf": "匯出設定",
   "exportConf": "匯出設定",
   "exportConfTip": "帳號、存取授權碼、同步、API token 和資料倉儲金鑰不會被匯出",
   "exportConfTip": "帳號、存取授權碼、同步、API token 和資料倉儲金鑰不會被匯出",

+ 2 - 0
app/appearance/langs/zh_CN.json

@@ -1,4 +1,6 @@
 {
 {
+  "confirmRemoveRelationField": "确定同时删除关联至 <b>${x}</b> 中的字段吗?",
+  "removeButKeepRelationField": "删除,保留关联字段",
   "exportPDFLowMemory": "系统可用内存不足,无法导出该 PDF,请减少内容或者增加可用内存后再尝试导出",
   "exportPDFLowMemory": "系统可用内存不足,无法导出该 PDF,请减少内容或者增加可用内存后再尝试导出",
   "exportConf": "导出设置",
   "exportConf": "导出设置",
   "exportConfTip": "账号、访问授权码、同步、API token 和数据仓库密钥不会被导出",
   "exportConfTip": "账号、访问授权码、同步、API token 和数据仓库密钥不会被导出",

+ 5 - 1
kernel/api/av.go

@@ -277,8 +277,12 @@ func removeAttributeViewKey(c *gin.Context) {
 
 
 	avID := arg["avID"].(string)
 	avID := arg["avID"].(string)
 	keyID := arg["keyID"].(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 {
 	if err != nil {
 		ret.Code = -1
 		ret.Code = -1
 		ret.Msg = err.Error()
 		ret.Msg = err.Error()

+ 34 - 34
kernel/model/attribute_view.go

@@ -2772,14 +2772,14 @@ func updateAttributeViewColumn(operation *Operation) (err error) {
 }
 }
 
 
 func (tx *Transaction) doRemoveAttrViewColumn(operation *Operation) (ret *TxErr) {
 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 {
 	if err != nil {
 		return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
 		return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
 	}
 	}
 	return
 	return
 }
 }
 
 
-func RemoveAttributeViewKey(avID, keyID string) (err error) {
+func RemoveAttributeViewKey(avID, keyID string, removeRelationDest bool) (err error) {
 	attrView, err := av.ParseAttributeView(avID)
 	attrView, err := av.ParseAttributeView(avID)
 	if err != nil {
 	if err != nil {
 		return
 		return
@@ -2796,47 +2796,47 @@ func RemoveAttributeViewKey(avID, keyID string) (err error) {
 
 
 	if nil != removedKey && av.KeyTypeRelation == removedKey.Type && nil != removedKey.Relation {
 	if nil != removedKey && av.KeyTypeRelation == removedKey.Type && nil != removedKey.Relation {
 		if removedKey.Relation.IsTwoWay {
 		if removedKey.Relation.IsTwoWay {
-			// 删除双向关联的目标列
-
-			var destAv *av.AttributeView
-			if avID == removedKey.Relation.AvID {
-				destAv = attrView
-			} else {
-				destAv, _ = av.ParseAttributeView(removedKey.Relation.AvID)
-			}
+			if removeRelationDest { // 删除双向关联的目标列
+				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 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 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
+					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)
+					}
 				}
 				}
 			}
 			}
 
 

+ 1 - 0
kernel/model/transaction.go

@@ -1415,6 +1415,7 @@ type Operation struct {
 	RowID               string                   `json:"rowID"`             // 属性视图行 ID
 	RowID               string                   `json:"rowID"`             // 属性视图行 ID
 	IsTwoWay            bool                     `json:"isTwoWay"`          // 属性视图关联列是否是双向关系
 	IsTwoWay            bool                     `json:"isTwoWay"`          // 属性视图关联列是否是双向关系
 	BackRelationKeyID   string                   `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID
 	BackRelationKeyID   string                   `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID
+	RemoveDest          bool                     `json:"removeDest"`        // 属性视图删除关联目标
 }
 }
 
 
 type Transaction struct {
 type Transaction struct {

+ 3 - 2
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/247
 	// https://github.com/siyuan-note/siyuan/issues/3813
 	// https://github.com/siyuan-note/siyuan/issues/3813
 	mime.AddExtensionType(".css", "text/css")
 	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(".html", "text/html")
+	mime.AddExtensionType(".json", "application/json")
 
 
 	// 某些系统上下载资源文件后打开是 zip https://github.com/siyuan-note/siyuan/issues/6347
 	// 某些系统上下载资源文件后打开是 zip https://github.com/siyuan-note/siyuan/issues/6347
 	mime.AddExtensionType(".doc", "application/msword")
 	mime.AddExtensionType(".doc", "application/msword")