Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(project): 2187 2313 disable export on no data
Browse files Browse the repository at this point in the history
- remove 'JSON' word from button
- exportCasesButton: move $scope.ngDisabled check, so button is
not still disabled after ng-disabled changes to false
Closes #2187, #2313
  • Loading branch information
Christine Yu committed May 12, 2016
1 parent 36a0162 commit 949c584
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/scripts/cases/cases.directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ module ngApp.cases.directives {
},
template: '<button tabindex="0" ng-class="[styleClass || \'btn btn-primary\']" data-downloader> \
<i class="fa {{icon || \'fa-download\'}}" ng-class="{\'fa-spinner\': active, \'fa-pulse\': active}" /> \
<span ng-if="textNormal"><span ng-if="! active">&nbsp;{{ ::textNormal }}</span> \
<span ng-if="textNormal"><span ng-if="! active">&nbsp;{{ textNormal }}</span> \
<span ng-if="active">&nbsp;{{ ::textInProgress }}</span></span></button>',
link: (scope, $element, $attrs) => {
if (! scope.ngDisabled) {
$element.on('click', () => {
$element.on('click', () => {
if (!scope.ngDisabled) {
const reportStatus = _.isFunction(scope.$parent.reportStatus)
? _.partial(scope.$parent.reportStatus, scope.$id)
: () => {};
Expand Down Expand Up @@ -64,8 +64,8 @@ module ngApp.cases.directives {
const checkProgress = scope.download(params, url, () => $element, 'POST');

checkProgress(inProgress, done);
});
}
}
});
scope.active = false;
}
});
Expand Down
78 changes: 78 additions & 0 deletions app/scripts/projects/projects.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module ngApp.projects.controllers {
import IAnnotationsService = ngApp.annotations.services.IAnnotationsService;
import IProjectsState = ngApp.projects.services.IProjectsState;
import IFacetService = ngApp.components.facets.services.IFacetService;
import IParticipantsService = ngApp.participants.services.IParticipantsService;

export interface IProjectsController {
projects: IProjects;
Expand Down Expand Up @@ -139,12 +140,18 @@ module ngApp.projects.controllers {

export interface IProjectController {
project: IProject;
biospecimenCount: number;
clinicalCount: number;
}

class ProjectController implements IProjectController {
biospecimenCount: number = 0;
clinicalCount: number = 0;

/* @ngInject */
constructor(public project: IProject, private CoreService: ICoreService,
private AnnotationsService: IAnnotationsService,
private ParticipantsService: IParticipantsService,
private ExperimentalStrategyNames: string[],
private DATA_CATEGORIES,
public $state: ng.ui.IStateService,
Expand Down Expand Up @@ -278,6 +285,77 @@ module ngApp.projects.controllers {
}).then((data) => {
this.project.annotations = data;
});

var missingBiospecFilter = {
content: [
{
content: {
field: "project.project_id",
value: project.project_id
},
op: "="
},
{
content: {
field: "samples.sample_id",
value: "MISSING"
},
op: "NOT"
}
],
op: "AND"
};
ParticipantsService.getParticipants({
filters: missingBiospecFilter,
size: 0,
}).then(data => this.biospecimenCount = data.pagination.total);

var missingClinicalFilter = {
content: [
{
content: {
field: "project.project_id",
value: project.project_id
},
op: "="
},
{
content: [
{
content: {
field: "demographic.demographic_id",
value: "MISSING"
},
op: "NOT"
}, {
content: {
field: "diagnoses.diagnosis_id",
value: "MISSING"
},
op: "NOT"
}, {
content: {
field: "family_histories.family_history_id",
value: "MISSING"
},
op: "NOT"
}, {
content: {
field: "exposures.exposure_id",
value: "MISSING"
},
op: "NOT"
}
],
op: "OR"
}
],
op: "AND"
};
ParticipantsService.getParticipants({
filters: missingClinicalFilter,
size: 0
}).then(data => this.clinicalCount = data.pagination.total);
}
}

Expand Down
6 changes: 4 additions & 2 deletions app/scripts/projects/templates/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ <h1 class="col-lg-12">

<span class="btn-row">
<export-cases-button
data-ng-disabled="prc.biospecimenCount === 0"
data-filter-key-values=prc.biospecimenDataExportFilters
data-expands=prc.biospecimenDataExportExpands
data-filename=prc.biospecimenDataExportFileName
data-text-normal="Download Biospecimen JSON"
data-text-normal="{{prc.biospecimenCount === 0 ? 'No Biospecimen Data' : 'Download Biospecimen'}}"
data-text-in-progress="Processing"
data-style-class="btn pull-right btn-primary">
</export-cases-button>

<export-cases-button
data-ng-disabled="prc.clinicalCount === 0"
data-filter-key-values=prc.clinicalDataExportFilters
data-expands=prc.clinicalDataExportExpands
data-filename=prc.clinicalDataExportFileName
data-text-normal="Download Clinical JSON"
data-text-normal="{{prc.clinicalCount === 0 ? 'No Clinical Data' : 'Download Clinical' }}"
data-text-in-progress="Processing"
data-style-class="btn pull-right btn-primary">
</export-cases-button>
Expand Down

0 comments on commit 949c584

Please sign in to comment.