From 6f8921e9dea4a7958e114ec90eb737f252ae9e05 Mon Sep 17 00:00:00 2001
From: ameliebernier <45005853+ameliebernier@users.noreply.github.com>
Date: Thu, 6 Dec 2018 15:39:00 -0500
Subject: [PATCH] fix(print): Print options fix Issue #189 (#238)
* Issue #189 Print options fix
* Issue #189 Removed alert
* Issue #189 Ajusted margins
* Removed '!important' and unused modules
---
package.json | 2 +-
.../print-form/print-form.component.html | 38 ++++++++++---------
.../print-form/print-form.component.scss | 19 ++++------
projects/geo/src/lib/print/print.module.ts | 6 +--
.../geo/src/lib/print/shared/print.service.ts | 17 +++++----
projects/geo/src/locale/en.geo.json | 1 +
projects/geo/src/locale/fr.geo.json | 1 +
7 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/package.json b/package.json
index 89ec75b87d..f8882cf205 100644
--- a/package.json
+++ b/package.json
@@ -73,7 +73,7 @@
"file-saver": "^1.3.8",
"hammerjs": "^2.0.8",
"html2canvas": "^1.0.0-alpha.12",
- "jspdf": "^1.3.5",
+ "jspdf": "^1.4.1",
"jszip": "^3.1.5",
"jwt-decode": "^2.2.0",
"moment": "^2.22.2",
diff --git a/projects/geo/src/lib/print/print-form/print-form.component.html b/projects/geo/src/lib/print/print-form/print-form.component.html
index 5a903683c2..c1427f7554 100644
--- a/projects/geo/src/lib/print/print-form/print-form.component.html
+++ b/projects/geo/src/lib/print/print-form/print-form.component.html
@@ -19,18 +19,18 @@
-
- {{'igo.geo.printForm.showProjection' | translate}}
-
-
- {{'igo.geo.printForm.showScale' | translate}}
-
-
- {{'igo.geo.printForm.showLegend' | translate}}
-
-
- {{'igo.geo.printForm.doZipFile' | translate}}
-
+
+ {{'igo.geo.printForm.showProjection' | translate}}
+
+
+ {{'igo.geo.printForm.showScale' | translate}}
+
+
+ {{'igo.geo.printForm.showLegend' | translate}}
+
+
+ {{'igo.geo.printForm.doZipFile' | translate}}
+
@@ -82,11 +82,15 @@
-
-
- {{('igo.geo.printForm.' + orientation.value) | translate}}
-
-
+
+
+
+ {{('igo.geo.printForm.' + orientation.value) | translate}}
+
+
+
diff --git a/projects/geo/src/lib/print/print-form/print-form.component.scss b/projects/geo/src/lib/print/print-form/print-form.component.scss
index 35c612b411..19e1a343e1 100644
--- a/projects/geo/src/lib/print/print-form/print-form.component.scss
+++ b/projects/geo/src/lib/print/print-form/print-form.component.scss
@@ -4,20 +4,21 @@ mat-form-field {
width: 100%;
}
-mat-checkbox.horizontal-left {
+mat-slide-toggle.horizontal-left {
text-align: left;
@include mobile {
text-align: inherit;
}
}
- mat-checkbox.horizontal-left span {
- padding: 0 8px;
+mat-slide-toggle ::ng-deep .mat-slide-toggle-content {
+ font-size: 100%;
}
-mat-checkbox, mat-radio-button {
- padding-right: 20px;
- padding-bottom: 10px;
+.print-option {
+ display: block;
+ margin-right: 10px;
+ margin-bottom: 15px;
}
.print-button-top-padding {
@@ -30,8 +31,4 @@ mat-checkbox, mat-radio-button {
.igo-form-button-group {
text-align: center;
-}
-
-mat-checkbox ::ng-deep label.mat-checkbox-layout {
- padding-bottom: 10px;
-}
+}
\ No newline at end of file
diff --git a/projects/geo/src/lib/print/print.module.ts b/projects/geo/src/lib/print/print.module.ts
index 67a2820554..80a5d10fa7 100644
--- a/projects/geo/src/lib/print/print.module.ts
+++ b/projects/geo/src/lib/print/print.module.ts
@@ -8,8 +8,7 @@ import {
MatOptionModule,
MatInputModule,
MatFormFieldModule,
- MatRadioModule,
- MatCheckboxModule
+ MatSlideToggleModule
} from '@angular/material';
import { IgoLanguageModule } from '@igo2/core';
@@ -31,8 +30,7 @@ import { PrintService } from './shared/print.service';
MatOptionModule,
MatInputModule,
MatFormFieldModule,
- MatRadioModule,
- MatCheckboxModule,
+ MatSlideToggleModule,
IgoLanguageModule,
IgoKeyValueModule
],
diff --git a/projects/geo/src/lib/print/shared/print.service.ts b/projects/geo/src/lib/print/shared/print.service.ts
index 9fb6dae02d..3b5b95bb33 100644
--- a/projects/geo/src/lib/print/shared/print.service.ts
+++ b/projects/geo/src/lib/print/shared/print.service.ts
@@ -71,7 +71,7 @@ export class PrintService {
(status: SubjectStatus) => {
if (status === SubjectStatus.Done) {
if (options.showLegend === true) {
- this.addLegend(doc, map);
+ this.addLegend(doc, map, margins);
} else {
this.saveDoc(doc);
}
@@ -236,8 +236,10 @@ export class PrintService {
/**
Add the legend to the document
@param doc - Pdf document where legend will be added
+ @param map - Map of the app
+ @param margins - Page margins
*/
- private addLegend(doc: jsPDF, map: IgoMap) {
+ private addLegend(doc: jsPDF, map: IgoMap, margins: Array) {
const that = this;
// Get html code for the legend
const width = doc.internal.pageSize.width;
@@ -256,7 +258,7 @@ export class PrintService {
imgData = canvas.toDataURL('image/png');
doc.addPage();
- const imageSize = this.getImageSizeToFitPdf(doc, canvas);
+ const imageSize = this.getImageSizeToFitPdf(doc, canvas, margins);
doc.addImage(imgData, 'PNG', 10, position, imageSize[0], imageSize[1]);
that.saveDoc(doc);
div.parentNode.removeChild(div); // remove temp div (IE style)
@@ -280,7 +282,7 @@ export class PrintService {
if (image !== undefined) {
- const imageSize = this.getImageSizeToFitPdf(doc, canvas);
+ const imageSize = this.getImageSizeToFitPdf(doc, canvas, margins);
doc.addImage(image, 'JPEG', margins[3], margins[0], imageSize[0], imageSize[1]);
doc.rect(margins[3], margins[0], imageSize[0], imageSize[1]);
}
@@ -558,11 +560,12 @@ export class PrintService {
Calculate the best Image size to fit in pdf
@param doc - Pdf Document
@param canvas - Canvas of image
+ @param margins - Page margins
*/
- private getImageSizeToFitPdf(doc, canvas) {
+ private getImageSizeToFitPdf(doc, canvas, margins) {
// Define variable to calculate best size to fit in one page
- const pageHeight = doc.internal.pageSize.getHeight() - 20; // -20 to let margin work great
- const pageWidth = doc.internal.pageSize.getWidth() - 20; // -20 to let margin work great
+ const pageHeight = doc.internal.pageSize.getHeight() - (margins[0] + margins[2]);
+ const pageWidth = doc.internal.pageSize.getWidth() - (margins[1] + margins[3]);
const canHeight = canvas.height;
const canWidth = canvas.width;
const heightRatio = canHeight / pageHeight;
diff --git a/projects/geo/src/locale/en.geo.json b/projects/geo/src/locale/en.geo.json
index 266db0d0e5..158ab3fc97 100644
--- a/projects/geo/src/locale/en.geo.json
+++ b/projects/geo/src/locale/en.geo.json
@@ -116,6 +116,7 @@
"outputFormat": "Output format",
"paperFormat": "Paper format",
"imageFormat": "Image format",
+ "orientation" : "Orientation",
"landscape": "Landscape",
"portrait": "Portrait",
"projection": "Projection",
diff --git a/projects/geo/src/locale/fr.geo.json b/projects/geo/src/locale/fr.geo.json
index dbd61fe9eb..43c963a6b0 100644
--- a/projects/geo/src/locale/fr.geo.json
+++ b/projects/geo/src/locale/fr.geo.json
@@ -117,6 +117,7 @@
"outputFormat": "Format de sortie",
"paperFormat": "Format du papier",
"imageFormat": "Format de l'image",
+ "orientation" : "Orientation",
"landscape": "Paysage",
"portrait": "Portrait",
"printBtn": "Imprimer",