From 643f91c18b493b4a778cf8e0ecff355641a339f3 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 14 Dec 2021 19:28:53 -0800 Subject: [PATCH] Fix depth copy issue. Update welcome.xml map. --- .../components/commands/AddTopicCommand.js | 2 +- .../src/components/commands/DeleteCommand.js | 8 +- .../src/components/model/NodeModel.js | 4 +- .../map-render/samples/img-support.xml | 48 ++++++++++ .../playground/map-render/samples/welcome.xml | 94 ++++++++++++------- 5 files changed, 113 insertions(+), 43 deletions(-) create mode 100644 packages/mindplot/test/playground/map-render/samples/img-support.xml diff --git a/packages/mindplot/src/components/commands/AddTopicCommand.js b/packages/mindplot/src/components/commands/AddTopicCommand.js index b20060c2..916d6d9c 100644 --- a/packages/mindplot/src/components/commands/AddTopicCommand.js +++ b/packages/mindplot/src/components/commands/AddTopicCommand.js @@ -75,7 +75,7 @@ class AddTopicCommand extends Command { // Delete disconnected the nodes. Create a copy of the topics ... const clonedModel = []; this._models.forEach((model) => { - clonedModel.push({ ...model }); + clonedModel.push(model.clone()); }); // Finally, remove the nodes ... diff --git a/packages/mindplot/src/components/commands/DeleteCommand.js b/packages/mindplot/src/components/commands/DeleteCommand.js index d0b03ff6..4164a296 100644 --- a/packages/mindplot/src/components/commands/DeleteCommand.js +++ b/packages/mindplot/src/components/commands/DeleteCommand.js @@ -53,14 +53,14 @@ class DeleteCommand extends Command { // Delete relationships const relationships = this._collectInDepthRelationships(topic); - this._deletedRelModel.append(relationships.map((rel) => ({ ...rel.getModel() }))); + this._deletedRelModel = this._deletedRelModel.concat(relationships.map((rel) => rel.getModel().clone())); relationships.forEach((relationship) => { commandContext.deleteRelationship(relationship); }); // Store information for undo ... - const clonedModel = { ...model }; + const clonedModel = model.clone(); this._deletedTopicModels.push(clonedModel); const outTopic = topic.getOutgoingConnectedTopic(); let outTopicId = null; @@ -77,7 +77,7 @@ class DeleteCommand extends Command { const rels = commandContext.findRelationships(this._relIds); if (rels.length > 0) { rels.forEach(((rel) => { - this._deletedRelModel.push({ ...rel.getModel() }); + this._deletedRelModel.push(rel.getModel().clone()); commandContext.deleteRelationship(rel); })); } @@ -156,7 +156,7 @@ class DeleteCommand extends Command { const children = topic.getChildren(); const rels = children.map(((t) => this._collectInDepthRelationships(t))); - result.append(rels.flatten()); + result = result.concat(rels.flat()); if (result.length > 0) { // Filter for unique ... diff --git a/packages/mindplot/src/components/model/NodeModel.js b/packages/mindplot/src/components/model/NodeModel.js index 815ddd46..286c90c6 100644 --- a/packages/mindplot/src/components/model/NodeModel.js +++ b/packages/mindplot/src/components/model/NodeModel.js @@ -128,8 +128,8 @@ class NodeModel extends INodeModel { return cnode; }); - result._properties = Object.clone(this._properties); - result._feature = this._feature.clone(); + result._properties = { ...this._properties }; + result._feature = { ...this._feature }; return result; } diff --git a/packages/mindplot/test/playground/map-render/samples/img-support.xml b/packages/mindplot/test/playground/map-render/samples/img-support.xml new file mode 100644 index 00000000..cac5906b --- /dev/null +++ b/packages/mindplot/test/playground/map-render/samples/img-support.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/mindplot/test/playground/map-render/samples/welcome.xml b/packages/mindplot/test/playground/map-render/samples/welcome.xml index cac5906b..f945987c 100644 --- a/packages/mindplot/test/playground/map-render/samples/welcome.xml +++ b/packages/mindplot/test/playground/map-render/samples/welcome.xml @@ -1,48 +1,70 @@ - - - - - - + + + + + + + - - - - + + + + + - - - + - - - - - - - - - - + + + - - - - - - + + + + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file