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

HIV-428: formentry pdf creation fix #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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.15",
"version": "0.0.18",
"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.15",
"version": "0.0.18",
"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 && merge" type="button" (click)="mergeImages()" title="merge the images as pages in one pdf document" class="buttonMerge">
<span class="glyphicon glyphicon-upload"></span> Merge Images 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:#3c763d;
border: none;
color: #FFFFFF;
text-decoration: none;
}
.button {
display: inline-block;
padding: 6px 12px;
Expand Down
42 changes: 23 additions & 19 deletions projects/ngx-file-uploader/src/lib/ngx-file-uploader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,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 @@ -145,10 +142,9 @@ this.UploadCaptions = true;
const name = file.name;
const fileSize = Math.round(file.size / 1024);
if (fileSize >= 3072) {
this.message = 'File Too large';
this.message = 'File Selected Too large';
this.messageType = 'danger';
this.messageViewTimeout();
this.back();
} else {
const payload = {
data,
Expand All @@ -159,6 +155,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 @@ -190,18 +190,18 @@ public messageViewTimeout () {
this.UploadCaptions = false;
this.singleFile = false;
this.pdfAvailable = false;
this.liveCamera = false;
this.uploading = false;
this.merge = false;
this.fileUpload = false;
this.liveCamera = false;
}
public toggleVisibility(filetype: string) {
if (this.value) {
this.clear();
}
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 All @@ -222,18 +222,13 @@ public messageViewTimeout () {
}
this.selectFileType = false;
this.backButton = true;
if (this.value) {
this.clear();
}

}

public upload() {
if (!this.pdfCreated) {
if (this.formEntry && this.pdfAvailable === false) {
if (!this.pdfCreated && this.formEntry && !this.pdfAvailable ) {
this.mergeImages();
}
}
}this.merge = true;
this.uploadData.emit(this.fileList);
this.back();
}
Expand Down Expand Up @@ -334,14 +329,23 @@ 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.merge = true;
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>