Skip to content

Commit

Permalink
add evidence now submitting evidence properly after form model
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjosh-zz committed Jan 14, 2019
1 parent 449981b commit ee6fb87
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/app/views/add/evidence/addEvidenceBasic.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
vm.newEvidence = {
gene: '',
variant: '',
source_type: '',
source: {citation_id: ''},
source: {citation_id: '', source_type: ''},
description: '',
disease: {
name: ''
Expand Down Expand Up @@ -205,7 +204,7 @@
}
},
{
key: 'source_type',
key: 'source.source_type',
type: 'horizontalSelectHelp',
wrapper: 'attributeDefinition',
controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) {
Expand All @@ -227,7 +226,6 @@
templateOptions: {
label: 'Source Type',
required: true,
value: 'vm.newEvidence.source_type',
options: [{ value: '', label: 'Please select a Source Type' }].concat(make_options(descriptions.source_type)),
valueProp: 'value',
labelProp: 'label',
Expand All @@ -237,13 +235,15 @@
attributeDefinitions: descriptions.source_type
},
onChange: function(value, options, scope) {
// field value is showing up undefined here for some reason, accessing it via options
var val = options.value();
// set attribute definition
options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value];
options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[val];
// set source_type on citation_id and clear field
var sourceField = _.find(scope.fields, { key: 'source.citation_id'});
sourceField.value('');
sourceField.templateOptions.data.citation = '--';
if(value) { sourceField.templateOptions.data.sourceType = value; }
if(val) { sourceField.templateOptions.data.sourceType = val; }
else { sourceField.templateOptions.data.sourceType = undefined; }
}
}
Expand All @@ -262,7 +262,7 @@
asyncValidators: {
validId: {
expression: function($viewValue, $modelValue, scope) {
var type = scope.model.source_type;
var type = scope.model.source.source_type;
var deferred = $q.defer();
if ($viewValue.length > 0 && type !== '') {
if ($viewValue.match(/[^0-9]+/)) { return false; } // must be number
Expand Down Expand Up @@ -307,10 +307,10 @@
}
},
expressionProperties: {
'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined',
'templateOptions.disabled': 'to.data.sourceType === "" || to.data.sourceType === undefined',
'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO Web ID" : "PubMed ID" : "Source ID"',
'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Please select Source Type"',
// ng expressions here don't have access to config help objects, so must clumsily insert them into the expression here
// ng expressions here don't have access to config help objects, so we must clumsily insert them into the expression here
'templateOptions.helpText': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "' + help['SourceASCO'] + '" : "' + help['SourcePubMed'] + '" : "Please enter a Source Type before entering a Source ID."',
},
modelOptions: {
Expand Down

0 comments on commit ee6fb87

Please sign in to comment.