Skip to content

Commit

Permalink
Merge branch 'master' into issue-2758-disable-edits-for-existing-alleles
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Sep 1, 2023
2 parents c8b4e3c + 561012e commit 4a23edf
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 60 deletions.
13 changes: 12 additions & 1 deletion canto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ header_image: logos/curation_tool.png

canto_url: https://curation.pombase.org/

app_version: v1762
app_version: v1767

schema_version: 35

Expand Down Expand Up @@ -1488,6 +1488,7 @@ allele_type_list:
export_type: amino_acid_insertion
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1496,6 +1497,7 @@ allele_type_list:
export_type: amino_acid_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1504,6 +1506,7 @@ allele_type_list:
export_type: amino_acid_insertion_and_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1512,6 +1515,7 @@ allele_type_list:
export_type: amino_acid_insertion_and_deletion
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1520,6 +1524,7 @@ allele_type_list:
export_type: amino_acid_deletion_and_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1528,6 +1533,7 @@ allele_type_list:
export_type: partial_amino_acid_deletion
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1536,6 +1542,7 @@ allele_type_list:
export_type: nucleotide_insertion
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1544,6 +1551,7 @@ allele_type_list:
export_type: nucleotide_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1552,6 +1560,7 @@ allele_type_list:
export_type: partial_nucleotide_deletion
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1560,6 +1569,7 @@ allele_type_list:
export_type: nucleotide_deletion_and_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand All @@ -1568,6 +1578,7 @@ allele_type_list:
export_type: nucleotide_insertion_and_mutation
show_description: true
description_required: true
check_description_with_api: true
allele_name_required: true
allow_expression_change: true
expression_required: true
Expand Down
2 changes: 1 addition & 1 deletion root/curs/autohandler
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ my $annotation_type_config_js = Data::JavaScript::Anon->anon_dump($annotation_ty
my $multi_organism_mode = $st->{multi_organism_mode} || 0;
my $split_genotypes_by_organism = $st->{split_genotypes_by_organism} || 0;
my $annotation_figure_field = $st->{annotation_figure_field} || 0;
my $allele_qc_api_url = $c->config()->{allele_qc_api_url};
my $allele_qc_api_url = $c->config()->{webservices}->{allele_qc_api_url};
my $show_genotype_management_genes_list = $st->{show_genotype_management_genes_list} || 0;
my $strains_mode = $st->{strains_mode} || 0;
my $pathogen_host_mode = $st->{pathogen_host_mode} || 0;
Expand Down
9 changes: 9 additions & 0 deletions root/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2009,3 +2009,12 @@ dd {
.allele-desc-problem-summ {
margin-bottom: 1em;
}

/* override Bootstrap */
summary {
display: list-item;
}

details > div {
margin-left: 1em;
}
123 changes: 77 additions & 46 deletions root/static/js/canto-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -4125,7 +4125,7 @@ function alleleQCCheckAllele($http, alleleQCUrl, geneSystematicId, alleleDescrip
}

var alleleEditDialogCtrl =
function ($scope, $uibModal, $uibModalInstance, $http, toaster, CantoConfig, args, Curs, CantoGlobals) {
function ($scope, $uibModal, $uibModalInstance, $http, $q, toaster, CantoConfig, args, Curs, CantoGlobals) {
$scope.alleleData = {};
copyObject(args.allele, $scope.alleleData);
$scope.taxonId = args.taxonId;
Expand All @@ -4150,6 +4150,7 @@ var alleleEditDialogCtrl =
$scope.descriptionNeedsChecking = false;
$scope.descriptionState = 'unset';
$scope.lastDescriptionError = '';
$scope.okInProgress = false;

$scope.showAlleleTypeField = (
! $scope.lockedAlleleType && (
Expand Down Expand Up @@ -4239,31 +4240,25 @@ var alleleEditDialogCtrl =
processSynonyms();
};

$scope.updateAlleleCheckButton = function() {
$scope.descriptionChanged = function() {
$scope.descriptionNeedsChecking = false;
$scope.descriptionState = 'unset';

const description = $scope.alleleData.description.trim();
const alleleName = $scope.alleleData.name.trim();

if ($scope.allele_qc_api_url && $scope.userIsAdmin &&
alleleName.length > 0 &&
description.length > 0) {
$scope.descriptionNeedsChecking = true;
}
};

$scope.$watch('alleleData.name', $scope.updateAlleleCheckButton);

$scope.checkDescription = function() {
const qcUrl = CantoGlobals.allele_qc_api_url;

const alleleType = $scope.alleleData.type.trim();

if (!qcUrl || !$scope.current_type_config) {
return;
if (!qcUrl || !$scope.current_type_config ||
!$scope.userIsAdmin ||
!$scope.current_type_config.check_description_with_api) {
$scope.descriptionState = 'ok';
return $q.when(null);
}

$scope.descriptionState = 'unset';

const geneSystematicId = $scope.alleleData.gene_systematic_id;
const alleleDescription = $scope.alleleData.description.trim();
const alleleName = $scope.alleleData.name.trim();
Expand All @@ -4290,28 +4285,29 @@ var alleleEditDialogCtrl =
.map((err) => '<dt>' + err[0] + '</dt> <dd>' + err[1] + '</dd>')
.join("\n") + '</dl>';

let content = '';
let content = errorMessages;

if (summaryParts.length > 0) {
content += '<div class="allele-desc-problem-summ">' +
content += '<details><summary>Details</summary><div class="allele-desc-problem-summ">' +
summaryParts.map((part) => '<div>' + part + '</div>').join("\n") +
'</div>';
'</div></details>';
}

content += errorMessages;

openSimpleDialog($uibModal, 'Allele description problems',
'Allele description problems', content);
} else {
$scope.descriptionState = 'ok';
$scope.lastDescriptionError = '';

toaster.pop({type: 'info', title: 'Allele description passes checks',
timeout: 5000, showCloseButton: true });
// toaster.pop({type: 'info', title: 'Allele description passes checks',
// timeout: 5000, showCloseButton: true });
}
})
.finally(function () {
loadingEnd();
});

return promise;
};

$scope.isValidType = function () {
Expand Down Expand Up @@ -4345,12 +4341,40 @@ var alleleEditDialogCtrl =
}
};

$scope.okTitle = function() {
if ($scope.isExistingAllele()) {
return 'Finish editing this allele';
}

if ($scope.descriptionState == 'not-ok') {
return 'Fix the allele description to continue';
}

if (!$scope.isValidName()) {
return 'Set the allele name to continue';
}

if (!$scope.isValidType()) {
return 'Set the allele type to continue';
}

if (!$scope.isValidDescription()) {
return 'Set the allele description to continue';
}

return 'Finish editing this allele';
};

$scope.isValid = function () {
if ($scope.descriptionState == 'not-ok') {
return false;
}

return $scope.isValidExpression() &&
(
$scope.isExistingAllele() ||
$scope.isValidType() && $scope.isValidName() &&
$scope.isValidDescription()
$scope.isValidType() && $scope.isValidName() &&
$scope.isValidDescription()
) &&
$scope.isValidStrain();
};
Expand Down Expand Up @@ -4379,20 +4403,35 @@ var alleleEditDialogCtrl =
}

$scope.ok = function () {
if ($scope.isValid()) {
splitSynonymsForStoring($scope.alleleData, $scope.data.newSynonymsString);
copyObject($scope.alleleData, args.allele);
var strainName = null;
if ($scope.strainData.selectedStrain) {
strainName = $scope.strainData.selectedStrain.strain_name;
}
$uibModalInstance.close({
alleleData: args.allele,
strainName: strainName
});
} else {
toaster.pop('error', "No changes have been made");
if ($scope.descriptionState == 'not-ok') {
return;
}

const promise = $scope.checkDescription();

promise.then(() => {
if ($scope.descriptionState == 'not-ok') {
return;
}

if ($scope.isValid()) {
$scope.okInProgress = true;
splitSynonymsForStoring($scope.alleleData, $scope.data.newSynonymsString);
copyObject($scope.alleleData, args.allele);
var strainName = null;
if ($scope.strainData.selectedStrain) {
strainName = $scope.strainData.selectedStrain.strain_name;
}
setTimeout(function () {
$uibModalInstance.close({
alleleData: args.allele,
strainName: strainName
});
}, 400);
} else {
toaster.pop('error', "No changes have been made");
}
});
};

$scope.cancel = function () {
Expand Down Expand Up @@ -4434,7 +4473,7 @@ var alleleEditDialogCtrl =
};

canto.controller('AlleleEditDialogCtrl',
['$scope', '$uibModal', '$uibModalInstance', '$http', 'toaster', 'CantoConfig', 'args', 'Curs', 'CantoGlobals',
['$scope', '$uibModal', '$uibModalInstance', '$http', '$q', 'toaster', 'CantoConfig', 'args', 'Curs', 'CantoGlobals',
alleleEditDialogCtrl
]);

Expand Down Expand Up @@ -8365,14 +8404,6 @@ var annotationEditDialogCtrl =
return countKeys(changesToStore) > 0;
};

$scope.featureChooserTitle = function() {
if ($scope.featureEditable) {
return 'Choose a ' + $scope.annotationType.feature_type;
} else {
return 'This annotation is not editable because it has associated genetic interactions';
}
};

$scope.okButtonTitleMessage = function () {
if ($scope.isValid()) {
if ($scope.annotationChanged()) {
Expand Down
19 changes: 9 additions & 10 deletions root/static/ng_templates/allele_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h4 class="modal-title">
</allele-name-complete>
<input ng-if="alleleData.type == 'aberration' || alleleData.type == 'aberration wild type'" ng-model="alleleData.name"/>
<span ng-show="!isValidName()"
class="help-block">Required for this allele type</span>
class="help-block">Allele name is required</span>
</td>
</tr>

Expand All @@ -58,7 +58,7 @@ <h4 class="modal-title">
</td>
</tr>

<tr ng-if="userIsAdmin && !!alleleData.type">
<tr ng-if="!!alleleData.type">
<td>
New synonyms:
</td>
Expand Down Expand Up @@ -109,7 +109,7 @@ <h4 class="modal-title">
</td>
<td ng-class="{ 'has-error': !isValidDescription() }">
<input ng-model="alleleData.description"
ng-change="updateAlleleCheckButton()"
ng-change="descriptionChanged()"
name="curs-allele-description-input" type="text" value=""
class="form-control" />
<span ng-show="descriptionState == 'ok'"
Expand All @@ -118,11 +118,8 @@ <h4 class="modal-title">
<span ng-show="descriptionState == 'not-ok'"
title="{{lastDescriptionError}}"
class="glyphicon glyphicon-remove curs-allele-desc-not-ok"></span>
<span ng-show="descriptionNeedsChecking" class="allele-description-check">
<button class="btn btn-warning" ng-click="checkDescription()">Check</button>
</span>
<span ng-show="!isValidDescription()"
class="help-block">Required for this allele type</span>
class="help-block">Description required for this allele type</span>
</td>
</tr>

Expand Down Expand Up @@ -166,7 +163,7 @@ <h4 class="modal-title">
</td>
</tr>

<tr ng-if="userIsAdmin && !!alleleData.type">
<tr ng-if="!!alleleData.type">
<td class="title">
New synonyms:
</td>
Expand Down Expand Up @@ -240,9 +237,11 @@ <h4 class="modal-title">
</div>

<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
<button class="btn btn-warning" ng-click="cancel()"
ng-disabled="okInProgress">Cancel</button>
<button class="btn btn-primary" ng-click="ok()" ng-alt-enter="ok()"
ng-disabled="!isValid()">OK</button>
title="{{okTitle()}}"
ng-disabled="okInProgress || !isValid()">OK</button>
</div>
</div>
</form>
Expand Down
Loading

0 comments on commit 4a23edf

Please sign in to comment.