Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Patient documents #575

Merged
merged 5 commits into from
Jul 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions client/src/js/components/bhFindDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,22 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
var result = {};

if (mimetype.indexOf('image') > -1) {
result = { icon : 'fa-file-image-o', label : 'Image' };
var ext =
(mimetype.indexOf('jpg') > -1 || mimetype.indexOf('jpeg') > -1) ? '.jpg' :
(mimetype.indexOf('png') > -1) ? '.png' :
(mimetype.indexOf('gif') > -1) ? '.gif' : '';

result = { icon : 'fa-file-image-o', label : 'Image', ext: ext };
} else if (mimetype.indexOf('pdf') > -1) {
result = { icon : 'fa-file-pdf-o', label : 'PDF' };
result = { icon : 'fa-file-pdf-o', label : 'PDF', ext: '.pdf' };
} else if (mimetype.indexOf('word') > -1) {
result = { icon : 'fa-file-word-o', label : 'MS WORD' };
result = { icon : 'fa-file-word-o', label : 'MS WORD', ext: '.doc' };
} else if (mimetype.indexOf('sheet') > -1) {
result = { icon : 'fa-file-excel-o', label : 'MS EXCEL' };
result = { icon : 'fa-file-excel-o', label : 'MS EXCEL', ext: '.xls' };
} else if (mimetype.indexOf('presentation') > -1) {
result = { icon : 'fa-file-powerpoint-o', label : 'MS Power Point' };
result = { icon : 'fa-file-powerpoint-o', label : 'MS Power Point', ext: '.ppt' };
} else {
result = { icon : 'fa-file-o', label : 'Fichier' };
result = { icon : 'fa-file-o', label : 'Fichier', ext: '' };
}

return result;
Expand Down
2 changes: 2 additions & 0 deletions client/src/partials/patients/documents/documents.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@
/* document upload thumbnail */
.document-upload-thumbnail {
width: 100%;
height: 300px;
overflow: hidden;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
</div>

<!-- thumbnail -->
<img class="document-upload-thumbnail" ngf-thumbnail="{{ '$ctrl.thumbnail' }}">
<img
ng-if="$ctrl.file"
class="document-upload-thumbnail"
ngf-thumbnail="{{ '$ctrl.thumbnail' }}">

<!-- progress bar -->
<div class="progress" ng-show="$ctrl.file.progress >= 0">
Expand Down
33 changes: 12 additions & 21 deletions client/src/partials/patients/record/patient_record.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
<span style="font-size : 3em; color : #ccc; padding-top: 70px;" class="glyphicon glyphicon-picture"></span>
</div>
<div ng-if="PatientRecordCtrl.patient.avatar" style="text-align : center;">
<img ng-src="{{ PatientRecordCtrl.patient.avatar }}" width="120">
<img ng-src="{{ PatientRecordCtrl.patient.avatar }}" style="width: 100%; height: 200px; overflow: hidden;">
</div>
</div>

<label class="btn btn-default btn-block">
<span class="glyphicon glyphicon-upload"></span> {{ PatientRecordCtrl.uploadButtonText | translate }}
<span class="glyphicon glyphicon-upload"></span> {{ PatientRecordCtrl.uploadButtonText | translate }}
<input type="file" accept="image/*" ngf-max-size="2MB" ngf-select="PatientRecordCtrl.uploadFiles($file, $invalidFiles)" style="display: none;">
</label>

Expand All @@ -99,25 +99,16 @@

<div class="row">

<div class="col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">
<span class="glyphicon glyphicon-paperclip"></span> Patient Documents
</div>
<div class="panel-body" style="height : 250px; overflow: auto;">

<!-- find document -->
<bh-find-document
patient-uuid="PatientRecordCtrl.patient.uuid"
enable-patient-details="false"
enable-search="false"
enable-option-bar="false"
display="default">
</bh-find-document>
<!-- end find document -->

</div>
</div>
<div class="col-sm-6" style="height : 250px; overflow: auto;">
<!-- find document -->
<bh-find-document
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads really nicely. The component API looks fantastic. Well done!

patient-uuid="PatientRecordCtrl.patient.uuid"
enable-patient-details="false"
enable-search="false"
enable-option-bar="true"
display="default">
</bh-find-document>
<!-- end find document -->
</div>

<!-- Patient Bill Panel -->
Expand Down
51 changes: 17 additions & 34 deletions client/src/partials/templates/bhFindDocument.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
<!-- heading -->
<div ng-if="$ctrl.session.enableOptionBar" class="heading">
<div class="left">
<b><i class="fa fa-universal-access"></i> {{ $ctrl.session.patient.reference }} / </b>
{{ $ctrl.session.patient.first_name + ' ' + $ctrl.session.patient.last_name + ' ' + $ctrl.session.patient.middle_name }}
<i class="glyphicon glyphicon-paperclip"></i> {{ 'PATIENT_DOCUMENT.DOCUMENTS' | translate }}
({{ $ctrl.session.patientDocuments.length }})
</div>

Expand Down Expand Up @@ -69,32 +68,11 @@
<i class="fa fa-3x" ng-class="{{ '$ctrl.mimeIcon(doc.mimetype).icon' }}"></i>
</a>
<div class="media-body">
<b class="btn-sm pull-right">
<i ng-show="$ctrl.session.showAction && $ctrl.selectedIndex === $index" class="fa fa-angle-up"></i>
<i ng-hide="$ctrl.session.showAction && $ctrl.selectedIndex === $index" class="fa fa-angle-down"></i>
</b>

<h4 class="media-heading">{{ doc.label }}</h4>

<div ng-show="$ctrl.session.showAction && $ctrl.selectedIndex === $index">
<i class="fa fa-file-o"></i>
{{ $ctrl.mimeIcon(doc.mimetype).label }} (~{{ doc.size | bytes }})
</div>

<i class="fa fa-calendar-o"></i>
{{ doc.timestamp | date }}, {{ 'FORM.LABELS.BY' | translate }}
{{ doc.first + ' ' + doc.last }}

<div ng-show="$ctrl.session.showAction && $ctrl.selectedIndex === $index" class="document-action" style="border-top:1px solid #ccc; padding-top:5px;">
<button
title="{{ 'PATIENT_DOCUMENT.OVERVIEW' | translate }}"
type="button"
class="btn btn-sm btn-default">
<i class="fa fa-eye"></i>
</button>

<!-- actions buttons -->
<div class="pull-right">
<a
ng-href="/{{ doc.link }}" download="{{ doc.label }}"
ng-href="/{{ doc.link }}" download="{{ doc.label + $ctrl.mimeIcon(doc.mimetype).ext }}"
title="{{ 'PATIENT_DOCUMENT.DOWNLOAD' | translate }}"
type="button"
class="btn btn-sm btn-default">
Expand All @@ -109,6 +87,18 @@ <h4 class="media-heading">{{ doc.label }}</h4>
<i class="fa fa-trash"></i>
</button>
</div>

<!-- title -->
<h4 class="media-heading">{{ doc.label }}</h4>

<!-- file size -->
<i class="fa fa-file-o"></i>
{{ $ctrl.mimeIcon(doc.mimetype).label }} (~{{ doc.size | bytes }}) <br>

<!-- date and author -->
<i class="fa fa-calendar-o"></i>
{{ doc.timestamp | date }}, {{ 'FORM.LABELS.BY' | translate }}
{{ doc.first + ' ' + doc.last }}
</div>
</li>
</ul>
Expand Down Expand Up @@ -142,15 +132,8 @@ <h4 class="media-heading">{{ doc.label }}</h4>
{{ doc.first + ' ' + doc.last }}
</div>
<div ng-show="$ctrl.session.showAction && $ctrl.selectedIndex === $index" class="document-actions">
<button
title="{{ 'PATIENT_DOCUMENT.OVERVIEW' | translate }}"
type="button"
class="btn btn-sm btn-default">
<i class="fa fa-eye"></i>
</button>

<a
ng-href="/{{ doc.link }}" download="{{ doc.label }}"
ng-href="/{{ doc.link }}" download="{{ doc.label + $ctrl.mimeIcon(doc.mimetype).ext }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally not a good idea to include functions in the view - they will be re-evaluated on every $digest() loop.

Could this be pre-processed in the controller? Something like:

// in the controller
documents.forEach(function (doc) {
  doc.downloadLink = doc.label + mimeIcon(doc.mimetype).ext;
});

.. in the view..

<a ng-href="/{{doc.link}}" download="{{doc.downloadLink}}" ...></a>

That would be much more efficient!

title="{{ 'PATIENT_DOCUMENT.DOWNLOAD' | translate }}"
type="button"
class="btn btn-sm btn-default">
Expand Down