Skip to content

Commit

Permalink
Wrong UUID when undo/redo (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenjohanson authored Dec 19, 2024
1 parent 307fcfb commit a95b422
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 17 deletions.
16 changes: 8 additions & 8 deletions teammapper-backend/src/map/utils/clientServerMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ const mapClientNodeToMmpNode = (
mapId: string
): Partial<MmpNode> => ({
id: clientNode.id,
colorsBackground: clientNode.colors.background,
colorsBranch: clientNode.colors.branch,
colorsName: clientNode.colors.name,
coordinatesX: clientNode.coordinates.x,
coordinatesY: clientNode.coordinates.y,
fontSize: clientNode.font.size,
fontStyle: clientNode.font.style,
fontWeight: clientNode.font.weight,
colorsBackground: clientNode.colors?.background,
colorsBranch: clientNode.colors?.branch,
colorsName: clientNode.colors?.name,
coordinatesX: clientNode.coordinates?.x,
coordinatesY: clientNode.coordinates?.y,
fontSize: clientNode.font?.size,
fontStyle: clientNode.font?.style,
fontWeight: clientNode.font?.weight,
imageSrc: clientNode.image?.src,
imageSize: clientNode.image?.size,
k: clientNode.k,
Expand Down
13 changes: 12 additions & 1 deletion teammapper-frontend/src/app/core/services/mmp/mmp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '@mmp/map/types';
import { COLORS, EMPTY_IMAGE_DATA } from './mmp-utils';
import { CachedMapOptions } from 'src/app/shared/models/cached-map.model';
import { validate as uuidValidate } from 'uuid';

/**
* Mmp wrapper service with mmp and other functions.
Expand Down Expand Up @@ -86,7 +87,17 @@ export class MmpService implements OnDestroy {
/**
* Clear or load an existing mind mmp.
*/
public new(map?: MapSnapshot, notifyWithEvent = true) {
public async new(map?: MapSnapshot, notifyWithEvent = true) {
const hasInvalidUUID = map.some(node => !uuidValidate(node.id));

if (hasInvalidUUID) {
const importErrorMessage = await this.utilsService.translate(
'TOASTS.ERRORS.IMPORT_ERROR'
);
this.toastrService.error(importErrorMessage);
return;
}

const mapWithCoordinates =
this.currentMap.instance.applyCoordinatesToMapSnapshot(map);
this.currentMap.instance.new(mapWithCoordinates, notifyWithEvent);
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@
"NODE_COPY_GENERIC": "Beim Kopieren des Knotens ist ein Fehler aufgetreten.",
"NODE_CUT_GENERIC": "Beim Ausschneiden des Knotens ist ein Fehler aufgetreten.",
"EXPORT_IMAGE_ERROR": "Beim Bild-Export ist ein Fehler aufgetreten. Womöglich ist die Mindmap zu groß.",
"MAP_COULD_NOT_BE_FOUND": "Mindmap konnte nicht gefunden werden!"
"MAP_COULD_NOT_BE_FOUND": "Mindmap konnte nicht gefunden werden!",
"IMPORT_ERROR": "Mindmap konnte nicht importiert werden!"
},
"DELETE_MAP_SUCCESS": "Mindmap erfolgreich gelöscht!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "An error occurred whilst trying to copy the node.",
"NODE_CUT_GENERIC": "An error occurred whilst trying to cut the node.",
"EXPORT_IMAGE_ERROR": "An error has occurred during image export. The mind map may be too large.",
"MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!"
"MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!",
"IMPORT_ERROR": "Mindmap could not be imported!"
},
"DELETE_MAP_SUCCESS": "Mindmap successfully deleted!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "Se ha producido un error al intentar copiar el nodo.",
"NODE_CUT_GENERIC": "Se ha producido un error al intentar cortar el nodo.",
"EXPORT_IMAGE_ERROR": "Se ha producido un error durante la exportación de la imagen. El mapa mental puede ser demasiado grande.",
"MAP_COULD_NOT_BE_FOUND": "No se ha encontrado el mapa mental."
"MAP_COULD_NOT_BE_FOUND": "No se ha encontrado el mapa mental.",
"IMPORT_ERROR": "No se ha podido importar el mapa mental."
},
"DELETE_MAP_SUCCESS": "¡Mapa mental borrado con éxito!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "Une erreur s'est produite lors de la copie du nœud.",
"NODE_CUT_GENERIC": "Une erreur s'est produite lors de la découpe du nœud.",
"EXPORT_IMAGE_ERROR": "Une erreur s'est produite lors de l'exportation de l'image. Il se peut que la mind map soit trop grande.",
"MAP_COULD_NOT_BE_FOUND": "La carte heuristique est introuvable !"
"MAP_COULD_NOT_BE_FOUND": "La carte heuristique est introuvable !",
"IMPORT_ERROR": "La Mindmap n'a pas pu être importée !"
},
"DELETE_MAP_SUCCESS": "Mindmap supprimée avec succès !"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "Si è verificato un errore durante il tentativo di copiare il nodo.",
"NODE_CUT_GENERIC": "Si è verificato un errore durante il tentativo di tagliare il nodo.",
"EXPORT_IMAGE_ERROR": "Si è verificato un errore durante l'esportazione dell'immagine. La mappa mentale potrebbe essere troppo grande.",
"MAP_COULD_NOT_BE_FOUND": "Impossibile trovare la mappa mentale!"
"MAP_COULD_NOT_BE_FOUND": "Impossibile trovare la mappa mentale!",
"IMPORT_ERROR": "Non è stato possibile importare la mappa mentale!"
},
"DELETE_MAP_SUCCESS": "Mappa mentale cancellata con successo!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "Ocorreu um erro ao tentar copiar o nó.",
"NODE_CUT_GENERIC": "Ocorreu um erro ao tentar cortar o nó.",
"EXPORT_IMAGE_ERROR": "Ocorreu um erro durante a exportação da imagem. O mapa mental pode ser muito grande.",
"MAP_COULD_NOT_BE_FOUND": "Não foi possível encontrar o mapa mental!"
"MAP_COULD_NOT_BE_FOUND": "Não foi possível encontrar o mapa mental!",
"IMPORT_ERROR": "O mapa mental não pôde ser importado!"
},
"DELETE_MAP_SUCCESS": "Mapa mental excluído com sucesso!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "尝试复制节点时发生错误。",
"NODE_CUT_GENERIC": "在尝试切割节点时发生错误。",
"EXPORT_IMAGE_ERROR": "导出图像时发生错误。思维导图可能过大。",
"MAP_COULD_NOT_BE_FOUND": "找不到思维导图!"
"MAP_COULD_NOT_BE_FOUND": "找不到思维导图!",
"IMPORT_ERROR": "无法导入思维导图!"
},
"DELETE_MAP_SUCCESS": "思维导图已成功删除!"
},
Expand Down
3 changes: 2 additions & 1 deletion teammapper-frontend/src/assets/i18n/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
"NODE_COPY_GENERIC": "An error occurred whilst trying to copy the node.",
"NODE_CUT_GENERIC": "An error occurred whilst trying to cut the node.",
"EXPORT_IMAGE_ERROR": "An error has occurred during image export. The mind map may be too large.",
"MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!"
"MAP_COULD_NOT_BE_FOUND": "Mindmap could not be found!",
"IMPORT_ERROR": "Mindmap could not be imported!"
},
"DELETE_MAP_SUCCESS": "Mindmap successfully deleted!"
},
Expand Down

0 comments on commit a95b422

Please sign in to comment.