diff --git a/canto.yaml b/canto.yaml index 4094601c1..65973914e 100644 --- a/canto.yaml +++ b/canto.yaml @@ -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 diff --git a/root/static/js/canto-modules.js b/root/static/js/canto-modules.js index cf2d42f7b..ed10f5c4d 100644 --- a/root/static/js/canto-modules.js +++ b/root/static/js/canto-modules.js @@ -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; } diff --git a/root/static/js/canto.js b/root/static/js/canto.js index bf2ad8f6d..b06b2ee4d 100644 --- a/root/static/js/canto.js +++ b/root/static/js/canto.js @@ -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 = $('
');