@lighthouse/common 4.34.0-canary-2 → 4.34.0-canary-4
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/dist/pdf/task/index.js +21 -10
- package/lib/pdf/task/index.js +21 -10
- package/lib/pdf/task/index.js.map +1 -1
- package/package.json +1 -1
package/dist/pdf/task/index.js
CHANGED
|
@@ -83,24 +83,35 @@ function generateContent(data) {
|
|
|
83
83
|
const headerAddress = (0, _helpers.text)(address, {
|
|
84
84
|
style: 'small'
|
|
85
85
|
});
|
|
86
|
-
const startedAt = (0, _helpers.text)(`Started: ${entityDetails.startedAt}`, {
|
|
87
|
-
style: 'small'
|
|
88
|
-
});
|
|
89
|
-
const submittedAt = (0, _helpers.text)(`Submitted: ${entityDetails.submittedAt}`, {
|
|
90
|
-
style: 'small'
|
|
91
|
-
});
|
|
92
|
-
const formDuration = (0, _helpers.text)(`Form Duration: ${entity.formDuration} minutes`, {
|
|
93
|
-
style: 'small'
|
|
94
|
-
});
|
|
95
86
|
const body = [[headerTitle], [headerSubTitle]];
|
|
96
87
|
|
|
97
88
|
if (!(0, _lodash.isEmpty)(reverseGeocoded)) {
|
|
98
89
|
body.push([headerAddress]);
|
|
99
90
|
}
|
|
100
91
|
|
|
101
|
-
|
|
92
|
+
console.log('entityDetails Keys:', Object.keys(entityDetails).join(', '));
|
|
93
|
+
console.dir(entityDetails, {
|
|
94
|
+
depth: null
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (entityDetails.startedAt) {
|
|
98
|
+
const startedAt = (0, _helpers.text)(`Started: ${entityDetails.startedAt}`, {
|
|
99
|
+
style: 'small'
|
|
100
|
+
});
|
|
102
101
|
body.push([startedAt]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (entityDetails.submittedAt) {
|
|
105
|
+
const submittedAt = (0, _helpers.text)(`Submitted: ${entityDetails.submittedAt}`, {
|
|
106
|
+
style: 'small'
|
|
107
|
+
});
|
|
103
108
|
body.push([submittedAt]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (entity.formDuration) {
|
|
112
|
+
const formDuration = (0, _helpers.text)(`Form Duration: ${entity.formDuration} minutes`, {
|
|
113
|
+
style: 'small'
|
|
114
|
+
});
|
|
104
115
|
body.push([formDuration]);
|
|
105
116
|
}
|
|
106
117
|
|
package/lib/pdf/task/index.js
CHANGED
|
@@ -75,24 +75,35 @@ function generateContent(data) {
|
|
|
75
75
|
var headerAddress = text(address, {
|
|
76
76
|
style: 'small'
|
|
77
77
|
});
|
|
78
|
-
var startedAt = text("Started: ".concat(entityDetails.startedAt), {
|
|
79
|
-
style: 'small'
|
|
80
|
-
});
|
|
81
|
-
var submittedAt = text("Submitted: ".concat(entityDetails.submittedAt), {
|
|
82
|
-
style: 'small'
|
|
83
|
-
});
|
|
84
|
-
var formDuration = text("Form Duration: ".concat(entity.formDuration, " minutes"), {
|
|
85
|
-
style: 'small'
|
|
86
|
-
});
|
|
87
78
|
var body = [[headerTitle], [headerSubTitle]];
|
|
88
79
|
|
|
89
80
|
if (!isEmpty(reverseGeocoded)) {
|
|
90
81
|
body.push([headerAddress]);
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
|
|
84
|
+
console.log('entityDetails Keys:', Object.keys(entityDetails).join(', '));
|
|
85
|
+
console.dir(entityDetails, {
|
|
86
|
+
depth: null
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (entityDetails.startedAt) {
|
|
90
|
+
var startedAt = text("Started: ".concat(entityDetails.startedAt), {
|
|
91
|
+
style: 'small'
|
|
92
|
+
});
|
|
94
93
|
body.push([startedAt]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (entityDetails.submittedAt) {
|
|
97
|
+
var submittedAt = text("Submitted: ".concat(entityDetails.submittedAt), {
|
|
98
|
+
style: 'small'
|
|
99
|
+
});
|
|
95
100
|
body.push([submittedAt]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (entity.formDuration) {
|
|
104
|
+
var formDuration = text("Form Duration: ".concat(entity.formDuration, " minutes"), {
|
|
105
|
+
style: 'small'
|
|
106
|
+
});
|
|
96
107
|
body.push([formDuration]);
|
|
97
108
|
}
|
|
98
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/pdf/task/index.js"],"names":["isEmpty","buildTemplateContent","generateDefinition","getFormattedAddress","text","table","getTaskEntryDetails","buildTaskPdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","generateContent","then","content","type","entry","gps","entityDetails","gpsText","locationText","referenceValue","timezoneHourTime","reverseGeocoded","subTitle","headerSubTitle","style","headerTitle","address","headerAddress","
|
|
1
|
+
{"version":3,"sources":["../../../src/pdf/task/index.js"],"names":["isEmpty","buildTemplateContent","generateDefinition","getFormattedAddress","text","table","getTaskEntryDetails","buildTaskPdf","pdfOptions","data","entity","timezone","sequenceId","timestamp","createdAt","title","fileTitle","generateContent","then","content","type","entry","gps","entityDetails","gpsText","locationText","referenceValue","timezoneHourTime","reverseGeocoded","subTitle","headerSubTitle","style","headerTitle","address","headerAddress","body","push","console","log","Object","keys","join","dir","depth","startedAt","submittedAt","formDuration","titleTable","layout","formGroups"],"mappings":";;;;;;;AAAA,SAASA,OAAT,QAAwB,QAAxB;AACA,SACEC,oBADF,EAEEC,kBAFF,EAGEC,mBAHF,EAIEC,IAJF,EAKEC,KALF,QAMO,YANP;AAQA,SAASC,mBAAT,QAAoC,eAApC;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,OAAO,SAASC,YAAT,CAAsBC,UAAtB,EAAkCC,IAAlC,EAAwC;AAAA,MACrCC,MADqC,GAChBD,IADgB,CACrCC,MADqC;AAAA,MAC7BC,QAD6B,GAChBF,IADgB,CAC7BE,QAD6B;AAG7C,MAAMC,UAAU,GAAGF,MAAM,CAACE,UAA1B;AACA,MAAMC,SAAS,GAAGH,MAAM,CAACI,SAAzB;AACA,MAAMC,KAAK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AAkD;AACzEf,MAAAA,KAAK,EAAE;AADkE,KAAlD,CAAzB;AAGAI,IAAAA,IAAI,CAACC,IAAL,CAAU,CAACU,YAAD,CAAV;AACD;;AAED,MAAMC,UAAU,GAAG1C,KAAK,CAAC;AACvB8B,IAAAA,IAAI,EAAJA,IADuB;AAEvBa,IAAAA,MAAM,EAAE,WAFe;AAGvBjB,IAAAA,KAAK,EAAE;AAHgB,GAAD,CAAxB;AAMA,SAAO9B,oBAAoB,CAACoB,KAAK,CAAC4B,UAAP,EAAmBxC,IAAnB,CAApB,CAA6CS,IAA7C,CAAkD,UAAAG,KAAK;AAAA,YAC5D0B,UAD4D,4BAEzD1B,KAFyD;AAAA,GAAvD,CAAP;AAID","sourcesContent":["import { isEmpty } from 'lodash'\nimport {\n buildTemplateContent,\n generateDefinition,\n getFormattedAddress,\n text,\n table,\n} from '../helpers'\n\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 } = 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 console.log('entityDetails Keys:', Object.keys(entityDetails).join(', '))\n console.dir(entityDetails, { depth: null })\n\n if (entityDetails.startedAt) {\n const startedAt = text(`Started: ${entityDetails.startedAt}`, {\n style: 'small',\n })\n body.push([startedAt])\n }\n\n if (entityDetails.submittedAt) {\n const submittedAt = text(`Submitted: ${entityDetails.submittedAt}`, {\n style: 'small',\n })\n body.push([submittedAt])\n }\n\n if (entity.formDuration) {\n const formDuration = text(`Form Duration: ${entity.formDuration} minutes`, {\n style: 'small',\n })\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"],"file":"index.js"}
|