From ee6fb87c6585735c28869fb6e7ed780eeb713b32 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 14 Jan 2019 10:22:12 -0600 Subject: [PATCH] add evidence now submitting evidence properly after form model --- src/app/views/add/evidence/addEvidenceBasic.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 46595bcad..f711738cf 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -73,8 +73,7 @@ vm.newEvidence = { gene: '', variant: '', - source_type: '', - source: {citation_id: ''}, + source: {citation_id: '', source_type: ''}, description: '', disease: { name: '' @@ -205,7 +204,7 @@ } }, { - key: 'source_type', + key: 'source.source_type', type: 'horizontalSelectHelp', wrapper: 'attributeDefinition', controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { @@ -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', @@ -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; } } } @@ -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 @@ -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: {