@sunbird-cb/cbp-ai 0.1.115 → 0.1.116
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/esm2022/lib/components/view-final-cbp-plan/view-final-cbp-plan.component.mjs +47 -16
- package/fesm2022/sunbird-cb-cbp-ai.mjs +46 -15
- package/fesm2022/sunbird-cb-cbp-ai.mjs.map +1 -1
- package/lib/components/view-final-cbp-plan/view-final-cbp-plan.component.d.ts.map +1 -1
- package/package.json +1 -1
- package/sunbird-cb-cbp-ai-0.1.115.tgz +0 -0
|
@@ -13235,10 +13235,10 @@ class ViewFinalCbpPlanComponent {
|
|
|
13235
13235
|
}, 2000);
|
|
13236
13236
|
}
|
|
13237
13237
|
generateExcel(jsonArray, filename = "final.xlsx") {
|
|
13238
|
-
console.log('jsonArray', jsonArray);
|
|
13239
13238
|
this.loading = true;
|
|
13240
13239
|
if (!jsonArray || jsonArray.length === 0)
|
|
13241
13240
|
return;
|
|
13241
|
+
const excelCellTextLimit = 32000;
|
|
13242
13242
|
// -------- MAIN HEADER FROM FIRST OBJECT ---------
|
|
13243
13243
|
const firstObj = jsonArray[0];
|
|
13244
13244
|
let title = firstObj.state_center_name || "";
|
|
@@ -13251,29 +13251,44 @@ class ViewFinalCbpPlanComponent {
|
|
|
13251
13251
|
"Activities",
|
|
13252
13252
|
"Behavioral Competencies",
|
|
13253
13253
|
"Functional Competencies",
|
|
13254
|
-
"Domain Competencies"
|
|
13255
|
-
'courseDetails'
|
|
13254
|
+
"Domain Competencies"
|
|
13256
13255
|
];
|
|
13257
13256
|
// -------- DATA ROWS ---------
|
|
13258
13257
|
const dataRows = jsonArray.map(json => {
|
|
13259
13258
|
const courses = json?.cbp_plans?.length
|
|
13260
13259
|
? json.cbp_plans[json.cbp_plans.length - 1]?.selected_courses || []
|
|
13261
13260
|
: [];
|
|
13262
|
-
const
|
|
13261
|
+
const courseDetailBlocks = courses.map((c, i) => {
|
|
13263
13262
|
const competencies = (c.competencies || c.competencies_v6 || [])
|
|
13264
13263
|
.map((cc) => `${cc.competencyAreaName} → ${cc.competencyThemeName} → ${cc.competencySubThemeName}`)
|
|
13265
13264
|
.join(" | ");
|
|
13266
|
-
return
|
|
13265
|
+
return `${i + 1}. Course Name: ${c?.course || c?.name}\n` +
|
|
13267
13266
|
` Identifier: ${c?.identifier}\n` +
|
|
13268
13267
|
` Duration (mins): ${Math.round(+c.duration / 60)}\n` +
|
|
13269
13268
|
` Relevancy: ${c?.relevancy}%\n` +
|
|
13270
13269
|
` Rationale: ${c?.rationale}\n` +
|
|
13271
|
-
`
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13270
|
+
` Organisation: ${Array.isArray(c?.organisation) ? c.organisation.join(", ") : (c?.organisation ?? "")}\n` +
|
|
13271
|
+
` Competencies: ${competencies}`;
|
|
13272
|
+
});
|
|
13273
|
+
const truncationNotice = "\n[course details truncated]";
|
|
13274
|
+
const courseDetailParts = [];
|
|
13275
|
+
let currentPart = "";
|
|
13276
|
+
courseDetailBlocks.forEach((courseDetail) => {
|
|
13277
|
+
if (courseDetail.length > excelCellTextLimit) {
|
|
13278
|
+
courseDetail = courseDetail.slice(0, excelCellTextLimit - truncationNotice.length) + truncationNotice;
|
|
13279
|
+
}
|
|
13280
|
+
const separator = currentPart ? "\n\n" : "";
|
|
13281
|
+
if (currentPart && currentPart.length + separator.length + courseDetail.length > excelCellTextLimit) {
|
|
13282
|
+
courseDetailParts.push(currentPart);
|
|
13283
|
+
currentPart = courseDetail;
|
|
13284
|
+
}
|
|
13285
|
+
else {
|
|
13286
|
+
currentPart += separator + courseDetail;
|
|
13287
|
+
}
|
|
13288
|
+
});
|
|
13289
|
+
if (currentPart)
|
|
13290
|
+
courseDetailParts.push(currentPart);
|
|
13291
|
+
const row = {
|
|
13277
13292
|
"Designation": `${json.designation_name} : Wing/Division - ${json.wing_division_section}`,
|
|
13278
13293
|
"Role & Responsibilities": (json.role_responsibilities || [])
|
|
13279
13294
|
.map((v, i) => `${i + 1}. ${v}`).join("\n\n"),
|
|
@@ -13287,9 +13302,23 @@ class ViewFinalCbpPlanComponent {
|
|
|
13287
13302
|
.map((c, i) => `${i + 1}. ${c.theme} - ${c.sub_theme} (${c?.proficiency_level}, ${c?.delivery_mode})`).join("\n\n"),
|
|
13288
13303
|
"Domain Competencies": (json.competencies || [])
|
|
13289
13304
|
.filter((c) => c.type === "Domain")
|
|
13290
|
-
.map((c, i) => `${i + 1}. ${c.theme} - ${c.sub_theme}
|
|
13291
|
-
"Course Details":
|
|
13305
|
+
.map((c, i) => `${i + 1}. ${c.theme} - ${c.sub_theme}`).join("\n\n"),
|
|
13306
|
+
"Course Details 1": courseDetailParts[0] || ""
|
|
13292
13307
|
};
|
|
13308
|
+
for (let part = 1; part < courseDetailParts.length; part++) {
|
|
13309
|
+
row[`Course Details ${part + 1}`] = courseDetailParts[part];
|
|
13310
|
+
}
|
|
13311
|
+
return row;
|
|
13312
|
+
});
|
|
13313
|
+
const maxCourseDetailParts = Math.max(1, ...dataRows.map(row => Object.keys(row).filter(key => key.indexOf("Course Details ") === 0).length));
|
|
13314
|
+
for (let part = 1; part <= maxCourseDetailParts; part++) {
|
|
13315
|
+
headers.push(`Course Details ${part}`);
|
|
13316
|
+
}
|
|
13317
|
+
dataRows.forEach(row => {
|
|
13318
|
+
headers.forEach(header => {
|
|
13319
|
+
if (!(header in row))
|
|
13320
|
+
row[header] = "";
|
|
13321
|
+
});
|
|
13293
13322
|
});
|
|
13294
13323
|
// -------- CREATE WORKSHEET ---------
|
|
13295
13324
|
const ws = XLSX.utils.aoa_to_sheet([]);
|
|
@@ -13315,8 +13344,10 @@ class ViewFinalCbpPlanComponent {
|
|
|
13315
13344
|
// Insert data rows starting from row 3
|
|
13316
13345
|
XLSX.utils.sheet_add_json(ws, dataRows, { origin: "A3", skipHeader: true });
|
|
13317
13346
|
// Auto column widths based on longest line in each column
|
|
13318
|
-
const colWidths = headers.map(
|
|
13319
|
-
const maxLen = Math.max(header.length, ...dataRows.map(row => (row[header] || "")
|
|
13347
|
+
const colWidths = headers.map(header => {
|
|
13348
|
+
const maxLen = Math.max(header.length, ...dataRows.map(row => String(row[header] || "")
|
|
13349
|
+
.split("\n")
|
|
13350
|
+
.reduce((maxLength, line) => Math.max(maxLength, line.length), 0)));
|
|
13320
13351
|
return { wch: Math.min(Math.max(maxLen + 5, 20), 80) }; // min 20, max 80
|
|
13321
13352
|
});
|
|
13322
13353
|
ws['!cols'] = colWidths;
|