@@ -4142,7 +4142,7 @@ function alleleQCCheckAllele($http, alleleQCUrl, geneSystematicId, alleleDescrip
4142
4142
}
4143
4143
4144
4144
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 ) {
4146
4146
$scope . alleleData = { } ;
4147
4147
copyObject ( args . allele , $scope . alleleData ) ;
4148
4148
$scope . taxonId = args . taxonId ;
@@ -4475,22 +4475,46 @@ var alleleEditDialogCtrl =
4475
4475
return ;
4476
4476
}
4477
4477
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 ) ;
4483
4498
}
4484
4499
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
+ } ) ;
4488
4512
} ) ;
4489
4513
}
4490
4514
} ;
4491
4515
4492
4516
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' ,
4494
4518
alleleEditDialogCtrl
4495
4519
] ) ;
4496
4520
0 commit comments