Skip to content

Commit 524784e

Browse files
committed
HIV-402: formentry pdf creation fix
1 parent dd9086b commit 524784e

File tree

6 files changed

+48
-20
lines changed

6 files changed

+48
-20
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-file-uploader",
3-
"version": "0.0.14",
3+
"version": "0.0.17",
44
"main": "ngx-file-uploader/dist/ngx-file-uploader",
55
"scripts": {
66
"ng": "ng",

projects/ngx-file-uploader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-file-uploader",
3-
"version": "0.0.14",
3+
"version": "0.0.17",
44
"peerDependencies": {
55
"@angular/common": "^6.1.0",
66
"@angular/core": "^6.1.0",

projects/ngx-file-uploader/src/lib/ngx-file-uploader.component.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
</a>
5555
</div>
5656
</div>
57-
<div class="panel-footer">
57+
<div *ngIf="uploading" class="panel-footer">
5858
<button *ngIf="UploadCaptions" type="button" (click)="upload()" class="button pull-right">
5959
<span class="glyphicon glyphicon-upload"></span> Upload Files
6060
</button>
61-
<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">
62-
<span class="glyphicon glyphicon-upload"></span> Merge Files
61+
<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">
62+
<span class="glyphicon glyphicon-upload"></span> Merge or convert to PDF
6363
</button>
6464
</div>
6565
</div>
@@ -80,9 +80,9 @@
8080
<button *ngIf="value" type="button" (click)="clear()" class="btn btn-default image-preview-clear">
8181
<span class="glyphicon glyphicon-remove"></span> Clear
8282
</button>
83-
<button type="button" (click)="upload()" class="button">
83+
<!-- <button *ngIf="uploading" type="button" (click)="upload()" class="button">
8484
<span class="glyphicon glyphicon-upload"></span> Upload
85-
</button>
85+
</button> -->
8686
</div>
8787
</div>
8888
<div *ngIf="!mobile" class="image-upload-wrap">

projects/ngx-file-uploader/src/lib/ngx-file-uploader.component.scss

+18
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@
121121
margin: auto;
122122
padding: 20px;
123123
}
124+
.buttonMerge {
125+
display: inline-block;
126+
padding: 6px 12px;
127+
margin-bottom: 0;
128+
font-size: 14px;
129+
font-weight: 400;
130+
line-height: 1.42857143;
131+
text-align: center;
132+
white-space: nowrap;
133+
vertical-align: middle;
134+
-ms-touch-action: manipulation;
135+
touch-action: manipulation;
136+
cursor: pointer;
137+
background-color: greenyellow;
138+
border: none;
139+
color: #FFFFFF;
140+
text-decoration: none;
141+
}
124142
.button {
125143
display: inline-block;
126144
padding: 6px 12px;

projects/ngx-file-uploader/src/lib/ngx-file-uploader.component.ts

+22-12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
3131
public fileList = new Array<any>();
3232
public fileType: string;
3333
public message = '';
34+
public pdfCreated = false;
3435
public messageType = '';
3536
public liveCamera = false;
3637
public pdfAvailable = false;
@@ -129,9 +130,6 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
129130
const files = event.srcElement.files;
130131
this.uploading = true;
131132
// const fileToLoad = files;
132-
if (this.fieType === 'liveCamera') {
133-
this.UploadCaptions = true;
134-
}
135133
if (files) {
136134
for (const file of files) {
137135
const fileReader = new FileReader();
@@ -158,6 +156,10 @@ this.UploadCaptions = true;
158156
if (!this.singleFile) {
159157
this.urls.push(payload);
160158
this.fileList.push(payload);
159+
this.UploadCaptions = true;
160+
if (this.fieType === 'image' || 'liveCamera') {
161+
this.checkFilesSelected();
162+
}
161163
} else {
162164
this.fileChanged.emit(payload);
163165
this.back();
@@ -189,18 +191,14 @@ public messageViewTimeout () {
189191
this.UploadCaptions = false;
190192
this.singleFile = false;
191193
this.pdfAvailable = false;
194+
this.uploading = false;
192195
this.merge = false;
193196
this.fileUpload = false;
194197
this.liveCamera = false;
195198
}
196199
public toggleVisibility(filetype: string) {
197200
this.fieType = filetype;
198201
if (filetype === 'image') {
199-
if (this.formEntry) {
200-
this.message = ' Images will be merged into one pdf when uploaded in formentry';
201-
this.messageType = 'danger';
202-
this.messageViewTimeout();
203-
}
204202
this.fileType = 'image/png, image/jpeg, image/gif';
205203
this.fileUpload = true;
206204

@@ -228,8 +226,10 @@ public messageViewTimeout () {
228226
}
229227

230228
public upload() {
231-
if (this.formEntry && this.pdfAvailable === false) {
232-
this.mergeImages();
229+
if (!this.pdfCreated) {
230+
if (this.formEntry && !this.pdfAvailable) {
231+
this.mergeImages();
232+
}
233233
}
234234
this.uploadData.emit(this.fileList);
235235
this.back();
@@ -275,6 +275,8 @@ public messageViewTimeout () {
275275
this.urls.push(payload);
276276
this.singleFile = false;
277277
this.UploadCaptions = true;
278+
this.pdfCreated = true;
279+
this.pdfAvailable = true;
278280

279281
}
280282
public delete(urls: any) {
@@ -330,14 +332,22 @@ public messageViewTimeout () {
330332
if (this.singleFile) {
331333
this.urls = [];
332334
this.fileList = [];
333-
this.pushData(webcamImage);
334-
335335
}
336336
this.pushData(webcamImage);
337+
this.UploadCaptions = true;
338+
this.uploading = true;
339+
}
340+
public checkFilesSelected() {
341+
if (this.formEntry && this.urls.length > 1) {
342+
this.message = '*Please click merge to convert and combine Multipe images into one PDF file';
343+
this.messageType = 'danger';
344+
this.messageViewTimeout();
345+
}
337346
}
338347
public pushData(webcamImage) {
339348
this.urls.push(webcamImage);
340349
this.fileList.push(webcamImage);
350+
this.checkFilesSelected();
341351
}
342352

343353
public cameraWasSwitched(deviceId: string): void {

src/app/app.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Image {{dataModel}} <lib-file-uploader
1+
<lib-file-uploader
22
[(ngModel)]="dataModel" (onClear)="clear()" (fileChanged)="upload($event)">
33
</lib-file-uploader>

0 commit comments

Comments
 (0)