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 all commits
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
32 changes: 19 additions & 13 deletions client/src/js/components/bhFindDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular.module('bhima.components')
enableOptionBar : '<', // bind boolean (true|false) : Enable option for add, display list or display thumbnail in a bar
enableSearch : '<', // bind boolean (true|false) : Enable search bar option
display : '@', // bind (list|thumbnail) : Display either in list or thumbnail mode
height : '@', // bind the height of list of contents
patientUuid : '<' // Required patient uuid
}
});
Expand All @@ -31,12 +32,12 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
enableOptionBar : Boolean(this.enableOptionBar),
enableSearch : Boolean(this.enableSearch),
display : this.display,
height : this.height,
showAction : false
};

/** expose to the view */
vm.switchDisplay = switchDisplay;
vm.toggleAction = toggleAction;
vm.addDocument = addDocument;
vm.deleteDocument = deleteDocument;
vm.mimeIcon = mimeIcon;
Expand All @@ -49,12 +50,6 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
vm.session.display = mode;
}

/** toggle document actions */
function toggleAction(index) {
vm.selectedIndex = index;
vm.session.showAction = vm.session.showAction === true ? false : true;
}

/** function add documents modal */
function addDocument() {
Modal.openUploadDocument({ patient_uuid: vm.session.patientUuid })
Expand Down Expand Up @@ -90,6 +85,12 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
Document.read(vm.session.patientUuid)
.then(function (documents) {
vm.session.patientDocuments = documents;

vm.session.patientDocuments.forEach(function (doc) {
doc.downloadLink = doc.label + mimeIcon(doc.mimetype).ext;
doc.icon = mimeIcon(doc.mimetype).icon;
doc.type = mimeIcon(doc.mimetype).label;
});
})
.catch(Notify.handleError);
}
Expand All @@ -99,17 +100,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
102 changes: 51 additions & 51 deletions client/src/partials/patients/documents/documents.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
/* ============================ Generic Style ============================= */
.document-section {
display: block;
margin: 7px auto;
}
.panel .panel-heading > .right {
position: relative;
float: right;
top: -5px;
}
/* =========================== End Generic Style ========================== */


/* ============================ Document style ============================= */
.document {
border: 1px solid #ddd;
padding: 5px;
margin-bottom: 15px;
cursor: pointer;
padding: 5px;
margin: 3px auto;
border: 1px solid #ddd;
}
.document:hover {
background-color: #eee;
}
.document h4 {
margin: 2px;
}
.document-actions {
text-align: center;
width: 100%;
margin: auto;
margin-top: 5px;
/* ========================== End Document style ========================== */


/* ==================== Document thumbnails style ========================= */
.document-thumbnail {
display: inline-block;
}
.document .crop {
.document-thumbnail > .crop {
width: 100%;
height: 150px;
overflow: hidden;
}
.document .crop img.document-thumbnail {
.document-thumbnail > .crop > .image {
text-align: center;
font-size: 10rem;
color: #337ab7;
}
.document-thumbnail > .crop > .image > img {
display: block;
width: 100%;
margin: auto;
Expand All @@ -32,55 +49,38 @@
-webkit-transition: margin-top 1s;
transition: margin-top 1s;
}
.document:hover .crop img.document-thumbnail {
.document-thumbnail:hover > .crop > .image > img {
-webkit-filter: grayscale(0%);
filter: grayscale(0%);
-webkit-filter: grayscale(0%);
filter: grayscale(0%);
margin-top: -25px;
}
.document .crop .document-icon {
/* ==================== End Document thumbnails style ====================== */


/* ========================== Avatar thumbnail ============================= */
.avatar-thumbnail {
text-align: center;
font-size: 10rem;
color: #337ab7;
}
.patient-document .pd-patient {
padding: 7px;
margin-bottom: 5px;
border: 1px solid green;
color: green;
background-color: #e4f9ec;
}
.patient-document .pd-search {
margin-bottom: 5px;
border : 1px solid #ccc;
}

/* patient document heading */
.patient-document .pd-documents .heading {
display: flex;
justify-content: space-between;
background-color: #337ab7;
color: #fff;
padding: 5px;
margin-bottom: 5px;
.avatar-thumbnail > .crop > img {
width: 100%;
height: 200px;
overflow: hidden;
}
.patient-document .pd-documents .heading > .left {
margin: 5px 10px;
.avatar-thumbnail > .crop > .glyphicon {
font-size : 3em;
color : #ccc;
padding-top: 70px;
}
/* ========================== End Avatar thumbnail ========================== */

/* patient list thumbanil */
.patient-document .display-thumbnail {
display: flex;
align-items: flex-start;
align-content: flex-start;
justify-content: flex-start;
flex-wrap: wrap;
}
.patient-document .display-thumbnail > .document {
width: 50%;
}

/* document upload thumbnail */
.document-upload-thumbnail {
/* ============================= Upload thumbnail =========================== */
.upload-thumbnail {
width: 100%;
height: 300px;
overflow: hidden;
}
/* ========================== End Upload thumbnail ========================== */
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="upload-thumbnail"
ngf-thumbnail="{{ '$ctrl.thumbnail' }}">

<!-- progress bar -->
<div class="progress" ng-show="$ctrl.file.progress >= 0">
Expand Down
40 changes: 16 additions & 24 deletions client/src/partials/patients/record/patient_record.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@
</div>

<div class="col-sm-4">
<div style="border : 1px solid #ccc; height : 200px;">
<div ng-if="!PatientRecordCtrl.patient.avatar" style="text-align : center;">
<span style="font-size : 3em; color : #ccc; padding-top: 70px;" class="glyphicon glyphicon-picture"></span>
<div class="avatar-thumbnail">
<div class="crop" ng-if="!PatientRecordCtrl.patient.avatar">
<span class="glyphicon glyphicon-picture"></span>
</div>
<div ng-if="PatientRecordCtrl.patient.avatar" style="text-align : center;">
<img ng-src="{{ PatientRecordCtrl.patient.avatar }}" width="120">
<div class="crop" ng-if="PatientRecordCtrl.patient.avatar">
<img ng-src="{{ PatientRecordCtrl.patient.avatar }}">
</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 @@ -100,24 +100,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>
<!-- 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"
height="250px">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm.. Hardcoded styles are not a great idea. Is there anyway to make this component take up 100% height?

This won't block the PR, as it may require CSS changes beyond this component.

</bh-find-document>
<!-- end find document -->
</div>

<!-- Patient Bill Panel -->
Expand Down
Loading