@measurequick/measurequick-report-generator 1.2.42 → 1.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import * as photos6 from '../base-64/photos6.js';
|
|
|
5
5
|
import * as base64 from '../base-64/icons.js';
|
|
6
6
|
import * as util from '../util.js';
|
|
7
7
|
|
|
8
|
-
export async function getReport(payload) { console.log(payload);
|
|
8
|
+
export async function getReport(payload) { // console.log(payload);
|
|
9
9
|
|
|
10
10
|
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
11
11
|
let maxPhotosPerPage = payload.meta.pdf_settings.maxPhotosPerPage;
|
|
@@ -25,15 +25,22 @@ export async function getReport(payload) { console.log(payload);
|
|
|
25
25
|
let photos = payload.photos.project;
|
|
26
26
|
if (photos && Object.keys(photos) && Object.keys(photos).length > 0) {
|
|
27
27
|
let s3ReferenceIds = Object.keys(photos);
|
|
28
|
+
let arrPhotos = [];
|
|
29
|
+
for (let i = 0; i < s3ReferenceIds.length; i++) { if (s3ReferenceIds[i] !== 'unsynced') arrPhotos.push(photos[s3ReferenceIds[i]]); }
|
|
30
|
+
console.log(arrPhotos);
|
|
31
|
+
arrPhotos.sort((a, b) => (a.section > b.section) ? 1 : -1);
|
|
32
|
+
console.log(arrPhotos);
|
|
28
33
|
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
29
34
|
forms[docIndex] = docs[docIndex].getForm();
|
|
30
35
|
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
31
36
|
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
32
37
|
let photoPosition = 1;
|
|
38
|
+
let prevSection, currSection;
|
|
33
39
|
for (let s3IdIndex = 0; s3IdIndex < s3ReferenceIds.length; s3IdIndex++) {
|
|
34
40
|
let s3ReferenceId = s3ReferenceIds[s3IdIndex];
|
|
35
41
|
if (s3ReferenceId !== "unsynced") {
|
|
36
42
|
let photo = photos[s3ReferenceId];
|
|
43
|
+
currSection = photo.section;
|
|
37
44
|
if (photoPosition > maxPhotosPerPage) {
|
|
38
45
|
photoPosition = 1;
|
|
39
46
|
docIndex++;
|
|
@@ -47,6 +54,10 @@ export async function getReport(payload) { console.log(payload);
|
|
|
47
54
|
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
48
55
|
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
49
56
|
photoPosition++;
|
|
57
|
+
let caption = photo.section;
|
|
58
|
+
if (prevSection == currSection) caption += photo.notes;
|
|
59
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(caption);
|
|
60
|
+
prevSection = currSection;
|
|
50
61
|
}
|
|
51
62
|
}
|
|
52
63
|
docIndex++;
|