Skip to content

Commit

Permalink
Clear the modification residue if gene changes
Browse files Browse the repository at this point in the history
In the annotation edit dialog

Refs #2803
  • Loading branch information
kimrutherford committed Mar 14, 2024
1 parent 8a32c63 commit 32642e5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions canto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,8 @@ available_annotation_type_list:
evidence_codes:
- IDA
detailed_help_path: /docs/modification_annotation
clear_extensions_on_feature_change:
- residue
- name: wt_rna_expression
category: ontology
ontology_size: small
Expand Down
26 changes: 25 additions & 1 deletion root/static/js/canto-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8612,11 +8612,35 @@ var annotationEditDialogCtrl =

}

function featureIdWatcher(featureId) {
function featureIdWatcher(featureId, prevFeatureId) {
$q.all([$scope.annotationTypePromise, $scope.filteredFeaturesPromise])
.then(function (data) {
var annotationType = data[0];

if (annotationType.clear_extensions_on_feature_change &&
$scope.annotation.extension &&
prevFeatureId !== undefined && featureId !== undefined &&
prevFeatureId !== featureId) {
$.map($scope.annotation.extension,
(orPart) => {
orPart.removeIf((ext) => {
if ($.grep(annotationType.clear_extensions_on_feature_change,
(rel) => rel == ext.relation)) {
toaster.pop({
type: 'warning',
title: 'The ' + ext.relation + '(' + ext.rangeValue +
') extension has been removed because the gene changed',
timeout: 10000,
showCloseButton: true
});
return true;
} else {
return false;
}
});
});
}

if (annotationType.second_feature_organism_selector) {
return;
}
Expand Down
9 changes: 9 additions & 0 deletions root/static/js/canto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ function trim(a) {
a=a.replace(/^\s+/,''); return a.replace(/\s+$/,'');
}

Array.prototype.removeIf = function(callback) {
var i = this.length;
while (i--) {
if (callback(this[i], i)) {
this.splice(i, 1);
}
}
};

var loadingDiv = $('<div id="loading" style="z-index: 2000;"><img src="' + application_root +
'/static/images/spinner.gif"/></div>');

Expand Down

0 comments on commit 32642e5

Please sign in to comment.