Skip to content

Commit 30ae4e3

Browse files
committed
HIV-402: formentry pdf creation fix
1 parent dccac15 commit 30ae4e3

File tree

6 files changed

+42
-21
lines changed

6 files changed

+42
-21
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.15",
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.15",
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

+16-13
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ export class NgxFileUploaderComponent implements ControlValueAccessor, OnInit {
130130
const files = event.srcElement.files;
131131
this.uploading = true;
132132
// const fileToLoad = files;
133-
if (this.fieType === 'liveCamera') {
134-
this.UploadCaptions = true;
135-
}
136133
if (files) {
137134
for (const file of files) {
138135
const fileReader = new FileReader();
@@ -159,6 +156,10 @@ this.UploadCaptions = true;
159156
if (!this.singleFile) {
160157
this.urls.push(payload);
161158
this.fileList.push(payload);
159+
this.UploadCaptions = true;
160+
if (this.fieType === 'image' || 'liveCamera') {
161+
this.checkFilesSelected();
162+
}
162163
} else {
163164
this.fileChanged.emit(payload);
164165
this.back();
@@ -190,18 +191,14 @@ public messageViewTimeout () {
190191
this.UploadCaptions = false;
191192
this.singleFile = false;
192193
this.pdfAvailable = false;
194+
this.uploading = false;
193195
this.merge = false;
194196
this.fileUpload = false;
195197
this.liveCamera = false;
196198
}
197199
public toggleVisibility(filetype: string) {
198200
this.fieType = filetype;
199201
if (filetype === 'image') {
200-
if (this.formEntry) {
201-
this.message = ' Images will be merged into one pdf when uploaded in formentry';
202-
this.messageType = 'danger';
203-
this.messageViewTimeout();
204-
}
205202
this.fileType = 'image/png, image/jpeg, image/gif';
206203
this.fileUpload = true;
207204

@@ -229,10 +226,8 @@ public messageViewTimeout () {
229226
}
230227

231228
public upload() {
232-
if (!this.pdfCreated) {
233-
if (this.formEntry && this.pdfAvailable === false) {
229+
if (!this.pdfCreated && this.formEntry && !this.pdfAvailable ) {
234230
this.mergeImages();
235-
}
236231
}
237232
this.uploadData.emit(this.fileList);
238233
this.back();
@@ -334,14 +329,22 @@ public messageViewTimeout () {
334329
if (this.singleFile) {
335330
this.urls = [];
336331
this.fileList = [];
337-
this.pushData(webcamImage);
338-
339332
}
340333
this.pushData(webcamImage);
334+
this.UploadCaptions = true;
335+
this.uploading = true;
336+
}
337+
public checkFilesSelected() {
338+
if (this.formEntry && this.urls.length > 1) {
339+
this.message = '*Please click merge to convert and combine Multipe images into one PDF file';
340+
this.messageType = 'danger';
341+
this.messageViewTimeout();
342+
}
341343
}
342344
public pushData(webcamImage) {
343345
this.urls.push(webcamImage);
344346
this.fileList.push(webcamImage);
347+
this.checkFilesSelected();
345348
}
346349

347350
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)