forked from opentargets-archive/webapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
drugs-display-directive.js
23 lines (22 loc) · 1.36 KB
/
drugs-display-directive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
angular.module('plugins')
.directive('drugsDisplay', ['$log', 'cttvConfig', 'cttvConsts', 'cttvDictionary', function ($log, cttvConfig, cttvConsts, cttvDictionary) {
'use strict';
return {
restrict: 'E',
template: '<div ng-show="data.length>0">'
+ ' <p>Source: <span ng-repeat="source in sources"><a href="{{source.url}}" target="_blank">{{source.label}}</a><span ng-if="!$last">, </span><span></p>'
+ ' <known-drug-table target="{{target.id}}" disease="{{disease.efo}}" title="drug" data="data"></known-drug-table>'
+ '</div>'
// this is sort of redundant as it's also included in table directive
// but we pull out the data and check the length from here so that we can show/hide also the source at the top
// for consistency with the evicence page
+ '<div ng-show="data.length==0"><p>No data available</p></div>',
scope: {
target: '=',
disease: '='
},
link: function(scope, element, attrs) {
scope.sources = cttvConfig.evidence_sources.known_drug.map(function(s){return {label:cttvDictionary[ cttvConsts.invert(s) ], url:cttvConsts.dbs_info_url[cttvConsts.invert(s)]}; });
}
};
}]);