Skip to content

Commit

Permalink
HIV-402: formentry pdf creation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
madvincy committed Oct 3, 2019
1 parent dd9086b commit 524784e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-file-uploader",
"version": "0.0.14",
"version": "0.0.17",
"main": "ngx-file-uploader/dist/ngx-file-uploader",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-file-uploader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-file-uploader",
"version": "0.0.14",
"version": "0.0.17",
"peerDependencies": {
"@angular/common": "^6.1.0",
"@angular/core": "^6.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
</a>
</div>
</div>
<div class="panel-footer">
<div *ngIf="uploading" class="panel-footer">
<button *ngIf="UploadCaptions" type="button" (click)="upload()" class="button pull-right">
<span class="glyphicon glyphicon-upload"></span> Upload Files
</button>
<button *ngIf="!pdfAvailable && fileUpload || liveCamera || merge" type="button" [disabled]="!urls[1]" (click)="mergeImages()" title="merge the images as pages in one pdf document" class="button">
<span class="glyphicon glyphicon-upload"></span> Merge Files
<button *ngIf="!pdfAvailable && fileUpload || liveCamera || merge" type="button" [hidden]="!urls[1]" (click)="mergeImages()" title="merge the images as pages in one pdf document" class="button">
<span class="glyphicon glyphicon-upload"></span> Merge or convert to PDF
</button>
</div>
</div>
Expand All @@ -80,9 +80,9 @@
<button *ngIf="value" type="button" (click)="clear()" class="btn btn-default image-preview-clear">
<span class="glyphicon glyphicon-remove"></span> Clear
</button>
<button type="button" (click)="upload()" class="button">
<!-- <button *ngIf="uploading" type="button" (click)="upload()" class="button">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
</button> -->
</div>
</div>
<div *ngIf="!mobile" class="image-upload-wrap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@
margin: auto;
padding: 20px;
}
.buttonMerge {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
background-color: greenyellow;
border: none;
color: #FFFFFF;
text-decoration: none;
}
.button {
display: inline-block;
padding: 6px 12px;
Expand Down
34 changes: 22 additions & 12 deletions projects/ngx-file-uploader/src/lib/ngx-file-uploader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
public fileList = new Array<any>();
public fileType: string;
public message = '';
public pdfCreated = false;
public messageType = '';
public liveCamera = false;
public pdfAvailable = false;
Expand Down Expand Up @@ -129,9 +130,6 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
const files = event.srcElement.files;
this.uploading = true;
// const fileToLoad = files;
if (this.fieType === 'liveCamera') {
this.UploadCaptions = true;
}
if (files) {
for (const file of files) {
const fileReader = new FileReader();
Expand All @@ -158,6 +156,10 @@ this.UploadCaptions = true;
if (!this.singleFile) {
this.urls.push(payload);
this.fileList.push(payload);
this.UploadCaptions = true;
if (this.fieType === 'image' || 'liveCamera') {
this.checkFilesSelected();
}
} else {
this.fileChanged.emit(payload);
this.back();
Expand Down Expand Up @@ -189,18 +191,14 @@ public messageViewTimeout () {
this.UploadCaptions = false;
this.singleFile = false;
this.pdfAvailable = false;
this.uploading = false;
this.merge = false;
this.fileUpload = false;
this.liveCamera = false;
}
public toggleVisibility(filetype: string) {
this.fieType = filetype;
if (filetype === 'image') {
if (this.formEntry) {
this.message = ' Images will be merged into one pdf when uploaded in formentry';
this.messageType = 'danger';
this.messageViewTimeout();
}
this.fileType = 'image/png, image/jpeg, image/gif';
this.fileUpload = true;

Expand Down Expand Up @@ -228,8 +226,10 @@ public messageViewTimeout () {
}

public upload() {
if (this.formEntry && this.pdfAvailable === false) {
this.mergeImages();
if (!this.pdfCreated) {
if (this.formEntry && !this.pdfAvailable) {
this.mergeImages();
}
}
this.uploadData.emit(this.fileList);
this.back();
Expand Down Expand Up @@ -275,6 +275,8 @@ public messageViewTimeout () {
this.urls.push(payload);
this.singleFile = false;
this.UploadCaptions = true;
this.pdfCreated = true;
this.pdfAvailable = true;

}
public delete(urls: any) {
Expand Down Expand Up @@ -330,14 +332,22 @@ public messageViewTimeout () {
if (this.singleFile) {
this.urls = [];
this.fileList = [];
this.pushData(webcamImage);

}
this.pushData(webcamImage);
this.UploadCaptions = true;
this.uploading = true;
}
public checkFilesSelected() {
if (this.formEntry && this.urls.length > 1) {
this.message = '*Please click merge to convert and combine Multipe images into one PDF file';
this.messageType = 'danger';
this.messageViewTimeout();
}
}
public pushData(webcamImage) {
this.urls.push(webcamImage);
this.fileList.push(webcamImage);
this.checkFilesSelected();
}

public cameraWasSwitched(deviceId: string): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Image {{dataModel}} <lib-file-uploader
<lib-file-uploader
[(ngModel)]="dataModel" (onClear)="clear()" (fileChanged)="upload($event)">
</lib-file-uploader>

0 comments on commit 524784e

Please sign in to comment.