Skip to content

Commit

Permalink
Prevent annotations from vanishing when toggling or canceling #1321 (#…
Browse files Browse the repository at this point in the history
…1359)

* Prevent annotations from vanishing when toggling or canceling #1321

Before, upon creating n>=2 analysis area annotations, two scenarios
caused a shape to vanish from the canvas (but not from the sidebar).

1 - Click twice on feature 1 to get edit controls. Deselect it.
Result: feature 1 disappears

2 - With feature 2 selected, click Cancel.
Result: feature 2 disappears

* Remove wide catch re #1321

During development this wide catch was swallowing
JS errors rather than hypothetical server errors, failing
with `response.json is not a function`.
  • Loading branch information
jacobtylerwalls authored Oct 24, 2023
1 parent b5fa941 commit 7d8da5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ define([

var unaddedSelectedAnalysisAreaInstanceFeatures = self.selectedAnalysisAreaInstanceFeatures().reduce(function(acc, feature) {
if (!physicalThingAnnotationNodeAnnotationIds.includes(ko.unwrap(feature.id)) &&
feature.properties.canvas === self.canvas) {
ko.unwrap(feature.properties.canvas) === ko.unwrap(self.canvas)) {
feature.properties.tileId = self.selectedAnalysisAreaInstance().tileid;
acc.push(ko.toJS(feature));
}
Expand Down Expand Up @@ -424,8 +424,13 @@ define([
if(response.ok){
return;
}

throw response;
response.json().then(function(error){
params.pageVm.alert(new params.form.AlertViewModel(
"ep-alert-red",
error.title,
error.message,
));
});
}).then(function(data){
parentPhysicalThing.data[physicalThingPartAnnotationNodeId].features().forEach(function(feature){
self.deleteFeature(feature);
Expand All @@ -434,14 +439,6 @@ define([
self.card.tiles.remove(parentPhysicalThing);
self.selectAnalysisAreaInstance(undefined);
self.resetAnalysisAreasTile();
}).catch((response) => {
response.json().then(function(error){
params.pageVm.alert(new params.form.AlertViewModel(
"ep-alert-red",
error.title,
error.message,
));
});
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ define([

var unaddedSelectedSampleLocationInstanceFeatures = self.selectedSampleLocationInstanceFeatures().reduce(function(acc, feature) {
if (!physicalThingAnnotationNodeAnnotationIds.includes(ko.unwrap(feature.id)) &&
feature.properties.canvas === self.canvas) {
ko.unwrap(feature.properties.canvas) === ko.unwrap(self.canvas)) {
feature.properties.tileId = self.selectedSampleLocationInstance().tileid;
acc.push(ko.toJS(feature));
}
Expand Down Expand Up @@ -534,8 +534,13 @@ define([
if(response.ok){
return;
}

throw response;
response.json().then(function(error){
params.pageVm.alert(new params.form.AlertViewModel(
"ep-alert-red",
error.title,
error.message,
));
});
})
.then(function(data){
selectedSampleLocationInstance.data[physicalThingPartAnnotationNodeId].features().forEach(function(feature){
Expand All @@ -545,15 +550,6 @@ define([
self.card.tiles.remove(selectedSampleLocationInstance);
self.selectSampleLocationInstance(undefined);
self.resetSampleLocationTile();
})
.catch((response) => {
response.json().then(function(error){
params.pageVm.alert(new params.form.AlertViewModel(
"ep-alert-red",
error.title,
error.message,
));
});
});
}

Expand Down

0 comments on commit 7d8da5b

Please sign in to comment.