@lighthouse/common 5.3.0-canary.0 → 5.4.0-canary.0
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/.mise.toml +6 -0
- package/dist/helpers/get-audit-items-data/index.js +4 -1
- package/dist/pdf/audit/index.js +27 -18
- package/dist/pdf/helpers/fields/index.js +6 -6
- package/dist/pdf/issue/index.js +20 -16
- package/dist/pdf/task/index.js +20 -16
- package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
- package/lib/helpers/get-audit-items-data/index.js +3 -0
- package/lib/helpers/get-audit-items-data/index.js.map +1 -1
- package/lib/pdf/audit/index.js +27 -18
- package/lib/pdf/audit/index.js.map +1 -1
- package/lib/pdf/helpers/fields/index.js +6 -6
- package/lib/pdf/helpers/fields/index.js.map +1 -1
- package/lib/pdf/issue/index.js +20 -16
- package/lib/pdf/issue/index.js.map +1 -1
- package/lib/pdf/task/index.js +20 -16
- package/lib/pdf/task/index.js.map +1 -1
- package/package.json +1 -1
package/.mise.toml
ADDED
|
@@ -11,7 +11,8 @@ function getAuditItemsData(items, data) {
|
|
|
11
11
|
settings: {
|
|
12
12
|
awsS3BaseUrl,
|
|
13
13
|
cloudinaryBaseUrl,
|
|
14
|
-
cloudfrontBaseUrl
|
|
14
|
+
cloudfrontBaseUrl,
|
|
15
|
+
shouldUseCloudfront
|
|
15
16
|
} = {},
|
|
16
17
|
entity: {
|
|
17
18
|
groupScores
|
|
@@ -54,6 +55,7 @@ function getAuditItemsData(items, data) {
|
|
|
54
55
|
awsS3BaseUrl,
|
|
55
56
|
cloudfrontBaseUrl,
|
|
56
57
|
cloudinaryBaseUrl,
|
|
58
|
+
shouldUseCloudfront,
|
|
57
59
|
fit: true,
|
|
58
60
|
height: 400,
|
|
59
61
|
width: 600,
|
|
@@ -64,6 +66,7 @@ function getAuditItemsData(items, data) {
|
|
|
64
66
|
awsS3BaseUrl,
|
|
65
67
|
cloudfrontBaseUrl,
|
|
66
68
|
cloudinaryBaseUrl,
|
|
69
|
+
shouldUseCloudfront,
|
|
67
70
|
width: 100,
|
|
68
71
|
quality: 50
|
|
69
72
|
});
|
package/dist/pdf/audit/index.js
CHANGED
|
@@ -144,29 +144,38 @@ function generateContent(data) {
|
|
|
144
144
|
style: 'totalScore'
|
|
145
145
|
});
|
|
146
146
|
const body = renderThirdRow ? [firstRow, secondRow, thirdRow] : [firstRow, secondRow];
|
|
147
|
-
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
148
|
-
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
149
|
-
colSpan: 2,
|
|
150
|
-
style: 'small'
|
|
151
|
-
});
|
|
152
147
|
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
153
148
|
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
154
149
|
colSpan: 2,
|
|
155
150
|
style: 'small'
|
|
156
151
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
152
|
+
if (entity.showSimplifiedDuration) {
|
|
153
|
+
body.push([submittedAt, dummyColumn]);
|
|
154
|
+
} else {
|
|
155
|
+
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
156
|
+
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
157
|
+
colSpan: 2,
|
|
158
|
+
style: 'small'
|
|
159
|
+
});
|
|
160
|
+
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
161
|
+
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
162
|
+
colSpan: 2,
|
|
163
|
+
style: 'small'
|
|
164
|
+
});
|
|
165
|
+
const momentDuration = _momentTimezone.default.duration(Math.abs(entity.formDuration));
|
|
166
|
+
const days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
167
|
+
const hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
168
|
+
const minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
169
|
+
const seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
170
|
+
const formattedFormDuration = entity.formDuration ? `${entity.formDuration < 0 ? '-' : ''}${days}:${hours}:${minutes}:${seconds}` : 'Not recorded';
|
|
171
|
+
const formDuration = (0, _helpers.text)(`Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`, {
|
|
172
|
+
colSpan: 2,
|
|
173
|
+
style: 'small'
|
|
174
|
+
});
|
|
175
|
+
body.push([startedAt, dummyColumn]);
|
|
176
|
+
body.push([submittedAt, dummyColumn]);
|
|
177
|
+
body.push([formDuration, dummyColumn]);
|
|
178
|
+
}
|
|
170
179
|
const titleTable = (0, _helpers.twoColumnTable)({
|
|
171
180
|
body,
|
|
172
181
|
layout: 'noBorders',
|
|
@@ -42,7 +42,8 @@ function buildImage(options) {
|
|
|
42
42
|
const {
|
|
43
43
|
awsS3BaseUrl,
|
|
44
44
|
cloudinaryBaseUrl,
|
|
45
|
-
cloudfrontBaseUrl
|
|
45
|
+
cloudfrontBaseUrl,
|
|
46
|
+
shouldUseCloudfront
|
|
46
47
|
} = settings;
|
|
47
48
|
const isVideoType = new RegExp('.mp4$').test(filepath);
|
|
48
49
|
const link = `${awsS3BaseUrl}/${filepath}`;
|
|
@@ -61,7 +62,8 @@ function buildImage(options) {
|
|
|
61
62
|
fit: true,
|
|
62
63
|
height: 400,
|
|
63
64
|
width: 600,
|
|
64
|
-
quality: 50
|
|
65
|
+
quality: 50,
|
|
66
|
+
shouldUseCloudfront
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
// NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context
|
|
@@ -216,10 +218,8 @@ function buildTemplateFieldRow({
|
|
|
216
218
|
const isTextField = fieldtype === 'text';
|
|
217
219
|
const is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a';
|
|
218
220
|
const is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm';
|
|
219
|
-
const isDisplayImageField = fieldtype === 'image-display' && showOnRead;
|
|
220
|
-
const isEmptyArray = fieldtype === 'image-display' && (0, _lodash.isArray)(value) && value.length === 0;
|
|
221
|
+
const isDisplayImageField = fieldtype === 'image-display' && showOnRead && !((0, _lodash.isArray)(value) && value.length === 0);
|
|
221
222
|
const isReferenceField = fieldtype === 'reference';
|
|
222
|
-
|
|
223
223
|
// NOTE: only show field when show on read is true
|
|
224
224
|
if (!showOnRead) return null;
|
|
225
225
|
const labelText = [{
|
|
@@ -246,7 +246,7 @@ function buildTemplateFieldRow({
|
|
|
246
246
|
return [labelText, values];
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
-
if (isDisplayImageField
|
|
249
|
+
if (isDisplayImageField) {
|
|
250
250
|
return _bluebird.default.map([value], filepath => buildImage({
|
|
251
251
|
filepath,
|
|
252
252
|
settings
|
package/dist/pdf/issue/index.js
CHANGED
|
@@ -85,26 +85,30 @@ function generateContent(data) {
|
|
|
85
85
|
style: 'small'
|
|
86
86
|
});
|
|
87
87
|
const body = !(0, _lodash.isEmpty)(reverseGeocoded) ? [[headerTitle], [headerSubTitle], [headerAddress]] : [[headerTitle], [headerSubTitle]];
|
|
88
|
-
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
89
|
-
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
90
|
-
style: 'small'
|
|
91
|
-
});
|
|
92
88
|
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
93
89
|
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
94
90
|
style: 'small'
|
|
95
91
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
if (entity.showSimplifiedDuration) {
|
|
93
|
+
body.push([submittedAt]);
|
|
94
|
+
} else {
|
|
95
|
+
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
96
|
+
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
97
|
+
style: 'small'
|
|
98
|
+
});
|
|
99
|
+
const momentDuration = _momentTimezone.default.duration(Math.abs(entity.formDuration));
|
|
100
|
+
const days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
101
|
+
const hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
102
|
+
const minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
103
|
+
const seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
104
|
+
const formattedFormDuration = entity.formDuration ? `${entity.formDuration < 0 ? '-' : ''}${days}:${hours}:${minutes}:${seconds}` : 'Not recorded';
|
|
105
|
+
const formDuration = (0, _helpers.text)(`Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`, {
|
|
106
|
+
style: 'small'
|
|
107
|
+
});
|
|
108
|
+
body.push([startedAt]);
|
|
109
|
+
body.push([submittedAt]);
|
|
110
|
+
body.push([formDuration]);
|
|
111
|
+
}
|
|
108
112
|
const titleTable = (0, _helpers.table)({
|
|
109
113
|
body,
|
|
110
114
|
layout: 'noBorders',
|
package/dist/pdf/task/index.js
CHANGED
|
@@ -85,26 +85,30 @@ function generateContent(data) {
|
|
|
85
85
|
if (!(0, _lodash.isEmpty)(reverseGeocoded)) {
|
|
86
86
|
body.push([headerAddress]);
|
|
87
87
|
}
|
|
88
|
-
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
89
|
-
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
90
|
-
style: 'small'
|
|
91
|
-
});
|
|
92
88
|
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
93
89
|
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
94
90
|
style: 'small'
|
|
95
91
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
if (entity.showSimplifiedDuration) {
|
|
93
|
+
body.push([submittedAt]);
|
|
94
|
+
} else {
|
|
95
|
+
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
96
|
+
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
97
|
+
style: 'small'
|
|
98
|
+
});
|
|
99
|
+
const momentDuration = _momentTimezone.default.duration(Math.abs(entity.formDuration));
|
|
100
|
+
const days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
101
|
+
const hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
102
|
+
const minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
103
|
+
const seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
104
|
+
const formattedFormDuration = entity.formDuration ? `${entity.formDuration < 0 ? '-' : ''}${days}:${hours}:${minutes}:${seconds}` : 'Not recorded';
|
|
105
|
+
const formDuration = (0, _helpers.text)(`Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`, {
|
|
106
|
+
style: 'small'
|
|
107
|
+
});
|
|
108
|
+
body.push([startedAt]);
|
|
109
|
+
body.push([submittedAt]);
|
|
110
|
+
body.push([formDuration]);
|
|
111
|
+
}
|
|
108
112
|
const titleTable = (0, _helpers.table)({
|
|
109
113
|
body,
|
|
110
114
|
layout: 'noBorders',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["get","getAuditItemsData","getLocationReference","getReferenceDetails","getTimezoneDatetime","getAuditEntryDetails","data","entity","timezone","createdAt","gps","items","templateRevision","sequenceId","score","target","targetServiceLevel","locationText","gpsText","groupedData","referenceDetails","scoreText","percentageResult","undefined","concat","timezoneHourTime","format","timestamp","timezoneDatetime","referenceLabel","label","referenceValue","value"],"sources":["../../../src/helpers/get-audit-entry-details/index.js"],"sourcesContent":["import { get } from 'lodash'\n\nimport {\n getAuditItemsData,\n getLocationReference,\n getReferenceDetails,\n getTimezoneDatetime,\n} from '../'\n\nexport function getAuditEntryDetails(data) {\n const { entity, timezone } = data\n\n const {\n createdAt,\n gps,\n items,\n templateRevision,\n sequenceId,\n score,\n target,\n targetServiceLevel,\n } = entity\n\n const locationText = getLocationReference(data)\n const gpsText = get(gps, 'reverseGeocoded.label', 'Unknown Location')\n const groupedData = getAuditItemsData(items, data)\n const referenceDetails = getReferenceDetails(data)\n const scoreText =\n score && score.percentageResult !== undefined\n ? `${score.percentageResult}%`\n : ''\n const timezoneHourTime = getTimezoneDatetime({\n format: 'h:mm a',\n timestamp: createdAt,\n timezone,\n })\n const timezoneDatetime = getTimezoneDatetime({\n timestamp: createdAt,\n timezone,\n })\n\n return {\n gpsText,\n groupedData,\n locationText,\n referenceLabel: referenceDetails.label,\n referenceValue: referenceDetails.value,\n templateRevision,\n scoreText,\n sequenceId,\n target,\n targetServiceLevel,\n timezoneDatetime,\n timezoneHourTime,\n }\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,QAAQ;AAE5B,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,QACd,KAAK;AAEZ,OAAO,SAASC,oBAAoBA,CAACC,IAAI,EAAE;EACzC,IAAQC,MAAM,GAAeD,IAAI,CAAzBC,MAAM;IAAEC,QAAQ,GAAKF,IAAI,CAAjBE,QAAQ;EAExB,IACEC,SAAS,GAQPF,MAAM,CARRE,SAAS;IACTC,GAAG,GAODH,MAAM,CAPRG,GAAG;IACHC,KAAK,GAMHJ,MAAM,CANRI,KAAK;IACLC,gBAAgB,GAKdL,MAAM,CALRK,gBAAgB;IAChBC,UAAU,GAIRN,MAAM,CAJRM,UAAU;IACVC,KAAK,GAGHP,MAAM,CAHRO,KAAK;IACLC,MAAM,GAEJR,MAAM,CAFRQ,MAAM;IACNC,kBAAkB,GAChBT,MAAM,CADRS,kBAAkB;EAGpB,IAAMC,YAAY,GAAGf,oBAAoB,CAACI,IAAI,CAAC;EAC/C,IAAMY,OAAO,GAAGlB,GAAG,CAACU,GAAG,EAAE,uBAAuB,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","names":["get","getAuditItemsData","getLocationReference","getReferenceDetails","getTimezoneDatetime","getAuditEntryDetails","data","entity","timezone","createdAt","gps","items","templateRevision","sequenceId","score","target","targetServiceLevel","locationText","gpsText","groupedData","referenceDetails","scoreText","percentageResult","undefined","concat","timezoneHourTime","format","timestamp","timezoneDatetime","referenceLabel","label","referenceValue","value"],"sources":["../../../src/helpers/get-audit-entry-details/index.js"],"sourcesContent":["import { get } from 'lodash'\n\nimport {\n getAuditItemsData,\n getLocationReference,\n getReferenceDetails,\n getTimezoneDatetime,\n} from '../'\n\nexport function getAuditEntryDetails(data) {\n const { entity, timezone } = data\n\n const {\n createdAt,\n gps,\n items,\n templateRevision,\n sequenceId,\n score,\n target,\n targetServiceLevel,\n } = entity\n\n const locationText = getLocationReference(data)\n const gpsText = get(gps, 'reverseGeocoded.label', 'Unknown Location')\n\n const groupedData = getAuditItemsData(items, data)\n const referenceDetails = getReferenceDetails(data)\n const scoreText =\n score && score.percentageResult !== undefined\n ? `${score.percentageResult}%`\n : ''\n const timezoneHourTime = getTimezoneDatetime({\n format: 'h:mm a',\n timestamp: createdAt,\n timezone,\n })\n const timezoneDatetime = getTimezoneDatetime({\n timestamp: createdAt,\n timezone,\n })\n\n return {\n gpsText,\n groupedData,\n locationText,\n referenceLabel: referenceDetails.label,\n referenceValue: referenceDetails.value,\n templateRevision,\n scoreText,\n sequenceId,\n target,\n targetServiceLevel,\n timezoneDatetime,\n timezoneHourTime,\n }\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,QAAQ;AAE5B,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,QACd,KAAK;AAEZ,OAAO,SAASC,oBAAoBA,CAACC,IAAI,EAAE;EACzC,IAAQC,MAAM,GAAeD,IAAI,CAAzBC,MAAM;IAAEC,QAAQ,GAAKF,IAAI,CAAjBE,QAAQ;EAExB,IACEC,SAAS,GAQPF,MAAM,CARRE,SAAS;IACTC,GAAG,GAODH,MAAM,CAPRG,GAAG;IACHC,KAAK,GAMHJ,MAAM,CANRI,KAAK;IACLC,gBAAgB,GAKdL,MAAM,CALRK,gBAAgB;IAChBC,UAAU,GAIRN,MAAM,CAJRM,UAAU;IACVC,KAAK,GAGHP,MAAM,CAHRO,KAAK;IACLC,MAAM,GAEJR,MAAM,CAFRQ,MAAM;IACNC,kBAAkB,GAChBT,MAAM,CADRS,kBAAkB;EAGpB,IAAMC,YAAY,GAAGf,oBAAoB,CAACI,IAAI,CAAC;EAC/C,IAAMY,OAAO,GAAGlB,GAAG,CAACU,GAAG,EAAE,uBAAuB,EAAE,kBAAkB,CAAC;EAErE,IAAMS,WAAW,GAAGlB,iBAAiB,CAACU,KAAK,EAAEL,IAAI,CAAC;EAClD,IAAMc,gBAAgB,GAAGjB,mBAAmB,CAACG,IAAI,CAAC;EAClD,IAAMe,SAAS,GACbP,KAAK,IAAIA,KAAK,CAACQ,gBAAgB,KAAKC,SAAS,MAAAC,MAAA,CACtCV,KAAK,CAACQ,gBAAgB,SACzB,EAAE;EACR,IAAMG,gBAAgB,GAAGrB,mBAAmB,CAAC;IAC3CsB,MAAM,EAAE,QAAQ;IAChBC,SAAS,EAAElB,SAAS;IACpBD,QAAQ,EAARA;EACF,CAAC,CAAC;EACF,IAAMoB,gBAAgB,GAAGxB,mBAAmB,CAAC;IAC3CuB,SAAS,EAAElB,SAAS;IACpBD,QAAQ,EAARA;EACF,CAAC,CAAC;EAEF,OAAO;IACLU,OAAO,EAAPA,OAAO;IACPC,WAAW,EAAXA,WAAW;IACXF,YAAY,EAAZA,YAAY;IACZY,cAAc,EAAET,gBAAgB,CAACU,KAAK;IACtCC,cAAc,EAAEX,gBAAgB,CAACY,KAAK;IACtCpB,gBAAgB,EAAhBA,gBAAgB;IAChBS,SAAS,EAATA,SAAS;IACTR,UAAU,EAAVA,UAAU;IACVE,MAAM,EAANA,MAAM;IACNC,kBAAkB,EAAlBA,kBAAkB;IAClBY,gBAAgB,EAAhBA,gBAAgB;IAChBH,gBAAgB,EAAhBA;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ export function getAuditItemsData(items, data) {
|
|
|
6
6
|
awsS3BaseUrl = _data$settings2.awsS3BaseUrl,
|
|
7
7
|
cloudinaryBaseUrl = _data$settings2.cloudinaryBaseUrl,
|
|
8
8
|
cloudfrontBaseUrl = _data$settings2.cloudfrontBaseUrl,
|
|
9
|
+
shouldUseCloudfront = _data$settings2.shouldUseCloudfront,
|
|
9
10
|
_data$entity = data.entity,
|
|
10
11
|
_data$entity2 = _data$entity === void 0 ? {} : _data$entity,
|
|
11
12
|
groupScores = _data$entity2.groupScores;
|
|
@@ -46,6 +47,7 @@ export function getAuditItemsData(items, data) {
|
|
|
46
47
|
awsS3BaseUrl: awsS3BaseUrl,
|
|
47
48
|
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
48
49
|
cloudinaryBaseUrl: cloudinaryBaseUrl,
|
|
50
|
+
shouldUseCloudfront: shouldUseCloudfront,
|
|
49
51
|
fit: true,
|
|
50
52
|
height: 400,
|
|
51
53
|
width: 600,
|
|
@@ -56,6 +58,7 @@ export function getAuditItemsData(items, data) {
|
|
|
56
58
|
awsS3BaseUrl: awsS3BaseUrl,
|
|
57
59
|
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
58
60
|
cloudinaryBaseUrl: cloudinaryBaseUrl,
|
|
61
|
+
shouldUseCloudfront: shouldUseCloudfront,
|
|
59
62
|
width: 100,
|
|
60
63
|
quality: 50
|
|
61
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","getAuditItemsData","items","data","_data$settings","settings","_data$settings2","awsS3BaseUrl","cloudinaryBaseUrl","cloudfrontBaseUrl","_data$entity","entity","_data$entity2","groupScores","groupedItems","auditData","overallActualScore","overallMaximumScore","groupIndex","key","skipped","group","title","label","groupData","groupMaximumScore","groupActualScore","groupResultScore","groupPercentageResultScore","currentGroupScores","max","actual","result","percentageResult","item","itemIndex","hasScore","score","rawAssets","assets","assetCount","length","asset","assetIndex","assetUrl","fit","height","width","quality","link","concat","thumbnailUrl","comments","matchingScore","scores","value","scoreLabel","scoreWeight","weight","questionId","_id"],"sources":["../../../src/helpers/get-audit-items-data/index.js"],"sourcesContent":["import { find, groupBy, map, get, round } from 'lodash'\n\nimport { buildFetchUrl } from '../'\n\nexport function getAuditItemsData(items, data) {\n const {\n settings: {
|
|
1
|
+
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","getAuditItemsData","items","data","_data$settings","settings","_data$settings2","awsS3BaseUrl","cloudinaryBaseUrl","cloudfrontBaseUrl","shouldUseCloudfront","_data$entity","entity","_data$entity2","groupScores","groupedItems","auditData","overallActualScore","overallMaximumScore","groupIndex","key","skipped","group","title","label","groupData","groupMaximumScore","groupActualScore","groupResultScore","groupPercentageResultScore","currentGroupScores","max","actual","result","percentageResult","item","itemIndex","hasScore","score","rawAssets","assets","assetCount","length","asset","assetIndex","assetUrl","fit","height","width","quality","link","concat","thumbnailUrl","comments","matchingScore","scores","value","scoreLabel","scoreWeight","weight","questionId","_id"],"sources":["../../../src/helpers/get-audit-items-data/index.js"],"sourcesContent":["import { find, groupBy, map, get, round } from 'lodash'\n\nimport { buildFetchUrl } from '../'\n\nexport function getAuditItemsData(items, data) {\n const {\n settings: {\n awsS3BaseUrl,\n cloudinaryBaseUrl,\n cloudfrontBaseUrl,\n shouldUseCloudfront,\n } = {},\n entity: { groupScores } = {},\n } = data\n\n const groupedItems = groupBy(items, 'group.id')\n\n const auditData = {\n overallActualScore: 0,\n overallMaximumScore: 0,\n }\n\n auditData.items = map(groupedItems, (items, groupIndex) => {\n const key = groupIndex\n const skipped = !!items[0].group.skipped\n const title = items[0].group.label\n\n const groupData = {\n key,\n groupMaximumScore: 0,\n groupActualScore: 0,\n groupResultScore: 0,\n groupPercentageResultScore: 0,\n skipped,\n title,\n }\n\n const currentGroupScores = get(groupScores, key)\n\n if (currentGroupScores) {\n groupData.groupMaximumScore = round(currentGroupScores.max, 2)\n groupData.groupActualScore = round(currentGroupScores.actual, 2)\n groupData.groupResultScore = currentGroupScores.result\n groupData.groupPercentageResultScore = currentGroupScores.percentageResult\n }\n\n groupData.items = items.map((item, itemIndex) => {\n // NOTE: we handle scores of -1, 0 and 1\n // -1 scores are skipped from group max and actual score\n // 0 and 1 must be included in the final scores\n const hasScore = item.score !== null && item.score !== -1\n const rawAssets = item.assets || []\n const assetCount = rawAssets.length\n\n const assets = rawAssets.map((asset, assetIndex) => {\n const assetUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n shouldUseCloudfront,\n fit: true,\n height: 400,\n width: 600,\n quality: 50,\n })\n\n const link = `${awsS3BaseUrl}/${asset}`\n\n const thumbnailUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n shouldUseCloudfront,\n width: 100,\n quality: 50,\n })\n\n const key = `${groupIndex}-item-asset-${assetIndex}`\n\n return {\n assetUrl,\n key,\n link,\n thumbnailUrl,\n }\n })\n\n const comments = item.comments\n const label = item.label\n const score = item.score\n const key = `${groupIndex}-item-${itemIndex}`\n const matchingScore = find(item.scores, { value: score })\n\n // NOTE: ensure we have a score otherwise fallback to - value\n const scoreLabel =\n hasScore && matchingScore && !skipped ? matchingScore.label : '-'\n const scoreWeight = hasScore && !skipped ? item.scoreWeight : '-'\n const weight = hasScore ? item.weight : '-'\n\n return {\n assetCount,\n assets,\n comments,\n key,\n label,\n questionId: item._id,\n score,\n scoreLabel,\n scoreWeight,\n weight,\n }\n })\n\n return groupData\n })\n\n return auditData\n}\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,OAAO,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,QAAQ,QAAQ;AAEvD,SAASC,aAAa,QAAQ,KAAK;AAEnC,OAAO,SAASC,iBAAiBA,CAACC,KAAK,EAAEC,IAAI,EAAE;EAC7C,IAAAC,cAAA,GAQID,IAAI,CAPNE,QAAQ;IAAAC,eAAA,GAAAF,cAAA,cAKJ,CAAC,CAAC,GAAAA,cAAA;IAJJG,YAAY,GAAAD,eAAA,CAAZC,YAAY;IACZC,iBAAiB,GAAAF,eAAA,CAAjBE,iBAAiB;IACjBC,iBAAiB,GAAAH,eAAA,CAAjBG,iBAAiB;IACjBC,mBAAmB,GAAAJ,eAAA,CAAnBI,m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CAACkB,QAAQ;MAC9B,IAAM7B,KAAK,GAAGW,IAAI,CAACX,KAAK;MACxB,IAAMc,KAAK,GAAGH,IAAI,CAACG,KAAK;MACxB,IAAMlB,GAAG,MAAA+B,MAAA,CAAMhC,UAAU,YAAAgC,MAAA,CAASf,SAAS,CAAE;MAC7C,IAAMkB,aAAa,GAAG3D,IAAI,CAACwC,IAAI,CAACoB,MAAM,EAAE;QAAEC,KAAK,EAAElB;MAAM,CAAC,CAAC;;MAEzD;MACA,IAAMmB,UAAU,GACdpB,QAAQ,IAAIiB,aAAa,IAAI,CAACjC,OAAO,GAAGiC,aAAa,CAAC9B,KAAK,GAAG,GAAG;MACnE,IAAMkC,WAAW,GAAGrB,QAAQ,IAAI,CAAChB,OAAO,GAAGc,IAAI,CAACuB,WAAW,GAAG,GAAG;MACjE,IAAMC,MAAM,GAAGtB,QAAQ,GAAGF,IAAI,CAACwB,MAAM,GAAG,GAAG;MAE3C,OAAO;QACLlB,UAAU,EAAVA,UAAU;QACVD,MAAM,EAANA,MAAM;QACNa,QAAQ,EAARA,QAAQ;QACRjC,GAAG,EAAHA,GAAG;QACHI,KAAK,EAALA,KAAK;QACLoC,UAAU,EAAEzB,IAAI,CAAC0B,GAAG;QACpBvB,KAAK,EAALA,KAAK;QACLmB,UAAU,EAAVA,UAAU;QACVC,WAAW,EAAXA,WAAW;QACXC,MAAM,EAANA;MACF,CAAC;IACH,CAAC,CAAC;IAEF,OAAOlC,SAAS;EAClB,CAAC,CAAC;EAEF,OAAOT,SAAS;AAClB","ignoreList":[]}
|
package/lib/pdf/audit/index.js
CHANGED
|
@@ -140,29 +140,38 @@ function generateContent(data) {
|
|
|
140
140
|
style: 'totalScore'
|
|
141
141
|
});
|
|
142
142
|
var body = renderThirdRow ? [firstRow, secondRow, thirdRow] : [firstRow, secondRow];
|
|
143
|
-
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
144
|
-
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
145
|
-
colSpan: 2,
|
|
146
|
-
style: 'small'
|
|
147
|
-
});
|
|
148
143
|
var submittedAtInTimezone = entity.submittedAt ? moment(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
149
144
|
var submittedAt = text("Submitted: ".concat(submittedAtInTimezone), {
|
|
150
145
|
colSpan: 2,
|
|
151
146
|
style: 'small'
|
|
152
147
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
148
|
+
if (entity.showSimplifiedDuration) {
|
|
149
|
+
body.push([submittedAt, dummyColumn]);
|
|
150
|
+
} else {
|
|
151
|
+
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
152
|
+
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
153
|
+
colSpan: 2,
|
|
154
|
+
style: 'small'
|
|
155
|
+
});
|
|
156
|
+
var _submittedAtInTimezone = entity.submittedAt ? moment(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
157
|
+
var _submittedAt = text("Submitted: ".concat(_submittedAtInTimezone), {
|
|
158
|
+
colSpan: 2,
|
|
159
|
+
style: 'small'
|
|
160
|
+
});
|
|
161
|
+
var momentDuration = moment.duration(Math.abs(entity.formDuration));
|
|
162
|
+
var days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
163
|
+
var hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
164
|
+
var minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
165
|
+
var seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
166
|
+
var formattedFormDuration = entity.formDuration ? "".concat(entity.formDuration < 0 ? '-' : '').concat(days, ":").concat(hours, ":").concat(minutes, ":").concat(seconds) : 'Not recorded';
|
|
167
|
+
var formDuration = text("Form Duration (DD:HH:MM:SS): ".concat(formattedFormDuration), {
|
|
168
|
+
colSpan: 2,
|
|
169
|
+
style: 'small'
|
|
170
|
+
});
|
|
171
|
+
body.push([startedAt, dummyColumn]);
|
|
172
|
+
body.push([_submittedAt, dummyColumn]);
|
|
173
|
+
body.push([formDuration, dummyColumn]);
|
|
174
|
+
}
|
|
166
175
|
var titleTable = twoColumnTable({
|
|
167
176
|
body: body,
|
|
168
177
|
layout: 'noBorders',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Promise","isEmpty","round","moment","buildAuditContent","buildAuditFollowUps","buildTemplateContent","generateDefinition","getFormattedAddress","horizontalLine","text","twoColumnTable","getAuditEntryDetails","buildAuditPdf","pdfOptions","data","entity","timezone","_pdfOptions$flags","flags","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","catch","err","Error","message","_entity$followUps","followUps","_entity$footerFields","footerFields","_entity$gps","gps","_entity$headerFields","headerFields","_entity$score","score","_entity$title","entityDetails","gpsText","groupedData","locationText","referenceValue","timezoneHourTime","scoreText","target","targetServiceLevel","renderTargetFields","headerTitle","style","headerScore","alignment","firstRow","subTitle","headerSubTitle","colSpan","secondRow","reverseGeocoded","address","renderHeaderAddress","dummyColumn","headerAddress","renderThirdRow","thirdRow","serviceLevelBelow","serviceLevelText","scoreServiceLevelSubTitle","truncatedTargetPercent","scoreTargetText","scoreTargetSubTitle","scoreBreakdown","actual","max","scorePercentage","scoreTitle","body","startedAtInTimezone","startedAt","tz","format","submittedAtInTimezone","submittedAt","momentDuration","duration","Math","abs","formDuration","days","floor","asDays","toString","padStart","hours","minutes","seconds","formattedFormDuration","push","titleTable","layout","widths","margin","totalScoreTable","hLineTop","hLineBottom","followUpItems","promises","entry","items","footerTemplate","formGroups","headerTemplate","auditItemsTitle","font","lineHeight","props","_ref","_toConsumableArray"],"sources":["../../../src/pdf/audit/index.js"],"sourcesContent":["import Promise from 'bluebird'\nimport { isEmpty, round } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n buildAuditContent,\n buildAuditFollowUps,\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n horizontalLine,\n text,\n twoColumnTable,\n} from '../helpers'\nimport { getAuditEntryDetails } from '../../helpers'\n\n/**\n * buildAuditPdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} pdfOptions.flags - flags to conditionally render parts of the pdf\n * @param {object} data - pdf data\n * @param {object} data.entity - audit document\n * @param {object} data.locations - locations documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildAuditPdf(pdfOptions, data) {\n const { entity, timezone } = data\n const { flags = {} } = pdfOptions\n\n const sequenceId = entity.sequenceId\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n const fileTitle = `Audit Report - ${title}`\n\n return generateContent(data, flags)\n .then(content =>\n generateDefinition({\n content,\n fileTitle,\n sequenceId,\n timestamp,\n timezone,\n type: 'Audit',\n ...pdfOptions,\n })\n )\n .catch(err => {\n throw new Error(`BuildAuditPdfError: ${err.message}`)\n })\n}\n\nfunction generateContent(data) {\n const { entity } = data\n\n const {\n followUps = [],\n footerFields = {},\n gps = {},\n headerFields = {},\n score = {},\n title = 'Unknown',\n } = entity\n\n const timezone = entity?.timezone || data?.timezone || 'UTC'\n const entityDetails = getAuditEntryDetails(data)\n\n const {\n gpsText,\n groupedData,\n locationText,\n referenceValue,\n timezoneHourTime,\n scoreText,\n target,\n targetServiceLevel,\n } = entityDetails\n\n const renderTargetFields = !!targetServiceLevel\n const headerTitle = text(title, { style: 'title' })\n const headerScore = text(scoreText, { alignment: 'right', style: 'title' })\n const firstRow = [headerTitle, headerScore]\n const subTitle = `${locationText ||\n gpsText} - ${timezoneHourTime} by ${referenceValue}`\n\n let headerSubTitle = text(subTitle, { colSpan: 2, style: 'subTitle' })\n let secondRow = [headerSubTitle]\n\n const reverseGeocoded = gps.reverseGeocoded\n const address = !isEmpty(reverseGeocoded)\n ? getFormattedAddress(reverseGeocoded)\n : ''\n const renderHeaderAddress = !isEmpty(reverseGeocoded)\n const dummyColumn = text(' ', { style: 'small' })\n\n let headerAddress = text(address, { colSpan: 2, style: 'small' })\n const renderThirdRow = renderHeaderAddress || renderTargetFields\n let thirdRow = renderHeaderAddress ? [headerAddress] : []\n\n if (renderTargetFields) {\n headerSubTitle = text(subTitle, { style: 'subTitle' })\n\n const serviceLevelBelow = targetServiceLevel === 'below'\n const serviceLevelText =\n targetServiceLevel === 'above'\n ? 'Above Target'\n : targetServiceLevel === 'on'\n ? 'On Target'\n : targetServiceLevel === 'below'\n ? 'Below Target'\n : ''\n\n const scoreServiceLevelSubTitle = text(serviceLevelText, {\n alignment: 'right',\n style: serviceLevelBelow ? 'serviceLevelBelow' : 'serviceLevelAboveOrOn',\n })\n\n secondRow = [headerSubTitle, scoreServiceLevelSubTitle]\n headerAddress = text(address, { style: 'small' })\n\n const truncatedTargetPercent = round(target, 2)\n const scoreTargetText = `(Target - ${truncatedTargetPercent}%)`\n const scoreTargetSubTitle = text(scoreTargetText, {\n alignment: 'right',\n style: 'subTitle',\n })\n\n thirdRow = renderHeaderAddress\n ? [headerAddress, scoreTargetSubTitle]\n : [dummyColumn, scoreTargetSubTitle]\n }\n\n const scoreBreakdown = text(\n `${round(score.actual, 2)} / ${round(score.max, 2)}`,\n {\n alignment: 'right',\n style: 'totalScore',\n }\n )\n const scorePercentage = text(scoreText, {\n alignment: 'right',\n colSpan: 2,\n style: 'totalAuditScore',\n })\n const scoreTitle = text('Total Score', { style: 'totalScore' })\n\n const body = renderThirdRow\n ? [firstRow, secondRow, thirdRow]\n : [firstRow, secondRow]\n\n const startedAtInTimezone = entity.startedAt\n ? moment(entity.startedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const startedAt = text(`Started: ${startedAtInTimezone}`, {\n colSpan: 2,\n style: 'small',\n })\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n colSpan: 2,\n style: 'small',\n })\n\n const momentDuration = moment.duration(Math.abs(entity.formDuration))\n const days = Math.floor(momentDuration.asDays())\n .toString()\n .padStart(2, '0')\n const hours = Math.floor(momentDuration.hours())\n .toString()\n .padStart(2, '0')\n const minutes = momentDuration\n .minutes()\n .toString()\n .padStart(2, '0')\n const seconds = momentDuration\n .seconds()\n .toString()\n .padStart(2, '0')\n const formattedFormDuration = entity.formDuration\n ? `${\n entity.formDuration < 0 ? '-' : ''\n }${days}:${hours}:${minutes}:${seconds}`\n : 'Not recorded'\n const formDuration = text(\n `Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`,\n {\n colSpan: 2,\n style: 'small',\n }\n )\n\n body.push([startedAt, dummyColumn])\n body.push([submittedAt, dummyColumn])\n body.push([formDuration, dummyColumn])\n\n const titleTable = twoColumnTable({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n widths: ['*', 100],\n margin: [0, 0, 0, 30],\n })\n\n const totalScoreTable = twoColumnTable({\n body: [[scoreTitle, scoreBreakdown], [scorePercentage]],\n layout: 'noBorders',\n widths: ['*', 100],\n })\n\n const hLineTop = horizontalLine({ margin: [0, 10, 0, 0] })\n const hLineBottom = horizontalLine()\n\n const followUpItems = buildAuditFollowUps(followUps, { timezone })\n\n const promises = {\n entry: buildAuditContent(groupedData.items),\n footerTemplate: buildTemplateContent(footerFields.formGroups, data),\n headerTemplate: buildTemplateContent(headerFields.formGroups, data),\n }\n\n const auditItemsTitle = [\n {\n text: 'Audit Items',\n style: {\n font: 'Gotham',\n lineHeight: 1.1,\n },\n },\n hLineTop,\n ]\n\n return Promise.props(promises)\n .then(({ entry, footerTemplate, headerTemplate }) => [\n titleTable,\n followUpItems,\n ...auditItemsTitle,\n ...headerTemplate,\n ...entry,\n hLineTop,\n totalScoreTable,\n hLineBottom,\n ...footerTemplate,\n ])\n .catch(err => {\n throw new Error(`GenerateContentError: ${err.message}`)\n })\n}\n"],"mappings":";;;;AAAA,OAAOA,OAAO,MAAM,UAAU;AAC9B,SAASC,OAAO,EAAEC,KAAK,QAAQ,QAAQ;AACvC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SACEC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,EACpBC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,IAAI,EACJC,cAAc,QACT,YAAY;AACnB,SAASC,oBAAoB,QAAQ,eAAe;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,UAAU,EAAEC,IAAI,EAAE;EAC9C,IAAQC,MAAM,GAAeD,IAAI,CAAzBC,MAAM;IAAEC,QAAQ,GAAKF,IAAI,CAAjBE,QAAQ;EACxB,IAAAC,iBAAA,GAAuBJ,UAAU,CAAzBK,KAAK;IAALA,KAAK,GAAAD,iBAAA,cAAG,CAAC,CAAC,GAAAA,iBAAA;EAElB,IAA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EtG,IAAI,CAAC;IACnEuG,cAAc,EAAEhH,oBAAoB,CAACoC,YAAY,CAAC2E,UAAU,EAAEtG,IAAI;EACpE,CAAC;EAED,IAAMwG,eAAe,GAAG,CACtB;IACE7G,IAAI,EAAE,aAAa;IACnB+C,KAAK,EAAE;MACL+D,IAAI,EAAE,QAAQ;MACdC,UAAU,EAAE;IACd;EACF,CAAC,EACDX,QAAQ,CACT;EAED,OAAO9G,OAAO,CAAC0H,KAAK,CAACT,QAAQ,CAAC,CAC3BtF,IAAI,CAAC,UAAAgG,IAAA;IAAA,IAAGT,KAAK,GAAAS,IAAA,CAALT,KAAK;MAAEE,cAAc,GAAAO,IAAA,CAAdP,cAAc;MAAEE,cAAc,GAAAK,IAAA,CAAdL,cAAc;IAAA,QAC5Cb,UAAU,EACVO,aAAa,EAAAvF,MAAA,CACV8F,eAAe,EAAAK,kBAAA,CACfN,cAAc,GAAAM,kBAAA,CACdV,KAAK,IACRJ,QAAQ,EACRD,eAAe,EACfE,WAAW,GAAAa,kBAAA,CACRR,cAAc;EAAA,CAClB,CAAC,CACDrF,KAAK,CAAC,UAAAC,GAAG,EAAI;IACZ,MAAM,IAAIC,KAAK,0BAAAR,MAAA,CAA0BO,GAAG,CAACE,OAAO,CAAE,CAAC;EACzD,CAAC,CAAC;AACN","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Promise","isEmpty","round","moment","buildAuditContent","buildAuditFollowUps","buildTemplateContent","generateDefinition","getFormattedAddress","horizontalLine","text","twoColumnTable","getAuditEntryDetails","buildAuditPdf","pdfOptions","data","entity","timezone","_pdfOptions$flags","flags","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","catch","err","Error","message","_entity$followUps","followUps","_entity$footerFields","footerFields","_entity$gps","gps","_entity$headerFields","headerFields","_entity$score","score","_entity$title","entityDetails","gpsText","groupedData","locationText","referenceValue","timezoneHourTime","scoreText","target","targetServiceLevel","renderTargetFields","headerTitle","style","headerScore","alignment","firstRow","subTitle","headerSubTitle","colSpan","secondRow","reverseGeocoded","address","renderHeaderAddress","dummyColumn","headerAddress","renderThirdRow","thirdRow","serviceLevelBelow","serviceLevelText","scoreServiceLevelSubTitle","truncatedTargetPercent","scoreTargetText","scoreTargetSubTitle","scoreBreakdown","actual","max","scorePercentage","scoreTitle","body","submittedAtInTimezone","submittedAt","tz","format","showSimplifiedDuration","push","startedAtInTimezone","startedAt","momentDuration","duration","Math","abs","formDuration","days","floor","asDays","toString","padStart","hours","minutes","seconds","formattedFormDuration","titleTable","layout","widths","margin","totalScoreTable","hLineTop","hLineBottom","followUpItems","promises","entry","items","footerTemplate","formGroups","headerTemplate","auditItemsTitle","font","lineHeight","props","_ref","_toConsumableArray"],"sources":["../../../src/pdf/audit/index.js"],"sourcesContent":["import Promise from 'bluebird'\nimport { isEmpty, round } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n buildAuditContent,\n buildAuditFollowUps,\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n horizontalLine,\n text,\n twoColumnTable,\n} from '../helpers'\nimport { getAuditEntryDetails } from '../../helpers'\n\n/**\n * buildAuditPdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} pdfOptions.flags - flags to conditionally render parts of the pdf\n * @param {object} data - pdf data\n * @param {object} data.entity - audit document\n * @param {object} data.locations - locations documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildAuditPdf(pdfOptions, data) {\n const { entity, timezone } = data\n const { flags = {} } = pdfOptions\n\n const sequenceId = entity.sequenceId\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n const fileTitle = `Audit Report - ${title}`\n\n return generateContent(data, flags)\n .then(content =>\n generateDefinition({\n content,\n fileTitle,\n sequenceId,\n timestamp,\n timezone,\n type: 'Audit',\n ...pdfOptions,\n })\n )\n .catch(err => {\n throw new Error(`BuildAuditPdfError: ${err.message}`)\n })\n}\n\nfunction generateContent(data) {\n const { entity } = data\n\n const {\n followUps = [],\n footerFields = {},\n gps = {},\n headerFields = {},\n score = {},\n title = 'Unknown',\n } = entity\n\n const timezone = entity?.timezone || data?.timezone || 'UTC'\n const entityDetails = getAuditEntryDetails(data)\n\n const {\n gpsText,\n groupedData,\n locationText,\n referenceValue,\n timezoneHourTime,\n scoreText,\n target,\n targetServiceLevel,\n } = entityDetails\n\n const renderTargetFields = !!targetServiceLevel\n const headerTitle = text(title, { style: 'title' })\n const headerScore = text(scoreText, { alignment: 'right', style: 'title' })\n const firstRow = [headerTitle, headerScore]\n const subTitle = `${locationText ||\n gpsText} - ${timezoneHourTime} by ${referenceValue}`\n\n let headerSubTitle = text(subTitle, { colSpan: 2, style: 'subTitle' })\n let secondRow = [headerSubTitle]\n\n const reverseGeocoded = gps.reverseGeocoded\n const address = !isEmpty(reverseGeocoded)\n ? getFormattedAddress(reverseGeocoded)\n : ''\n const renderHeaderAddress = !isEmpty(reverseGeocoded)\n const dummyColumn = text(' ', { style: 'small' })\n\n let headerAddress = text(address, { colSpan: 2, style: 'small' })\n const renderThirdRow = renderHeaderAddress || renderTargetFields\n let thirdRow = renderHeaderAddress ? [headerAddress] : []\n\n if (renderTargetFields) {\n headerSubTitle = text(subTitle, { style: 'subTitle' })\n\n const serviceLevelBelow = targetServiceLevel === 'below'\n const serviceLevelText =\n targetServiceLevel === 'above'\n ? 'Above Target'\n : targetServiceLevel === 'on'\n ? 'On Target'\n : targetServiceLevel === 'below'\n ? 'Below Target'\n : ''\n\n const scoreServiceLevelSubTitle = text(serviceLevelText, {\n alignment: 'right',\n style: serviceLevelBelow ? 'serviceLevelBelow' : 'serviceLevelAboveOrOn',\n })\n\n secondRow = [headerSubTitle, scoreServiceLevelSubTitle]\n headerAddress = text(address, { style: 'small' })\n\n const truncatedTargetPercent = round(target, 2)\n const scoreTargetText = `(Target - ${truncatedTargetPercent}%)`\n const scoreTargetSubTitle = text(scoreTargetText, {\n alignment: 'right',\n style: 'subTitle',\n })\n\n thirdRow = renderHeaderAddress\n ? [headerAddress, scoreTargetSubTitle]\n : [dummyColumn, scoreTargetSubTitle]\n }\n\n const scoreBreakdown = text(\n `${round(score.actual, 2)} / ${round(score.max, 2)}`,\n {\n alignment: 'right',\n style: 'totalScore',\n }\n )\n const scorePercentage = text(scoreText, {\n alignment: 'right',\n colSpan: 2,\n style: 'totalAuditScore',\n })\n const scoreTitle = text('Total Score', { style: 'totalScore' })\n\n const body = renderThirdRow\n ? [firstRow, secondRow, thirdRow]\n : [firstRow, secondRow]\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n colSpan: 2,\n style: 'small',\n })\n\n if (entity.showSimplifiedDuration) {\n body.push([submittedAt, dummyColumn])\n } else {\n const startedAtInTimezone = entity.startedAt\n ? moment(entity.startedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const startedAt = text(`Started: ${startedAtInTimezone}`, {\n colSpan: 2,\n style: 'small',\n })\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n colSpan: 2,\n style: 'small',\n })\n\n const momentDuration = moment.duration(Math.abs(entity.formDuration))\n const days = Math.floor(momentDuration.asDays())\n .toString()\n .padStart(2, '0')\n const hours = Math.floor(momentDuration.hours())\n .toString()\n .padStart(2, '0')\n const minutes = momentDuration\n .minutes()\n .toString()\n .padStart(2, '0')\n const seconds = momentDuration\n .seconds()\n .toString()\n .padStart(2, '0')\n const formattedFormDuration = entity.formDuration\n ? `${\n entity.formDuration < 0 ? '-' : ''\n }${days}:${hours}:${minutes}:${seconds}`\n : 'Not recorded'\n const formDuration = text(\n `Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`,\n {\n colSpan: 2,\n style: 'small',\n }\n )\n\n body.push([startedAt, dummyColumn])\n body.push([submittedAt, dummyColumn])\n body.push([formDuration, dummyColumn])\n }\n\n const titleTable = twoColumnTable({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n widths: ['*', 100],\n margin: [0, 0, 0, 30],\n })\n\n const totalScoreTable = twoColumnTable({\n body: [[scoreTitle, scoreBreakdown], [scorePercentage]],\n layout: 'noBorders',\n widths: ['*', 100],\n })\n\n const hLineTop = horizontalLine({ margin: [0, 10, 0, 0] })\n const hLineBottom = horizontalLine()\n\n const followUpItems = buildAuditFollowUps(followUps, { timezone })\n\n const promises = {\n entry: buildAuditContent(groupedData.items),\n footerTemplate: buildTemplateContent(footerFields.formGroups, data),\n headerTemplate: buildTemplateContent(headerFields.formGroups, data),\n }\n\n const auditItemsTitle = [\n {\n text: 'Audit Items',\n style: {\n font: 'Gotham',\n lineHeight: 1.1,\n },\n },\n hLineTop,\n ]\n\n return Promise.props(promises)\n .then(({ entry, footerTemplate, headerTemplate }) => [\n titleTable,\n followUpItems,\n ...auditItemsTitle,\n ...headerTemplate,\n ...entry,\n hLineTop,\n totalScoreTable,\n hLineBottom,\n ...footerTemplate,\n ])\n .catch(err => {\n throw new Error(`GenerateContentError: ${err.message}`)\n })\n}\n"],"mappings":";;;;AAAA,OAAOA,OAAO,MA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I,EAAE,aAAa;IACnB+C,KAAK,EAAE;MACLgE,IAAI,EAAE,QAAQ;MACdC,UAAU,EAAE;IACd;EACF,CAAC,EACDX,QAAQ,CACT;EAED,OAAO/G,OAAO,CAAC2H,KAAK,CAACT,QAAQ,CAAC,CAC3BvF,IAAI,CAAC,UAAAiG,IAAA;IAAA,IAAGT,KAAK,GAAAS,IAAA,CAALT,KAAK;MAAEE,cAAc,GAAAO,IAAA,CAAdP,cAAc;MAAEE,cAAc,GAAAK,IAAA,CAAdL,cAAc;IAAA,QAC5Cb,UAAU,EACVO,aAAa,EAAAxF,MAAA,CACV+F,eAAe,EAAAK,kBAAA,CACfN,cAAc,GAAAM,kBAAA,CACdV,KAAK,IACRJ,QAAQ,EACRD,eAAe,EACfE,WAAW,GAAAa,kBAAA,CACRR,cAAc;EAAA,CAClB,CAAC,CACDtF,KAAK,CAAC,UAAAC,GAAG,EAAI;IACZ,MAAM,IAAIC,KAAK,0BAAAR,MAAA,CAA0BO,GAAG,CAACE,OAAO,CAAE,CAAC;EACzD,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -30,7 +30,8 @@ function buildImage(options) {
|
|
|
30
30
|
width = _options$width === void 0 ? 210 : _options$width;
|
|
31
31
|
var awsS3BaseUrl = settings.awsS3BaseUrl,
|
|
32
32
|
cloudinaryBaseUrl = settings.cloudinaryBaseUrl,
|
|
33
|
-
cloudfrontBaseUrl = settings.cloudfrontBaseUrl
|
|
33
|
+
cloudfrontBaseUrl = settings.cloudfrontBaseUrl,
|
|
34
|
+
shouldUseCloudfront = settings.shouldUseCloudfront;
|
|
34
35
|
var isVideoType = new RegExp('.mp4$').test(filepath);
|
|
35
36
|
var link = "".concat(awsS3BaseUrl, "/").concat(filepath);
|
|
36
37
|
if (isVideoType) {
|
|
@@ -48,7 +49,8 @@ function buildImage(options) {
|
|
|
48
49
|
fit: true,
|
|
49
50
|
height: 400,
|
|
50
51
|
width: 600,
|
|
51
|
-
quality: 50
|
|
52
|
+
quality: 50,
|
|
53
|
+
shouldUseCloudfront: shouldUseCloudfront
|
|
52
54
|
});
|
|
53
55
|
|
|
54
56
|
// NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context
|
|
@@ -206,10 +208,8 @@ export function buildTemplateFieldRow(_ref3) {
|
|
|
206
208
|
var isTextField = fieldtype === 'text';
|
|
207
209
|
var is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a';
|
|
208
210
|
var is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm';
|
|
209
|
-
var isDisplayImageField = fieldtype === 'image-display' && showOnRead;
|
|
210
|
-
var isEmptyArray = fieldtype === 'image-display' && isArray(value) && value.length === 0;
|
|
211
|
+
var isDisplayImageField = fieldtype === 'image-display' && showOnRead && !(isArray(value) && value.length === 0);
|
|
211
212
|
var isReferenceField = fieldtype === 'reference';
|
|
212
|
-
|
|
213
213
|
// NOTE: only show field when show on read is true
|
|
214
214
|
if (!showOnRead) return null;
|
|
215
215
|
var labelText = [{
|
|
@@ -236,7 +236,7 @@ export function buildTemplateFieldRow(_ref3) {
|
|
|
236
236
|
return [labelText, values];
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
if (isDisplayImageField
|
|
239
|
+
if (isDisplayImageField) {
|
|
240
240
|
return Promise.map([value], function (filepath) {
|
|
241
241
|
return buildImage({
|
|
242
242
|
filepath: filepath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isArray","isEmpty","join","first","map","startsWith","Promise","moment","buildFetchUrl","fetchImage","videoIcon","imageTables","parseValue","text","toPdf","buildFile","_ref","file","settings","extension","name","path","awsS3BaseUrl","link","concat","margin","buildImage","options","_options$alignment","alignment","filepath","_options$height","height","_options$settings","_options$width","width","cloudinaryBaseUrl","cloudfrontBaseUrl","isVideoType","RegExp","test","fit","image","url","quality","then","base64String","buildSummaryField","_ref2","field","timezone","fieldtype","_field$options","value","isDayFirstDateField","format","isMonthFirstDateField","isFileField","isHtmlField","type","isNumberField","isPhotoField","isReferenceField","isSelectField","isSignatureField","isStarField","isSwitchField","isTextField","is12HourTimeField","is24HourTimeField","isDataImage","fileList","ol","parsedValue","displayValue","fontSize","filter","val","label","tz","buildTemplateFieldRow","_ref3","skipped","_field$options2","_options$showOnRead","showOnRead","isDisplayImageField","isEmptyArray","length","labelText","parsed","replace","values","fieldImages","tables","imagesRow","colSpan","layout","hLineWidth","paddingLeft","paddingRight","paddingTop","paddingBottom","vLineWidth","table","body","_toConsumableArray","widths","string"],"sources":["../../../../src/pdf/helpers/fields/index.js"],"sourcesContent":["import { isArray, isEmpty, join, first, map, startsWith } from 'lodash'\nimport Promise from 'bluebird'\nimport moment from 'moment-timezone'\n\nimport { buildFetchUrl, fetchImage } from '../../../helpers'\nimport { videoIcon } from '../../../images'\nimport { imageTables, parseValue, text, toPdf } from '../'\n\nexport function buildFile({ file, settings }) {\n const { extension, name, path } = file\n const { awsS3BaseUrl } = settings\n\n const link = `${awsS3BaseUrl}/${path}`\n return text(`${name}.${extension}`, { link, margin: [0, 0, 0, 10] })\n}\n\nfunction buildImage(options) {\n const {\n alignment = 'center',\n filepath,\n height = 210,\n settings = {},\n width = 210,\n } = options\n const { awsS3BaseUrl, cloudinaryBaseUrl, cloudfrontBaseUrl } = settings\n\n const isVideoType = new RegExp('.mp4$').test(filepath)\n const link = `${awsS3BaseUrl}/${filepath}`\n\n if (isVideoType) {\n return {\n alignment,\n fit: [width, height],\n image: videoIcon,\n link,\n }\n }\n\n const url = buildFetchUrl(filepath, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n fit: true,\n height: 400,\n width: 600,\n quality: 50,\n })\n\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(url, settings).then(base64String => ({\n alignment,\n fit: [width, height],\n image: base64String,\n link,\n }))\n}\n\nexport function buildSummaryField({ field, settings, timezone }) {\n const { fieldtype, options = {}, value } = field\n\n const isDayFirstDateField =\n fieldtype === 'date' && options.format === 'DD/MM/YY'\n const isMonthFirstDateField =\n fieldtype === 'date' && options.format === 'MM/DD/YY'\n const isFileField = fieldtype === 'file'\n const isHtmlField = fieldtype === 'text' && options.type === 'html'\n const isNumberField = fieldtype === 'number'\n const isPhotoField = fieldtype === 'list' && options.type === 'media'\n const isReferenceField = fieldtype === 'reference'\n const isSelectField = fieldtype === 'select' && options.type !== 'stars'\n const isSignatureField = fieldtype === 'text' && options.type === 'signature'\n const isStarField = fieldtype === 'select' && options.type === 'stars'\n const isSwitchField = fieldtype === 'switch'\n const isTextField = fieldtype === 'text'\n const is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a'\n const is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm'\n\n // NOTE: html field is not supported for the summary fields but adding\n // logic to catch this and return empty text for completeness\n if (isHtmlField) {\n return { text: '' }\n }\n\n if (isSignatureField) {\n if (!value) return ''\n\n if (isDataImage(value)) {\n return { alignment: 'left', image: value, width: 140 }\n }\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(value, settings).then(base64String => {\n return {\n alignment: 'left',\n image: base64String,\n width: 140,\n }\n })\n }\n\n if (isPhotoField) {\n const filepath = first(value)\n\n // NOTE: if no filepath return empty text as user has not uploaded an image\n // for this field\n if (!filepath) {\n return { text: '' }\n }\n\n const image = buildImage({\n alignment: 'left',\n filepath,\n height: 140,\n width: 140,\n settings,\n })\n\n return image\n }\n\n if (isFileField) {\n const fileList = map(value, file => buildFile({ file, settings }))\n return { ol: fileList }\n }\n\n if (isNumberField || isSelectField || isSwitchField || isTextField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? { text: join(parsedValue, ', '), fontSize: 7 }\n : { text: parsedValue, fontSize: 7 }\n\n return displayValue\n }\n\n if (isReferenceField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? {\n text: parsedValue\n .filter(val => val && val.label)\n .map(val => val.label)\n .join(', '),\n fontSize: 7,\n }\n : { text: parsedValue.label, fontSize: 7 }\n\n return displayValue\n }\n\n if (isStarField) {\n if (!value) return ''\n const displayValue = value === '1' ? `${value} star` : `${value} stars`\n return displayValue\n }\n\n if (\n isDayFirstDateField ||\n isMonthFirstDateField ||\n is12HourTimeField ||\n is24HourTimeField\n ) {\n const format = options.format\n const displayValue = moment(value)\n .tz(timezone)\n .format(format)\n\n return displayValue\n }\n\n // NOTE: return empty text fallback value when no match\n return { text: '' }\n}\n\nexport function buildTemplateFieldRow({ field, settings, timezone, skipped }) {\n const { fieldtype, label, options = {}, value } = field\n const { showOnRead = true } = options\n\n const isDayFirstDateField =\n fieldtype === 'date' && options.format === 'DD/MM/YY'\n const isMonthFirstDateField =\n fieldtype === 'date' && options.format === 'MM/DD/YY'\n const isFileField = fieldtype === 'file'\n const isHtmlField = fieldtype === 'text' && options.type === 'html'\n const isNumberField = fieldtype === 'number'\n const isPhotoField = fieldtype === 'list' && options.type === 'media'\n const isSelectField = fieldtype === 'select' && options.type !== 'stars'\n const isSignatureField = fieldtype === 'text' && options.type === 'signature'\n const isStarField = fieldtype === 'select' && options.type === 'stars'\n const isSwitchField = fieldtype === 'switch'\n const isTextField = fieldtype === 'text'\n const is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a'\n const is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm'\n const isDisplayImageField = fieldtype === 'image-display' && showOnRead\n const isEmptyArray =\n fieldtype === 'image-display' && isArray(value) && value.length === 0\n const isReferenceField = fieldtype === 'reference'\n\n // NOTE: only show field when show on read is true\n if (!showOnRead) return null\n\n const labelText = [{ text: label }]\n\n if (skipped) {\n return [labelText, [{ text: '-' }]]\n }\n\n if (isHtmlField) {\n const parsed = value.replace(/<p><\\/p>/g, '')\n return [labelText, toPdf(parsed)]\n }\n\n if (isSignatureField) {\n if (!value) return [labelText, '']\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(value, settings).then(base64String => {\n const values = {\n alignment: 'left',\n image: base64String,\n width: 140,\n }\n return [labelText, values]\n })\n }\n\n if (isDisplayImageField && !isEmptyArray) {\n return Promise.map([value], filepath =>\n buildImage({ filepath, settings })\n ).then(fieldImages => [fieldImages, {}])\n }\n\n if (isPhotoField) {\n return Promise.map(value, filepath =>\n buildImage({ filepath, settings })\n ).then(fieldImages => {\n const tables = !isEmpty(fieldImages) ? imageTables(fieldImages) : []\n\n const imagesRow = {\n colSpan: 2,\n layout: {\n hLineWidth: () => 0,\n paddingLeft: () => 0,\n paddingRight: () => 0,\n paddingTop: () => 0,\n paddingBottom: () => 0,\n vLineWidth: () => 0,\n },\n table: {\n body: [labelText, ...tables],\n widths: ['*'],\n },\n }\n\n // NOTE: pass empty value here as otherwise\n // we can accidentally hide content below\n // this row. Please see the following issue:\n // https://github.com/bpampuch/pdfmake/issues/1598\n return [imagesRow, {}]\n })\n }\n\n if (isFileField) {\n const fileList = map(value, file => buildFile({ file, settings }))\n return [labelText, { ol: fileList }]\n }\n\n if (isNumberField || isSelectField || isSwitchField || isTextField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? { text: join(parsedValue, ', ') }\n : { text: parsedValue }\n\n return [labelText, displayValue]\n }\n\n if (isReferenceField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? {\n text: parsedValue\n .filter(val => val && val.label)\n .map(val => val.label)\n .join(', '),\n fontSize: 7,\n }\n : { text: parsedValue.label, fontSize: 7 }\n\n return [labelText, displayValue]\n }\n\n if (isStarField) {\n if (!value) return [labelText, '']\n const displayValue = value === '1' ? `${value} star` : `${value} stars`\n return [labelText, displayValue]\n }\n\n if (\n isDayFirstDateField ||\n isMonthFirstDateField ||\n is12HourTimeField ||\n is24HourTimeField\n ) {\n const format = options.format\n const displayValue = value\n ? moment(value)\n .tz(timezone)\n .format(format)\n : ''\n\n return [labelText, displayValue]\n }\n\n // NOTE: if no match above null values will be stripped within calling fn\n return null\n}\n\nfunction isData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5D,IAAI,EAAE4D,aAAW,CACdG,MAAM,CAAC,UAAAC,GAAG;QAAA,OAAIA,GAAG,IAAIA,GAAG,CAACC,KAAK;MAAA,EAAC,CAC/B1E,GAAG,CAAC,UAAAyE,GAAG;QAAA,OAAIA,GAAG,CAACC,KAAK;MAAA,EAAC,CACrB5E,IAAI,CAAC,IAAI,CAAC;MACbyE,QAAQ,EAAE;IACZ,CAAC,GACD;MAAE9D,IAAI,EAAE4D,aAAW,CAACK,KAAK;MAAEH,QAAQ,EAAE;IAAE,CAAC;IAE5C,OAAO,CAACc,SAAS,EAAEf,cAAY,CAAC;EAClC;EAEA,IAAIT,WAAW,EAAE;IACf,IAAI,CAACZ,KAAK,EAAE,OAAO,CAACoC,SAAS,EAAE,EAAE,CAAC;IAClC,IAAMf,cAAY,GAAGrB,KAAK,KAAK,GAAG,MAAA7B,MAAA,CAAM6B,KAAK,gBAAA7B,MAAA,CAAa6B,KAAK,WAAQ;IACvE,OAAO,CAACoC,SAAS,EAAEf,cAAY,CAAC;EAClC;EAEA,IACEpB,mBAAmB,IACnBE,qBAAqB,IACrBY,iBAAiB,IACjBC,iBAAiB,EACjB;IACA,IAAMd,MAAM,GAAG5B,OAAO,CAAC4B,MAAM;IAC7B,IAAMmB,cAAY,GAAGrB,KAAK,GACtB9C,MAAM,CAAC8C,KAAK,CAAC,CACV0B,EAAE,CAAC7B,QAAQ,CAAC,CACZK,MAAM,CAACA,MAAM,CAAC,GACjB,EAAE;IAEN,OAAO,CAACkC,SAAS,EAAEf,cAAY,CAAC;EAClC;;EAEA;EACA,OAAO,IAAI;AACb;AAEA,SAASJ,WAAWA,CAACsC,MAAM,EAAE;EAC3B,OAAOvG,UAAU,CAACuG,MAAM,EAAE,iBAAiB,CAAC;AAC9C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isArray","isEmpty","join","first","map","startsWith","Promise","moment","buildFetchUrl","fetchImage","videoIcon","imageTables","parseValue","text","toPdf","buildFile","_ref","file","settings","extension","name","path","awsS3BaseUrl","link","concat","margin","buildImage","options","_options$alignment","alignment","filepath","_options$height","height","_options$settings","_options$width","width","cloudinaryBaseUrl","cloudfrontBaseUrl","shouldUseCloudfront","isVideoType","RegExp","test","fit","image","url","quality","then","base64String","buildSummaryField","_ref2","field","timezone","fieldtype","_field$options","value","isDayFirstDateField","format","isMonthFirstDateField","isFileField","isHtmlField","type","isNumberField","isPhotoField","isReferenceField","isSelectField","isSignatureField","isStarField","isSwitchField","isTextField","is12HourTimeField","is24HourTimeField","isDataImage","fileList","ol","parsedValue","displayValue","fontSize","filter","val","label","tz","buildTemplateFieldRow","_ref3","skipped","_field$options2","_options$showOnRead","showOnRead","isDisplayImageField","length","labelText","parsed","replace","values","fieldImages","tables","imagesRow","colSpan","layout","hLineWidth","paddingLeft","paddingRight","paddingTop","paddingBottom","vLineWidth","table","body","_toConsumableArray","widths","string"],"sources":["../../../../src/pdf/helpers/fields/index.js"],"sourcesContent":["import { isArray, isEmpty, join, first, map, startsWith } from 'lodash'\nimport Promise from 'bluebird'\nimport moment from 'moment-timezone'\n\nimport { buildFetchUrl, fetchImage } from '../../../helpers'\nimport { videoIcon } from '../../../images'\nimport { imageTables, parseValue, text, toPdf } from '../'\n\nexport function buildFile({ file, settings }) {\n const { extension, name, path } = file\n const { awsS3BaseUrl } = settings\n\n const link = `${awsS3BaseUrl}/${path}`\n return text(`${name}.${extension}`, { link, margin: [0, 0, 0, 10] })\n}\n\nfunction buildImage(options) {\n const {\n alignment = 'center',\n filepath,\n height = 210,\n settings = {},\n width = 210,\n } = options\n const {\n awsS3BaseUrl,\n cloudinaryBaseUrl,\n cloudfrontBaseUrl,\n shouldUseCloudfront,\n } = settings\n\n const isVideoType = new RegExp('.mp4$').test(filepath)\n const link = `${awsS3BaseUrl}/${filepath}`\n\n if (isVideoType) {\n return {\n alignment,\n fit: [width, height],\n image: videoIcon,\n link,\n }\n }\n\n const url = buildFetchUrl(filepath, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n fit: true,\n height: 400,\n width: 600,\n quality: 50,\n shouldUseCloudfront,\n })\n\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(url, settings).then(base64String => ({\n alignment,\n fit: [width, height],\n image: base64String,\n link,\n }))\n}\n\nexport function buildSummaryField({ field, settings, timezone }) {\n const { fieldtype, options = {}, value } = field\n\n const isDayFirstDateField =\n fieldtype === 'date' && options.format === 'DD/MM/YY'\n const isMonthFirstDateField =\n fieldtype === 'date' && options.format === 'MM/DD/YY'\n const isFileField = fieldtype === 'file'\n const isHtmlField = fieldtype === 'text' && options.type === 'html'\n const isNumberField = fieldtype === 'number'\n const isPhotoField = fieldtype === 'list' && options.type === 'media'\n const isReferenceField = fieldtype === 'reference'\n const isSelectField = fieldtype === 'select' && options.type !== 'stars'\n const isSignatureField = fieldtype === 'text' && options.type === 'signature'\n const isStarField = fieldtype === 'select' && options.type === 'stars'\n const isSwitchField = fieldtype === 'switch'\n const isTextField = fieldtype === 'text'\n const is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a'\n const is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm'\n\n // NOTE: html field is not supported for the summary fields but adding\n // logic to catch this and return empty text for completeness\n if (isHtmlField) {\n return { text: '' }\n }\n\n if (isSignatureField) {\n if (!value) return ''\n\n if (isDataImage(value)) {\n return { alignment: 'left', image: value, width: 140 }\n }\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(value, settings).then(base64String => {\n return {\n alignment: 'left',\n image: base64String,\n width: 140,\n }\n })\n }\n\n if (isPhotoField) {\n const filepath = first(value)\n\n // NOTE: if no filepath return empty text as user has not uploaded an image\n // for this field\n if (!filepath) {\n return { text: '' }\n }\n\n const image = buildImage({\n alignment: 'left',\n filepath,\n height: 140,\n width: 140,\n settings,\n })\n\n return image\n }\n\n if (isFileField) {\n const fileList = map(value, file => buildFile({ file, settings }))\n return { ol: fileList }\n }\n\n if (isNumberField || isSelectField || isSwitchField || isTextField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? { text: join(parsedValue, ', '), fontSize: 7 }\n : { text: parsedValue, fontSize: 7 }\n\n return displayValue\n }\n\n if (isReferenceField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? {\n text: parsedValue\n .filter(val => val && val.label)\n .map(val => val.label)\n .join(', '),\n fontSize: 7,\n }\n : { text: parsedValue.label, fontSize: 7 }\n\n return displayValue\n }\n\n if (isStarField) {\n if (!value) return ''\n const displayValue = value === '1' ? `${value} star` : `${value} stars`\n return displayValue\n }\n\n if (\n isDayFirstDateField ||\n isMonthFirstDateField ||\n is12HourTimeField ||\n is24HourTimeField\n ) {\n const format = options.format\n const displayValue = moment(value)\n .tz(timezone)\n .format(format)\n\n return displayValue\n }\n\n // NOTE: return empty text fallback value when no match\n return { text: '' }\n}\n\nexport function buildTemplateFieldRow({ field, settings, timezone, skipped }) {\n const { fieldtype, label, options = {}, value } = field\n const { showOnRead = true } = options\n\n const isDayFirstDateField =\n fieldtype === 'date' && options.format === 'DD/MM/YY'\n const isMonthFirstDateField =\n fieldtype === 'date' && options.format === 'MM/DD/YY'\n const isFileField = fieldtype === 'file'\n const isHtmlField = fieldtype === 'text' && options.type === 'html'\n const isNumberField = fieldtype === 'number'\n const isPhotoField = fieldtype === 'list' && options.type === 'media'\n const isSelectField = fieldtype === 'select' && options.type !== 'stars'\n const isSignatureField = fieldtype === 'text' && options.type === 'signature'\n const isStarField = fieldtype === 'select' && options.type === 'stars'\n const isSwitchField = fieldtype === 'switch'\n const isTextField = fieldtype === 'text'\n const is12HourTimeField = fieldtype === 'time' && options.format === 'h:mm a'\n const is24HourTimeField = fieldtype === 'time' && options.format === 'HH:mm'\n const isDisplayImageField =\n fieldtype === 'image-display' &&\n showOnRead &&\n !(isArray(value) && value.length === 0)\n const isReferenceField = fieldtype === 'reference'\n // NOTE: only show field when show on read is true\n if (!showOnRead) return null\n\n const labelText = [{ text: label }]\n\n if (skipped) {\n return [labelText, [{ text: '-' }]]\n }\n\n if (isHtmlField) {\n const parsed = value.replace(/<p><\\/p>/g, '')\n return [labelText, toPdf(parsed)]\n }\n\n if (isSignatureField) {\n if (!value) return [labelText, '']\n // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context\n return fetchImage(value, settings).then(base64String => {\n const values = {\n alignment: 'left',\n image: base64String,\n width: 140,\n }\n return [labelText, values]\n })\n }\n\n if (isDisplayImageField) {\n return Promise.map([value], filepath =>\n buildImage({ filepath, settings })\n ).then(fieldImages => [fieldImages, {}])\n }\n\n if (isPhotoField) {\n return Promise.map(value, filepath =>\n buildImage({ filepath, settings })\n ).then(fieldImages => {\n const tables = !isEmpty(fieldImages) ? imageTables(fieldImages) : []\n\n const imagesRow = {\n colSpan: 2,\n layout: {\n hLineWidth: () => 0,\n paddingLeft: () => 0,\n paddingRight: () => 0,\n paddingTop: () => 0,\n paddingBottom: () => 0,\n vLineWidth: () => 0,\n },\n table: {\n body: [labelText, ...tables],\n widths: ['*'],\n },\n }\n\n // NOTE: pass empty value here as otherwise\n // we can accidentally hide content below\n // this row. Please see the following issue:\n // https://github.com/bpampuch/pdfmake/issues/1598\n return [imagesRow, {}]\n })\n }\n\n if (isFileField) {\n const fileList = map(value, file => buildFile({ file, settings }))\n return [labelText, { ol: fileList }]\n }\n\n if (isNumberField || isSelectField || isSwitchField || isTextField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? { text: join(parsedValue, ', ') }\n : { text: parsedValue }\n\n return [labelText, displayValue]\n }\n\n if (isReferenceField) {\n const parsedValue = parseValue(value)\n const displayValue = isArray(parsedValue)\n ? {\n text: parsedValue\n .filter(val => val && val.label)\n .map(val => val.label)\n .join(', '),\n fontSize: 7,\n }\n : { text: parsedValue.label, fontSize: 7 }\n\n return [labelText, displayValue]\n }\n\n if (isStarField) {\n if (!value) return [labelText, '']\n const displayValue = value === '1' ? `${value} star` : `${value} stars`\n return [labelText, displayValue]\n }\n\n if (\n isDayFirstDateField ||\n isMonthFirstDateField ||\n is12HourTimeField ||\n is24HourTimeField\n ) {\n const format = options.format\n const displayValue = value\n ? moment(value)\n .tz(timezone)\n .format(format)\n : ''\n\n return [labelText, displayValue]\n }\n\n // NOTE: if no match above null values will be stripped within calling fn\n return null\n}\n\nfunction isDataImage(string) {\n return startsWith(string, 'data:image/png;')\n}\n"],"mappings":";AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,UAAU,QAAQ,QAAQ;AACvE,OAAOC,OAAO,MAAM,UAAU;AAC9B,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAASC,aAAa,EAAEC,UAAU,QAAQ,kBAAkB;AAC5D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,EAAEC,UAAU,EAAEC,IAAI,EAAEC,KAAK,QAAQ,KAAK;AAE1D,OAAO,SAASC,SAASA,CAAAC,IAAA,EAAqB;EAAA,IAAlBC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EACxC,IAAQC,SAAS,GAAiBF,IAAI,CAA9BE,SAAS;IAAEC,IAAI,GAAWH,IAAI,CAAnBG,IAAI;IAAEC,IAAI,GAAKJ,IAAI,CAAbI,IAAI;EAC7B,IAAQC,YAAY,GAAKJ,QAAQ,CAAzBI,YAAY;EAEpB,IAAMC,IAAI,MAAAC,MAAA,CAAMF,YAAY,OAAAE,MAAA,CAAIH,IAAI,CAAE;EACtC,OAAOR,IAAI,IAAAW,MAAA,CAAIJ,IAAI,OAAAI,MAAA,CAAIL,SAAS,GAAI;IAAEI,IAAI,EAAJA,IAAI;IAAEE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;EAAE,CAAC,CAAC;AACtE;AAEA,SAASC,UAAUA,CAACC,OAAO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C;;EAEA;EACA,OAAO,IAAI;AACb;AAEA,SAASJ,WAAWA,CAACqC,MAAM,EAAE;EAC3B,OAAOvG,UAAU,CAACuG,MAAM,EAAE,iBAAiB,CAAC;AAC9C","ignoreList":[]}
|
package/lib/pdf/issue/index.js
CHANGED
|
@@ -78,26 +78,30 @@ function generateContent(data) {
|
|
|
78
78
|
style: 'small'
|
|
79
79
|
});
|
|
80
80
|
var body = !isEmpty(reverseGeocoded) ? [[headerTitle], [headerSubTitle], [headerAddress]] : [[headerTitle], [headerSubTitle]];
|
|
81
|
-
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
82
|
-
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
83
|
-
style: 'small'
|
|
84
|
-
});
|
|
85
81
|
var submittedAtInTimezone = entity.submittedAt ? moment(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
86
82
|
var submittedAt = text("Submitted: ".concat(submittedAtInTimezone), {
|
|
87
83
|
style: 'small'
|
|
88
84
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
if (entity.showSimplifiedDuration) {
|
|
86
|
+
body.push([submittedAt]);
|
|
87
|
+
} else {
|
|
88
|
+
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
89
|
+
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
90
|
+
style: 'small'
|
|
91
|
+
});
|
|
92
|
+
var momentDuration = moment.duration(Math.abs(entity.formDuration));
|
|
93
|
+
var days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
94
|
+
var hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
95
|
+
var minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
96
|
+
var seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
97
|
+
var formattedFormDuration = entity.formDuration ? "".concat(entity.formDuration < 0 ? '-' : '').concat(days, ":").concat(hours, ":").concat(minutes, ":").concat(seconds) : 'Not recorded';
|
|
98
|
+
var formDuration = text("Form Duration (DD:HH:MM:SS): ".concat(formattedFormDuration), {
|
|
99
|
+
style: 'small'
|
|
100
|
+
});
|
|
101
|
+
body.push([startedAt]);
|
|
102
|
+
body.push([submittedAt]);
|
|
103
|
+
body.push([formDuration]);
|
|
104
|
+
}
|
|
101
105
|
var titleTable = table({
|
|
102
106
|
body: body,
|
|
103
107
|
layout: 'noBorders',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["get","filter","isEmpty","map","moment","buildTemplateContent","generateDefinition","getFormattedAddress","horizontalLine","table","text","threeColumnTable","getIssueDetails","getStatusDetails","getTimezoneAbbr","getTimezoneDatetime","buildIssuePdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","entry","_entity$gps","gps","_entity$timeline","timeline","entityDetails","assigneeNames","durationText","gpsText","locationText","statusColor","statusText","reverseGeocoded","subTitle","headerTitle","style","headerSubTitle","address","headerAddress","body","startedAtInTimezone","startedAt","tz","format","submittedAtInTimezone","submittedAt","momentDuration","duration","Math","abs","formDuration","days","floor","asDays","toString","padStart","hours","minutes","seconds","formattedFormDuration","push","titleTable","layout","statusLabelText","bold","statusValueText","color","metaTable","durationLabelText","durationValueText","assigneeLabelText","assigneeValueText","timelineTitle","timelineHorizontalLine","timelineTable","createTimelineTable","formGroups","_toConsumableArray","timezoneAbbr","timelineHeaderRow","alignment","statusUpdates","timelineBodyRows","colSpan","item","_item$meta","meta","source","next","firstName","lastName","fullName","isNew","isUpdate","isOpen","statusDetails","nextStatusText","activity","datetime","showTzAbbr"],"sources":["../../../src/pdf/issue/index.js"],"sourcesContent":["import { get, filter, isEmpty, map } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n horizontalLine,\n table,\n text,\n threeColumnTable,\n} from '../helpers'\n\nimport {\n getIssueDetails,\n getStatusDetails,\n getTimezoneAbbr,\n getTimezoneDatetime,\n} from '../../helpers'\n\n/**\n * buildIssuePdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} data - pdf data\n * @param {object} data.entity - issue document\n * @param {object} data.locations - locations documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @param {object} data.zones - zone documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildIssuePdf(pdfOptions, data) {\n const { entity, timezone } = data\n\n const sequenceId = entity.sequenceId\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n\n const fileTitle = `Issue Report - ${title}`\n\n return generateContent(data).then(content =>\n generateDefinition({\n content,\n fileTitle,\n sequenceId,\n timestamp,\n timezone,\n type: 'Issue',\n ...pdfOptions,\n })\n )\n}\n\nfunction generateContent(data) {\n const { entity, timezone } = data\n const { entry, gps = {}, timeline = [], title } = entity\n\n const entityDetails = getIssueDetails(data)\n\n const {\n assigneeNames,\n durationText,\n gpsText,\n locationText,\n statusColor,\n statusText,\n } = entityDetails\n\n const reverseGeocoded = gps.reverseGeocoded\n\n const subTitle = `${locationText || gpsText}`\n const headerTitle = text(title, { style: 'title' })\n const headerSubTitle = text(subTitle, { style: 'subTitle' })\n const address = !isEmpty(reverseGeocoded)\n ? getFormattedAddress(reverseGeocoded)\n : ''\n const headerAddress = text(address, { style: 'small' })\n\n const body = !isEmpty(reverseGeocoded)\n ? [[headerTitle], [headerSubTitle], [headerAddress]]\n : [[headerTitle], [headerSubTitle]]\n\n const startedAtInTimezone = entity.startedAt\n ? moment(entity.startedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const startedAt = text(`Started: ${startedAtInTimezone}`, {\n style: 'small',\n })\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n style: 'small',\n })\n\n const momentDuration = moment.duration(Math.abs(entity.formDuration))\n const days = Math.floor(momentDuration.asDays())\n .toString()\n .padStart(2, '0')\n const hours = Math.floor(momentDuration.hours())\n .toString()\n .padStart(2, '0')\n const minutes = momentDuration\n .minutes()\n .toString()\n .padStart(2, '0')\n const seconds = momentDuration\n .seconds()\n .toString()\n .padStart(2, '0')\n const formattedFormDuration = entity.formDuration\n ? `${\n entity.formDuration < 0 ? '-' : ''\n }${days}:${hours}:${minutes}:${seconds}`\n : 'Not recorded'\n const formDuration = text(\n `Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`,\n {\n style: 'small',\n }\n )\n\n body.push([startedAt])\n body.push([submittedAt])\n body.push([formDuration])\n\n const titleTable = table({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n })\n\n const statusLabelText = text('Status', { bold: true })\n const statusValueText = text(statusText, { color: statusColor })\n\n const metaTable = table({\n body: [[statusLabelText, statusValueText]],\n layout: 'noBorders',\n style: 'metaTable',\n })\n\n if (statusText === 'CLOSED') {\n const durationLabelText = text('Duration', { bold: true })\n const durationValueText = text(durationText)\n metaTable.table.body.push([durationLabelText, durationValueText])\n }\n\n const assigneeLabelText = text('Assignees', { bold: true })\n const assigneeValueText = text(assigneeNames)\n metaTable.table.body.push([assigneeLabelText, assigneeValueText])\n\n const timelineTitle = text('Timeline', { style: 'timelineTitle' })\n const timelineHorizontalLine = horizontalLine()\n const timelineTable = createTimelineTable(timeline, timezone)\n\n return buildTemplateContent(entry.formGroups, data).then(entry => [\n titleTable,\n metaTable,\n timelineTitle,\n timelineHorizontalLine,\n timelineTable,\n ...entry,\n ])\n}\n\nfunction createTimelineTable(timeline, timezone) {\n const timezoneAbbr = getTimezoneAbbr(timezone)\n\n const timelineHeaderRow = [\n text('Activity', { bold: true }),\n text('User', { bold: true }),\n text(`Date & Timestamp (${timezoneAbbr})`, {\n alignment: 'right',\n bold: true,\n }),\n ]\n\n const statusUpdates = filter(timeline, ['meta.field', 'status'])\n\n const timelineBodyRows = isEmpty(statusUpdates)\n ? [text('No Timeline activity', { colSpan: 3 })]\n : map(statusUpdates, item => {\n const { meta = {}, source, timestamp, type } = item\n\n const next = get(meta, 'next')\n const firstName = get(source, 'meta.firstName')\n const lastName = get(source, 'meta.lastName')\n\n const fullName =\n firstName && lastName ? `${firstName} ${lastName}` : 'Unknown User'\n\n const isNew = type === 'issue-new'\n const isUpdate = type === 'issue-update'\n const isOpen = next === 'open'\n\n const statusDetails = getStatusDetails(next)\n const nextStatusText = statusDetails.text\n\n const activity =\n isNew && isOpen\n ? 'Issue opened'\n : isNew && !isOpen\n ? `Issue opened with status ${nextStatusText}`\n : isUpdate\n ? `Issue updated to ${nextStatusText}`\n : 'Unknown status timeline change'\n\n const datetime = getTimezoneDatetime({\n format: 'ddd, MMM D h:mm:ssa z',\n showTzAbbr: false,\n timestamp,\n timezone,\n })\n\n return [\n text(activity),\n text(fullName),\n text(datetime, { alignment: 'right' }),\n ]\n })\n\n const timelineTable = threeColumnTable({\n body: [timelineHeaderRow, ...timelineBodyRows],\n })\n\n return tim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,IAC1CH,QAAQ,uBAAA/E,MAAA,CACYkF,cAAc,IAClC,gCAAgC;IAEtC,IAAME,QAAQ,GAAG/F,mBAAmB,CAAC;MACnCwC,MAAM,EAAE,uBAAuB;MAC/BwD,UAAU,EAAE,KAAK;MACjBzF,SAAS,EAATA,SAAS;MACTF,QAAQ,EAARA;IACF,CAAC,CAAC;IAEF,OAAO,CACLV,IAAI,CAACmG,QAAQ,CAAC,EACdnG,IAAI,CAAC6F,QAAQ,CAAC,EACd7F,IAAI,CAACoG,QAAQ,EAAE;MAAElB,SAAS,EAAE;IAAQ,CAAC,CAAC,CACvC;EACH,CAAC,CAAC;EAEN,IAAMN,aAAa,GAAG3E,gBAAgB,CAAC;IACrCwC,IAAI,GAAGwC,iBAAiB,EAAAjE,MAAA,CAAA+D,kBAAA,CAAKK,gBAAgB;EAC/C,CAAC,CAAC;EAEF,OAAOR,aAAa;AACtB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["get","filter","isEmpty","map","moment","buildTemplateContent","generateDefinition","getFormattedAddress","horizontalLine","table","text","threeColumnTable","getIssueDetails","getStatusDetails","getTimezoneAbbr","getTimezoneDatetime","buildIssuePdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","entry","_entity$gps","gps","_entity$timeline","timeline","entityDetails","assigneeNames","durationText","gpsText","locationText","statusColor","statusText","reverseGeocoded","subTitle","headerTitle","style","headerSubTitle","address","headerAddress","body","submittedAtInTimezone","submittedAt","tz","format","showSimplifiedDuration","push","startedAtInTimezone","startedAt","momentDuration","duration","Math","abs","formDuration","days","floor","asDays","toString","padStart","hours","minutes","seconds","formattedFormDuration","titleTable","layout","statusLabelText","bold","statusValueText","color","metaTable","durationLabelText","durationValueText","assigneeLabelText","assigneeValueText","timelineTitle","timelineHorizontalLine","timelineTable","createTimelineTable","formGroups","_toConsumableArray","timezoneAbbr","timelineHeaderRow","alignment","statusUpdates","timelineBodyRows","colSpan","item","_item$meta","meta","source","next","firstName","lastName","fullName","isNew","isUpdate","isOpen","statusDetails","nextStatusText","activity","datetime","showTzAbbr"],"sources":["../../../src/pdf/issue/index.js"],"sourcesContent":["import { get, filter, isEmpty, map } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n horizontalLine,\n table,\n text,\n threeColumnTable,\n} from '../helpers'\n\nimport {\n getIssueDetails,\n getStatusDetails,\n getTimezoneAbbr,\n getTimezoneDatetime,\n} from '../../helpers'\n\n/**\n * buildIssuePdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} data - pdf data\n * @param {object} data.entity - issue document\n * @param {object} data.locations - locations documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @param {object} data.zones - zone documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildIssuePdf(pdfOptions, data) {\n const { entity, timezone } = data\n\n const sequenceId = entity.sequenceId\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n\n const fileTitle = `Issue Report - ${title}`\n\n return generateContent(data).then(content =>\n generateDefinition({\n content,\n fileTitle,\n sequenceId,\n timestamp,\n timezone,\n type: 'Issue',\n ...pdfOptions,\n })\n )\n}\n\nfunction generateContent(data) {\n const { entity, timezone } = data\n const { entry, gps = {}, timeline = [], title } = entity\n\n const entityDetails = getIssueDetails(data)\n\n const {\n assigneeNames,\n durationText,\n gpsText,\n locationText,\n statusColor,\n statusText,\n } = entityDetails\n\n const reverseGeocoded = gps.reverseGeocoded\n\n const subTitle = `${locationText || gpsText}`\n const headerTitle = text(title, { style: 'title' })\n const headerSubTitle = text(subTitle, { style: 'subTitle' })\n const address = !isEmpty(reverseGeocoded)\n ? getFormattedAddress(reverseGeocoded)\n : ''\n const headerAddress = text(address, { style: 'small' })\n\n const body = !isEmpty(reverseGeocoded)\n ? [[headerTitle], [headerSubTitle], [headerAddress]]\n : [[headerTitle], [headerSubTitle]]\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n style: 'small',\n })\n\n if (entity.showSimplifiedDuration) {\n body.push([submittedAt])\n } else {\n const startedAtInTimezone = entity.startedAt\n ? moment(entity.startedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const startedAt = text(`Started: ${startedAtInTimezone}`, {\n style: 'small',\n })\n\n const momentDuration = moment.duration(Math.abs(entity.formDuration))\n const days = Math.floor(momentDuration.asDays())\n .toString()\n .padStart(2, '0')\n const hours = Math.floor(momentDuration.hours())\n .toString()\n .padStart(2, '0')\n const minutes = momentDuration\n .minutes()\n .toString()\n .padStart(2, '0')\n const seconds = momentDuration\n .seconds()\n .toString()\n .padStart(2, '0')\n const formattedFormDuration = entity.formDuration\n ? `${\n entity.formDuration < 0 ? '-' : ''\n }${days}:${hours}:${minutes}:${seconds}`\n : 'Not recorded'\n const formDuration = text(\n `Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`,\n {\n style: 'small',\n }\n )\n\n body.push([startedAt])\n body.push([submittedAt])\n body.push([formDuration])\n }\n\n const titleTable = table({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n })\n\n const statusLabelText = text('Status', { bold: true })\n const statusValueText = text(statusText, { color: statusColor })\n\n const metaTable = table({\n body: [[statusLabelText, statusValueText]],\n layout: 'noBorders',\n style: 'metaTable',\n })\n\n if (statusText === 'CLOSED') {\n const durationLabelText = text('Duration', { bold: true })\n const durationValueText = text(durationText)\n metaTable.table.body.push([durationLabelText, durationValueText])\n }\n\n const assigneeLabelText = text('Assignees', { bold: true })\n const assigneeValueText = text(assigneeNames)\n metaTable.table.body.push([assigneeLabelText, assigneeValueText])\n\n const timelineTitle = text('Timeline', { style: 'timelineTitle' })\n const timelineHorizontalLine = horizontalLine()\n const timelineTable = createTimelineTable(timeline, timezone)\n\n return buildTemplateContent(entry.formGroups, data).then(entry => [\n titleTable,\n metaTable,\n timelineTitle,\n timelineHorizontalLine,\n timelineTable,\n ...entry,\n ])\n}\n\nfunction createTimelineTable(timeline, timezone) {\n const timezoneAbbr = getTimezoneAbbr(timezone)\n\n const timelineHeaderRow = [\n text('Activity', { bold: true }),\n text('User', { bold: true }),\n text(`Date & Timestamp (${timezoneAbbr})`, {\n alignment: 'right',\n bold: true,\n }),\n ]\n\n const statusUpdates = filter(timeline, ['meta.field', 'status'])\n\n const timelineBodyRows = isEmpty(statusUpdates)\n ? [text('No Timeline activity', { colSpan: 3 })]\n : map(statusUpdates, item => {\n const { meta = {}, source, timestamp, type } = item\n\n const next = get(meta, 'next')\n const firstName = get(source, 'meta.firstName')\n const lastName = get(source, 'meta.lastName')\n\n const fullName =\n firstName && lastName ? `${firstName} ${lastName}` : 'Unknown User'\n\n const isNew = type === 'issue-new'\n const isUpdate = type === 'issue-update'\n const isOpen = next === 'open'\n\n const statusDetails = getStatusDetails(next)\n const nextStatusText = statusDetails.text\n\n const activity =\n isNew && isOpen\n ? 'Issue opened'\n : isNew && !isOpen\n ? `Issue opened with status ${nextStatusText}`\n : isUpdate\n ? `Issue updated to ${nextStatusText}`\n : 'Unknown status timeline change'\n\n const datetime = getTimezoneDatetime({\n format: 'ddd, MMM D h:mm:ssa z',\n showTzAbbr: false,\n timestamp,\n timezone,\n })\n\n return [\n text(activity),\n text(fullName),\n text(datetime, { alignment: 'right' }),\n ]\n })\n\n const timelineTable = threeColumnTable({\n body: [timelineHeaderRow, ...timelineBodyRows],\n })\n\n return timelineTable\n}\n"],"mappings":";;;;AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,GAAG,QAAQ,QAAQ;AAClD,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,KAAK,EACLC,IAAI,EACJC,gBAAgB,QACX,YAAY;AAEnB,SACEC,eAAe,EACfC,gBAAgB,EAChBC,eAAe,EACfC,mBAAmB,QACd,eAAe;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,UAAU,EAAEC,IAAI,EAAE;EAC9C,IAAQC,MAAM,GAAeD,IAAI,CAAzBC,MAAM;IAAEC,QAAQ,GAAKF,IAAI,CAAjBE,QAAQ;EAExB,IAAMC,UAAU,GAAGF,MAAM,CAACE,UAAU;EACpC,IAAMC,SAAS,GAAGH,MAAM,CAACI,SAAS;EAClC,IAAMC,KAAK,GAAGL,MAAM,CAACK,KAAK,IAAI,SAAS;EAEvC,IAAMC,SAAS,qBAAAC,MAAA,CAAqBF,KAAK,CAAE;EAE3C,OAAOG,eAAe,CAACT,IAAI,CAAC,CAACU,IAAI,CAAC,UAAAC,OAAO;IAAA,OACvCvB,kBAAkB,CAAAwB,aAAA;MAChBD,OAAO,EAAPA,OAAO;MACPJ,SAAS,EAATA,SAAS;MACTJ,UAAU,EAAVA,UAAU;MACVC,SAAS,EAATA,SAAS;MACTF,QAAQ,EAARA,QAAQ;MACRW,IAAI,EAAE;IAAO,GACVd,UAAU,CACd,CAAC;EAAA,CACJ,CAAC;AACH;AAEA,SA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4E,MAAM,GAAGN,IAAI,KAAK,MAAM;IAE9B,IAAMO,aAAa,GAAG/F,gBAAgB,CAACwF,IAAI,CAAC;IAC5C,IAAMQ,cAAc,GAAGD,aAAa,CAAClG,IAAI;IAEzC,IAAMoG,QAAQ,GACZL,KAAK,IAAIE,MAAM,GACX,cAAc,GACdF,KAAK,IAAI,CAACE,MAAM,+BAAAjF,MAAA,CACYmF,cAAc,IAC1CH,QAAQ,uBAAAhF,MAAA,CACYmF,cAAc,IAClC,gCAAgC;IAEtC,IAAME,QAAQ,GAAGhG,mBAAmB,CAAC;MACnCwC,MAAM,EAAE,uBAAuB;MAC/ByD,UAAU,EAAE,KAAK;MACjB1F,SAAS,EAATA,SAAS;MACTF,QAAQ,EAARA;IACF,CAAC,CAAC;IAEF,OAAO,CACLV,IAAI,CAACoG,QAAQ,CAAC,EACdpG,IAAI,CAAC8F,QAAQ,CAAC,EACd9F,IAAI,CAACqG,QAAQ,EAAE;MAAElB,SAAS,EAAE;IAAQ,CAAC,CAAC,CACvC;EACH,CAAC,CAAC;EAEN,IAAMN,aAAa,GAAG5E,gBAAgB,CAAC;IACrCwC,IAAI,GAAGyC,iBAAiB,EAAAlE,MAAA,CAAAgE,kBAAA,CAAKK,gBAAgB;EAC/C,CAAC,CAAC;EAEF,OAAOR,aAAa;AACtB","ignoreList":[]}
|
package/lib/pdf/task/index.js
CHANGED
|
@@ -77,26 +77,30 @@ function generateContent(data) {
|
|
|
77
77
|
if (!isEmpty(reverseGeocoded)) {
|
|
78
78
|
body.push([headerAddress]);
|
|
79
79
|
}
|
|
80
|
-
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
81
|
-
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
82
|
-
style: 'small'
|
|
83
|
-
});
|
|
84
80
|
var submittedAtInTimezone = entity.submittedAt ? moment(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
85
81
|
var submittedAt = text("Submitted: ".concat(submittedAtInTimezone), {
|
|
86
82
|
style: 'small'
|
|
87
83
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
if (entity.showSimplifiedDuration) {
|
|
85
|
+
body.push([submittedAt]);
|
|
86
|
+
} else {
|
|
87
|
+
var startedAtInTimezone = entity.startedAt ? moment(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
88
|
+
var startedAt = text("Started: ".concat(startedAtInTimezone), {
|
|
89
|
+
style: 'small'
|
|
90
|
+
});
|
|
91
|
+
var momentDuration = moment.duration(Math.abs(entity.formDuration));
|
|
92
|
+
var days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
93
|
+
var hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
94
|
+
var minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
95
|
+
var seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
96
|
+
var formattedFormDuration = entity.formDuration ? "".concat(entity.formDuration < 0 ? '-' : '').concat(days, ":").concat(hours, ":").concat(minutes, ":").concat(seconds) : 'Not recorded';
|
|
97
|
+
var formDuration = text("Form Duration (DD:HH:MM:SS): ".concat(formattedFormDuration), {
|
|
98
|
+
style: 'small'
|
|
99
|
+
});
|
|
100
|
+
body.push([startedAt]);
|
|
101
|
+
body.push([submittedAt]);
|
|
102
|
+
body.push([formDuration]);
|
|
103
|
+
}
|
|
100
104
|
var titleTable = table({
|
|
101
105
|
body: body,
|
|
102
106
|
layout: 'noBorders',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isEmpty","moment","buildTemplateContent","generateDefinition","getFormattedAddress","text","table","getTaskEntryDetails","buildTaskPdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","entry","_entity$gps","gps","entityDetails","gpsText","locationText","referenceValue","timezoneHourTime","reverseGeocoded","subTitle","headerSubTitle","style","headerTitle","address","headerAddress","body","push","
|
|
1
|
+
{"version":3,"file":"index.js","names":["isEmpty","moment","buildTemplateContent","generateDefinition","getFormattedAddress","text","table","getTaskEntryDetails","buildTaskPdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","concat","generateContent","then","content","_objectSpread","type","entry","_entity$gps","gps","entityDetails","gpsText","locationText","referenceValue","timezoneHourTime","reverseGeocoded","subTitle","headerSubTitle","style","headerTitle","address","headerAddress","body","push","submittedAtInTimezone","submittedAt","tz","format","showSimplifiedDuration","startedAtInTimezone","startedAt","momentDuration","duration","Math","abs","formDuration","days","floor","asDays","toString","padStart","hours","minutes","seconds","formattedFormDuration","titleTable","layout","formGroups","_toConsumableArray"],"sources":["../../../src/pdf/task/index.js"],"sourcesContent":["import { isEmpty } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n text,\n table,\n} from '../helpers'\nimport { getTaskEntryDetails } from '../../helpers'\n\n/**\n * buildTaskPdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} data - pdf data\n * @param {object} data.entity - task document\n * @param {object} data.locations - locations documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @param {object} data.zones - zone documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildTaskPdf(pdfOptions, data) {\n const { entity, timezone } = data\n\n const sequenceId = entity.sequenceId\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n\n const fileTitle = `Task Report - ${title}`\n\n return generateContent(data).then(content =>\n generateDefinition({\n content,\n fileTitle,\n sequenceId,\n timestamp,\n timezone,\n type: 'Task',\n ...pdfOptions,\n })\n )\n}\n\nfunction generateContent(data) {\n const { entity, timezone } = data\n\n const { entry, gps = {}, title } = entity\n\n const entityDetails = getTaskEntryDetails(data)\n\n const {\n gpsText,\n locationText,\n referenceValue,\n timezoneHourTime,\n } = entityDetails\n\n const reverseGeocoded = gps.reverseGeocoded\n\n const subTitle = `${locationText ||\n gpsText} - ${timezoneHourTime} by ${referenceValue}`\n const headerSubTitle = text(subTitle, { style: 'subTitle' })\n const headerTitle = text(title, { style: 'title' })\n const address = !isEmpty(reverseGeocoded)\n ? getFormattedAddress(reverseGeocoded)\n : ''\n const headerAddress = text(address, { style: 'small' })\n\n const body = [[headerTitle], [headerSubTitle]]\n\n if (!isEmpty(reverseGeocoded)) {\n body.push([headerAddress])\n }\n\n const submittedAtInTimezone = entity.submittedAt\n ? moment(entity.submittedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const submittedAt = text(`Submitted: ${submittedAtInTimezone}`, {\n style: 'small',\n })\n\n if (entity.showSimplifiedDuration) {\n body.push([submittedAt])\n } else {\n const startedAtInTimezone = entity.startedAt\n ? moment(entity.startedAt)\n .tz(timezone)\n .format('YYYY-MM-DD HH:mm:ss z')\n : 'Not recorded'\n const startedAt = text(`Started: ${startedAtInTimezone}`, {\n style: 'small',\n })\n\n const momentDuration = moment.duration(Math.abs(entity.formDuration))\n const days = Math.floor(momentDuration.asDays())\n .toString()\n .padStart(2, '0')\n const hours = Math.floor(momentDuration.hours())\n .toString()\n .padStart(2, '0')\n const minutes = momentDuration\n .minutes()\n .toString()\n .padStart(2, '0')\n const seconds = momentDuration\n .seconds()\n .toString()\n .padStart(2, '0')\n const formattedFormDuration = entity.formDuration\n ? `${\n entity.formDuration < 0 ? '-' : ''\n }${days}:${hours}:${minutes}:${seconds}`\n : 'Not recorded'\n const formDuration = text(\n `Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`,\n {\n style: 'small',\n }\n )\n\n body.push([startedAt])\n body.push([submittedAt])\n body.push([formDuration])\n }\n\n const titleTable = table({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n })\n\n return buildTemplateContent(entry.formGroups, data).then(entry => [\n titleTable,\n ...entry,\n ])\n}\n"],"mappings":";;;;AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,mBAAmB,EACnBC,IAAI,EACJC,KAAK,QACA,YAAY;AACnB,SAASC,mBAAmB,QAAQ,eAAe;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,UAAU,EAAEC,IAAI,EAAE;EAC7C,IAAQC,MAAM,GAAeD,IAAI,CAAzBC,MAAM;IAAEC,QAAQ,GAAKF,IAAI,CAAjBE,QAAQ;EAExB,IAAMC,UAAU,GAAGF,MAAM,CAACE,UAAU;EACpC,IAAMC,SAAS,GAAGH,MAAM,CAACI,SAAS;EAClC,IAAMC,KAAK,GAAGL,MAAM,CAACK,KAAK,IAAI,SAAS;EAEvC,IAAMC,SAAS,oBAAAC,MAAA,CAAoBF,KAAK,CAAE;EAE1C,OAAOG,eAAe,CAACT,IAAI,CAAC,CAACU,IAAI,CAAC,UAAAC,OAAO;IAAA,OACvClB,kBAAkB,CA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