Skip to content

Commit

Permalink
Warn before editing genotype in an interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Mar 26, 2024
1 parent 1a5a739 commit 5ba3c2a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
45 changes: 33 additions & 12 deletions root/static/js/canto-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ var simpleDialogCtrl =
$scope.message = args.message;

$scope.close = function () {
$uibModalInstance.dismiss('close');
$uibModalInstance.close('closed');
};
};

Expand Down Expand Up @@ -10311,7 +10311,7 @@ var annotationTableRow =
$scope.annotation.feature_type === 'metagenotype'
);

$scope.disableEditing = function(annotation) {
$scope.disableDeletion = function(annotation) {
return annotation.used_in_interactions_count > 0;
};

Expand Down Expand Up @@ -10459,17 +10459,38 @@ var annotationTableRow =

$scope.edit = function () {
// FIXME: featureFilterDisplayName is from the parent scope
var editPromise =
startEditing($uibModal, annotation.annotation_type, $scope.annotation,
$scope.featureFilterDisplayName, false, true);

editPromise.then(function (editedAnnotation) {
$scope.annotation = editedAnnotation;
$scope.updateInteractionInitialData();
if (typeof ($scope.annotation.conditions) !== 'undefined') {
$scope.annotation.conditionsString =
conditionsToStringHighlightNew($scope.annotation.conditions);

var warningPromise;
if (annotation.used_in_interactions_count > 0) {
var message;
if (annotation.used_in_interactions_count > 1) {
message = 'Note: Edits to this annotation will also change ' +
annotation.used_in_interactions_count + ' interactions';
} else {
message = 'Note: Edits to this annotation will also change an interaction';
}
warningPromise =
openSimpleDialog($uibModal, 'Annotation edit warning',
'Annotation edit warning', message)
.result;
} else {
// immediately resolve
warningPromise = $q.when(null);
}

warningPromise.then(() => {
var editPromise =
startEditing($uibModal, annotation.annotation_type, $scope.annotation,
$scope.featureFilterDisplayName, false, true);

editPromise.then(function (editedAnnotation) {
$scope.annotation = editedAnnotation;
$scope.updateInteractionInitialData();
if (typeof ($scope.annotation.conditions) !== 'undefined') {
$scope.annotation.conditionsString =
conditionsToStringHighlightNew($scope.annotation.conditions);
}
});
});
};

Expand Down
10 changes: 3 additions & 7 deletions root/static/ng_templates/annotation_table_ontology_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@
</div>
<div ng-if="showEditLink">
<a title="Edit this annotation"
ng-if="!disableEditing(annotation)"
ng-click="edit()">Edit</a>
<span style="color: #c0c0c0"
title='Annotation cannot be edited because it is part of an interaction. Remove the interaction or try "Copy and edit"';
ng-if="disableEditing(annotation)">Edit</span>
</div>
<div ng-if="showTransferLink">
<a title="{{'Copy this annotation to other ' + annotationType.feature_type + 's'}}"
Expand All @@ -174,11 +170,11 @@
</div>
<div>
<a title="Delete this annotation"
ng-if="!disableEditing(annotation)"
ng-if="!disableDeletion(annotation)"
ng-click="confirmDelete()">Delete</a>
<span style="color: #c0c0c0"
title="Annotation cannot be deleted because it is part of an interaction"
ng-if="disableEditing(annotation)">Delete</span>
title="Annotation cannot be deleted because it is part of one or more interactions"
ng-if="disableDeletion(annotation)">Delete</span>
</div>
<div ng-if="sessionState == 'APPROVAL_IN_PROGRESS'">
<a ng-if="checked == 'no'" href="#" ng-click="setChecked($event)">Checked</a>
Expand Down

0 comments on commit 5ba3c2a

Please sign in to comment.