Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
spikeheap committed Mar 8, 2016
2 parents 4b904b4 + e923740 commit 3231151
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var config = {
subjectIdZeroPadding: 4,
subjectIdRegex: /^HEP-([0-9]+)$/,
demographicDataset: 'Database_Enrollment',
searchFields: ['ParticipantId', 'NHSNumber', 'MRNNumber', 'FirstName', 'LastName']
searchFields: ['ParticipantId', 'NHSNumber', 'MRNNumber', 'MedWarNum', 'FirstName', 'LastName']
// subjectNameFields: ['FirstName', 'LastName'],
// headlineSubjectInfoFields: ['ParticipantId', 'NHSNumber', 'MRNNumber', 'DOB']
};
Expand Down
12 changes: 10 additions & 2 deletions js/participantFilter/participantFilter.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function ParticipantFilterController($modal, $q, $scope, config, CohortService,
self.isParticipantSelected = isParticipantSelected;
self.keyFieldsPercentageComplete = keyFieldsPercentageComplete;

self.searchFields = config.searchFields.slice();
self.openAddParticipantModal = openAddParticipantModal;

self.updateParticipantGroupFilter = updateParticipantGroupFilter;
Expand Down Expand Up @@ -66,7 +67,14 @@ function ParticipantFilterController($modal, $q, $scope, config, CohortService,

function selectParticipant(participant) {
self.selectedParticipant = participant;
self.onParticipantSelect({participantId: participant[config.subjectNoun]});
var subjectKey = config.subjectNoun;

// lower-case the first character, because LabKey's expecting it that way
subjectKey = subjectKey[0].toLowerCase() + subjectKey.substr(1);

var payload = {};
payload[subjectKey] = participant[config.subjectNoun];
self.onParticipantSelect(payload);
}

function isParticipantSelected(participant){
Expand All @@ -76,7 +84,7 @@ function ParticipantFilterController($modal, $q, $scope, config, CohortService,
function filterParticipants(){
self.filteredParticipants = self.allParticipants.filter(function(candidateParticipant) {
return self.selectedCohorts[candidateParticipant.Cohort]
&& _.contains(self.groupFilterParticipantIDs, candidateParticipant.ParticipantId);
&& _.includes(self.groupFilterParticipantIDs, candidateParticipant.ParticipantId);
});
}

Expand Down
2 changes: 1 addition & 1 deletion js/participantFilter/participantFilter.directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4>
<div class="form-inline">
<div class="form-group has-feedback">
<label for="labking-participant-search">Search</label>
<input type="search" class="form-control" id="labking-participant-search" placeholder="NHS #, MRN or name" autofocus ng-model="vm.participantSearchText">
<input type="search" class="form-control" id="labking-participant-search" placeholder="{{vm.searchFields.join(', ')}}" autofocus ng-model="vm.participantSearchText">
<a ng-show="vm.participantSearchText" ng-click="vm.clearSearch()" class="text-muted">
<span class="fa fa-remove form-control-feedback"></span>
</a>
Expand Down
6 changes: 4 additions & 2 deletions js/participantFilter/participantRecord.directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ <h3 class="nav-header">Dataset:</h3>
ng-class="{active: vm.selectedDataSet == dataSet}"
ng-repeat="dataSet in vm.selectedCategory">
<a aria-controls="home" role="tab"
ng-bind="dataSet.Label"
ng-click="vm.selectDataSet(dataSet)"></a>
ng-click="vm.selectDataSet(dataSet)">
{{dataSet.Label}}
<span class="badge">{{vm.getRecordCount(dataSet.Name)}}</span>
</a>
</li>
</ul>

Expand Down
14 changes: 14 additions & 0 deletions js/participantFilter/participantRecord.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function ParticipantRecord(config, ParticipantService, DatasetMetadataService) {
self.getParticipantName = getParticipantName;
self.selectCategory = selectCategory;
self.selectDataSet = selectDataSet;
self.getRecordCount = getRecordCount;

DatasetMetadataService.getMetaData().then(function(metadata) {

Expand Down Expand Up @@ -55,6 +56,19 @@ function ParticipantRecord(config, ParticipantService, DatasetMetadataService) {
selectDataSet(self.selectedCategory[0]);
}

/**
* Gets the number of rows in a dataset for the currently selected user.
* @param {String} datasetName The name of the dataset. NOT the dataset object.
* @return {Number} The count of rows in the dataset with the passed name, for the currently selected participant.
*/
function getRecordCount (datasetName) {
if(self.participant !== undefined && self.participant.dataSets[datasetName] !== undefined){
return self.participant.dataSets[datasetName].rows.length;
}else{
return 0;
}
}

function selectDataSet(dataSet) {
self.selectedDataSet = dataSet;
}
Expand Down
4 changes: 2 additions & 2 deletions js/participantGroups/participantGroups.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports.service = ParticipantGroupsService;


/** @ngInject **/
function ParticipantGroupsService($q, logger) {
function ParticipantGroupsService($q, logger, config) {
var LabKeyAPI = require('../lib/LabKeyAPI'),
_ = require('lodash');

Expand Down Expand Up @@ -63,7 +63,7 @@ function ParticipantGroupsService($q, logger) {
var categoryLabel = participantGroupMapping['GroupId/CategoryId/Label'];
var groupId = participantGroupMapping.GroupId;
var groupLabel = participantGroupMapping['GroupId/Label'];
var participantId = participantGroupMapping.ParticipantId;
var participantId = participantGroupMapping[config.subjectNoun];

// Create participant group category if it doesn't exist
if(participantGroupCategories[categoryId] === undefined){
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "labking",
"version": "1.4.0",
"version": "1.5.0",
"description": "A LabKey module to allow creation and editing of Study module datasets in a subject-centric way",
"main": "js/labking.module.js",
"scripts": {
Expand Down Expand Up @@ -61,7 +61,7 @@
},
"homepage": "https://github.com/spikeheap/labkey-labking",
"devDependencies": {
"babel-eslint": "^3.1.23",
"babel-eslint": "4.1.7",
"babelify": "^5.0.4",
"bower": "^1.4.1",
"browserify": "^9.0.3",
Expand Down

0 comments on commit 3231151

Please sign in to comment.