Skip to content

Commit 83454e0

Browse files
committed
Lookup alleles when selecting deletion or WT
If the user selects deletion or wild type in the allele edit dialog, lookup existing alleles in Chado. Refs #2758
1 parent 72fa32c commit 83454e0

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

root/static/js/canto-modules.js

+34-10
Original file line numberDiff line numberDiff line change
@@ -4142,7 +4142,7 @@ function alleleQCCheckAllele($http, alleleQCUrl, geneSystematicId, alleleDescrip
41424142
}
41434143

41444144
var alleleEditDialogCtrl =
4145-
function ($scope, $uibModal, $uibModalInstance, $http, $q, toaster, CantoConfig, args, Curs, CantoGlobals) {
4145+
function ($scope, $uibModal, $uibModalInstance, $http, $q, toaster, CantoConfig, args, Curs, CantoGlobals, CursAlleleList) {
41464146
$scope.alleleData = {};
41474147
copyObject(args.allele, $scope.alleleData);
41484148
$scope.taxonId = args.taxonId;
@@ -4475,22 +4475,46 @@ var alleleEditDialogCtrl =
44754475
return;
44764476
}
44774477

4478-
if ($scope.name_autopopulated) {
4479-
if ($scope.name_autopopulated == $scope.alleleData.name) {
4480-
$scope.alleleData.name = '';
4481-
}
4482-
$scope.name_autopopulated = '';
4478+
var promise;
4479+
4480+
if (newType === 'deletion' || newType === 'wild type') {
4481+
var lookupPromise =
4482+
CursAlleleList.alleleLookupByDetails($scope.alleleData.gene_systematic_id,
4483+
'deletion', 'deletion');
4484+
4485+
promise = lookupPromise.then(existingAlleles => {
4486+
var externalUniquename;
4487+
if (existingAlleles.length > 0) {
4488+
var alleleFromLookup = existingAlleles[0];
4489+
$scope.alleleData.external_uniquename = alleleFromLookup.allele_uniquename;
4490+
$scope.alleleData.name = alleleFromLookup.name;
4491+
$scope.alleleData.description = alleleFromLookup.description;
4492+
$scope.alleleData.type = alleleFromLookup.type;
4493+
$scope.alleleData.synonyms = alleleFromLookup.synonyms;
4494+
}
4495+
});
4496+
} else {
4497+
promise = $q.when(null);
44834498
}
44844499

4485-
$scope.name_autopopulated = $scope.maybe_autopopulate();
4486-
$scope.alleleData.description = '';
4487-
$scope.alleleData.expression = '';
4500+
promise.then(function() {
4501+
if ($scope.name_autopopulated) {
4502+
if ($scope.name_autopopulated == $scope.alleleData.name) {
4503+
$scope.alleleData.name = '';
4504+
}
4505+
$scope.name_autopopulated = '';
4506+
}
4507+
4508+
$scope.name_autopopulated = $scope.maybe_autopopulate();
4509+
$scope.alleleData.description = '';
4510+
$scope.alleleData.expression = '';
4511+
});
44884512
});
44894513
}
44904514
};
44914515

44924516
canto.controller('AlleleEditDialogCtrl',
4493-
['$scope', '$uibModal', '$uibModalInstance', '$http', '$q', 'toaster', 'CantoConfig', 'args', 'Curs', 'CantoGlobals',
4517+
['$scope', '$uibModal', '$uibModalInstance', '$http', '$q', 'toaster', 'CantoConfig', 'args', 'Curs', 'CantoGlobals', 'CursAlleleList',
44944518
alleleEditDialogCtrl
44954519
]);
44964520

0 commit comments

Comments
 (0)