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

Commit

Permalink
fix(file): Update associated entities.
Browse files Browse the repository at this point in the history
- Adds missing fields.
- Updates annotations link to that entity.

Closes #531
  • Loading branch information
Matthew Schranz committed Mar 17, 2015
1 parent bebb9db commit 3acb792
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 8 additions & 3 deletions app/scripts/files/files.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ module ngApp.files.controllers {
this.archiveCount = 0;
}

this.annotationIds = _.map(file.annotations, (annotation) => {
return annotation.annotation_id;
});
_.every(file.associated_entities, (entity) => {
entity.annotations = _.find(file.annotations, (annotation) => {
return annotation.annotation_id === entity.entity_id;
});

if (entity.annotations) {
entity.annotations = _.pluck(entity.annotations, "annotation_id");
}
});
}

isInCart(): boolean {
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/files/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module ngApp.files {
"related_files.type",
"related_files.file_name",
"related_files.md5sum",
"associated_entities.entity_id",
"associated_entities.entity_type",
"associated_entities.participant_id",
"annotations.annotation_id",
"tags",
"origin"
Expand Down
19 changes: 10 additions & 9 deletions app/scripts/files/templates/file.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h3 class="panel-title">Associated Participants / Biospecimen</h3>
<div class="panel-body" data-ng-if="!fc.file.participants.length">
<h4 class="list-group-item-heading">No participants found.</h4>
</div>
<div class="table-responsive" data-ng-if="fc.file.participants.length">
<div class="table-responsive" data-ng-if="fc.file.associated_entities.length">
<table id="participants-table" class="table table-striped table-hover table-condensed table-bordered">
<thead>
<tr>
Expand All @@ -154,20 +154,21 @@ <h4 class="list-group-item-heading">No participants found.</h4>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="p in fc.file.participants track by p.participant_id">
<td>tbd</td>
<td>tbd</td>
<tr data-ng-repeat="e in fc.file.associated_entities track by e.participant_id">
<td>{{ ::e.entity_id }}</td>
<td>{{ ::e.entity_type | humanify }}</td>
<td>
<a data-ui-sref="participant({ participantId : p.participant_id })">
{{ ::p.participant_id }}
<a data-ui-sref="participant({ participantId : e.participant_id })">
{{ ::e.participant_id }}
</a>
</td>
<td>
<a data-ui-sref="annotations({ 'filters':
{{ [{name: 'annotation_id', value: fc.annotationIds }] | makeFilter }} })"
data-ng-if="fc.file.annotations">
{{ fc.file.annotations.length }}
{{ [{name: 'annotation_id', value: e.annotations }] | makeFilter }} })"
data-ng-if="e.annotations.length">
{{ e.annotations.length }}
</a>
<span data-ng-if="!e.annotations.length">0</span>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 3acb792

Please sign in to comment.