@@ -31,6 +31,7 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
31
31
public fileList = new Array < any > ( ) ;
32
32
public fileType : string ;
33
33
public message = '' ;
34
+ public pdfCreated = false ;
34
35
public messageType = '' ;
35
36
public liveCamera = false ;
36
37
public pdfAvailable = false ;
@@ -129,9 +130,6 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
129
130
const files = event . srcElement . files ;
130
131
this . uploading = true ;
131
132
// const fileToLoad = files;
132
- if ( this . fieType === 'liveCamera' ) {
133
- this . UploadCaptions = true ;
134
- }
135
133
if ( files ) {
136
134
for ( const file of files ) {
137
135
const fileReader = new FileReader ( ) ;
@@ -158,6 +156,10 @@ this.UploadCaptions = true;
158
156
if ( ! this . singleFile ) {
159
157
this . urls . push ( payload ) ;
160
158
this . fileList . push ( payload ) ;
159
+ this . UploadCaptions = true ;
160
+ if ( this . fieType === 'image' || 'liveCamera' ) {
161
+ this . checkFilesSelected ( ) ;
162
+ }
161
163
} else {
162
164
this . fileChanged . emit ( payload ) ;
163
165
this . back ( ) ;
@@ -189,18 +191,14 @@ public messageViewTimeout () {
189
191
this . UploadCaptions = false ;
190
192
this . singleFile = false ;
191
193
this . pdfAvailable = false ;
194
+ this . uploading = false ;
192
195
this . merge = false ;
193
196
this . fileUpload = false ;
194
197
this . liveCamera = false ;
195
198
}
196
199
public toggleVisibility ( filetype : string ) {
197
200
this . fieType = filetype ;
198
201
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
- }
204
202
this . fileType = 'image/png, image/jpeg, image/gif' ;
205
203
this . fileUpload = true ;
206
204
@@ -228,8 +226,10 @@ public messageViewTimeout () {
228
226
}
229
227
230
228
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
+ }
233
233
}
234
234
this . uploadData . emit ( this . fileList ) ;
235
235
this . back ( ) ;
@@ -275,6 +275,8 @@ public messageViewTimeout () {
275
275
this . urls . push ( payload ) ;
276
276
this . singleFile = false ;
277
277
this . UploadCaptions = true ;
278
+ this . pdfCreated = true ;
279
+ this . pdfAvailable = true ;
278
280
279
281
}
280
282
public delete ( urls : any ) {
@@ -330,14 +332,22 @@ public messageViewTimeout () {
330
332
if ( this . singleFile ) {
331
333
this . urls = [ ] ;
332
334
this . fileList = [ ] ;
333
- this . pushData ( webcamImage ) ;
334
-
335
335
}
336
336
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
+ }
337
346
}
338
347
public pushData ( webcamImage ) {
339
348
this . urls . push ( webcamImage ) ;
340
349
this . fileList . push ( webcamImage ) ;
350
+ this . checkFilesSelected ( ) ;
341
351
}
342
352
343
353
public cameraWasSwitched ( deviceId : string ) : void {
0 commit comments