Skip to content

Commit

Permalink
#366 Don't copy uuid on layer clone
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Apr 24, 2023
1 parent a27b388 commit 36c5dbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 11 additions & 2 deletions API/Backend/Config/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const validateStructure = (config) => {
const validateLayers = (config) => {
let errs = [];

let existingUUIDs = [];
Utils.traverseLayers(config.layers, (layer) => {
// Check layer name
const validNameErrs = isValidLayerName(layer.name);
Expand Down Expand Up @@ -90,9 +91,17 @@ const validateLayers = (config) => {
err(`Unknown layer type: '${layer.type}'`, ["layers[layer].type"])
);
}
});

errs = errs.concat(hasNonHeaderWithSublayers(config));
if (layer.uuid != null) {
if (existingUUIDs.includes(layer.uuid)) {
errs = errs.concat([
err(
`Found a layer with duplicate uuid: ${layer.name} - ${layer.uuid}`
),
]);
} else existingUUIDs.push(layer.uuid);
}
});

return errs;
};
Expand Down
7 changes: 3 additions & 4 deletions config/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,9 @@ function mmgisLinkModalsToLayersCloneClick(e) {
var mainThis = $(this).parent().parent().parent().parent();
var mainId = mainThis.attr("id");
mainId = mainId.substring(mainId.indexOf("_") + 1);
makeLayerBarAndModal(
dataOfLastUsedLayerSlot[mainId],
dataOfLastUsedLayerSlot[mainId].__level
);
const cloned = JSON.parse(JSON.stringify(dataOfLastUsedLayerSlot[mainId]));
delete cloned.uuid;
makeLayerBarAndModal(cloned, cloned.__level);

refresh();
}
Expand Down

0 comments on commit 36c5dbc

Please sign in to comment.