From d65d63037b5b879fd893ddb8dc7b08017f9eccf5 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 19 Nov 2018 16:02:14 -0600 Subject: [PATCH 01/65] added source_type field to add evidence form, updated Publications Service --- .../views/add/evidence/addEvidenceBasic.js | 61 ++++++++++++++++--- .../add/evidence/addEvidenceBasic.tpl.html | 34 +++++------ src/components/services/ConfigService.js | 4 ++ .../services/PublicationsService.js | 50 +++++++-------- 4 files changed, 98 insertions(+), 51 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index c724810eb..767597add 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -73,7 +73,8 @@ vm.newEvidence = { gene: '', variant: '', - pubmed_id: '', + source_type: '', + source_id: '', description: '', disease: { name: '' @@ -204,17 +205,50 @@ } } }, - { - key: 'pubmed_id', + key: 'source_type', + type: 'horizontalSelectHelp', + wrapper: 'attributeDefinition', + controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { + if($stateParams.sourceType) { + var st = $stateParams.sourceType; + var permitted = _.keys(ConfigService.evidenceAttributeDescriptions.source_type); + if(_.includes(permitted, st)) { + $scope.model.source_type = st; + $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; + } else { + console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); + } + } + }, + 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', + helpText: help['Source Type'], + data: { + attributeDefinition: ' ', + attributeDefinitions: descriptions.source_type + }, + onChange: function(value, options) { + // set attribute definition + options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; + } + } + }, + { + key: 'source_id', type: 'publication', templateOptions: { - label: 'Pubmed ID', - value: 'vm.newEvidence.pubmed_id', + label: 'Source ID', + value: 'vm.newEvidence.source_id', minLength: 1, required: true, data: { - description: '--' + description: 'Please choose a Source Type before entering a Source ID.' }, helpText: help['Pubmed ID'] }, @@ -226,9 +260,12 @@ blur: 0 } }, + expressionProperties: { + 'templateOptions.disabled': 'model.source_type === ""', // deactivate if no source type specified + }, controller: /* @ngInject */ function($scope, $stateParams) { - if($stateParams.pubmedId) { - $scope.model.pubmed_id = $stateParams.pubmedId; + if($stateParams.sourceId) { + $scope.model.source_id = $stateParams.sourceId; } }, validators: { @@ -236,9 +273,15 @@ expression: function($viewValue, $modelValue, scope) { if ($viewValue.length > 0) { if ($viewValue.match(/[^0-9]+/)) { return false; } + // get source type + var sourceType = _.find(scope.fields, { key: 'source_type' }).value().toLowerCase(); var deferred = $q.defer(); scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( + var reqObj = { + citationId: $viewValue, + sourceType: sourceType + }; + Publications.verify(reqObj).then( function (response) { scope.options.templateOptions.loading = false; scope.options.templateOptions.data.description = response.description; diff --git a/src/app/views/add/evidence/addEvidenceBasic.tpl.html b/src/app/views/add/evidence/addEvidenceBasic.tpl.html index 17f0facf5..de1635f09 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.tpl.html +++ b/src/app/views/add/evidence/addEvidenceBasic.tpl.html @@ -87,21 +87,21 @@

Thank you.

- - - - - - - - - - - - - - - - - +
+
+

vm.newEvidence

+

+      

submit button stuff

+

vm.form.$invalid: {{vm.form.$invalid}}

+

vm.isAuthenticated: {{vm.isAuthenticated}}

+
+
+

vm.form

+

+    
+
+

vm.evidenceFields

+

+    
+
diff --git a/src/components/services/ConfigService.js b/src/components/services/ConfigService.js index b1549979d..e8f351806 100644 --- a/src/components/services/ConfigService.js +++ b/src/components/services/ConfigService.js @@ -301,6 +301,10 @@ 'Unknown': 'The variant origin is uncertain based on the available evidence.', 'N/A': 'The variant type (e.g., expression) is not compatible (or easily classified) with the CIViC concepts of variant origin.' }, + source_type: { + 'PubMed': 'Evidence item source uses a PubMed publication.', + 'ASCO': 'Evidence item source uses an ASCO abstract.' + }, evidence_type: { 'Predictive': 'Evidence pertains to a variant\'s effect on therapeutic response', 'Diagnostic': 'Evidence pertains to a variant\'s impact on patient diagnosis (cancer subtype)', diff --git a/src/components/services/PublicationsService.js b/src/components/services/PublicationsService.js index 95655d708..3e5fa9d6a 100644 --- a/src/components/services/PublicationsService.js +++ b/src/components/services/PublicationsService.js @@ -6,28 +6,26 @@ // @ngInject function PublicationsResource($resource) { - return $resource('/api/sources', - {}, - { - query: { - method: 'GET', - isArray: true, - cache: true - }, - get: { - method: 'GET', - url: '/api/sources/existence/:pubmedId', - isArray: false, - cache: true - }, - verify: { - method: 'GET', - url: '/api/sources/existence/:pubmedId', - isArray: false, - cache: true - } + return $resource('/api/sources', { + }, { + query: { + method: 'GET', + isArray: true, + cache: true + }, + get: { + method: 'GET', + url: '/api/sources/existence/:citationId', + isArray: false, + cache: true + }, + verify: { + method: 'GET', + url: '/api/sources/existence/:citationId?source_type=:sourceType', + isArray: false, + cache: true } - ); + }); } // @ngInject @@ -53,16 +51,18 @@ }); } - function get(pubmedId) { - return PublicationsResource.get({pubmedId: pubmedId}).$promise + function get(citationId) { + return PublicationsResource.get({ + citationId: citationId + }).$promise .then(function(response) { angular.copy(response, item); return response.$promise; }); } - function verify(pubmedId) { - return PublicationsResource.verify({pubmedId: pubmedId}).$promise + function verify(reqObj) { + return PublicationsResource.verify(reqObj).$promise .then(function(response) { return response.$promise; }); From 6ee954814b061ad9f0d2187b64c20c30f33b647b Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 20 Nov 2018 14:30:55 -0600 Subject: [PATCH 02/65] renamed publication field to pubmed; created new asco field type --- src/components/forms/fieldTypes/asco.js | 24 +++++++++++++++ .../forms/fieldTypes/publication.js | 29 ------------------- src/components/forms/fieldTypes/pubmed.js | 24 +++++++++++++++ 3 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 src/components/forms/fieldTypes/asco.js delete mode 100644 src/components/forms/fieldTypes/publication.js create mode 100644 src/components/forms/fieldTypes/pubmed.js diff --git a/src/components/forms/fieldTypes/asco.js b/src/components/forms/fieldTypes/asco.js new file mode 100644 index 000000000..7fa9fca00 --- /dev/null +++ b/src/components/forms/fieldTypes/asco.js @@ -0,0 +1,24 @@ +(function() { + 'use strict'; + angular.module('civic.config') + .config(ascoConfig) + .controller('AscoController', AscoController); + + // @ngInject + function ascoConfig(formlyConfigProvider) { + formlyConfigProvider.setType({ + name: 'asco', + extends: 'input', + wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] + }); + } + + // @ngInject + function AscoController($scope, Ascos) { + console.log('AscoController called.'); + $scope.validateAsco = function(ascoId) { + return Ascos.verify(ascoId); + }; + } + +})(); diff --git a/src/components/forms/fieldTypes/publication.js b/src/components/forms/fieldTypes/publication.js deleted file mode 100644 index 19123af1c..000000000 --- a/src/components/forms/fieldTypes/publication.js +++ /dev/null @@ -1,29 +0,0 @@ -(function() { - 'use strict'; - angular.module('civic.config') - .config(publicationConfig) - .controller('PublicationController', PublicationController); - - // @ngInject - function publicationConfig(formlyConfigProvider) { - formlyConfigProvider.setType({ - name: 'publication', - extends: 'input', - wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] - }); - formlyConfigProvider.setType({ - name: 'publication-multi', - extends: 'input', - wrapper: ['loader','pubdisplay'] - }); - } - - // @ngInject - function PublicationController($scope, Publications) { - console.log('PublicationController called.'); - $scope.validatePublication = function(pubmedId) { - return Publications.verify(pubmedId); - }; - } - -})(); diff --git a/src/components/forms/fieldTypes/pubmed.js b/src/components/forms/fieldTypes/pubmed.js new file mode 100644 index 000000000..a8be6ad63 --- /dev/null +++ b/src/components/forms/fieldTypes/pubmed.js @@ -0,0 +1,24 @@ +(function() { + 'use strict'; + angular.module('civic.config') + .config(pubmedConfig) + .controller('PubmedController', PubmedController); + + // @ngInject + function pubmedConfig(formlyConfigProvider) { + formlyConfigProvider.setType({ + name: 'pubmed', + extends: 'input', + wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] + }); + } + + // @ngInject + function PubmedController($scope, Pubmeds) { + console.log('PubmedController called.'); + $scope.validatePubmed = function(pubmedId) { + return Pubmeds.verify(pubmedId); + }; + } + +})(); From 0a951e33479087f00f48ce2f42330f612b4edade Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 20 Nov 2018 14:31:22 -0600 Subject: [PATCH 03/65] switched to pubmed from publication field in several forms --- src/app/views/add/evidence/addEvidenceBasic.js | 12 +++++------- .../views/events/evidence/edit/evidenceEditBasic.js | 2 +- .../views/suggest/source/SuggestSourceController.js | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 767597add..e35f1a589 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,7 +74,7 @@ gene: '', variant: '', source_type: '', - source_id: '', + pubmed_id: '', description: '', disease: { name: '' @@ -240,15 +240,15 @@ } }, { - key: 'source_id', - type: 'publication', + key: 'pubmed_id', + type: 'pubmed', templateOptions: { label: 'Source ID', value: 'vm.newEvidence.source_id', minLength: 1, required: true, data: { - description: 'Please choose a Source Type before entering a Source ID.' + description: '--', }, helpText: help['Pubmed ID'] }, @@ -260,9 +260,7 @@ blur: 0 } }, - expressionProperties: { - 'templateOptions.disabled': 'model.source_type === ""', // deactivate if no source type specified - }, + hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() != "pubmed"', controller: /* @ngInject */ function($scope, $stateParams) { if($stateParams.sourceId) { $scope.model.source_id = $stateParams.sourceId; diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 218ebe81b..faa929a11 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -109,7 +109,7 @@ }, { key: 'pubmed_id', - type: 'publication', + type: 'pubmed', templateOptions: { label: 'Pubmed ID', value: 'vm.evidenceEdit.pubmed_id', diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index d5688164b..52f031cd4 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -38,7 +38,7 @@ vm.suggestionFields =[ { key: 'pubmed_id', - type: 'publication', + type: 'pubmed', model: vm.newSuggestion.suggestion, templateOptions: { label: 'Pubmed ID', From 59f9a32f59417a487f671c97b483dfff07b73138 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 20 Nov 2018 16:41:59 -0600 Subject: [PATCH 04/65] removed asco field --- src/components/forms/fieldTypes/asco.js | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 src/components/forms/fieldTypes/asco.js diff --git a/src/components/forms/fieldTypes/asco.js b/src/components/forms/fieldTypes/asco.js deleted file mode 100644 index 7fa9fca00..000000000 --- a/src/components/forms/fieldTypes/asco.js +++ /dev/null @@ -1,24 +0,0 @@ -(function() { - 'use strict'; - angular.module('civic.config') - .config(ascoConfig) - .controller('AscoController', AscoController); - - // @ngInject - function ascoConfig(formlyConfigProvider) { - formlyConfigProvider.setType({ - name: 'asco', - extends: 'input', - wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] - }); - } - - // @ngInject - function AscoController($scope, Ascos) { - console.log('AscoController called.'); - $scope.validateAsco = function(ascoId) { - return Ascos.verify(ascoId); - }; - } - -})(); From 61b9ad8d05212fae44ccd1f4e2e5ef6977a13cc2 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 20 Nov 2018 16:42:10 -0600 Subject: [PATCH 05/65] renamed pubmed field to citation --- .../views/add/evidence/addEvidenceBasic.js | 15 +++++++++--- src/components/forms/fieldTypes/citation.js | 24 +++++++++++++++++++ src/components/forms/fieldTypes/pubmed.js | 24 ------------------- 3 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 src/components/forms/fieldTypes/citation.js delete mode 100644 src/components/forms/fieldTypes/pubmed.js diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index e35f1a589..b0991d123 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -240,8 +240,17 @@ } }, { - key: 'pubmed_id', - type: 'pubmed', + key: 'asco_year', + type: 'horizontalInputHelp', + hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() === "pubmed"', + templateOptions: { + label: 'ASCO Year', + helpText: 'Year the ASCO Abstract was presented' + } + }, + { + key: 'citation_id', + type: 'citation', templateOptions: { label: 'Source ID', value: 'vm.newEvidence.source_id', @@ -260,7 +269,7 @@ blur: 0 } }, - hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() != "pubmed"', + hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() != "pubmed" || (model.source_type.toLowerCase() === "asco" && model.asco_year === "")"', controller: /* @ngInject */ function($scope, $stateParams) { if($stateParams.sourceId) { $scope.model.source_id = $stateParams.sourceId; diff --git a/src/components/forms/fieldTypes/citation.js b/src/components/forms/fieldTypes/citation.js new file mode 100644 index 000000000..ee2da8967 --- /dev/null +++ b/src/components/forms/fieldTypes/citation.js @@ -0,0 +1,24 @@ +(function() { + 'use strict'; + angular.module('civic.config') + .config(citationConfig) + .controller('CitationController', CitationController); + + // @ngInject + function citationConfig(formlyConfigProvider) { + formlyConfigProvider.setType({ + name: 'citation', + extends: 'input', + wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] + }); + } + + // @ngInject + function CitationController($scope, Citations) { + console.log('CitationController called.'); + $scope.validateCitation = function(citationId) { + return Citations.verify(citationId); + }; + } + +})(); diff --git a/src/components/forms/fieldTypes/pubmed.js b/src/components/forms/fieldTypes/pubmed.js deleted file mode 100644 index a8be6ad63..000000000 --- a/src/components/forms/fieldTypes/pubmed.js +++ /dev/null @@ -1,24 +0,0 @@ -(function() { - 'use strict'; - angular.module('civic.config') - .config(pubmedConfig) - .controller('PubmedController', PubmedController); - - // @ngInject - function pubmedConfig(formlyConfigProvider) { - formlyConfigProvider.setType({ - name: 'pubmed', - extends: 'input', - wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] - }); - } - - // @ngInject - function PubmedController($scope, Pubmeds) { - console.log('PubmedController called.'); - $scope.validatePubmed = function(pubmedId) { - return Pubmeds.verify(pubmedId); - }; - } - -})(); From a6d3125f55a5a9a16fe2dfac034ea89dd46b4914 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 10:14:49 -0600 Subject: [PATCH 06/65] asco year set to required if source_type is asco --- src/app/views/add/evidence/addEvidenceBasic.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index b0991d123..0eafd2e8e 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -245,8 +245,11 @@ hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() === "pubmed"', templateOptions: { label: 'ASCO Year', - helpText: 'Year the ASCO Abstract was presented' - } + helpText: 'Year the abstract was presented' + }, + expressionProperties: { + 'templateOptions.required': 'model.source_type.toLowerCase() === "asco"' + }, }, { key: 'citation_id', From c25714482fe73dafc17fd68d1078c5a689d94fe1 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 12:24:14 -0600 Subject: [PATCH 07/65] added citation typeahead template --- src/components/forms/fieldTypes/citationTypeahead.tpl.html | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/components/forms/fieldTypes/citationTypeahead.tpl.html diff --git a/src/components/forms/fieldTypes/citationTypeahead.tpl.html b/src/components/forms/fieldTypes/citationTypeahead.tpl.html new file mode 100644 index 000000000..109cea2f3 --- /dev/null +++ b/src/components/forms/fieldTypes/citationTypeahead.tpl.html @@ -0,0 +1,3 @@ + + CITATION + From 6a9379d330cc5cc9b73b9931e75db58332079149 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 12:24:23 -0600 Subject: [PATCH 08/65] citation field updates label based on source type --- .../views/add/evidence/addEvidenceBasic.js | 198 ++++++++++-------- 1 file changed, 111 insertions(+), 87 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 0eafd2e8e..8fb261a61 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,14 +74,13 @@ gene: '', variant: '', source_type: '', - pubmed_id: '', + citation_id: '', description: '', disease: { name: '' }, disease_name: '', noDoid: false, - //pubchem_id: '', drugs: [], drug_interaction_type: null, rating: '', @@ -233,86 +232,111 @@ attributeDefinition: ' ', attributeDefinitions: descriptions.source_type }, - onChange: function(value, options) { + onChange: function(value, options, scope) { // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; + // set source_type on citation_id + var citeField = _.find(scope.fields, { key: 'citation_id'}); + if (citeField.value() !== '') { // only update if user has selected an option + citeField.templateOptions.data.source_type = value.toLowerCase(); + } } } }, - { - key: 'asco_year', - type: 'horizontalInputHelp', - hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() === "pubmed"', - templateOptions: { - label: 'ASCO Year', - helpText: 'Year the abstract was presented' - }, - expressionProperties: { - 'templateOptions.required': 'model.source_type.toLowerCase() === "asco"' - }, - }, { key: 'citation_id', - type: 'citation', + type: 'horizontalTypeaheadHelp', templateOptions: { - label: 'Source ID', - value: 'vm.newEvidence.source_id', - minLength: 1, + label: 'Citation ID', required: true, + typeahead: 'item as item.name for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', + onSelect: 'to.data.citation = $model.citation', data: { - description: '--', + citation: '', + sourceType: undefined, + typeaheadSearch: function(val, sourceType) { + var reqObj = { + citationId: val, + sourceType: sourceType + }; + return Publications.verify(reqObj) + .then(function(response) { + return response; + }); + } }, - helpText: help['Pubmed ID'] + helpText: help['Citation ID'] }, - modelOptions: { - updateOn: 'default blur', - allowInvalid: false, - debounce: { - default: 300, - blur: 0 - } + expressionProperties: { + 'templateOptions.label': 'model.source_type === "" ? "Citation ID" : model.source_type + " ID"' }, - hideExpression: 'model.source_type === "" || model.source_type.toLowerCase() != "pubmed" || (model.source_type.toLowerCase() === "asco" && model.asco_year === "")"', controller: /* @ngInject */ function($scope, $stateParams) { - if($stateParams.sourceId) { - $scope.model.source_id = $stateParams.sourceId; + if($stateParams.citationId) { + $scope.model.citation_id = $stateParams.citationId; } }, - validators: { - validPubmedId: { - expression: function($viewValue, $modelValue, scope) { - if ($viewValue.length > 0) { - if ($viewValue.match(/[^0-9]+/)) { return false; } - // get source type - var sourceType = _.find(scope.fields, { key: 'source_type' }).value().toLowerCase(); - var deferred = $q.defer(); - scope.options.templateOptions.loading = true; - var reqObj = { - citationId: $viewValue, - sourceType: sourceType - }; - Publications.verify(reqObj).then( - function (response) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; - deferred.resolve(response); - }, - function (error) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = '--'; - deferred.reject(error); - } - ); - return deferred.promise; - } else { - scope.options.templateOptions.data.description = '--'; - return true; - } - }, - message: '"This does not appear to be a valid Pubmed ID."' - } - } }, + // { + // key: 'citation_id', + // type: 'citation', + // templateOptions: { + // label: 'Citation ID', + // value: 'vm.newEvidence.citation_id', + // minLength: 1, + // required: true, + // data: { + // description: '--', + // }, + // helpText: help['Citation ID'] + // }, + // modelOptions: { + // updateOn: 'default blur', + // allowInvalid: false, + // debounce: { + // default: 300, + // blur: 0 + // } + // }, + // controller: /* @ngInject */ function($scope, $stateParams) { + // if($stateParams.sourceId) { + // $scope.model.source_id = $stateParams.sourceId; + // } + // }, + // validators: { + // validCitationId: { + // expression: function($viewValue, $modelValue, scope) { + // if ($viewValue.length > 0) { + // if ($viewValue.match(/[^0-9]+/)) { return false; } + // var sourceType = _.find(scope.fields, { key: 'source_type' }).value().toLowerCase(); + // var deferred = $q.defer(); + // scope.options.templateOptions.loading = true; + // var reqObj = { + // citationId: $viewValue, + // sourceType: sourceType + // }; + // Publications.verify(reqObj).then( + // function (response) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = response.description; + // deferred.resolve(response); + // }, + // function (error) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = '--'; + // deferred.reject(error); + // } + // ); + // return deferred.promise; + // } else { + // scope.options.templateOptions.data.description = '--'; + // return true; + // } + // }, + // message: '"This does not appear to be a valid citation ID."' + // } + // } + // }, { // duplicates warning row templateUrl: 'app/views/add/evidence/addEvidenceDuplicateWarning.tpl.html', controller: /* @ngInject */ function($scope, Search) { @@ -324,25 +348,25 @@ if(_.every(values, function(val) { return _.isString(val) && val.length > 0; })) { vm.duplicates = []; Search.post({ - 'operator': 'AND', - 'queries': [ - { - 'field': 'gene_name', - 'condition': {'name': 'contains', 'parameters': [values[0]]} - }, - { - 'field': 'variant_name', - 'condition': {'name': 'contains', 'parameters': [values[1]]} - }, - { - 'field': 'pubmed_id', - 'condition': {'name': 'is', 'parameters': [values[2]] - } - } - ], - 'entity': 'evidence_items', - 'save': false - }) + 'operator': 'AND', + 'queries': [ + { + 'field': 'gene_name', + 'condition': {'name': 'contains', 'parameters': [values[0]]} + }, + { + 'field': 'variant_name', + 'condition': {'name': 'contains', 'parameters': [values[1]]} + }, + { + 'field': 'pubmed_id', + 'condition': {'name': 'is', 'parameters': [values[2]] + } + } + ], + 'entity': 'evidence_items', + 'save': false + }) .then(function (response) { vm.duplicates = response.results; }); @@ -646,8 +670,8 @@ 'templateOptions.options': function($viewValue, $modelValue, scope) { return _.filter(scope.to.clinicalSignificanceOptions, function(option) { return !!(option.type === scope.model.evidence_type || - option.type === 'default' || - option.type === 'N/A'); + option.type === 'default' || + option.type === 'N/A'); }); }, 'templateOptions.disabled': 'model.evidence_type === ""' // deactivate if evidence_type unselected @@ -709,7 +733,7 @@ }, hideExpression: function($viewValue, $modelValue, scope) { return !(scope.model.evidence_type === 'Predictive' && // evidence type must be predictive - _.without(scope.model.drugs, '').length > 1); + _.without(scope.model.drugs, '').length > 1); } }, { From bb594617e1a95dc15093c76a6568ae6871333884 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 12:33:00 -0600 Subject: [PATCH 09/65] citation_id field typeaheadSearch function working --- src/app/views/add/evidence/addEvidenceBasic.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 8fb261a61..47c061c00 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -237,9 +237,7 @@ options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id var citeField = _.find(scope.fields, { key: 'citation_id'}); - if (citeField.value() !== '') { // only update if user has selected an option - citeField.templateOptions.data.source_type = value.toLowerCase(); - } + citeField.templateOptions.data.sourceType = value.toLowerCase(); } } }, From 566a64176026526a9304e365ab0b7eb4a4ad2dd6 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 13:20:50 -0600 Subject: [PATCH 10/65] citation ID now shows citation description beneath --- src/app/views/add/evidence/addEvidenceBasic.js | 10 ++++------ .../forms/fieldTypes/citationTypeahead.tpl.html | 3 ++- .../forms/fieldWrappers/basicFieldWrappers.js | 4 ++-- src/components/services/PublicationsService.js | 3 ++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 47c061c00..a3d96aa67 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -244,14 +244,15 @@ { key: 'citation_id', type: 'horizontalTypeaheadHelp', + wrapper: ['citation'], templateOptions: { label: 'Citation ID', required: true, - typeahead: 'item as item.name for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + typeahead: 'item.citation_id as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.citation', + onSelect: 'to.data.citation = $model', data: { - citation: '', + citation: '--', sourceType: undefined, typeaheadSearch: function(val, sourceType) { var reqObj = { @@ -266,9 +267,6 @@ }, helpText: help['Citation ID'] }, - expressionProperties: { - 'templateOptions.label': 'model.source_type === "" ? "Citation ID" : model.source_type + " ID"' - }, controller: /* @ngInject */ function($scope, $stateParams) { if($stateParams.citationId) { $scope.model.citation_id = $stateParams.citationId; diff --git a/src/components/forms/fieldTypes/citationTypeahead.tpl.html b/src/components/forms/fieldTypes/citationTypeahead.tpl.html index 109cea2f3..6781d5d87 100644 --- a/src/components/forms/fieldTypes/citationTypeahead.tpl.html +++ b/src/components/forms/fieldTypes/citationTypeahead.tpl.html @@ -1,3 +1,4 @@ - CITATION + ID: CITATION ID  + CITATION: DESCRIPTIOn diff --git a/src/components/forms/fieldWrappers/basicFieldWrappers.js b/src/components/forms/fieldWrappers/basicFieldWrappers.js index 8d9540586..bb8e4d7c3 100644 --- a/src/components/forms/fieldWrappers/basicFieldWrappers.js +++ b/src/components/forms/fieldWrappers/basicFieldWrappers.js @@ -116,10 +116,10 @@ }); formlyConfigProvider.setWrapper({ - name: 'pubdisplay', + name: 'citation', template: [ '', - 'Citation: {{ to.data.description }}' + 'Citation: {{ to.data.citation }}' ].join(' ') }); diff --git a/src/components/services/PublicationsService.js b/src/components/services/PublicationsService.js index 3e5fa9d6a..584004662 100644 --- a/src/components/services/PublicationsService.js +++ b/src/components/services/PublicationsService.js @@ -1,6 +1,7 @@ (function() { 'use strict'; angular.module('civic.services') + .factory('PublicationsResource', PublicationsResource) .factory('Publications', PublicationsService); @@ -22,7 +23,7 @@ verify: { method: 'GET', url: '/api/sources/existence/:citationId?source_type=:sourceType', - isArray: false, + isArray: true, cache: true } }); From 24f1bc1530049b3f7c9920cc490d5f7e6d8c833f Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 14:02:16 -0600 Subject: [PATCH 11/65] changing source type clears citation id field; cit typeahead highlights ID --- src/app/views/add/evidence/addEvidenceBasic.js | 16 +++++++++++++--- .../forms/fieldTypes/citationTypeahead.tpl.html | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index a3d96aa67..74a342436 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -235,8 +235,10 @@ onChange: function(value, options, scope) { // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; - // set source_type on citation_id + // set source_type on citation_id and clear field var citeField = _.find(scope.fields, { key: 'citation_id'}); + citeField.value(''); + citeField.templateOptions.data.citation = '--'; citeField.templateOptions.data.sourceType = value.toLowerCase(); } } @@ -248,9 +250,10 @@ templateOptions: { label: 'Citation ID', required: true, - typeahead: 'item.citation_id as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + editable: false, + typeahead: 'item as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model', + onSelect: 'to.data.citation = $model.description', data: { citation: '--', sourceType: undefined, @@ -267,11 +270,18 @@ }, helpText: help['Citation ID'] }, + parsers: [function(val) { return val; }], + formatters: [function(val) { return val.citation_id;}], controller: /* @ngInject */ function($scope, $stateParams) { if($stateParams.citationId) { $scope.model.citation_id = $stateParams.citationId; } }, + modelOptions: { + debounce: { + default: 300 + } + } }, // { // key: 'citation_id', diff --git a/src/components/forms/fieldTypes/citationTypeahead.tpl.html b/src/components/forms/fieldTypes/citationTypeahead.tpl.html index 6781d5d87..81b5b65a4 100644 --- a/src/components/forms/fieldTypes/citationTypeahead.tpl.html +++ b/src/components/forms/fieldTypes/citationTypeahead.tpl.html @@ -1,4 +1,4 @@ ID: CITATION ID  - CITATION: DESCRIPTIOn + CITATION: DESCRIPTIOn From f7d5d70f24db8f56f44724644a954061206e3023 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 26 Nov 2018 16:52:30 -0600 Subject: [PATCH 12/65] add evidence form submit works --- .../views/add/evidence/addEvidenceBasic.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 74a342436..1e78fcb24 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,7 +74,7 @@ gene: '', variant: '', source_type: '', - citation_id: '', + source: {}, description: '', disease: { name: '' @@ -236,19 +236,19 @@ // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var citeField = _.find(scope.fields, { key: 'citation_id'}); - citeField.value(''); - citeField.templateOptions.data.citation = '--'; - citeField.templateOptions.data.sourceType = value.toLowerCase(); + var sourceField = _.find(scope.fields, { key: 'source'}); + sourceField.value({}); + sourceField.templateOptions.data.citation = '--'; + sourceField.templateOptions.data.sourceType = value.toLowerCase(); } } }, { - key: 'citation_id', + key: 'source', type: 'horizontalTypeaheadHelp', wrapper: ['citation'], templateOptions: { - label: 'Citation ID', + label: 'Source', required: true, editable: false, typeahead: 'item as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', @@ -256,7 +256,7 @@ onSelect: 'to.data.citation = $model.description', data: { citation: '--', - sourceType: undefined, + sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { var reqObj = { citationId: val, @@ -268,11 +268,11 @@ }); } }, - helpText: help['Citation ID'] + helpText: help['Source'] }, - parsers: [function(val) { return val; }], - formatters: [function(val) { return val.citation_id;}], + formatters: [function(val) { return val.citation_id;}], // this pulls the cit_id from the object to display in the input controller: /* @ngInject */ function($scope, $stateParams) { + // TODO this won't work, will need to query the server to get the entire source object if($stateParams.citationId) { $scope.model.citation_id = $stateParams.citationId; } @@ -835,6 +835,7 @@ newEvidence.evidenceId = newEvidence.id; newEvidence.drugs = _.without(newEvidence.drugs, ''); newEvidence.phenotypes = _.without(newEvidence.phenotypes, ''); + if(newEvidence.drugs.length < 2) { newEvidence.drug_interaction_type = null; } // delete interaction if only 1 drug // convert variant name to object, if a string // TODO: figure out how to handle this more elegantly using angular-formly config object From aedaa70003b6bdb141f8401ec2dfffba4c20a7af Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 11:33:13 -0600 Subject: [PATCH 13/65] removed old citation_id field --- .../views/add/evidence/addEvidenceBasic.js | 60 ------------------- 1 file changed, 60 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 1e78fcb24..f29ef6199 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -283,66 +283,6 @@ } } }, - // { - // key: 'citation_id', - // type: 'citation', - // templateOptions: { - // label: 'Citation ID', - // value: 'vm.newEvidence.citation_id', - // minLength: 1, - // required: true, - // data: { - // description: '--', - // }, - // helpText: help['Citation ID'] - // }, - // modelOptions: { - // updateOn: 'default blur', - // allowInvalid: false, - // debounce: { - // default: 300, - // blur: 0 - // } - // }, - // controller: /* @ngInject */ function($scope, $stateParams) { - // if($stateParams.sourceId) { - // $scope.model.source_id = $stateParams.sourceId; - // } - // }, - // validators: { - // validCitationId: { - // expression: function($viewValue, $modelValue, scope) { - // if ($viewValue.length > 0) { - // if ($viewValue.match(/[^0-9]+/)) { return false; } - // var sourceType = _.find(scope.fields, { key: 'source_type' }).value().toLowerCase(); - // var deferred = $q.defer(); - // scope.options.templateOptions.loading = true; - // var reqObj = { - // citationId: $viewValue, - // sourceType: sourceType - // }; - // Publications.verify(reqObj).then( - // function (response) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = response.description; - // deferred.resolve(response); - // }, - // function (error) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = '--'; - // deferred.reject(error); - // } - // ); - // return deferred.promise; - // } else { - // scope.options.templateOptions.data.description = '--'; - // return true; - // } - // }, - // message: '"This does not appear to be a valid citation ID."' - // } - // } - // }, { // duplicates warning row templateUrl: 'app/views/add/evidence/addEvidenceDuplicateWarning.tpl.html', controller: /* @ngInject */ function($scope, Search) { From 91afd6493519c4fa3da129b7eb93622abf2bf26c Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 11:33:24 -0600 Subject: [PATCH 14/65] evidence summary handles pubmed and asco ids/urls/citations --- .../evidence/summary/evidenceSummary.tpl.html | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html index d849ebc12..929a77570 100644 --- a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html +++ b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html @@ -106,7 +106,7 @@ - Citation: + Source: {{ evidence.source.citation }} @@ -114,14 +114,36 @@ - Pubmed ID: + + + + PubMed ID: + + + ASCO ID: + + + - - - - + + + + + + + + + + + + + + + From f5ebc640ec75cf0fbf76b3a9ceed2e161c4d0065 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 11:50:09 -0600 Subject: [PATCH 15/65] fixed pubmed id display --- src/app/views/events/evidence/summary/evidenceSummary.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html index 929a77570..681f00030 100644 --- a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html +++ b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html @@ -131,7 +131,7 @@ class="btn btn-xs button-new-window" target="_blank"> - + From 0a4a803c1747c835dd9e72d183b16ab72b7ce55e Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 13:48:17 -0600 Subject: [PATCH 16/65] source summary now handles asco sources --- .../summary/SourcesSummaryController.js | 19 ++++++-- .../sources/summary/sourcesSummary.tpl.html | 45 ++++++++++++++----- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/app/views/sources/summary/SourcesSummaryController.js b/src/app/views/sources/summary/SourcesSummaryController.js index b4c99a9d4..79955e432 100644 --- a/src/app/views/sources/summary/SourcesSummaryController.js +++ b/src/app/views/sources/summary/SourcesSummaryController.js @@ -43,14 +43,25 @@ var query = { 'operator': 'AND', 'queries': [ - {'field': 'pubmed_id', + { + 'field': 'source_type', 'condition': { - 'name': 'is', + 'name': 'is_equal_to', 'parameters': [ - source.pubmed_id + source.source_type ] } - }], + }, + { + 'field': 'citation_id', + 'condition': { + 'name': 'is_equal_to', + 'parameters': [ + source.citation_id + ] + } + } + ], 'entity': 'evidence_items', 'save': true }; diff --git a/src/app/views/sources/summary/sourcesSummary.tpl.html b/src/app/views/sources/summary/sourcesSummary.tpl.html index cef7a9984..248ee895c 100644 --- a/src/app/views/sources/summary/sourcesSummary.tpl.html +++ b/src/app/views/sources/summary/sourcesSummary.tpl.html @@ -10,13 +10,16 @@

-

Full Source Title

-

Authors: Authors List

+

Full Source Title

+

+ Authors: Authors List +

@@ -38,14 +41,36 @@

Full Source Title

- Pubmed ID: + + + + PubMed ID: + + + ASCO ID: + + + - - - - + + + + + + + + + + + + + + + From 1607cbd0a3ec114f13c1fdecae37c7d9fcc9fd11 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 16:04:18 -0600 Subject: [PATCH 17/65] evidence edit source fields filling properly on init --- .../events/evidence/edit/evidenceEditBasic.js | 161 +++++++++++++----- .../evidence/edit/evidenceEditBasic.tpl.html | 20 +-- 2 files changed, 131 insertions(+), 50 deletions(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index faa929a11..3fa926222 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -58,10 +58,13 @@ vm.evidenceRevisions = EvidenceRevisions; vm.evidenceHistory = EvidenceHistory; vm.evidenceEdit = angular.copy(vm.evidence); - vm.evidenceEdit.pubmed_id = vm.evidence.source.pubmed_id; vm.evidenceEdit.comment = { title: 'Evidence EID' + vm.evidence.id + ' Revision Description', text:'' }; vm.evidenceEdit.drugs = _.filter(_.map(vm.evidence.drugs, 'name'), function(name){ return name !== 'N/A'; }); vm.evidenceEdit.phenotypes = _.map(vm.evidenceEdit.phenotypes, function(phenotype) { return phenotype.hpo_class; }); + vm.evidenceEdit.source_type = vm.evidenceEdit.source.source_type; + vm.evidenceEdit.source_citation = vm.evidenceEdit.source.citation; + vm.evidenceEdit.source = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string + vm.evidenceEdit = _.omit(vm.evidenceEdit, ['lifecycle_actions']); vm.styles = EvidenceViewOptions.styles; vm.user = {}; @@ -108,54 +111,133 @@ } }, { - key: 'pubmed_id', - type: 'pubmed', + key: 'source_type', + type: 'horizontalSelectHelp', + wrapper: 'attributeDefinition', + controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { + if($stateParams.sourceType) { + var st = $stateParams.sourceType; + var permitted = _.keys(ConfigService.evidenceAttributeDescriptions.source_type); + if(_.includes(permitted, st)) { + $scope.model.source_type = st; + $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; + } else { + console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); + } + } + }, + templateOptions: { + label: 'Source Type', + required: true, + options: [ + { value: '', label: 'Please select a Source Type' }, + { value: 'pubmed', label: 'PubMed' }, + { value: 'asco', label: 'ASCO' } + ], + valueProp: 'value', + labelProp: 'label', + helpText: help['Source Type'], + data: { + attributeDefinition: ' ', + attributeDefinitions: descriptions.source_type + }, + onChange: function(value, options, scope) { + // set attribute definition + options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; + // set source_type on citation_id and clear field + var sourceField = _.find(scope.fields, { key: 'source'}); + sourceField.value({}); + sourceField.templateOptions.data.citation = '--'; + sourceField.templateOptions.data.sourceType = value.toLowerCase(); + } + } + }, + { + key: 'source', + type: 'horizontalTypeaheadHelp', + wrapper: ['citation'], templateOptions: { - label: 'Pubmed ID', - value: 'vm.evidenceEdit.pubmed_id', - minLength: 1, + label: 'Source', required: true, + editable: true, + typeahead: 'item as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', + onSelect: 'to.data.citation = $model.description', data: { - description: '--' + citation: '--', + sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType + typeaheadSearch: function(val, sourceType) { + var reqObj = { + citationId: val, + sourceType: sourceType + }; + return Publications.verify(reqObj) + .then(function(response) { + return response; + }); + } }, - helpText: help['Pubmed ID'] + helpText: help['Source'] + }, + controller: /* @ngInject */ function($scope) { + $scope.to.data.sourceType = $scope.model.source_type; + $scope.to.data.citation = $scope.model.source_citation; }, modelOptions: { - updateOn: 'default blur', - allowInvalid: false, debounce: { - default: 300, - blur: 0 - } - }, - validators: { - validPubmedId: { - expression: function($viewValue, $modelValue, scope) { - if ($viewValue.length > 0) { - var deferred = $q.defer(); - scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( - function (response) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; - deferred.resolve(response); - }, - function (error) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = '--'; - deferred.reject(error); - } - ); - return deferred.promise; - } else { - scope.options.templateOptions.data.description = '--'; - return true; - } - }, - message: '"This does not appear to be a valid Pubmed ID."' + default: 300 } } }, + // { + // key: 'pubmed_id', + // type: 'pubmed', + // templateOptions: { + // label: 'Pubmed ID', + // value: 'vm.evidenceEdit.pubmed_id', + // minLength: 1, + // required: true, + // data: { + // description: '--' + // }, + // helpText: help['Pubmed ID'] + // }, + // modelOptions: { + // updateOn: 'default blur', + // allowInvalid: false, + // debounce: { + // default: 300, + // blur: 0 + // } + // }, + // validators: { + // validPubmedId: { + // expression: function($viewValue, $modelValue, scope) { + // if ($viewValue.length > 0) { + // var deferred = $q.defer(); + // scope.options.templateOptions.loading = true; + // Publications.verify($viewValue).then( + // function (response) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = response.description; + // deferred.resolve(response); + // }, + // function (error) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = '--'; + // deferred.reject(error); + // } + // ); + // return deferred.promise; + // } else { + // scope.options.templateOptions.data.description = '--'; + // return true; + // } + // }, + // message: '"This does not appear to be a valid Pubmed ID."' + // } + // } + // }, { key: 'disease', type: 'horizontalTypeaheadHelp', @@ -216,7 +298,6 @@ templateOptions: { label: 'Disease Name', required: true, - value: 'vm.newEvidence.disease_name', minLength: 32, helpText: help['Disease Name'] }, diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html b/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html index 560ba4d84..6005a7992 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html @@ -103,14 +103,14 @@

Thank you.

View it here

- - - - - - - - - - +
+
+

vm.evidencEdit

+

+    
+
+

vm.evidenceFields

+

+    
+
From 8954badfd80a61501feccd3e887f8f20686e5ece Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 27 Nov 2018 16:20:23 -0600 Subject: [PATCH 18/65] edit evidence source_type select, source typeahead working properly --- src/app/views/add/evidence/addEvidenceBasic.js | 6 +++--- src/app/views/events/evidence/edit/evidenceEditBasic.js | 8 +++++--- .../forms/fieldTypes/citationTypeahead.tpl.html | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index f29ef6199..cc6bbf941 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -273,9 +273,9 @@ formatters: [function(val) { return val.citation_id;}], // this pulls the cit_id from the object to display in the input controller: /* @ngInject */ function($scope, $stateParams) { // TODO this won't work, will need to query the server to get the entire source object - if($stateParams.citationId) { - $scope.model.citation_id = $stateParams.citationId; - } + // if($stateParams.citationId) { + // $scope.model.citation_id = $stateParams.citationId; + // } }, modelOptions: { debounce: { diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 3fa926222..d03df3f62 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -58,13 +58,13 @@ vm.evidenceRevisions = EvidenceRevisions; vm.evidenceHistory = EvidenceHistory; vm.evidenceEdit = angular.copy(vm.evidence); + vm.evidenceEdit = _.omit(vm.evidenceEdit, ['lifecycle_actions']); vm.evidenceEdit.comment = { title: 'Evidence EID' + vm.evidence.id + ' Revision Description', text:'' }; vm.evidenceEdit.drugs = _.filter(_.map(vm.evidence.drugs, 'name'), function(name){ return name !== 'N/A'; }); vm.evidenceEdit.phenotypes = _.map(vm.evidenceEdit.phenotypes, function(phenotype) { return phenotype.hpo_class; }); vm.evidenceEdit.source_type = vm.evidenceEdit.source.source_type; vm.evidenceEdit.source_citation = vm.evidenceEdit.source.citation; vm.evidenceEdit.source = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string - vm.evidenceEdit = _.omit(vm.evidenceEdit, ['lifecycle_actions']); vm.styles = EvidenceViewOptions.styles; vm.user = {}; @@ -146,7 +146,7 @@ options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field var sourceField = _.find(scope.fields, { key: 'source'}); - sourceField.value({}); + sourceField.value({description: '', citation_id: ''}); sourceField.templateOptions.data.citation = '--'; sourceField.templateOptions.data.sourceType = value.toLowerCase(); } @@ -160,7 +160,7 @@ label: 'Source', required: true, editable: true, - typeahead: 'item as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', onSelect: 'to.data.citation = $model.description', data: { @@ -179,6 +179,8 @@ }, helpText: help['Source'] }, + formatters: [function(val) { return val;}], // this pulls the cit_id from the object to display in the input + parsers: [function(val) { return val;}], controller: /* @ngInject */ function($scope) { $scope.to.data.sourceType = $scope.model.source_type; $scope.to.data.citation = $scope.model.source_citation; diff --git a/src/components/forms/fieldTypes/citationTypeahead.tpl.html b/src/components/forms/fieldTypes/citationTypeahead.tpl.html index 81b5b65a4..a16150b4a 100644 --- a/src/components/forms/fieldTypes/citationTypeahead.tpl.html +++ b/src/components/forms/fieldTypes/citationTypeahead.tpl.html @@ -1,4 +1,4 @@ ID: CITATION ID  - CITATION: DESCRIPTIOn + CITATION: DESCRIPTIOn From 3eb85cdcf55bfad09171149a974ff6b8cb574410 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 09:26:43 -0600 Subject: [PATCH 19/65] fixed source field so it doesn't need a formatter --- src/app/views/add/evidence/addEvidenceBasic.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index cc6bbf941..49dae0564 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,7 +74,7 @@ gene: '', variant: '', source_type: '', - source: {}, + source: {citation_id: '', description: ''}, description: '', disease: { name: '' @@ -237,7 +237,7 @@ options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field var sourceField = _.find(scope.fields, { key: 'source'}); - sourceField.value({}); + sourceField.value({citation_id: '', description: ''}); sourceField.templateOptions.data.citation = '--'; sourceField.templateOptions.data.sourceType = value.toLowerCase(); } @@ -251,13 +251,15 @@ label: 'Source', required: true, editable: false, - typeahead: 'item as item.description for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', onSelect: 'to.data.citation = $model.description', data: { citation: '--', sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { + if (val.match(/[^0-9]+/)) { return false; } // must be numeric + if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType @@ -270,7 +272,7 @@ }, helpText: help['Source'] }, - formatters: [function(val) { return val.citation_id;}], // this pulls the cit_id from the object to display in the input + // formatters: [function(val) { return val.citation_id;}], // this pulls the cit_id from the object to display in the input controller: /* @ngInject */ function($scope, $stateParams) { // TODO this won't work, will need to query the server to get the entire source object // if($stateParams.citationId) { From 35effc6fd34b52752fba851bc2e7349c7813723c Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 09:27:06 -0600 Subject: [PATCH 20/65] source field now only permits numeric strings, checks ASCO ID length --- src/app/views/events/evidence/edit/evidenceEditBasic.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index d03df3f62..13b401c0f 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -167,6 +167,8 @@ citation: '--', sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { + if (val.match(/[^0-9]+/)) { return false; } // must be numeric + if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType From 2155aab6d101a83a6732c09694f8e94553649870 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 09:46:21 -0600 Subject: [PATCH 21/65] removed parsers, formatters --- src/app/views/events/evidence/edit/evidenceEditBasic.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 13b401c0f..3843c08b1 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -181,8 +181,6 @@ }, helpText: help['Source'] }, - formatters: [function(val) { return val;}], // this pulls the cit_id from the object to display in the input - parsers: [function(val) { return val;}], controller: /* @ngInject */ function($scope) { $scope.to.data.sourceType = $scope.model.source_type; $scope.to.data.citation = $scope.model.source_citation; From 5edb02db61d2cc854f249f5dfc95fe7edaf82258 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 10:04:31 -0600 Subject: [PATCH 22/65] source_type onChange behavior adjustments --- .../views/add/evidence/addEvidenceBasic.js | 7 ++- .../events/evidence/edit/evidenceEditBasic.js | 52 +------------------ 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 49dae0564..bb8fa1504 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -239,7 +239,8 @@ var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({citation_id: '', description: ''}); sourceField.templateOptions.data.citation = '--'; - sourceField.templateOptions.data.sourceType = value.toLowerCase(); + if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + else { sourceField.templateOptions.data.sourceType = undefined; } } } }, @@ -272,13 +273,15 @@ }, helpText: help['Source'] }, - // formatters: [function(val) { return val.citation_id;}], // this pulls the cit_id from the object to display in the input controller: /* @ngInject */ function($scope, $stateParams) { // TODO this won't work, will need to query the server to get the entire source object // if($stateParams.citationId) { // $scope.model.citation_id = $stateParams.citationId; // } }, + expressionProperties: { + 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified + }, modelOptions: { debounce: { default: 300 diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 3843c08b1..6fb31f9dd 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -148,7 +148,8 @@ var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({description: '', citation_id: ''}); sourceField.templateOptions.data.citation = '--'; - sourceField.templateOptions.data.sourceType = value.toLowerCase(); + if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + else { sourceField.templateOptions.data.sourceType = undefined; } } } }, @@ -191,55 +192,6 @@ } } }, - // { - // key: 'pubmed_id', - // type: 'pubmed', - // templateOptions: { - // label: 'Pubmed ID', - // value: 'vm.evidenceEdit.pubmed_id', - // minLength: 1, - // required: true, - // data: { - // description: '--' - // }, - // helpText: help['Pubmed ID'] - // }, - // modelOptions: { - // updateOn: 'default blur', - // allowInvalid: false, - // debounce: { - // default: 300, - // blur: 0 - // } - // }, - // validators: { - // validPubmedId: { - // expression: function($viewValue, $modelValue, scope) { - // if ($viewValue.length > 0) { - // var deferred = $q.defer(); - // scope.options.templateOptions.loading = true; - // Publications.verify($viewValue).then( - // function (response) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = response.description; - // deferred.resolve(response); - // }, - // function (error) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = '--'; - // deferred.reject(error); - // } - // ); - // return deferred.promise; - // } else { - // scope.options.templateOptions.data.description = '--'; - // return true; - // } - // }, - // message: '"This does not appear to be a valid Pubmed ID."' - // } - // } - // }, { key: 'disease', type: 'horizontalTypeaheadHelp', From ae1d4dd35d5abf0757e3c96ca157cdf267b3045e Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 10:29:39 -0600 Subject: [PATCH 23/65] source type field now sets its description properly on edit form --- .../events/evidence/edit/evidenceEditBasic.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 6fb31f9dd..b959577b4 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -114,17 +114,11 @@ key: 'source_type', type: 'horizontalSelectHelp', wrapper: 'attributeDefinition', - controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { - if($stateParams.sourceType) { - var st = $stateParams.sourceType; - var permitted = _.keys(ConfigService.evidenceAttributeDescriptions.source_type); - if(_.includes(permitted, st)) { - $scope.model.source_type = st; - $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; - } else { - console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); - } - } + controller: /* @ngInject */ function($scope) { + // set attribute definition + var type = $scope.model.source_type === 'asco' ? 'ASCO':'PubMed'; + $scope.options.templateOptions.data.attributeDefinition = + $scope.options.templateOptions.data.attributeDefinitions[type]; }, templateOptions: { label: 'Source Type', @@ -143,7 +137,10 @@ }, onChange: function(value, options, scope) { // set attribute definition - options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; + // server returns all lowercase for source_type, we need to convert to the multicase + // versions to match the attribute descriptions here... + var type = value === 'asco' ? 'ASCO':'PubMed'; + options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[type]; // set source_type on citation_id and clear field var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({description: '', citation_id: ''}); From e74372aa60f948c9ca16af7dfcd955a1a7a8cf3e Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 28 Nov 2018 16:39:23 -0600 Subject: [PATCH 24/65] add evidence duplicate notification working --- src/app/views/add/evidence/addEvidenceBasic.js | 12 ++++++++---- .../views/events/evidence/edit/evidenceEditBasic.js | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index bb8fa1504..3bc4cb9ba 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -310,9 +310,12 @@ 'condition': {'name': 'contains', 'parameters': [values[1]]} }, { - 'field': 'pubmed_id', - 'condition': {'name': 'is', 'parameters': [values[2]] - } + 'field': 'source_type', + 'condition': {'name': 'is_equal_to', 'parameters': [values[2].toLowerCase()]} + }, + { + 'field': 'citation_id', + 'condition': {'name': 'is_equal_to', 'parameters': [values[3]]} } ], 'entity': 'evidence_items', @@ -329,7 +332,8 @@ $scope.$watchGroup([ 'model.gene.name', 'model.variant.name', - 'model.pubmed_id' + 'model.source_type', + 'model.source.citation_id' ], searchForDups); } }, diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index b959577b4..d46957b9d 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -123,6 +123,7 @@ templateOptions: { label: 'Source Type', required: true, + // here we specify options instead of generating from config b/c the server gives us lowercase type strings instead of the multi-case strings used for the labels options: [ { value: '', label: 'Please select a Source Type' }, { value: 'pubmed', label: 'PubMed' }, From 1515459e94ca90bc5684a747975f980bd97a6100 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 29 Nov 2018 11:59:09 -0600 Subject: [PATCH 25/65] source, source_type fields on suggestion form working (submit still needs work) --- .../suggest/source/SuggestSourceController.js | 186 ++++++++++++++---- .../suggest/source/suggestSource.tpl.html | 22 +-- 2 files changed, 155 insertions(+), 53 deletions(-) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 52f031cd4..a7f5d4cdf 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -17,6 +17,8 @@ console.log('SuggestSourceController called.'); var help = ConfigService.evidenceHelpText; + var descriptions = ConfigService.evidenceAttributeDescriptions; + var make_options = ConfigService.optionMethods.make_options; // make options for pull down var vm = $scope.vm = {}; vm.isAuthenticated = Security.isAuthenticated(); @@ -29,6 +31,11 @@ vm.newSuggestion= { suggestion: { + source_type: '', + source: { + description: '', + citation_id: '' + } }, comment: { title: 'Source Suggestion Comment' @@ -37,55 +44,141 @@ vm.suggestionFields =[ { - key: 'pubmed_id', - type: 'pubmed', + key: 'source_type', + type: 'horizontalSelectHelp', model: vm.newSuggestion.suggestion, + wrapper: 'attributeDefinition', + controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { + if($stateParams.sourceType) { + var st = $stateParams.sourceType; + var permitted = _.keys(ConfigService.evidenceAttributeDescriptions.source_type); + if(_.includes(permitted, st)) { + $scope.model.source_type = st; + $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; + } else { + console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); + } + } + }, templateOptions: { - label: 'Pubmed ID', - value: 'vm.newSuggestion.pubmed_id', - minLength: 1, + 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', + helpText: help['Source Type'], data: { - description: '--' + attributeDefinition: ' ', + attributeDefinitions: descriptions.source_type }, - helpText: help['Pubmed ID'] + onChange: function(value, options, scope) { + // set attribute definition + options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; + // set source_type on citation_id and clear field + var sourceField = _.find(scope.fields, { key: 'source'}); + sourceField.value({citation_id: '', description: ''}); + sourceField.templateOptions.data.citation = '--'; + if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + else { sourceField.templateOptions.data.sourceType = undefined; } + } + } + }, + { + key: 'source', + type: 'horizontalTypeaheadHelp', + model: vm.newSuggestion.suggestion, + wrapper: ['citation'], + templateOptions: { + label: 'Source', + required: true, + editable: false, + typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', + templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', + onSelect: 'to.data.citation = $model.description', + data: { + citation: '--', + sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType + typeaheadSearch: function(val, sourceType) { + if (val.match(/[^0-9]+/)) { return false; } // must be numeric + if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr + var reqObj = { + citationId: val, + sourceType: sourceType + }; + return Publications.verify(reqObj) + .then(function(response) { + return response; + }); + } + }, + helpText: help['Source'] + }, + controller: /* @ngInject */ function($scope, $stateParams) { + // TODO this won't work, will need to query the server to get the entire source object + // if($stateParams.citationId) { + // $scope.model.citation_id = $stateParams.citationId; + // } + }, + expressionProperties: { + 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified }, modelOptions: { - updateOn: 'default blur', - allowInvalid: false, debounce: { - default: 300, - blur: 0 - } - }, - validators: { - validPubmedId: { - expression: function($viewValue, $modelValue, scope) { - if (!_.isUndefined($viewValue) && $viewValue.length > 0) { - var deferred = $q.defer(); - scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( - function (response) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; - deferred.resolve(response); - }, - function (error) { - scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = '--'; - deferred.reject(error); - } - ); - return deferred.promise; - } else { - scope.options.templateOptions.data.description = '--'; - return true; - } - }, - message: '"This does not appear to be a valid Pubmed ID."' + default: 300 } } }, + // { + // key: 'pubmed_id', + // type: 'pubmed', + // model: vm.newSuggestion.suggestion, + // templateOptions: { + // label: 'Pubmed ID', + // value: 'vm.newSuggestion.pubmed_id', + // minLength: 1, + // required: true, + // data: { + // description: '--' + // }, + // helpText: help['Pubmed ID'] + // }, + // modelOptions: { + // updateOn: 'default blur', + // allowInvalid: false, + // debounce: { + // default: 300, + // blur: 0 + // } + // }, + // validators: { + // validPubmedId: { + // expression: function($viewValue, $modelValue, scope) { + // if (!_.isUndefined($viewValue) && $viewValue.length > 0) { + // var deferred = $q.defer(); + // scope.options.templateOptions.loading = true; + // Publications.verify($viewValue).then( + // function (response) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = response.description; + // deferred.resolve(response); + // }, + // function (error) { + // scope.options.templateOptions.loading = false; + // scope.options.templateOptions.data.description = '--'; + // deferred.reject(error); + // } + // ); + // return deferred.promise; + // } else { + // scope.options.templateOptions.data.description = '--'; + // return true; + // } + // }, + // message: '"This does not appear to be a valid Pubmed ID."' + // } + // } + // }, { key: 'gene', type: 'horizontalTypeaheadHelp', @@ -268,12 +361,21 @@ vm.submit = function(req) { vm.error = {}; var reqObj = { - pubmed_id: req.suggestion.pubmed_id, + source: req.suggestion, comment: req.comment }; - if(!_.isUndefined(req.suggestion.gene) && _.isObject(req.suggestion.gene)) {reqObj.gene_name = req.suggestion.gene.name;} - if(!_.isUndefined(req.suggestion.variant) && _.isObject(req.suggestion.variant)) {reqObj.variant_name = req.suggestion.variant.name;} - if(!_.isUndefined(req.suggestion.disease) && _.isObject(req.suggestion.disease)) {reqObj.disease_name = req.suggestion.disease.name;} + if(!_.isUndefined(req.suggestion.gene) && _.isObject(req.suggestion.gene)) { + reqObj.gene_name = req.suggestion.gene.name; + reqObj.source = _.omit(reqObj.source, 'gene'); + } + if(!_.isUndefined(req.suggestion.variant) && _.isObject(req.suggestion.variant)) { + reqObj.variant_name = req.suggestion.variant.name; + reqObj.source = _.omit(reqObj.source, 'variant'); + } + if(!_.isUndefined(req.suggestion.disease) && _.isObject(req.suggestion.disease)) { + reqObj.disease_name = req.suggestion.disease.name; + reqObj.source = _.omit(reqObj.source, 'variant'); + } Sources.suggest(reqObj).then( function(response) { // success console.log('source suggestion submit success.'); diff --git a/src/app/views/suggest/source/suggestSource.tpl.html b/src/app/views/suggest/source/suggestSource.tpl.html index ab49266f4..5afb4715e 100644 --- a/src/app/views/suggest/source/suggestSource.tpl.html +++ b/src/app/views/suggest/source/suggestSource.tpl.html @@ -19,7 +19,7 @@

Sugges @@ -75,14 +75,14 @@

Thank you.

- - - - - - - - - - +
+
+

vm.newSuggestion

+

+    
+
+

Form:

+

+    
+
From 404fcbf5b21cc700de2289ed57c1f08ca2efffbd Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 29 Nov 2018 12:18:44 -0600 Subject: [PATCH 26/65] browsegrid sources coldefs now handle source_type and citation_id --- src/app/views/browse/directives/browseGrid.js | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/app/views/browse/directives/browseGrid.js b/src/app/views/browse/directives/browseGrid.js index c1cc33166..3f631b0b1 100644 --- a/src/app/views/browse/directives/browseGrid.js +++ b/src/app/views/browse/directives/browseGrid.js @@ -753,8 +753,27 @@ ], 'sources': [ { - name: 'pubmed_id', - displayName: 'Pubmed ID', + name: 'source_type', + displayName: 'Type', + enableFiltering: true, + allowCellFocus: false, + cellTemplate: 'app/views/events/common/genericHighlightCell.tpl.html', + type: 'string', + width: '8%', + filter: { + type: uiGridConstants.filter.SELECT, + term: null, + disableCancelFilterButton: false, + selectOptions: [ + { value: null, label: '--' }, + { value: '0', label: 'pubmed'}, + { value: '1', label: 'asco'} + ] + } + }, + { + name: 'citation_id', + displayName: 'Citation ID', enableFiltering: true, allowCellFocus: false, cellTemplate: 'app/views/events/common/genericHighlightCell.tpl.html', @@ -770,7 +789,7 @@ enableFiltering: true, allowCellFocus: false, type: 'string', - width: '20%', + width: '15%', cellTemplate: 'app/views/browse/directives/browseGridTooltipCell.tpl.html', filter: { condition: uiGridConstants.filter.CONTAINS @@ -794,7 +813,7 @@ type: 'string', enableFiltering: true, allowCellFocus: false, - width: '15%', + width: '12%', cellTemplate: 'app/views/browse/directives/browseGridTooltipCell.tpl.html', filter: { condition: uiGridConstants.filter.CONTAINS From c8dda63a2b87a4ec41e7037144036202d49298d7 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 29 Nov 2018 12:43:16 -0600 Subject: [PATCH 27/65] source suggestion grid adds source type column --- .../components/sourceSuggestionGrid.js | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/app/views/sources/components/sourceSuggestionGrid.js b/src/app/views/sources/components/sourceSuggestionGrid.js index f79499395..d810781dc 100644 --- a/src/app/views/sources/components/sourceSuggestionGrid.js +++ b/src/app/views/sources/components/sourceSuggestionGrid.js @@ -138,11 +138,30 @@ cellTemplate: '
' }, { - name: 'pubmed_id', - displayName: 'Pubmed ID', - width: '10%', + name: 'source_type', + displayName: 'Type', + enableFiltering: true, + allowCellFocus: false, + cellTemplate: 'app/views/events/common/genericHighlightCell.tpl.html', + type: 'string', + width: '8%', + filter: { + type: uiGridConstants.filter.SELECT, + term: null, + disableCancelFilterButton: false, + selectOptions: [ + { value: null, label: '--' }, + { value: '0', label: 'pubmed'}, + { value: '1', label: 'asco'} + ] + } + }, + { + name: 'citation_id', + displayName: 'Citation ID', + width: '8%', visible: true, - cellTemplate: '', + cellTemplate: '
{{ row.entity[col.field] }}
', //visible: mode === 'full', enableFiltering: true, allowCellFocus: false, @@ -157,7 +176,7 @@ visible: mode === 'full', enableFiltering: true, allowCellFocus: false, - width: '15%', + width: '13%', type: 'string', cellTemplate: 'app/views/sources/components/cellTemplateCitation.tpl.html', filter: { From 42ff03f01337fd99490d03722e974fb073e31503 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Fri, 30 Nov 2018 11:46:33 -0600 Subject: [PATCH 28/65] add evidence duplicate warning field properly resets itself after updating source type --- src/app/views/add/evidence/addEvidenceBasic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 3bc4cb9ba..d04c1dfb2 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -296,8 +296,8 @@ vm.pubmedName = ''; function searchForDups(values) { + vm.duplicates = []; if(_.every(values, function(val) { return _.isString(val) && val.length > 0; })) { - vm.duplicates = []; Search.post({ 'operator': 'AND', 'queries': [ From 5e5963555d0324dfd50bdac7a267bb81d717500c Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 10:05:51 -0600 Subject: [PATCH 29/65] updated evidence add/edit/summary to work with capitalized source types --- .../views/add/evidence/addEvidenceBasic.js | 7 +++-- .../events/evidence/edit/evidenceEditBasic.js | 2 +- .../evidence/summary/evidenceSummary.tpl.html | 27 +++++-------------- .../sources/summary/sourcesSummary.tpl.html | 10 +++---- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index d04c1dfb2..f1342fd88 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -239,7 +239,7 @@ var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({citation_id: '', description: ''}); sourceField.templateOptions.data.citation = '--'; - if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } } } @@ -255,6 +255,9 @@ typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', onSelect: 'to.data.citation = $model.description', + onChange: function(value, options, scope) { + // if field invalid, replace data.description with '--' + }, data: { citation: '--', sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType @@ -311,7 +314,7 @@ }, { 'field': 'source_type', - 'condition': {'name': 'is_equal_to', 'parameters': [values[2].toLowerCase()]} + 'condition': {'name': 'is_equal_to', 'parameters': [values[2]]} }, { 'field': 'citation_id', diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index d46957b9d..b326c4414 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -146,7 +146,7 @@ var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({description: '', citation_id: ''}); sourceField.templateOptions.data.citation = '--'; - if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } } } diff --git a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html index 681f00030..4d4a25fef 100644 --- a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html +++ b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html @@ -116,7 +116,7 @@ - + PubMed ID: @@ -125,25 +125,12 @@ - - - - - - - - - - - - - - - + + + + diff --git a/src/app/views/sources/summary/sourcesSummary.tpl.html b/src/app/views/sources/summary/sourcesSummary.tpl.html index 248ee895c..9b6d5412b 100644 --- a/src/app/views/sources/summary/sourcesSummary.tpl.html +++ b/src/app/views/sources/summary/sourcesSummary.tpl.html @@ -19,7 +19,7 @@

Full Source Title

Abstract: Abstract

-

Abstract: Due to the limitations of ASCO's copyright, we cannot display this source's abstract here. Please visit the source record on ASCO's website to view the abstract.

+

Abstract: Due to ASCO copyright limitations, we cannot display this source's abstract here. Please visit the source record on ASCO's website to view the abstract.

@@ -43,17 +43,17 @@

Full Source Title

- + PubMed ID: - + ASCO ID: - + @@ -61,7 +61,7 @@

Full Source Title

- + From 6257adab8c383657cf6d19ebe60ecb79dd28c55a Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 10:09:17 -0600 Subject: [PATCH 30/65] fixed evidence summary source type condition --- src/app/views/events/evidence/summary/evidenceSummary.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html index 4d4a25fef..0cc4736b8 100644 --- a/src/app/views/events/evidence/summary/evidenceSummary.tpl.html +++ b/src/app/views/events/evidence/summary/evidenceSummary.tpl.html @@ -119,7 +119,7 @@ PubMed ID: - + ASCO ID: From 59f857690fe5aef195a4b2acffce1e987603173a Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 10:22:00 -0600 Subject: [PATCH 31/65] source id label now updates itself depending on source type --- src/app/views/add/evidence/addEvidenceBasic.js | 5 +++-- .../views/events/evidence/edit/evidenceEditBasic.js | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index f1342fd88..890381a3d 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -249,7 +249,7 @@ type: 'horizontalTypeaheadHelp', wrapper: ['citation'], templateOptions: { - label: 'Source', + label: 'Source ID', required: true, editable: false, typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', @@ -283,7 +283,8 @@ // } }, expressionProperties: { - 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified + 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', + 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"' }, modelOptions: { debounce: { diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index b326c4414..d23d468f4 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -124,11 +124,7 @@ label: 'Source Type', required: true, // here we specify options instead of generating from config b/c the server gives us lowercase type strings instead of the multi-case strings used for the labels - options: [ - { value: '', label: 'Please select a Source Type' }, - { value: 'pubmed', label: 'PubMed' }, - { value: 'asco', label: 'ASCO' } - ], + options: [{ value: '', label: 'Please select a Source Type' }].concat(make_options(descriptions.source_type)), valueProp: 'value', labelProp: 'label', helpText: help['Source Type'], @@ -184,6 +180,10 @@ $scope.to.data.sourceType = $scope.model.source_type; $scope.to.data.citation = $scope.model.source_citation; }, + expressionProperties: { + 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', + 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"' + }, modelOptions: { debounce: { default: 300 From dbf54c12d38063295dd4f5187e3e7be8dbe6648b Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 14:21:24 -0600 Subject: [PATCH 32/65] updated more source_type logic using lowercase types --- src/app/views/add/evidence/addEvidenceBasic.js | 2 +- src/app/views/events/evidence/edit/evidenceEditBasic.js | 3 +-- src/app/views/suggest/source/SuggestSourceController.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 890381a3d..b6651f0ab 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -263,7 +263,7 @@ sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr + if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index d23d468f4..ab4d3fd6d 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -63,7 +63,6 @@ vm.evidenceEdit.drugs = _.filter(_.map(vm.evidence.drugs, 'name'), function(name){ return name !== 'N/A'; }); vm.evidenceEdit.phenotypes = _.map(vm.evidenceEdit.phenotypes, function(phenotype) { return phenotype.hpo_class; }); vm.evidenceEdit.source_type = vm.evidenceEdit.source.source_type; - vm.evidenceEdit.source_citation = vm.evidenceEdit.source.citation; vm.evidenceEdit.source = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string vm.styles = EvidenceViewOptions.styles; @@ -163,7 +162,7 @@ sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr + if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index a7f5d4cdf..8c4f1e6ef 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -101,7 +101,7 @@ sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'asco' && val.length < 2) { return false; } // asco IDs are all > 2 chr + if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType From b532b743f5f60474c49a6a3f7e045c203cf33972 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 15:50:47 -0600 Subject: [PATCH 33/65] added publication field type --- .../forms/fieldTypes/publication.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/components/forms/fieldTypes/publication.js diff --git a/src/components/forms/fieldTypes/publication.js b/src/components/forms/fieldTypes/publication.js new file mode 100644 index 000000000..0bd754bc6 --- /dev/null +++ b/src/components/forms/fieldTypes/publication.js @@ -0,0 +1,19 @@ +(function() { + 'use strict'; + angular.module('civic.config') + .config(publicationConfig); + + // @ngInject + function publicationConfig(formlyConfigProvider) { + formlyConfigProvider.setType({ + name: 'publication', + extends: 'input', + wrapper: ['loader', 'citation', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] + }); + formlyConfigProvider.setType({ + name: 'publication-multi', + extends: 'input', + wrapper: ['loader','citation'] + }); + } +})(); From 8f5d7ee3c7dcc5e54cb72724c3e85b005d823b7a Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 15:51:08 -0600 Subject: [PATCH 34/65] updated gene edit sources multi-input to work w/ new source response objects --- src/app/views/events/genes/edit/geneEditBasic.js | 12 +++++++++--- .../views/events/genes/edit/geneEditBasic.tpl.html | 12 ++++++------ src/components/forms/fieldTypes/citation.js | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/app/views/events/genes/edit/geneEditBasic.js b/src/app/views/events/genes/edit/geneEditBasic.js index d33da94e6..f758e3ee5 100644 --- a/src/app/views/events/genes/edit/geneEditBasic.js +++ b/src/app/views/events/genes/edit/geneEditBasic.js @@ -38,6 +38,8 @@ vm.isAuthenticated = Security.isAuthenticated(); vm.gene = Genes.data.item; + // convert source objects to array of IDs, multi-input field type does not handle objects at this time + vm.gene.sources = _.map(vm.gene.sources, 'citation_id'); vm.pendingFields = _.keys(GeneRevisions.data.pendingFields).length > 0; vm.pendingFieldsList = _.map(_.keys(GeneRevisions.data.pendingFields), function(field) { return field.charAt(0).toUpperCase() + field.slice(1); @@ -108,7 +110,7 @@ } }, { - key: 'source_ids', + key: 'sources', type: 'multiInput', templateOptions: { label: 'Sources', @@ -138,10 +140,14 @@ if ($viewValue.length > 0) { var deferred = $q.defer(); scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( + var reqObj = { + citationId: $viewValue, + sourceType: 'PubMed' + }; + Publications.verify(reqObj).then( function (response) { scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; + scope.options.templateOptions.data.citation = response[0].description; deferred.resolve(response); }, function (error) { diff --git a/src/app/views/events/genes/edit/geneEditBasic.tpl.html b/src/app/views/events/genes/edit/geneEditBasic.tpl.html index 892b82c05..1c3790739 100644 --- a/src/app/views/events/genes/edit/geneEditBasic.tpl.html +++ b/src/app/views/events/genes/edit/geneEditBasic.tpl.html @@ -98,11 +98,11 @@

Thank you.

- - - +
+
+
 
-  
-  
-  
+      
+
+
diff --git a/src/components/forms/fieldTypes/citation.js b/src/components/forms/fieldTypes/citation.js index ee2da8967..b1ba844a7 100644 --- a/src/components/forms/fieldTypes/citation.js +++ b/src/components/forms/fieldTypes/citation.js @@ -9,7 +9,7 @@ formlyConfigProvider.setType({ name: 'citation', extends: 'input', - wrapper: ['loader', 'pubdisplay', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] + wrapper: ['loader', 'citation', 'validationMessages', 'horizontalBootstrapHelp', 'bootstrapHasError'] }); } From 77306254ca47b71d59a2a3d61b979ea64ade93e7 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 16:08:49 -0600 Subject: [PATCH 35/65] gene sources edit now working w/ new endpoint responses --- src/app/views/events/genes/edit/geneEditBasic.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/views/events/genes/edit/geneEditBasic.js b/src/app/views/events/genes/edit/geneEditBasic.js index f758e3ee5..bc9ea41d9 100644 --- a/src/app/views/events/genes/edit/geneEditBasic.js +++ b/src/app/views/events/genes/edit/geneEditBasic.js @@ -39,7 +39,6 @@ vm.gene = Genes.data.item; // convert source objects to array of IDs, multi-input field type does not handle objects at this time - vm.gene.sources = _.map(vm.gene.sources, 'citation_id'); vm.pendingFields = _.keys(GeneRevisions.data.pendingFields).length > 0; vm.pendingFieldsList = _.map(_.keys(GeneRevisions.data.pendingFields), function(field) { return field.charAt(0).toUpperCase() + field.slice(1); @@ -48,7 +47,7 @@ vm.geneHistory = GeneHistory; vm.geneEdit = angular.copy(vm.gene); vm.geneEdit.comment = { title: 'GENE ' + vm.gene.name + ' Revision Description', text:'' }; - vm.geneEdit.source_ids = _.map(vm.gene.sources, 'pubmed_id'); + vm.geneEdit.source_ids = _.map(vm.gene.sources, 'citation_id'); vm.myGeneInfo = geneModel.data.myGeneInfo; vm.variants = geneModel.data.variants; vm.variantGroups = geneModel.data.variantGroups; @@ -110,7 +109,7 @@ } }, { - key: 'sources', + key: 'source_ids', type: 'multiInput', templateOptions: { label: 'Sources', From ae740438ea8ec6868a26053155ae3f287f67a5b8 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 16:26:41 -0600 Subject: [PATCH 36/65] variant edit form source multi-input works w/ new source response objects --- src/app/views/events/genes/edit/geneEditBasic.js | 2 +- .../views/events/variants/edit/variantEditBasic.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/views/events/genes/edit/geneEditBasic.js b/src/app/views/events/genes/edit/geneEditBasic.js index bc9ea41d9..71c8e3d5e 100644 --- a/src/app/views/events/genes/edit/geneEditBasic.js +++ b/src/app/views/events/genes/edit/geneEditBasic.js @@ -122,7 +122,7 @@ minLength: 1, required: true, data: { - description: '--' + citation: '--' } }, modelOptions: { diff --git a/src/app/views/events/variants/edit/variantEditBasic.js b/src/app/views/events/variants/edit/variantEditBasic.js index 0a349a11f..eb3c22684 100644 --- a/src/app/views/events/variants/edit/variantEditBasic.js +++ b/src/app/views/events/variants/edit/variantEditBasic.js @@ -49,7 +49,7 @@ vm.variantEdit = angular.copy(_.omit(vm.variant, ['evidence_items', 'lifecycle_actions'])); vm.variantEdit.comment = { title: 'VARIANT ' + vm.variant.name + ' Suggested Revision', text:'' }; - vm.variantEdit.sources = _.map(vm.variant.sources, 'pubmed_id'); + vm.variantEdit.sources = _.map(vm.variant.sources, 'citation_id'); vm.variantEdit.noClinVar = false; vm.myVariantInfo = variantModel.data.myVariantInfo; @@ -244,7 +244,7 @@ minLength: 1, required: true, data: { - description: '--' + citation: '--' } }, modelOptions: { @@ -261,10 +261,14 @@ if ($viewValue.length > 0) { var deferred = $q.defer(); scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( + var reqObj = { + citationId: $viewValue, + sourceType: 'PubMed' + }; + Publications.verify(reqObj).then( function (response) { scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; + scope.options.templateOptions.data.citation = response[0].description; deferred.resolve(response); }, function (error) { From 94febdfd4e3eb1d26f571c1ce81103de75c659f4 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 3 Dec 2018 16:39:51 -0600 Subject: [PATCH 37/65] variant group edit form sources multi-input handles new source response objects --- .../variantGroups/edit/variantGroupEditBasic.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/views/events/variantGroups/edit/variantGroupEditBasic.js b/src/app/views/events/variantGroups/edit/variantGroupEditBasic.js index 13931998d..48ae0b896 100644 --- a/src/app/views/events/variantGroups/edit/variantGroupEditBasic.js +++ b/src/app/views/events/variantGroups/edit/variantGroupEditBasic.js @@ -49,7 +49,7 @@ vm.variantGroupHistory = VariantGroupHistory; vm.variantGroupEdit = angular.copy(vm.variantGroup); vm.variantGroupEdit.comment = { title: 'VARIANT GROUP ' + vm.variantGroup.name + ' Revision Description', text:'' }; - vm.variantGroupEdit.sources = _.map(vm.variantGroup.sources, 'pubmed_id'); + vm.variantGroupEdit.sources = _.map(vm.variantGroup.sources, 'citation_id'); vm.variantGroupEdit.variantsEdit = _.map(vm.variantGroupEdit.variants, function(variant) { return { name: variant.entrez_name + ' - ' + variant.name, id: variant.id }; }); @@ -105,7 +105,7 @@ minLength: 1, required: true, data: { - description: '--' + citation: '--' } }, modelOptions: { @@ -122,10 +122,14 @@ if ($viewValue.length > 0) { var deferred = $q.defer(); scope.options.templateOptions.loading = true; - Publications.verify($viewValue).then( + var reqObj = { + citationId: $viewValue, + sourceType: 'PubMed' + }; + Publications.verify(reqObj).then( function (response) { scope.options.templateOptions.loading = false; - scope.options.templateOptions.data.description = response.description; + scope.options.templateOptions.data.citation = response[0].description; deferred.resolve(response); }, function (error) { From 81f4a79225e9d3e5b18f72fd23c8288af450b02e Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 09:32:08 -0600 Subject: [PATCH 38/65] add evidence variant origin field now required --- src/app/views/add/evidence/addEvidenceBasic.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index b6651f0ab..0eb67f1e4 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -359,6 +359,7 @@ }, templateOptions: { label: 'Variant Origin', + required: true, value: 'vm.newEvidence.variant_origin', options: [{ value: '', label: 'Please select a Variant Origin' }].concat(make_options(descriptions.variant_origin)), valueProp: 'value', From 5b80f571c5eb5d3643c3aebc1b1f15cf7ec2f125 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 09:56:00 -0600 Subject: [PATCH 39/65] source type field now populating if sourceType URL param specified --- src/app/views/add/evidence/AddEvidenceController.js | 2 +- src/app/views/add/evidence/addEvidenceBasic.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/views/add/evidence/AddEvidenceController.js b/src/app/views/add/evidence/AddEvidenceController.js index 0c9d645a6..c84194db5 100644 --- a/src/app/views/add/evidence/AddEvidenceController.js +++ b/src/app/views/add/evidence/AddEvidenceController.js @@ -19,7 +19,7 @@ controllerAs: 'vm' }) .state('add.evidence.basic', { - url: '/basic?geneId&variantId&geneName&variantName&diseaseName&pubmedId&sourceSuggestionId&variantOrigin&evidenceType&evidenceDirection&evidenceLevel&clinicalSignificance', + url: '/basic?geneId&variantId&geneName&variantName&diseaseName&pubmedId&sourceType&citationId&variantOrigin&evidenceType&evidenceDirection&evidenceLevel&clinicalSignificance&isSuggestedSource', template: '', data: { titleExp: '"Add Evidence"', diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 0eb67f1e4..41e0ff069 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -96,7 +96,7 @@ vm.newEvidence.comment = { title: 'Additional Comments', text:'' }; vm.newEvidence.drugs = []; - vm.newEvidence.source_suggestion_id = _.isUndefined($stateParams.sourceSuggestionId) ? null : Number($stateParams.sourceSuggestionId); + vm.newEvidence.is_suggested_source = _.isUndefined($stateParams.isSuggestedSource) ? false : vm.newEvidence.is_suggested_source; vm.formErrors = {}; vm.formMessages = {}; From d928588ba191647110d3d58ce425774721b46b6c Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 12:04:28 -0600 Subject: [PATCH 40/65] add evidence source id field now populates from URL parameters --- .../add/evidence/AddEvidenceController.js | 2 +- src/app/views/add/evidence/addEvidenceBasic.js | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/views/add/evidence/AddEvidenceController.js b/src/app/views/add/evidence/AddEvidenceController.js index c84194db5..a2c97a9cc 100644 --- a/src/app/views/add/evidence/AddEvidenceController.js +++ b/src/app/views/add/evidence/AddEvidenceController.js @@ -19,7 +19,7 @@ controllerAs: 'vm' }) .state('add.evidence.basic', { - url: '/basic?geneId&variantId&geneName&variantName&diseaseName&pubmedId&sourceType&citationId&variantOrigin&evidenceType&evidenceDirection&evidenceLevel&clinicalSignificance&isSuggestedSource', + url: '/basic?geneId&variantId&geneName&variantName&diseaseName&pubmedId&sourceType&sourceId&variantOrigin&evidenceType&evidenceDirection&evidenceLevel&clinicalSignificance&isSuggestedSource', template: '', data: { titleExp: '"Add Evidence"', diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 41e0ff069..1d3d057d3 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -96,7 +96,7 @@ vm.newEvidence.comment = { title: 'Additional Comments', text:'' }; vm.newEvidence.drugs = []; - vm.newEvidence.is_suggested_source = _.isUndefined($stateParams.isSuggestedSource) ? false : vm.newEvidence.is_suggested_source; + vm.newEvidence.source_suggestion_id = _.isUndefined($stateParams.sourceId) ? null : Number($stateParams.sourceId); vm.formErrors = {}; vm.formMessages = {}; @@ -215,6 +215,10 @@ if(_.includes(permitted, st)) { $scope.model.source_type = st; $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; + // update source field info + // this unfortunately reproduces code in onChange below, but updating value above doesn't trigger onChange... + var sourceField = _.find($scope.fields, { key: 'source'}); + sourceField.templateOptions.data.sourceType = st; } else { console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); } @@ -277,10 +281,14 @@ helpText: help['Source'] }, controller: /* @ngInject */ function($scope, $stateParams) { - // TODO this won't work, will need to query the server to get the entire source object - // if($stateParams.citationId) { - // $scope.model.citation_id = $stateParams.citationId; - // } + if($stateParams.sourceId) { + // get citation + Sources.get($stateParams.sourceId) + .then(function(response){ + $scope.model.source = response; + $scope.to.data.citation = response.citation; + }); + } }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', From 13de870306b05770af1bf66e70702179738fb1f8 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 12:06:22 -0600 Subject: [PATCH 41/65] fixed source type capitalization --- .../suggest/source/SuggestSourceController.js | 52 +------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 8c4f1e6ef..9845aae5d 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -79,7 +79,7 @@ var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({citation_id: '', description: ''}); sourceField.templateOptions.data.citation = '--'; - if(value) { sourceField.templateOptions.data.sourceType = value.toLowerCase(); } + if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } } } @@ -129,56 +129,6 @@ } } }, - // { - // key: 'pubmed_id', - // type: 'pubmed', - // model: vm.newSuggestion.suggestion, - // templateOptions: { - // label: 'Pubmed ID', - // value: 'vm.newSuggestion.pubmed_id', - // minLength: 1, - // required: true, - // data: { - // description: '--' - // }, - // helpText: help['Pubmed ID'] - // }, - // modelOptions: { - // updateOn: 'default blur', - // allowInvalid: false, - // debounce: { - // default: 300, - // blur: 0 - // } - // }, - // validators: { - // validPubmedId: { - // expression: function($viewValue, $modelValue, scope) { - // if (!_.isUndefined($viewValue) && $viewValue.length > 0) { - // var deferred = $q.defer(); - // scope.options.templateOptions.loading = true; - // Publications.verify($viewValue).then( - // function (response) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = response.description; - // deferred.resolve(response); - // }, - // function (error) { - // scope.options.templateOptions.loading = false; - // scope.options.templateOptions.data.description = '--'; - // deferred.reject(error); - // } - // ); - // return deferred.promise; - // } else { - // scope.options.templateOptions.data.description = '--'; - // return true; - // } - // }, - // message: '"This does not appear to be a valid Pubmed ID."' - // } - // } - // }, { key: 'gene', type: 'horizontalTypeaheadHelp', From e01903d05c41e53d51462e7e8ad0b6511e6c5a03 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 12:08:41 -0600 Subject: [PATCH 42/65] fixed source suggest diseases typeahead aliases --- .../suggest/source/SuggestSourceController.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 9845aae5d..72592b246 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -228,7 +228,16 @@ typeaheadSearch: function(val) { return Diseases.beginsWith(val) .then(function(response) { - return response; + var labelLimit = 70; + return _.map(response, function(disease) { + if (disease.aliases.length > 0) { + disease.alias_list = disease.aliases.join(', '); + if(disease.alias_list.length > labelLimit) { disease.alias_list = _.truncate(disease.alias_list, labelLimit); } + } else { + disease.alias_list = '--'; + } + return disease; + }); }); } } @@ -255,7 +264,7 @@ { 'field': 'pubmed_id', 'condition': {'name': 'is', 'parameters': [values[0]] - } + } }, { 'field': 'gene_name', @@ -268,7 +277,7 @@ { 'field': 'disease_doid', 'condition': {'name': 'is', 'parameters': [values[3]] - } + } } ], 'entity': 'evidence_items', From aea6ea17bd577bb306c24f80be336162fa956124 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 13:10:32 -0600 Subject: [PATCH 43/65] source suggestion form works with new source objects; fixed dups row query --- .../suggest/source/SuggestSourceController.js | 60 ++++++++----------- .../suggest/source/suggestSource.tpl.html | 2 +- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 72592b246..9ea299f6a 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -30,12 +30,10 @@ vm.error = {}; vm.newSuggestion= { - suggestion: { - source_type: '', - source: { - description: '', - citation_id: '' - } + source_type: '', + source: { + citation_id: '', + description: '' }, comment: { title: 'Source Suggestion Comment' @@ -46,7 +44,6 @@ { key: 'source_type', type: 'horizontalSelectHelp', - model: vm.newSuggestion.suggestion, wrapper: 'attributeDefinition', controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { if($stateParams.sourceType) { @@ -63,7 +60,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', @@ -87,7 +83,6 @@ { key: 'source', type: 'horizontalTypeaheadHelp', - model: vm.newSuggestion.suggestion, wrapper: ['citation'], templateOptions: { label: 'Source', @@ -249,35 +244,33 @@ hideExpression: 'model.noDoid' }, { // duplicates warning row - templateUrl: 'app/views/suggest/source/evidenceDuplicateWarning.tpl.html', + templateUrl: 'app/views/add/evidence/addEvidenceDuplicateWarning.tpl.html', controller: /* @ngInject */ function($scope, Search) { - console.log('dup warning controller loaded.'); var vm = $scope.vm = {}; vm.duplicates = []; vm.pubmedName = ''; function searchForDups(values) { + vm.duplicates = []; if(_.every(values, function(val) { return _.isString(val) && val.length > 0; })) { Search.post({ 'operator': 'AND', 'queries': [ { - 'field': 'pubmed_id', - 'condition': {'name': 'is', 'parameters': [values[0]] - } + 'field': 'gene_name', + 'condition': {'name': 'contains', 'parameters': [values[0]]} }, { - 'field': 'gene_name', + 'field': 'variant_name', 'condition': {'name': 'contains', 'parameters': [values[1]]} }, { - 'field': 'variant_name', - 'condition': {'name': 'contains', 'parameters': [values[2]]} + 'field': 'source_type', + 'condition': {'name': 'is_equal_to', 'parameters': [values[2]]} }, { - 'field': 'disease_doid', - 'condition': {'name': 'is', 'parameters': [values[3]] - } + 'field': 'citation_id', + 'condition': {'name': 'is_equal_to', 'parameters': [values[3]]} } ], 'entity': 'evidence_items', @@ -291,13 +284,11 @@ $scope.pubmedField = _.find($scope.fields, { key: 'pubmed_id' }); - // {"operator":"AND","queries":[{"field":"pubmed_id","condition":{"name":"is","parameters":["25589621"]}},{"field":"gene_name","condition":{"name":"contains","parameters":["BRAF"]}},{"field":"variant_name","condition":{"name":"contains","parameters":["V600E"]}},{"field":"disease_doid","condition":{"name":"is","parameters":["9256"]}}]} - $scope.$watchGroup([ - 'model.suggestion.pubmed_id', - 'model.suggestion.gene.name', - 'model.suggestion.variant.name', - 'model.suggestion.disease.doid' + 'model.gene.name', + 'model.variant.name', + 'model.source_type', + 'model.source.citation_id' ], searchForDups); } }, @@ -320,20 +311,17 @@ vm.submit = function(req) { vm.error = {}; var reqObj = { - source: req.suggestion, + source: req.source, comment: req.comment }; - if(!_.isUndefined(req.suggestion.gene) && _.isObject(req.suggestion.gene)) { - reqObj.gene_name = req.suggestion.gene.name; - reqObj.source = _.omit(reqObj.source, 'gene'); + if(!_.isUndefined(req.gene) && _.isObject(req.gene)) { + reqObj.gene_name = req.gene.name; } - if(!_.isUndefined(req.suggestion.variant) && _.isObject(req.suggestion.variant)) { - reqObj.variant_name = req.suggestion.variant.name; - reqObj.source = _.omit(reqObj.source, 'variant'); + if(!_.isUndefined(req.variant) && _.isObject(req.variant)) { + reqObj.variant_name = req.variant.name; } - if(!_.isUndefined(req.suggestion.disease) && _.isObject(req.suggestion.disease)) { - reqObj.disease_name = req.suggestion.disease.name; - reqObj.source = _.omit(reqObj.source, 'variant'); + if(!_.isUndefined(req.disease) && _.isObject(req.disease)) { + reqObj.disease_name = req.disease.name; } Sources.suggest(reqObj).then( function(response) { // success diff --git a/src/app/views/suggest/source/suggestSource.tpl.html b/src/app/views/suggest/source/suggestSource.tpl.html index 5afb4715e..87e12e08f 100644 --- a/src/app/views/suggest/source/suggestSource.tpl.html +++ b/src/app/views/suggest/source/suggestSource.tpl.html @@ -45,7 +45,7 @@

Sugges class="btn btn-default" ng-disabled="vm.form.$invalid" ng-click="vm.submit(vm.newSuggestion, vm.formOptions)"> - Submit Evidence for Inclusion + Submit Source for Evaluation

From 001afa28863ca11f93605db3840a6c3401901e09 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 4 Dec 2018 15:12:13 -0600 Subject: [PATCH 44/65] handles updated description to citation attribute name change --- src/app/views/add/evidence/addEvidenceBasic.js | 2 +- src/app/views/events/evidence/edit/evidenceEditBasic.js | 3 +-- src/app/views/suggest/source/SuggestSourceController.js | 2 +- src/components/forms/fieldTypes/citationTypeahead.tpl.html | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 1d3d057d3..8d0611bcd 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -258,7 +258,7 @@ editable: false, typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.description', + onSelect: 'to.data.citation = $model.citation', onChange: function(value, options, scope) { // if field invalid, replace data.description with '--' }, diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index ab4d3fd6d..6e299c3c1 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -156,7 +156,7 @@ editable: true, typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.description', + onSelect: 'to.data.citation = $model.citation', data: { citation: '--', sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType @@ -261,7 +261,6 @@ rows: 5, required: true, label: 'Evidence Statement', - value: 'vm.evidenceEdit.description', minLength: 32, helpText: help['Evidence Statement'] } diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 9ea299f6a..2474224b3 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -90,7 +90,7 @@ editable: false, typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.description', + onSelect: 'to.data.citation = $model.citation', data: { citation: '--', sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType diff --git a/src/components/forms/fieldTypes/citationTypeahead.tpl.html b/src/components/forms/fieldTypes/citationTypeahead.tpl.html index a16150b4a..6fe746da5 100644 --- a/src/components/forms/fieldTypes/citationTypeahead.tpl.html +++ b/src/components/forms/fieldTypes/citationTypeahead.tpl.html @@ -1,4 +1,4 @@ ID: CITATION ID  - CITATION: DESCRIPTIOn + CITATION: DESCRIPTIOn From 374e90426428383244b157d469ad45a622e12f4e Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 10:58:52 -0600 Subject: [PATCH 45/65] source suggestion 'add' links now pre-populate add evidence form properly --- .../sources/components/sourceSuggestionGrid.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/views/sources/components/sourceSuggestionGrid.js b/src/app/views/sources/components/sourceSuggestionGrid.js index d810781dc..aea8932a9 100644 --- a/src/app/views/sources/components/sourceSuggestionGrid.js +++ b/src/app/views/sources/components/sourceSuggestionGrid.js @@ -151,8 +151,8 @@ disableCancelFilterButton: false, selectOptions: [ { value: null, label: '--' }, - { value: '0', label: 'pubmed'}, - { value: '1', label: 'asco'} + { value: 'PubMed', label: 'PubMed'}, + { value: 'ASCO', label: 'ASCO'} ] } }, @@ -297,11 +297,14 @@ if(_.has(source, 'disease') && source.disease !== null) { urlElements.push('diseaseName=' + source.disease); } - if(_.has(source, 'pubmed_id') && source.pubmed_id !== null) { - urlElements.push('pubmedId=' + source.pubmed_id); + if(_.has(source, 'source_type') && source.source_type !== null) { + urlElements.push('sourceType=' + source.source_type); + } + if(_.has(source, 'citation_id') && source.citation_id !== null) { + urlElements.push('citationId=' + source.citation_id); } - urlElements.push('sourceSuggestionId=' + source.id); + urlElements.push('sourceId=' + source.source_id); source.addEvidenceUrl = urlBase + '?' + urlElements.join('&'); return source; From fac5d3a216db7e44345b41c4a298df508e0584d2 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 12:04:40 -0600 Subject: [PATCH 46/65] sources name display browse grid --- src/app/views/browse/directives/browseGrid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/views/browse/directives/browseGrid.js b/src/app/views/browse/directives/browseGrid.js index 3f631b0b1..d0e80a43b 100644 --- a/src/app/views/browse/directives/browseGrid.js +++ b/src/app/views/browse/directives/browseGrid.js @@ -766,8 +766,8 @@ disableCancelFilterButton: false, selectOptions: [ { value: null, label: '--' }, - { value: '0', label: 'pubmed'}, - { value: '1', label: 'asco'} + { value: '0', label: 'PubMed'}, + { value: '1', label: 'ASCO'} ] } }, From e6058d8d32b91d8ba373e7b961af8ad1aed18f89 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 12:28:59 -0600 Subject: [PATCH 47/65] all sources now show author_string on summary page --- src/app/views/sources/summary/sourcesSummary.tpl.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/views/sources/summary/sourcesSummary.tpl.html b/src/app/views/sources/summary/sourcesSummary.tpl.html index 9b6d5412b..a89173959 100644 --- a/src/app/views/sources/summary/sourcesSummary.tpl.html +++ b/src/app/views/sources/summary/sourcesSummary.tpl.html @@ -11,15 +11,13 @@

Full Source Title

-

- Authors: Authors List -

+ Authors: Authors List
-

Abstract: Abstract

-

Abstract: Due to ASCO copyright limitations, we cannot display this source's abstract here. Please visit the source record on ASCO's website to view the abstract.

+

Abstract: Abstract

+

Abstract: Due to ASCO copyright limitations, we cannot display this source's abstract here. Please visit the source record on ASCO's website to view the abstract.

@@ -67,7 +65,7 @@

Full Source Title

target="_blank"> - + From 3df7b52b98756bd8147573973fc33f34d9e2bc26 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 16:09:14 -0600 Subject: [PATCH 48/65] added help text for new source type and source fields --- src/components/services/ConfigService.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/services/ConfigService.js b/src/components/services/ConfigService.js index e8f351806..7726d5fdc 100644 --- a/src/components/services/ConfigService.js +++ b/src/components/services/ConfigService.js @@ -408,7 +408,9 @@ 'Drug Names' : 'For predictive evidence, specify one or more drug names. Drugs specified must possess a PubChem ID (e.g., 44462760 for Dabrafenib).', 'Drug Interaction Type' : 'Please indicate whether the drugs specified above are substitutes, or are used in sequential or combination treatments.', 'Phenotypes' : 'Please provide any HPO phenotypes.', - 'Rating' : '

Please rate your evidence on a scale of one to five stars. Use the star rating descriptions for guidance.

', + 'Rating' : 'Please rate your evidence on a scale of one to five stars. Use the star rating descriptions for guidance.', + 'Source Type': 'CIViC accepts PubMed or ASCO Abstracts sources. Please indicate the source of the support for your evidence here.', + 'Source': 'Please enter a PubMed ID or an ASCO Abstract number to search for your source, then select it from the dropdown (PubMed searches will only show a single record). NOTE: CIViC uses the ASCO ID, not the ASCO Abstract Number to uniquely identify ASCO sources. Upon selection it is the unique ASCO ID that will populate this field, not the ASCO Abstract Number.', 'Revision Description' : 'Please provide a short description of your edits to this Evidence record.', 'Additional Comments' : 'Please provide any additional comments you wish to make about this evidence item. This comment will appear as the first comment in this item\'s comment thread.', 'keepSourceStatus' : 'Check this box if you wish the originating source suggestion to keep its un-curated status. Otherwise, it will be marked as curated and removed from the source suggestion queues.', From 0fc87bdb58fbf8c704bf56a47e40162529be1812 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 16:49:29 -0600 Subject: [PATCH 49/65] source typeahead shows helpful placeholder msg --- src/app/views/add/evidence/addEvidenceBasic.js | 3 ++- src/components/directives/typeaheadWrapper.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 8d0611bcd..e8a88cd31 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -292,7 +292,8 @@ }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', - 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"' + 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' }, modelOptions: { debounce: { diff --git a/src/components/directives/typeaheadWrapper.js b/src/components/directives/typeaheadWrapper.js index d059df634..952b5e82a 100644 --- a/src/components/directives/typeaheadWrapper.js +++ b/src/components/directives/typeaheadWrapper.js @@ -13,6 +13,7 @@ { var template = ' Date: Wed, 5 Dec 2018 17:00:10 -0600 Subject: [PATCH 50/65] added source field placeholder expressionProperty to evidence edit form --- src/app/views/events/evidence/edit/evidenceEditBasic.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 6e299c3c1..f8f1dbc84 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -181,7 +181,8 @@ }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', - 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"' + 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' }, modelOptions: { debounce: { From 1562cfaaae1ceae77a898eeaab1516b29984dcf4 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 5 Dec 2018 17:01:24 -0600 Subject: [PATCH 51/65] added source placeholder expressionProperty to suggest source form --- src/app/views/suggest/source/SuggestSourceController.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 2474224b3..3d5737e5f 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -117,6 +117,8 @@ }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified + 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' }, modelOptions: { debounce: { From 8048b3acc37ebab7949cf7cca202a90c027c9cf1 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 6 Dec 2018 09:42:49 -0600 Subject: [PATCH 52/65] typeahead wrapper now adds ng-model-options directive --- src/components/directives/typeaheadWrapper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/directives/typeaheadWrapper.js b/src/components/directives/typeaheadWrapper.js index 952b5e82a..a027b8dac 100644 --- a/src/components/directives/typeaheadWrapper.js +++ b/src/components/directives/typeaheadWrapper.js @@ -24,6 +24,7 @@ var disabled = attrs['ngDisabled']; if(disabled !== undefined) { template+='ng-disabled="'+disabled+'" '; } template+='ng-model="'+attrs['ngModel']+'" '; + template+='ng-model-options="'+attrs['ngModelOptions']+'" '; template+='class="'+attrs['class']+'" '; template+='typeahead-editable="'+attrs['typeaheadEditable']+'" '; template+='typeahead-focus-first="'+attrs['typeaheadFocusFirst']+'" '; From d9ed74ea5358970b50fb6d65c145ce75b74c4ae5 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 6 Dec 2018 09:46:11 -0600 Subject: [PATCH 53/65] disabled source ID now shows placeholder prompt; typeahead queries debounced --- src/app/views/add/evidence/addEvidenceBasic.js | 8 +++++--- .../events/evidence/edit/evidenceEditBasic.js | 8 +++++--- .../suggest/source/SuggestSourceController.js | 18 +++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index e8a88cd31..381cffb50 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -293,12 +293,14 @@ expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', - 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Please select Source Type"' }, modelOptions: { debounce: { - default: 300 - } + default: 300, + blur: 0 + }, + updateOn: 'default blur' } }, { // duplicates warning row diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index f8f1dbc84..2080f53f6 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -182,12 +182,14 @@ expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', - 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Please select Source Type"' }, modelOptions: { debounce: { - default: 300 - } + default: 300, + blur: 0 + }, + updateOn: 'default blur' } }, { diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 3d5737e5f..6906af83d 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -118,12 +118,14 @@ expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', - 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : ""' + 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Select Source Type to enable Source ID"' }, modelOptions: { debounce: { - default: 300 - } + default: 300, + blur: 0 + }, + updateOn: 'default blur' } }, { @@ -160,10 +162,12 @@ } } }, - modelOptions: { - debounce: { - default: 300 - } + 'modelOptions': { + 'debounce': { + 'default': 2000, + 'blur': 0 + }, + 'updateOn': 'default blur' } }, { From e25a49ef659c0e7110141195e2dcd958e03d89c7 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 6 Dec 2018 12:38:54 -0600 Subject: [PATCH 54/65] multiple assertions now display properly on in variant summary --- src/components/directives/assertionTag.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/directives/assertionTag.less b/src/components/directives/assertionTag.less index 7e61db1d1..2cb921b3a 100644 --- a/src/components/directives/assertionTag.less +++ b/src/components/directives/assertionTag.less @@ -7,6 +7,7 @@ @tabPaddingV: .25em; .assertionTag { + display: inline-block; a { text-decoration: none; padding: @tabPaddingV @tabPaddingH; From 8500654e4a9bc9a6fa6b12af6567742f9d2f30aa Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 6 Dec 2018 16:32:53 -0600 Subject: [PATCH 55/65] remove debugging output --- .../add/evidence/addEvidenceBasic.tpl.html | 34 +++++++++---------- .../evidence/edit/evidenceEditBasic.tpl.html | 20 +++++------ .../sources/summary/sourcesSummary.tpl.html | 3 +- .../suggest/source/suggestSource.tpl.html | 20 +++++------ 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.tpl.html b/src/app/views/add/evidence/addEvidenceBasic.tpl.html index de1635f09..17f0facf5 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.tpl.html +++ b/src/app/views/add/evidence/addEvidenceBasic.tpl.html @@ -87,21 +87,21 @@

Thank you.

-
-
-

vm.newEvidence

-

-      

submit button stuff

-

vm.form.$invalid: {{vm.form.$invalid}}

-

vm.isAuthenticated: {{vm.isAuthenticated}}

-
-
-

vm.form

-

-    
-
-

vm.evidenceFields

-

-    
-
+ + + + + + + + + + + + + + + + +
diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html b/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html index 6005a7992..9144b3779 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.tpl.html @@ -103,14 +103,14 @@

Thank you.

View it here

-
-
-

vm.evidencEdit

-

-    
-
-

vm.evidenceFields

-

-    
-
+ + + + + + + + + + diff --git a/src/app/views/sources/summary/sourcesSummary.tpl.html b/src/app/views/sources/summary/sourcesSummary.tpl.html index a89173959..09c3d5710 100644 --- a/src/app/views/sources/summary/sourcesSummary.tpl.html +++ b/src/app/views/sources/summary/sourcesSummary.tpl.html @@ -64,8 +64,7 @@

Full Source Title

class="btn btn-xs button-new-window" target="_blank"> - - + diff --git a/src/app/views/suggest/source/suggestSource.tpl.html b/src/app/views/suggest/source/suggestSource.tpl.html index 87e12e08f..d9f2ba7b8 100644 --- a/src/app/views/suggest/source/suggestSource.tpl.html +++ b/src/app/views/suggest/source/suggestSource.tpl.html @@ -75,14 +75,14 @@

Thank you.

-
-
-

vm.newSuggestion

-

-    
-
-

Form:

-

-    
-
+ + + + + + + + + + From dc0ebeabe589829c91ea3a595904d55068941861 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 9 Jan 2019 10:23:12 -0600 Subject: [PATCH 56/65] edit evidence source type field now properly updates its description on change --- src/app/views/events/evidence/edit/evidenceEditBasic.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 2080f53f6..5bf74ff1b 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -136,7 +136,7 @@ // server returns all lowercase for source_type, we need to convert to the multicase // versions to match the attribute descriptions here... var type = value === 'asco' ? 'ASCO':'PubMed'; - options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[type]; + options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field var sourceField = _.find(scope.fields, { key: 'source'}); sourceField.value({description: '', citation_id: ''}); @@ -162,7 +162,7 @@ sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr + if(sourceType === 'ASCO' && val.length < 1) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType From 9dc790b680e7afa3b2c2c364cfccf3f4ad9ec770 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Wed, 9 Jan 2019 10:31:08 -0600 Subject: [PATCH 57/65] reverting update to ASCO number length filter in source field --- src/app/views/events/evidence/edit/evidenceEditBasic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 5bf74ff1b..417a06b72 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -162,7 +162,7 @@ sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType typeaheadSearch: function(val, sourceType) { if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'ASCO' && val.length < 1) { return false; } // asco IDs are all > 2 chr + if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr var reqObj = { citationId: val, sourceType: sourceType From fe2459a05a79f64a421098e2fa3d4493eb71c864 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 10 Jan 2019 14:46:56 -0600 Subject: [PATCH 58/65] asco/pubmed source ID field async validators working --- .../views/add/evidence/addEvidenceBasic.js | 68 ++++++++++++------- .../services/PublicationsService.js | 2 +- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 381cffb50..d0c9de66e 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,7 +74,7 @@ gene: '', variant: '', source_type: '', - source: {citation_id: '', description: ''}, + source_id:'', description: '', disease: { name: '' @@ -240,8 +240,8 @@ // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var sourceField = _.find(scope.fields, { key: 'source'}); - sourceField.value({citation_id: '', description: ''}); + var sourceField = _.find(scope.fields, { key: 'source_id'}); + sourceField.value(''); sourceField.templateOptions.data.citation = '--'; if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } @@ -249,37 +249,53 @@ } }, { - key: 'source', - type: 'horizontalTypeaheadHelp', - wrapper: ['citation'], + key: 'source_id', + type: 'publication', templateOptions: { label: 'Source ID', required: true, - editable: false, - typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', - templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.citation', - onChange: function(value, options, scope) { - // if field invalid, replace data.description with '--' - }, data: { citation: '--', - sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType - typeaheadSearch: function(val, sourceType) { - if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr - var reqObj = { - citationId: val, - sourceType: sourceType - }; - return Publications.verify(reqObj) - .then(function(response) { - return response; - }); - } }, helpText: help['Source'] }, + asyncValidators: { + validId: { + expression: function($viewValue, $modelValue, scope) { + var type = scope.model.source_type; + if ($viewValue.length > 0 && type !== '') { + if ($viewValue.match(/[^0-9]+/)) { return false; } // must be number + var deferred = $q.defer(); + scope.options.templateOptions.loading = true; + var reqObj = { + citationId: $viewValue, + sourceType: type + }; + Publications.verify(reqObj).then( + function (response) { + scope.options.templateOptions.loading = false; + scope.options.templateOptions.data.citation = response.citation; + deferred.resolve(true); + }, + function (error) { + scope.options.templateOptions.loading = false; + if(error.status === 404) { + scope.options.templateOptions.data.citation = 'No ' + type + ' source found with specified ID.'; + } else { + scope.options.templateOptions.data.citation = 'Error fetching source, check console log for details.'; + } + deferred.reject(false); + } + ); + return deferred.promise; + } else { + scope.options.templateOptions.data.description = '--'; + return true; + } + }, + message: '"This does not appear to be a valid source ID."' + } + }, controller: /* @ngInject */ function($scope, $stateParams) { if($stateParams.sourceId) { // get citation diff --git a/src/components/services/PublicationsService.js b/src/components/services/PublicationsService.js index 584004662..249c6c90a 100644 --- a/src/components/services/PublicationsService.js +++ b/src/components/services/PublicationsService.js @@ -23,7 +23,7 @@ verify: { method: 'GET', url: '/api/sources/existence/:citationId?source_type=:sourceType', - isArray: true, + isArray: false, cache: true } }); From 36522afa773d0c867cd6a3a6959c7ae91858edfa Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 10 Jan 2019 15:27:48 -0600 Subject: [PATCH 59/65] edit evidence form now works w/ ASCO IDs instead of No. --- .../views/add/evidence/addEvidenceBasic.js | 6 +- .../events/evidence/edit/evidenceEditBasic.js | 79 ++++++++++++------- 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index d0c9de66e..0ffd69e44 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -263,9 +263,9 @@ validId: { expression: function($viewValue, $modelValue, scope) { var type = scope.model.source_type; + var deferred = $q.defer(); if ($viewValue.length > 0 && type !== '') { if ($viewValue.match(/[^0-9]+/)) { return false; } // must be number - var deferred = $q.defer(); scope.options.templateOptions.loading = true; var reqObj = { citationId: $viewValue, @@ -287,11 +287,11 @@ deferred.reject(false); } ); - return deferred.promise; } else { scope.options.templateOptions.data.description = '--'; - return true; + deferred.resolve(true); } + return deferred.promise; }, message: '"This does not appear to be a valid source ID."' } diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 417a06b72..62e3d741a 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -63,7 +63,7 @@ vm.evidenceEdit.drugs = _.filter(_.map(vm.evidence.drugs, 'name'), function(name){ return name !== 'N/A'; }); vm.evidenceEdit.phenotypes = _.map(vm.evidenceEdit.phenotypes, function(phenotype) { return phenotype.hpo_class; }); vm.evidenceEdit.source_type = vm.evidenceEdit.source.source_type; - vm.evidenceEdit.source = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string + vm.evidenceEdit.source_id = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string vm.styles = EvidenceViewOptions.styles; vm.user = {}; @@ -138,8 +138,8 @@ var type = value === 'asco' ? 'ASCO':'PubMed'; options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var sourceField = _.find(scope.fields, { key: 'source'}); - sourceField.value({description: '', citation_id: ''}); + var sourceField = _.find(scope.fields, { key: 'source_id'}); + sourceField.value(''); sourceField.templateOptions.data.citation = '--'; if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } @@ -147,37 +147,62 @@ } }, { - key: 'source', - type: 'horizontalTypeaheadHelp', - wrapper: ['citation'], + key: 'source_id', + type: 'publication', templateOptions: { - label: 'Source', + label: 'Source ID', required: true, - editable: true, - typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', - templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.citation', data: { citation: '--', - sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType - typeaheadSearch: function(val, sourceType) { - if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr - var reqObj = { - citationId: val, - sourceType: sourceType - }; - return Publications.verify(reqObj) - .then(function(response) { - return response; - }); - } }, helpText: help['Source'] }, - controller: /* @ngInject */ function($scope) { - $scope.to.data.sourceType = $scope.model.source_type; - $scope.to.data.citation = $scope.model.source_citation; + asyncValidators: { + validId: { + expression: function($viewValue, $modelValue, scope) { + var type = scope.model.source_type; + var deferred = $q.defer(); + if ($viewValue.length > 0 && type !== '') { + if ($viewValue.match(/[^0-9]+/)) { return false; } // must be number + scope.options.templateOptions.loading = true; + var reqObj = { + citationId: $viewValue, + sourceType: type + }; + Publications.verify(reqObj).then( + function (response) { + scope.options.templateOptions.loading = false; + scope.options.templateOptions.data.citation = response.citation; + deferred.resolve(true); + }, + function (error) { + scope.options.templateOptions.loading = false; + if(error.status === 404) { + scope.options.templateOptions.data.citation = 'No ' + type + ' source found with specified ID.'; + } else { + scope.options.templateOptions.data.citation = 'Error fetching source, check console log for details.'; + } + deferred.reject(false); + } + ); + } else { + scope.options.templateOptions.data.description = '--'; + deferred.resolve(true); + } + return deferred.promise; + }, + message: '"This does not appear to be a valid source ID."' + } + }, + controller: /* @ngInject */ function($scope, $stateParams) { + if($stateParams.sourceId) { + // get citation + Sources.get($stateParams.sourceId) + .then(function(response){ + $scope.model.source = response; + $scope.to.data.citation = response.citation; + }); + } }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', From 553a824e47aa7618e5cdeda37143b50bb411b328 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Thu, 10 Jan 2019 15:48:16 -0600 Subject: [PATCH 60/65] updated instructions for ASCO ID --- src/components/services/ConfigService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/services/ConfigService.js b/src/components/services/ConfigService.js index 7726d5fdc..dff37e0ae 100644 --- a/src/components/services/ConfigService.js +++ b/src/components/services/ConfigService.js @@ -410,7 +410,7 @@ 'Phenotypes' : 'Please provide any HPO phenotypes.', 'Rating' : 'Please rate your evidence on a scale of one to five stars. Use the star rating descriptions for guidance.', 'Source Type': 'CIViC accepts PubMed or ASCO Abstracts sources. Please indicate the source of the support for your evidence here.', - 'Source': 'Please enter a PubMed ID or an ASCO Abstract number to search for your source, then select it from the dropdown (PubMed searches will only show a single record). NOTE: CIViC uses the ASCO ID, not the ASCO Abstract Number to uniquely identify ASCO sources. Upon selection it is the unique ASCO ID that will populate this field, not the ASCO Abstract Number.', + 'Source': 'Please enter a PubMed or an ASCO ID to specify your source. NOTE: CIViC uses the unique ASCO ID, not the reused ASCO Abstract Numbers to uniquely identify ASCO sources. ASCO only provides its abstract IDs in the URL of the abstract record, following the word \'record\'. Copy and paste that number into this field.', 'Revision Description' : 'Please provide a short description of your edits to this Evidence record.', 'Additional Comments' : 'Please provide any additional comments you wish to make about this evidence item. This comment will appear as the first comment in this item\'s comment thread.', 'keepSourceStatus' : 'Check this box if you wish the originating source suggestion to keep its un-curated status. Otherwise, it will be marked as curated and removed from the source suggestion queues.', From e776396509fa3f20c6670066c5c8e618e2064b77 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Fri, 11 Jan 2019 10:17:52 -0600 Subject: [PATCH 61/65] source id field now switches its help text depending on source type --- src/app/views/add/evidence/addEvidenceBasic.js | 8 +++++--- src/components/services/ConfigService.js | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 0ffd69e44..208bcd785 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -256,8 +256,8 @@ required: true, data: { citation: '--', + sourceType: undefined, }, - helpText: help['Source'] }, asyncValidators: { validId: { @@ -308,8 +308,10 @@ }, expressionProperties: { 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', - 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO 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"' + '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 + 'templateOptions.helpText': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "' + help['SourceASCO'] + '" : "' + help['SourcePubMed'] + '" : "Please enter a Source Type before entering a Source ID."', }, modelOptions: { debounce: { diff --git a/src/components/services/ConfigService.js b/src/components/services/ConfigService.js index dff37e0ae..abc239aa1 100644 --- a/src/components/services/ConfigService.js +++ b/src/components/services/ConfigService.js @@ -410,7 +410,8 @@ 'Phenotypes' : 'Please provide any HPO phenotypes.', 'Rating' : 'Please rate your evidence on a scale of one to five stars. Use the star rating descriptions for guidance.', 'Source Type': 'CIViC accepts PubMed or ASCO Abstracts sources. Please indicate the source of the support for your evidence here.', - 'Source': 'Please enter a PubMed or an ASCO ID to specify your source. NOTE: CIViC uses the unique ASCO ID, not the reused ASCO Abstract Numbers to uniquely identify ASCO sources. ASCO only provides its abstract IDs in the URL of the abstract record, following the word \'record\'. Copy and paste that number into this field.', + 'SourceASCO': 'Please enter an ASCO Web ID to specify your source. NOTE: The ASCO Web ID is not the ASCO abstract number. The ASCO Web ID can be found in the URL of the abstract, e.g. 160900 is the ASCO Web ID for Tyler Stewart, 2018, ASCO Annual Meeting, Abstract 9056 (https://meetinglibrary.asco.org/record/160900/abstract).', + 'SourcePubMed': 'Please enter the PubMed ID for your source.', 'Revision Description' : 'Please provide a short description of your edits to this Evidence record.', 'Additional Comments' : 'Please provide any additional comments you wish to make about this evidence item. This comment will appear as the first comment in this item\'s comment thread.', 'keepSourceStatus' : 'Check this box if you wish the originating source suggestion to keep its un-curated status. Otherwise, it will be marked as curated and removed from the source suggestion queues.', From 449981bdfb31b1cac242fc17f02e764d60ae14d4 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Fri, 11 Jan 2019 11:21:04 -0600 Subject: [PATCH 62/65] switched source back to sending object instead of source_id string --- src/app/views/add/evidence/addEvidenceBasic.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/views/add/evidence/addEvidenceBasic.js b/src/app/views/add/evidence/addEvidenceBasic.js index 208bcd785..46595bcad 100644 --- a/src/app/views/add/evidence/addEvidenceBasic.js +++ b/src/app/views/add/evidence/addEvidenceBasic.js @@ -74,7 +74,7 @@ gene: '', variant: '', source_type: '', - source_id:'', + source: {citation_id: ''}, description: '', disease: { name: '' @@ -217,7 +217,7 @@ $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; // update source field info // this unfortunately reproduces code in onChange below, but updating value above doesn't trigger onChange... - var sourceField = _.find($scope.fields, { key: 'source'}); + var sourceField = _.find($scope.fields, { key: 'source.citation_id'}); sourceField.templateOptions.data.sourceType = st; } else { console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); @@ -240,7 +240,7 @@ // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var sourceField = _.find(scope.fields, { key: 'source_id'}); + var sourceField = _.find(scope.fields, { key: 'source.citation_id'}); sourceField.value(''); sourceField.templateOptions.data.citation = '--'; if(value) { sourceField.templateOptions.data.sourceType = value; } @@ -249,7 +249,7 @@ } }, { - key: 'source_id', + key: 'source.citation_id', type: 'publication', templateOptions: { label: 'Source ID', From ee6fb87c6585735c28869fb6e7ed780eeb713b32 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 14 Jan 2019 10:22:12 -0600 Subject: [PATCH 63/65] 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: { From 9a10aa4af26a47335cbb1848274523a91ac050b5 Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Mon, 14 Jan 2019 16:10:21 -0600 Subject: [PATCH 64/65] edit evidence item form now works with ASCO IDs instead of Numbers --- .../events/evidence/edit/evidenceEditBasic.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/app/views/events/evidence/edit/evidenceEditBasic.js b/src/app/views/events/evidence/edit/evidenceEditBasic.js index 62e3d741a..8bcfd1b08 100644 --- a/src/app/views/events/evidence/edit/evidenceEditBasic.js +++ b/src/app/views/events/evidence/edit/evidenceEditBasic.js @@ -4,6 +4,7 @@ .directive('evidenceEditBasic', evidenceEditBasicDirective) .controller('EvidenceEditBasicController', EvidenceEditBasicController); + // @ngInject function evidenceEditBasicDirective() { return { @@ -62,8 +63,10 @@ vm.evidenceEdit.comment = { title: 'Evidence EID' + vm.evidence.id + ' Revision Description', text:'' }; vm.evidenceEdit.drugs = _.filter(_.map(vm.evidence.drugs, 'name'), function(name){ return name !== 'N/A'; }); vm.evidenceEdit.phenotypes = _.map(vm.evidenceEdit.phenotypes, function(phenotype) { return phenotype.hpo_class; }); - vm.evidenceEdit.source_type = vm.evidenceEdit.source.source_type; - vm.evidenceEdit.source_id = vm.evidenceEdit.source.citation_id; // replacing source here w/ just the ID b/c source typehead coerces init object to string + vm.evidenceEdit.source = { + source_type: vm.evidenceEdit.source.source_type, + citation_id: vm.evidenceEdit.source.citation_id + }; vm.styles = EvidenceViewOptions.styles; vm.user = {}; @@ -110,7 +113,7 @@ } }, { - key: 'source_type', + key: 'source.source_type', type: 'horizontalSelectHelp', wrapper: 'attributeDefinition', controller: /* @ngInject */ function($scope) { @@ -138,7 +141,7 @@ var type = value === 'asco' ? 'ASCO':'PubMed'; options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var sourceField = _.find(scope.fields, { key: 'source_id'}); + var sourceField = _.find(scope.fields, { key: 'source.citation_id'}); sourceField.value(''); sourceField.templateOptions.data.citation = '--'; if(value) { sourceField.templateOptions.data.sourceType = value; } @@ -147,7 +150,7 @@ } }, { - key: 'source_id', + key: 'source.citation_id', type: 'publication', templateOptions: { label: 'Source ID', @@ -160,7 +163,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 @@ -205,9 +208,11 @@ } }, expressionProperties: { - 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', - 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO 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"' + 'templateOptions.disabled': 'model.source.source_type === "" || model.source.source_type === undefined', + 'templateOptions.label': 'model.source.source_type ? model.source.source_type === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', + 'templateOptions.placeholder': 'model.source.source_type ? model.source.source_type === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Please select Source Type"', + 'templateOptions.helpText': 'model.source.source_type ? model.source.source_type === "ASCO" ? "' + help['SourceASCO'] + '" : "' + help['SourcePubMed'] + '" : "Please enter a Source Type before entering a Source ID."', + }, modelOptions: { debounce: { From 9b3d5589d0393c9e5e228b29a62bedd396a1c1aa Mon Sep 17 00:00:00 2001 From: Joshua McMichael Date: Tue, 15 Jan 2019 10:42:08 -0600 Subject: [PATCH 65/65] suggest source page working with ASCO IDs --- .../suggest/source/SuggestSourceController.js | 106 ++++++++++-------- 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/src/app/views/suggest/source/SuggestSourceController.js b/src/app/views/suggest/source/SuggestSourceController.js index 6906af83d..774c6344e 100644 --- a/src/app/views/suggest/source/SuggestSourceController.js +++ b/src/app/views/suggest/source/SuggestSourceController.js @@ -30,10 +30,9 @@ vm.error = {}; vm.newSuggestion= { - source_type: '', source: { citation_id: '', - description: '' + source_type: '' }, comment: { title: 'Source Suggestion Comment' @@ -42,24 +41,13 @@ vm.suggestionFields =[ { - key: 'source_type', + key: 'source.source_type', type: 'horizontalSelectHelp', wrapper: 'attributeDefinition', - controller: /* @ngInject */ function($scope, $stateParams, ConfigService, _) { - if($stateParams.sourceType) { - var st = $stateParams.sourceType; - var permitted = _.keys(ConfigService.evidenceAttributeDescriptions.source_type); - if(_.includes(permitted, st)) { - $scope.model.source_type = st; - $scope.to.data.attributeDefinition = $scope.to.data.attributeDefinitions[st]; - } else { - console.warn('Ignoring pre-population of Source Type with invalid value: ' + st); - } - } - }, templateOptions: { label: 'Source Type', required: true, + // here we specify options instead of generating from config b/c the server gives us lowercase type strings instead of the multi-case strings used for the labels options: [{ value: '', label: 'Please select a Source Type' }].concat(make_options(descriptions.source_type)), valueProp: 'value', labelProp: 'label', @@ -69,11 +57,10 @@ attributeDefinitions: descriptions.source_type }, onChange: function(value, options, scope) { - // set attribute definition options.templateOptions.data.attributeDefinition = options.templateOptions.data.attributeDefinitions[value]; // set source_type on citation_id and clear field - var sourceField = _.find(scope.fields, { key: 'source'}); - sourceField.value({citation_id: '', description: ''}); + var sourceField = _.find(scope.fields, { key: 'source.citation_id'}); + sourceField.value(''); sourceField.templateOptions.data.citation = '--'; if(value) { sourceField.templateOptions.data.sourceType = value; } else { sourceField.templateOptions.data.sourceType = undefined; } @@ -81,44 +68,69 @@ } }, { - key: 'source', - type: 'horizontalTypeaheadHelp', - wrapper: ['citation'], + key: 'source.citation_id', + type: 'publication', templateOptions: { - label: 'Source', + label: 'Source ID', required: true, - editable: false, - typeahead: 'item as item.citation_id for item in to.data.typeaheadSearch($viewValue, to.data.sourceType)', - templateUrl: 'components/forms/fieldTypes/citationTypeahead.tpl.html', - onSelect: 'to.data.citation = $model.citation', data: { citation: '--', - sourceType: undefined, // need to store this here to pass into the typeahead expression as to.data.sourceType - typeaheadSearch: function(val, sourceType) { - if (val.match(/[^0-9]+/)) { return false; } // must be numeric - if(sourceType === 'ASCO' && val.length < 2) { return false; } // asco IDs are all > 2 chr - var reqObj = { - citationId: val, - sourceType: sourceType - }; - return Publications.verify(reqObj) - .then(function(response) { - return response; - }); - } }, helpText: help['Source'] }, + asyncValidators: { + validId: { + expression: function($viewValue, $modelValue, scope) { + 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 + scope.options.templateOptions.loading = true; + var reqObj = { + citationId: $viewValue, + sourceType: type + }; + Publications.verify(reqObj).then( + function (response) { + scope.options.templateOptions.loading = false; + scope.options.templateOptions.data.citation = response.citation; + deferred.resolve(true); + }, + function (error) { + scope.options.templateOptions.loading = false; + if(error.status === 404) { + scope.options.templateOptions.data.citation = 'No ' + type + ' source found with specified ID.'; + } else { + scope.options.templateOptions.data.citation = 'Error fetching source, check console log for details.'; + } + deferred.reject(false); + } + ); + } else { + scope.options.templateOptions.data.description = '--'; + deferred.resolve(true); + } + return deferred.promise; + }, + message: '"This does not appear to be a valid source ID."' + } + }, controller: /* @ngInject */ function($scope, $stateParams) { - // TODO this won't work, will need to query the server to get the entire source object - // if($stateParams.citationId) { - // $scope.model.citation_id = $stateParams.citationId; - // } + if($stateParams.sourceId) { + // get citation + Sources.get($stateParams.sourceId) + .then(function(response){ + $scope.model.source = response; + $scope.to.data.citation = response.citation; + }); + } }, expressionProperties: { - 'templateOptions.disabled': 'model.source_type === "" || model.source_type === undefined', // deactivate if source type specified - 'templateOptions.label': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', - 'templateOptions.placeholder': 'to.data.sourceType ? to.data.sourceType === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Select Source Type to enable Source ID"' + 'templateOptions.disabled': 'model.source.source_type === "" || model.source.source_type === undefined', + 'templateOptions.label': 'model.source.source_type ? model.source.source_type === "ASCO" ? "ASCO ID" : "PubMed ID" : "Source ID"', + 'templateOptions.placeholder': 'model.source.source_type ? model.source.source_type === "ASCO" ? "Search by ASCO Abstract Number" : "Search by PubMed ID" : "Please select Source Type"', + 'templateOptions.helpText': 'model.source.source_type ? model.source.source_type === "ASCO" ? "' + help['SourceASCO'] + '" : "' + help['SourcePubMed'] + '" : "Please enter a Source Type before entering a Source ID."', + }, modelOptions: { debounce: { @@ -164,7 +176,7 @@ }, 'modelOptions': { 'debounce': { - 'default': 2000, + 'default': 200, 'blur': 0 }, 'updateOn': 'default blur'