@solidpepper/solidpepper-solidgeneration 0.2.5 → 0.2.7
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.
|
@@ -92,6 +92,7 @@ class DataSheet {
|
|
|
92
92
|
this.variantTables = [];
|
|
93
93
|
this.variantTableFirstHeight = 0;
|
|
94
94
|
this.variantTableLastHeight = 0;
|
|
95
|
+
this.overflowBehavior = 'none';
|
|
95
96
|
// Provisoire
|
|
96
97
|
this.backgroundWidth = 0;
|
|
97
98
|
this.backgroundHeight = 0;
|
|
@@ -125,11 +126,11 @@ class DataSheet {
|
|
|
125
126
|
line-height: 120%;
|
|
126
127
|
overflow: hidden;
|
|
127
128
|
text-align: left;
|
|
128
|
-
padding: 5px;
|
|
129
|
+
padding: var(--vertical-padding, 5px) var(--horizontal-padding, 5px);
|
|
129
130
|
border-width: 0.8px;
|
|
130
131
|
border-color: rgb(0, 0, 0);
|
|
131
132
|
border-style: solid;
|
|
132
|
-
font-family:
|
|
133
|
+
font-family: sans-serif;
|
|
133
134
|
font-size: 16px;
|
|
134
135
|
color: rgb(0, 0, 0);
|
|
135
136
|
font-style: normal;
|
|
@@ -138,9 +139,9 @@ class DataSheet {
|
|
|
138
139
|
background-color: rgba(0, 0, 0, 0);
|
|
139
140
|
min-height: inherit;
|
|
140
141
|
}
|
|
141
|
-
foreignObject td div.wrap { display: flex;text-align: inherit;justify-content: inherit;min-height: inherit;align-items: inherit;font-family: inherit !important; }
|
|
142
|
-
foreignObject .cellContent
|
|
143
|
-
foreignObject .cellContent {display: flex; align-items: inherit; justify-content: inherit; width: 100%; height: auto;flex-direction: column;}
|
|
142
|
+
foreignObject td div.wrap, foreignObject th div.wrap { display: flex; flex-direction: column; text-align: inherit; justify-content: inherit; min-height: inherit; align-items: inherit; font-family: inherit !important; width: 100%; }
|
|
143
|
+
foreignObject .cellContent div, foreignObject td div.wrap > div, foreignObject th div.wrap > div { width: 100%; min-height: 1em; }
|
|
144
|
+
foreignObject .cellContent { display: flex; align-items: inherit; justify-content: inherit; width: 100%; height: auto; flex-direction: column; }
|
|
144
145
|
foreignObject [locked='true'].fake-textarea > * {
|
|
145
146
|
max-width: 100%;
|
|
146
147
|
}
|
|
@@ -340,6 +341,7 @@ class DataSheet {
|
|
|
340
341
|
this.publicationTemplateBackgroundLeftMargin = 0;
|
|
341
342
|
this.publicationTemplateBackgroundFooterY = 0;
|
|
342
343
|
this.publicationTemplateBackgroundMarginX = 0;
|
|
344
|
+
this.overflowBehavior = 'none';
|
|
343
345
|
this.pricesListCurrency = '';
|
|
344
346
|
this.gabarits.length = 0;
|
|
345
347
|
this.defaultGabaritGuid = null;
|
|
@@ -498,12 +500,140 @@ class DataSheetSVG {
|
|
|
498
500
|
dsSingleton.token = token;
|
|
499
501
|
dsSingleton.loadAttributes();
|
|
500
502
|
}
|
|
503
|
+
parseBackgroundSvgDimensions(backgroundSvg) {
|
|
504
|
+
if (!backgroundSvg)
|
|
505
|
+
return;
|
|
506
|
+
try {
|
|
507
|
+
const allElements = this.GetAllTags(backgroundSvg);
|
|
508
|
+
allElements?.forEach((element) => {
|
|
509
|
+
const tagName = element.tagName?.toLowerCase();
|
|
510
|
+
if (tagName === 'svg') {
|
|
511
|
+
const heightAttr = element.getAttribute('height') ||
|
|
512
|
+
element.getAttribute('data-height');
|
|
513
|
+
if (heightAttr) {
|
|
514
|
+
const parsedH = parseFloat(heightAttr);
|
|
515
|
+
if (!isNaN(parsedH) && parsedH > 0) {
|
|
516
|
+
this.DataSheet.publicationTemplateHeight = parsedH;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const widthAttr = element.getAttribute('width') ||
|
|
520
|
+
element.getAttribute('data-width');
|
|
521
|
+
if (widthAttr) {
|
|
522
|
+
const parsedW = parseFloat(widthAttr);
|
|
523
|
+
if (!isNaN(parsedW) && parsedW > 0) {
|
|
524
|
+
this.DataSheet.publicationTemplateWidth = parsedW;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const viewBox = element.getAttribute('viewBox');
|
|
528
|
+
if (viewBox) {
|
|
529
|
+
const vbParts = viewBox.trim().split(/[\s,]+/);
|
|
530
|
+
if (vbParts.length === 4) {
|
|
531
|
+
const vbW = parseFloat(vbParts[2]);
|
|
532
|
+
const vbH = parseFloat(vbParts[3]);
|
|
533
|
+
if ((!this.DataSheet.publicationTemplateWidth ||
|
|
534
|
+
this.DataSheet.publicationTemplateWidth === 0) &&
|
|
535
|
+
!isNaN(vbW) &&
|
|
536
|
+
vbW > 0) {
|
|
537
|
+
this.DataSheet.publicationTemplateWidth = vbW;
|
|
538
|
+
}
|
|
539
|
+
if ((!this.DataSheet.publicationTemplateHeight ||
|
|
540
|
+
this.DataSheet.publicationTemplateHeight === 0) &&
|
|
541
|
+
!isNaN(vbH) &&
|
|
542
|
+
vbH > 0) {
|
|
543
|
+
this.DataSheet.publicationTemplateHeight = vbH;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// HEADER HEIGHT
|
|
548
|
+
const attrHeader = element.getAttribute('data-margin-top') ||
|
|
549
|
+
element.getAttribute('data-header-height') ||
|
|
550
|
+
element.getAttribute('data-margin-vertical');
|
|
551
|
+
const parsedHeader = parseFloat(attrHeader);
|
|
552
|
+
if (!isNaN(parsedHeader)) {
|
|
553
|
+
this.DataSheet.publicationTemplateBackgroundHeightHeader =
|
|
554
|
+
parsedHeader;
|
|
555
|
+
}
|
|
556
|
+
else if (!this.DataSheet.publicationTemplateBackgroundHeightHeader) {
|
|
557
|
+
this.DataSheet.publicationTemplateBackgroundHeightHeader = 0;
|
|
558
|
+
}
|
|
559
|
+
// FOOTER HEIGHT
|
|
560
|
+
const attrFooter = element.getAttribute('data-margin-bottom') ||
|
|
561
|
+
element.getAttribute('data-footer-height') ||
|
|
562
|
+
element.getAttribute('data-margin-vertical');
|
|
563
|
+
const parsedFooter = parseFloat(attrFooter);
|
|
564
|
+
if (!isNaN(parsedFooter)) {
|
|
565
|
+
this.DataSheet.publicationTemplateBackgroundHeightFooter =
|
|
566
|
+
parsedFooter;
|
|
567
|
+
this.DataSheet.publicationTemplateBackgroundFooterY =
|
|
568
|
+
(this.DataSheet.publicationTemplateHeight || 1122) - parsedFooter;
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
this.DataSheet.publicationTemplateBackgroundHeightFooter =
|
|
572
|
+
this.DataSheet.publicationTemplateBackgroundHeightFooter || 0;
|
|
573
|
+
this.DataSheet.publicationTemplateBackgroundFooterY =
|
|
574
|
+
(this.DataSheet.publicationTemplateHeight || 1122) -
|
|
575
|
+
this.DataSheet.publicationTemplateBackgroundHeightFooter;
|
|
576
|
+
}
|
|
577
|
+
// MARGIN
|
|
578
|
+
const attrMarginLeft = element.getAttribute('data-margin-left') ||
|
|
579
|
+
element.getAttribute('data-margin-horizontal');
|
|
580
|
+
const attrMarginRight = element.getAttribute('data-margin-right') ||
|
|
581
|
+
element.getAttribute('data-margin-horizontal');
|
|
582
|
+
const parsedMarginLeft = parseFloat(attrMarginLeft);
|
|
583
|
+
if (!isNaN(parsedMarginLeft)) {
|
|
584
|
+
this.DataSheet.publicationTemplateBackgroundLeftMargin =
|
|
585
|
+
parsedMarginLeft;
|
|
586
|
+
}
|
|
587
|
+
else if (!this.DataSheet.publicationTemplateBackgroundLeftMargin) {
|
|
588
|
+
this.DataSheet.publicationTemplateBackgroundLeftMargin = 0;
|
|
589
|
+
}
|
|
590
|
+
const parsedMarginRight = parseFloat(attrMarginRight);
|
|
591
|
+
if (!isNaN(parsedMarginRight)) {
|
|
592
|
+
this.DataSheet.publicationTemplateBackgroundRightMargin =
|
|
593
|
+
parsedMarginRight;
|
|
594
|
+
this.DataSheet.publicationTemplateBackgroundMarginX =
|
|
595
|
+
(this.DataSheet.publicationTemplateWidth || 793) - parsedMarginRight;
|
|
596
|
+
}
|
|
597
|
+
else if (!this.DataSheet.publicationTemplateBackgroundRightMargin) {
|
|
598
|
+
this.DataSheet.publicationTemplateBackgroundRightMargin = 0;
|
|
599
|
+
this.DataSheet.publicationTemplateBackgroundMarginX =
|
|
600
|
+
this.DataSheet.publicationTemplateWidth || 793;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
// STYLE
|
|
604
|
+
else if (tagName === 'style') {
|
|
605
|
+
const styleContent = element.textContent;
|
|
606
|
+
const importMatch = styleContent.match(/@import\s+url\("https:\/\/fonts\.googleapis\.com.*?"\);/);
|
|
607
|
+
if (importMatch &&
|
|
608
|
+
!this.DataSheet.DictImportFontFamily.push(importMatch[0])) {
|
|
609
|
+
this.DataSheet.importFontFamily += importMatch[0] + ' ';
|
|
610
|
+
this.DataSheet.DictImportFontFamily.push(importMatch[0]);
|
|
611
|
+
}
|
|
612
|
+
const fontFaceMatches = styleContent.match(/@font-face\s*\{[^}]+\}/g);
|
|
613
|
+
if (fontFaceMatches) {
|
|
614
|
+
fontFaceMatches.forEach((block) => {
|
|
615
|
+
if (!this.DataSheet.DictImportFontFamily.push(block)) {
|
|
616
|
+
this.DataSheet.importFontFamily += block + '\n';
|
|
617
|
+
this.DataSheet.DictImportFontFamily.push(block);
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
catch (e) {
|
|
625
|
+
console.warn('[SOLIDGENERATION] Error parsing background dimensions:', e);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
501
628
|
async GenerateSvgFiles(lstSkus, backgroundTplLeft, backgroundTplRight, sectionId = '', fast = false) {
|
|
502
629
|
let AllTplProductsBlock = '';
|
|
503
630
|
let tplProductBlock = '';
|
|
504
631
|
let tplRowProductsBlocks = '';
|
|
505
632
|
let pathNewSvgFile = '';
|
|
506
633
|
try {
|
|
634
|
+
if (backgroundTplLeft || backgroundTplRight) {
|
|
635
|
+
this.parseBackgroundSvgDimensions(backgroundTplLeft || backgroundTplRight);
|
|
636
|
+
}
|
|
507
637
|
if (sectionId == '' || sectionId == null) {
|
|
508
638
|
pathNewSvgFile = 'temp[';
|
|
509
639
|
}
|
|
@@ -537,7 +667,7 @@ class DataSheetSVG {
|
|
|
537
667
|
}
|
|
538
668
|
}
|
|
539
669
|
let initDoc = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
|
|
540
|
-
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="' +
|
|
670
|
+
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-sp-version="1.105" viewBox="' +
|
|
541
671
|
vbx +
|
|
542
672
|
' ' +
|
|
543
673
|
vby +
|
|
@@ -940,8 +1070,11 @@ class DataSheetSVG {
|
|
|
940
1070
|
widths +
|
|
941
1071
|
aWidths[nbBlockInRow] -
|
|
942
1072
|
(nbBlockInRow > 0 ? gMarginLeft : 0);
|
|
1073
|
+
newTplGroup = newTplGroup
|
|
1074
|
+
.replace(/<foreignobject/gi, '<foreignObject')
|
|
1075
|
+
.replace(/<\/foreignobject>/gi, '</foreignObject>');
|
|
943
1076
|
// Check how many table variants are presents in the product block
|
|
944
|
-
const pattern = /<foreignObject
|
|
1077
|
+
const pattern = /<foreignObject[^>]*id=["']tableVariant["'][^>]*>[\s\S]*?<\/foreignObject>/gi;
|
|
945
1078
|
const matches = newTplGroup.match(pattern);
|
|
946
1079
|
// Manage the variants tables if they are more than 1 (change of column / page)
|
|
947
1080
|
if (this.debugTable) {
|
|
@@ -949,15 +1082,23 @@ class DataSheetSVG {
|
|
|
949
1082
|
}
|
|
950
1083
|
if (matches &&
|
|
951
1084
|
matches.length > 1 &&
|
|
952
|
-
jObject.splitVariantTable !== false
|
|
1085
|
+
(jObject.splitVariantTable !== false ||
|
|
1086
|
+
matches.some((m) => m.includes('data-split-continuation="true"')))) {
|
|
953
1087
|
let otherPage = newTplGroup;
|
|
954
1088
|
const priorHeights = heights;
|
|
955
1089
|
skipPart = true;
|
|
956
1090
|
for (let i = 0; i < matches.length; i++) {
|
|
957
1091
|
newTplGroup = otherPage;
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1092
|
+
if (i > 0 &&
|
|
1093
|
+
matches[i].includes('data-split-continuation="true"')) {
|
|
1094
|
+
const continuationTable = matches[i].replace(/(?<![a-zA-Z])y\s*=\s*"-?\d+(?:\.\d+)?"/g, `y="${headerShift}"`);
|
|
1095
|
+
newTplGroup = `<g>${continuationTable}</g>`;
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
for (let n = 0; n < matches.length; n++) {
|
|
1099
|
+
if (n !== i) {
|
|
1100
|
+
newTplGroup = newTplGroup.replace(matches[n], '');
|
|
1101
|
+
}
|
|
961
1102
|
}
|
|
962
1103
|
}
|
|
963
1104
|
const matchHeightRes = this.getActualBlockHeight(newTplGroup, origBlockHeight, blockY);
|
|
@@ -1015,9 +1156,10 @@ class DataSheetSVG {
|
|
|
1015
1156
|
newRowHeights +
|
|
1016
1157
|
matchBlockHeight -
|
|
1017
1158
|
blockY;
|
|
1018
|
-
if (
|
|
1019
|
-
|
|
1020
|
-
|
|
1159
|
+
if (i === 0 &&
|
|
1160
|
+
(allBlockHeight <=
|
|
1161
|
+
this.DataSheet.publicationTemplateBackgroundFooterY ||
|
|
1162
|
+
(nbRow === 0 && aHeightsRows.length === 0)) &&
|
|
1021
1163
|
allBlockHeight != 0) {
|
|
1022
1164
|
const diffY = newRowHeights - heights;
|
|
1023
1165
|
heights = newRowHeights;
|
|
@@ -1063,7 +1205,9 @@ class DataSheetSVG {
|
|
|
1063
1205
|
};
|
|
1064
1206
|
fileList.push(json);
|
|
1065
1207
|
newTplGroup = this.ChangeAllX(newTplGroup, nbBlockInRow, this.DataSheet.publicationTemplateBackgroundLeftMargin);
|
|
1066
|
-
|
|
1208
|
+
if (!matches[i].includes('data-split-continuation="true"')) {
|
|
1209
|
+
newTplGroup = this.ChangeAllYBis(newTplGroup, -priorHeights);
|
|
1210
|
+
}
|
|
1067
1211
|
AllTplProductsBlock = '';
|
|
1068
1212
|
newTplGroup = this.wrapTemplateGroup(newTplGroup, jObject, gabarit, nbBlock);
|
|
1069
1213
|
tplRowProductsBlocks = newTplGroup;
|
|
@@ -1074,7 +1218,9 @@ class DataSheetSVG {
|
|
|
1074
1218
|
aGabaritMarginRights = [];
|
|
1075
1219
|
aGabaritMarginRights.push(gMarginRight);
|
|
1076
1220
|
aHeightsRows = [];
|
|
1077
|
-
aHeightsRows.push(
|
|
1221
|
+
aHeightsRows.push(i > 0
|
|
1222
|
+
? matchBlockHeight
|
|
1223
|
+
: Math.max(origBlockHeight, matchBlockHeight));
|
|
1078
1224
|
aRowMarginTops = [];
|
|
1079
1225
|
aRowMarginTops.push(gMarginTop);
|
|
1080
1226
|
aRowMarginBottoms = [];
|
|
@@ -1095,7 +1241,7 @@ class DataSheetSVG {
|
|
|
1095
1241
|
}
|
|
1096
1242
|
}
|
|
1097
1243
|
else {
|
|
1098
|
-
console.
|
|
1244
|
+
console.error('[ERROR] RowTotalWidth is 0, this should not happen.');
|
|
1099
1245
|
}
|
|
1100
1246
|
}
|
|
1101
1247
|
}
|
|
@@ -1219,7 +1365,7 @@ class DataSheetSVG {
|
|
|
1219
1365
|
}
|
|
1220
1366
|
}
|
|
1221
1367
|
else {
|
|
1222
|
-
console.
|
|
1368
|
+
console.error('[ERROR] RowTotalWidth is 0, this should not happen.');
|
|
1223
1369
|
}
|
|
1224
1370
|
}
|
|
1225
1371
|
// Save for variant table (very useful)
|
|
@@ -1530,6 +1676,17 @@ class DataSheetSVG {
|
|
|
1530
1676
|
for (const missingFilter of uniqueMissingFilters) {
|
|
1531
1677
|
tempSvg = tempSvg.split(missingFilter).join('');
|
|
1532
1678
|
}
|
|
1679
|
+
const now = new Date();
|
|
1680
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
1681
|
+
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
1682
|
+
const year = now.getFullYear();
|
|
1683
|
+
const hours = String(now.getHours()).padStart(2, '0');
|
|
1684
|
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
1685
|
+
const dateStr = `${day}/${month}/${year}`;
|
|
1686
|
+
const dateCompleteStr = `${day}/${month}/${year} ${hours}:${minutes}`;
|
|
1687
|
+
tempSvg = tempSvg
|
|
1688
|
+
.replace(/\{\{(DateGeneration|Date_Generation|dateGeneration|date_generation)\}\}/gi, dateStr)
|
|
1689
|
+
.replace(/\{\{(DateCompleteGeneration|Date_Complete_Generation|dateCompleteGeneration|date_complete_generation)\}\}/gi, dateCompleteStr);
|
|
1533
1690
|
return tempSvg;
|
|
1534
1691
|
}
|
|
1535
1692
|
RemoveUnwantedSVGTagsOld(svgContent) {
|
|
@@ -2262,13 +2419,23 @@ class DataSheetSVG {
|
|
|
2262
2419
|
ProductTable: false,
|
|
2263
2420
|
Barcode: false,
|
|
2264
2421
|
QRCode: false,
|
|
2422
|
+
overflowBehavior: 'none',
|
|
2265
2423
|
};
|
|
2266
2424
|
// element est un objet du domparser, verifier que c'est le cas
|
|
2267
2425
|
if (element == null) {
|
|
2268
2426
|
return tag;
|
|
2269
2427
|
}
|
|
2270
2428
|
tag.XmlTag = element;
|
|
2271
|
-
|
|
2429
|
+
let elemId = element.getAttribute('id');
|
|
2430
|
+
if (!elemId) {
|
|
2431
|
+
elemId =
|
|
2432
|
+
element.getAttribute('data-id') ||
|
|
2433
|
+
(element.getAttribute('data-type')
|
|
2434
|
+
? `${element.getAttribute('data-type')}-${Math.random().toString(36).substr(2, 7)}`
|
|
2435
|
+
: `tag-${Math.random().toString(36).substr(2, 7)}`);
|
|
2436
|
+
element.setAttribute('id', elemId);
|
|
2437
|
+
}
|
|
2438
|
+
tag.IdTag = elemId;
|
|
2272
2439
|
const [yVal, xVal] = this.GetXY(tag.XmlTag);
|
|
2273
2440
|
tag.YTotal = this.safeParseFloat(yVal);
|
|
2274
2441
|
tag.X = this.safeParseFloat(xVal);
|
|
@@ -2334,6 +2501,11 @@ class DataSheetSVG {
|
|
|
2334
2501
|
: table.getAttribute('data-remove-empty-cells') === 'false'
|
|
2335
2502
|
? false
|
|
2336
2503
|
: this.DataSheet.publicationTemplateSettingVariants?.['hideEmptyCells'] === true;
|
|
2504
|
+
this.DataSheet.overflowBehavior =
|
|
2505
|
+
table.getAttribute('data-overflow-behavior') ||
|
|
2506
|
+
this.DataSheet.publicationTemplateSettingVariants?.['overflowBehavior'] ||
|
|
2507
|
+
'none';
|
|
2508
|
+
tag.overflowBehavior = this.DataSheet.overflowBehavior;
|
|
2337
2509
|
// Récup la première ligne du tableau
|
|
2338
2510
|
const firstRow = table.querySelector('tr');
|
|
2339
2511
|
if (firstRow) {
|
|
@@ -2381,6 +2553,11 @@ class DataSheetSVG {
|
|
|
2381
2553
|
: table.getAttribute('data-remove-empty-cells') === 'false'
|
|
2382
2554
|
? false
|
|
2383
2555
|
: this.DataSheet.publicationTemplateSettingVariants?.['hideEmptyCells'] === true;
|
|
2556
|
+
this.DataSheet.overflowBehavior =
|
|
2557
|
+
table.getAttribute('data-overflow-behavior') ||
|
|
2558
|
+
this.DataSheet.publicationTemplateSettingVariants?.['overflowBehavior'] ||
|
|
2559
|
+
'none';
|
|
2560
|
+
tag.overflowBehavior = this.DataSheet.overflowBehavior;
|
|
2384
2561
|
}
|
|
2385
2562
|
}
|
|
2386
2563
|
else if (tag.XmlTag.getAttribute('data-type').includes('barcode')) {
|
|
@@ -2412,11 +2589,21 @@ class DataSheetSVG {
|
|
|
2412
2589
|
tag.ProductTable = true;
|
|
2413
2590
|
tag.Image = false;
|
|
2414
2591
|
tag.VariantsTable = false;
|
|
2592
|
+
const table = tag.XmlTag.querySelector('table');
|
|
2593
|
+
if (table) {
|
|
2594
|
+
tag.overflowBehavior =
|
|
2595
|
+
table.getAttribute('data-overflow-behavior') || 'none';
|
|
2596
|
+
}
|
|
2415
2597
|
}
|
|
2416
2598
|
else if (dataType.includes('variantsTable')) {
|
|
2417
2599
|
tag.VariantsTable = true;
|
|
2418
2600
|
tag.Image = false;
|
|
2419
2601
|
tag.ProductTable = false;
|
|
2602
|
+
const table = tag.XmlTag.querySelector('table');
|
|
2603
|
+
if (table) {
|
|
2604
|
+
tag.overflowBehavior =
|
|
2605
|
+
table.getAttribute('data-overflow-behavior') || 'none';
|
|
2606
|
+
}
|
|
2420
2607
|
}
|
|
2421
2608
|
else {
|
|
2422
2609
|
tag.nbFieldToReplace = 0;
|
|
@@ -2531,10 +2718,6 @@ class DataSheetSVG {
|
|
|
2531
2718
|
let fieldObject = this.DataSheet.fields[i];
|
|
2532
2719
|
if (fieldToSearch.includes('[') && fieldToSearch.includes(']')) {
|
|
2533
2720
|
let name = fieldToSearch.substring(fieldToSearch.indexOf('[') + 1, fieldToSearch.length - 1 - fieldToSearch.indexOf('[') - 1);
|
|
2534
|
-
// Debug case for new functionnality
|
|
2535
|
-
if (fieldToSearch.indexOf('CLASSIFICATION') == -1) {
|
|
2536
|
-
console.log('[INFO] Field not currently managed : ' + fieldToSearch);
|
|
2537
|
-
}
|
|
2538
2721
|
}
|
|
2539
2722
|
if (fieldObject['fieldsGroup']['key'].toString() !== 'p_categories') {
|
|
2540
2723
|
let fieldObjectFields = fieldObject['fields'];
|
|
@@ -2671,8 +2854,13 @@ class DataSheetSVG {
|
|
|
2671
2854
|
this.addStyle(styles, 'padding-right', variant?.padding?.horizontal);
|
|
2672
2855
|
this.addStyle(styles, 'border-width', header?.border?.width);
|
|
2673
2856
|
this.addStyle(styles, 'border-color', header?.border?.color);
|
|
2674
|
-
|
|
2675
|
-
|
|
2857
|
+
const headerFont = header?.text?.font
|
|
2858
|
+
? header.text.font.replace(/['"]/g, '').trim()
|
|
2859
|
+
: 'sans-serif';
|
|
2860
|
+
const headerFontFamily = ['sans-serif', 'serif', 'monospace'].includes(headerFont.toLowerCase())
|
|
2861
|
+
? headerFont
|
|
2862
|
+
: `'${headerFont}', sans-serif`;
|
|
2863
|
+
this.addStyle(styles, 'font-family', headerFontFamily);
|
|
2676
2864
|
this.addStyle(styles, 'font-size', header?.text?.size);
|
|
2677
2865
|
this.addStyle(styles, 'color', header?.text?.color);
|
|
2678
2866
|
this.addStyle(styles, 'font-style', header?.text?.style);
|
|
@@ -3145,7 +3333,7 @@ class DataSheetSVG {
|
|
|
3145
3333
|
}
|
|
3146
3334
|
catch (e) {
|
|
3147
3335
|
val = '';
|
|
3148
|
-
console.
|
|
3336
|
+
console.error('[ERROR QR] ', e);
|
|
3149
3337
|
}
|
|
3150
3338
|
}
|
|
3151
3339
|
// Gestion Barcode
|
|
@@ -3160,7 +3348,7 @@ class DataSheetSVG {
|
|
|
3160
3348
|
}
|
|
3161
3349
|
catch (e) {
|
|
3162
3350
|
val = '';
|
|
3163
|
-
console.
|
|
3351
|
+
console.error('[ERROR Barcode] ', e);
|
|
3164
3352
|
}
|
|
3165
3353
|
}
|
|
3166
3354
|
val =
|
|
@@ -3181,8 +3369,13 @@ class DataSheetSVG {
|
|
|
3181
3369
|
this.addStyle(styles, 'padding-right', variant?.padding?.horizontal);
|
|
3182
3370
|
this.addStyle(styles, 'border-width', body?.border?.width);
|
|
3183
3371
|
this.addStyle(styles, 'border-color', body?.border?.color);
|
|
3184
|
-
|
|
3185
|
-
|
|
3372
|
+
const bodyFont = body?.text?.font
|
|
3373
|
+
? body.text.font.replace(/['"]/g, '').trim()
|
|
3374
|
+
: 'sans-serif';
|
|
3375
|
+
const bodyFontFamily = ['sans-serif', 'serif', 'monospace'].includes(bodyFont.toLowerCase())
|
|
3376
|
+
? bodyFont
|
|
3377
|
+
: `'${bodyFont}', sans-serif`;
|
|
3378
|
+
this.addStyle(styles, 'font-family', bodyFontFamily);
|
|
3186
3379
|
this.addStyle(styles, 'font-size', body?.text?.size);
|
|
3187
3380
|
this.addStyle(styles, 'color', body?.text?.color);
|
|
3188
3381
|
this.addStyle(styles, 'font-style', body?.text?.style);
|
|
@@ -3474,8 +3667,25 @@ class DataSheetSVG {
|
|
|
3474
3667
|
}
|
|
3475
3668
|
try {
|
|
3476
3669
|
// Cas spéciaux
|
|
3477
|
-
|
|
3478
|
-
|
|
3670
|
+
const cleanId = (idVal || field || '')
|
|
3671
|
+
.toLowerCase()
|
|
3672
|
+
.replace(/[\s_-]/g, '');
|
|
3673
|
+
if (cleanId === 'dategeneration' || field === 'publication_date') {
|
|
3674
|
+
const d = new Date();
|
|
3675
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
3676
|
+
const month = String(d.getMonth() + 1).padStart(2, '0');
|
|
3677
|
+
const year = d.getFullYear();
|
|
3678
|
+
newVal = `${day}/${month}/${year}`;
|
|
3679
|
+
return newVal;
|
|
3680
|
+
}
|
|
3681
|
+
if (cleanId === 'datecompletegeneration') {
|
|
3682
|
+
const d = new Date();
|
|
3683
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
3684
|
+
const month = String(d.getMonth() + 1).padStart(2, '0');
|
|
3685
|
+
const year = d.getFullYear();
|
|
3686
|
+
const hours = String(d.getHours()).padStart(2, '0');
|
|
3687
|
+
const minutes = String(d.getMinutes()).padStart(2, '0');
|
|
3688
|
+
newVal = `${day}/${month}/${year} ${hours}:${minutes}`;
|
|
3479
3689
|
return newVal;
|
|
3480
3690
|
}
|
|
3481
3691
|
const attrObj = jRowSku['attributeObject'] || [];
|
|
@@ -3676,7 +3886,6 @@ class DataSheetSVG {
|
|
|
3676
3886
|
}
|
|
3677
3887
|
else if (idVal.toLowerCase().includes('sku images')) {
|
|
3678
3888
|
// TODO
|
|
3679
|
-
console.log('todo');
|
|
3680
3889
|
}
|
|
3681
3890
|
else if (field.includes('skuDiscount')) {
|
|
3682
3891
|
let priceStart = null;
|
|
@@ -4273,8 +4482,9 @@ class DataSheetSVG {
|
|
|
4273
4482
|
const originalTpl = tpl;
|
|
4274
4483
|
tpl = tpl.replace(/>\s+</g, '><');
|
|
4275
4484
|
tpl = tpl.replace(/foreignObject\s*\.cellContent\s*div\s*\{[^}]*max-content[^}]*\}/g, function (match) {
|
|
4276
|
-
return match.replace('max-content', '
|
|
4485
|
+
return match.replace('max-content', '100%');
|
|
4277
4486
|
});
|
|
4487
|
+
tpl = tpl.replace(/foreignObject\s+td\s+div\.wrap\s*\{[^}]*\}/g, 'foreignObject td div.wrap, foreignObject th div.wrap, foreignObject .cellContent { display: flex; flex-direction: column; text-align: inherit; justify-content: inherit; min-height: inherit; align-items: inherit; font-family: inherit !important; width: 100%; }');
|
|
4278
4488
|
let templateVersion = '';
|
|
4279
4489
|
const versionMatch = tpl.match(/data-sp-version=["']([^"']+)["']/);
|
|
4280
4490
|
if (versionMatch) {
|
|
@@ -4375,7 +4585,7 @@ class DataSheetSVG {
|
|
|
4375
4585
|
newVal = await this.GenerateBarcode(tag, newVal);
|
|
4376
4586
|
}
|
|
4377
4587
|
catch (e) {
|
|
4378
|
-
console.
|
|
4588
|
+
console.error('[ERROR] Error generating Barcode: ', e);
|
|
4379
4589
|
newVal = '';
|
|
4380
4590
|
}
|
|
4381
4591
|
}
|
|
@@ -4399,7 +4609,7 @@ class DataSheetSVG {
|
|
|
4399
4609
|
newVal = await this.GenerateQRCode(tag, newVal);
|
|
4400
4610
|
}
|
|
4401
4611
|
catch (e) {
|
|
4402
|
-
console.
|
|
4612
|
+
console.error('[ERROR] Error generating QRCode: ', e);
|
|
4403
4613
|
newVal = '';
|
|
4404
4614
|
}
|
|
4405
4615
|
}
|
|
@@ -4414,7 +4624,7 @@ class DataSheetSVG {
|
|
|
4414
4624
|
newVal = await this.GenerateQRCode(tag, newVal);
|
|
4415
4625
|
}
|
|
4416
4626
|
catch (e) {
|
|
4417
|
-
console.
|
|
4627
|
+
console.error('[ERROR] Error generating QRCode: ', e);
|
|
4418
4628
|
newVal = '';
|
|
4419
4629
|
}
|
|
4420
4630
|
}
|
|
@@ -4433,7 +4643,7 @@ class DataSheetSVG {
|
|
|
4433
4643
|
newVal = await this.GenerateQRCode(tag, newVal);
|
|
4434
4644
|
}
|
|
4435
4645
|
catch (e) {
|
|
4436
|
-
console.
|
|
4646
|
+
console.error('[ERROR] Error generating QRCode: ', e);
|
|
4437
4647
|
newVal = '';
|
|
4438
4648
|
}
|
|
4439
4649
|
}
|
|
@@ -4461,7 +4671,7 @@ class DataSheetSVG {
|
|
|
4461
4671
|
else {
|
|
4462
4672
|
field = this.getPropertyOfField(idVal);
|
|
4463
4673
|
}
|
|
4464
|
-
const tspans = container.querySelectorAll('tspan');
|
|
4674
|
+
const tspans = container.querySelectorAll('tspan, span.textAttribute, [data-type="attribute"]');
|
|
4465
4675
|
let replaced = false;
|
|
4466
4676
|
for (let j = 0; j < tspans.length; j++) {
|
|
4467
4677
|
const tspan = tspans[j];
|
|
@@ -4487,9 +4697,42 @@ class DataSheetSVG {
|
|
|
4487
4697
|
}
|
|
4488
4698
|
let valueToInsert = this.getNewVal(field, rowToUse, idVal, tag, showText === 'true', showPicto === 'true', separator, keepAttributes);
|
|
4489
4699
|
valueToInsert = this.applyTextTransform(valueToInsert, textTransform);
|
|
4700
|
+
const isValEmpty = valueToInsert === null ||
|
|
4701
|
+
valueToInsert === undefined ||
|
|
4702
|
+
(typeof valueToInsert === 'string' &&
|
|
4703
|
+
valueToInsert.trim() === '');
|
|
4704
|
+
if (isValEmpty &&
|
|
4705
|
+
(tspan.hasAttribute('deleteline') ||
|
|
4706
|
+
tspan.getAttribute('deleteline') === 'true' ||
|
|
4707
|
+
tspan.hasAttribute('deleteblock') ||
|
|
4708
|
+
tspan.getAttribute('deleteblock') === 'true')) {
|
|
4709
|
+
let lineDiv = tspan.closest('div');
|
|
4710
|
+
if (lineDiv &&
|
|
4711
|
+
!lineDiv.classList.contains('cellContent') &&
|
|
4712
|
+
!lineDiv.classList.contains('wrap') &&
|
|
4713
|
+
lineDiv.parentElement) {
|
|
4714
|
+
lineDiv.remove();
|
|
4715
|
+
}
|
|
4716
|
+
else {
|
|
4717
|
+
tspan.remove();
|
|
4718
|
+
}
|
|
4719
|
+
replaced = true;
|
|
4720
|
+
if (tag.XmlTag.getAttribute('data-type') !== 'productTable') {
|
|
4721
|
+
break;
|
|
4722
|
+
}
|
|
4723
|
+
continue;
|
|
4724
|
+
}
|
|
4490
4725
|
if (valueToInsert != null &&
|
|
4491
4726
|
innerHTML.includes(placeholder)) {
|
|
4492
|
-
|
|
4727
|
+
let formattedVal = valueToInsert;
|
|
4728
|
+
if (formattedVal &&
|
|
4729
|
+
typeof formattedVal === 'string' &&
|
|
4730
|
+
formattedVal.includes('\n')) {
|
|
4731
|
+
formattedVal = formattedVal
|
|
4732
|
+
.replace(/\r\n/g, '<br/>')
|
|
4733
|
+
.replace(/\n/g, '<br/>');
|
|
4734
|
+
}
|
|
4735
|
+
const newValue = this.replaceDynamicTextInHtml(innerHTML, placeholder, formattedVal);
|
|
4493
4736
|
if (tag.XmlTag.getAttribute('data-type') === 'productTable') {
|
|
4494
4737
|
tspan.insertAdjacentHTML('beforebegin', newValue);
|
|
4495
4738
|
tspan.remove();
|
|
@@ -4499,7 +4742,9 @@ class DataSheetSVG {
|
|
|
4499
4742
|
}
|
|
4500
4743
|
}
|
|
4501
4744
|
replaced = true;
|
|
4502
|
-
|
|
4745
|
+
if (tag.XmlTag.getAttribute('data-type') !== 'productTable') {
|
|
4746
|
+
break;
|
|
4747
|
+
}
|
|
4503
4748
|
}
|
|
4504
4749
|
}
|
|
4505
4750
|
if (!replaced) {
|
|
@@ -4875,9 +5120,6 @@ class DataSheetSVG {
|
|
|
4875
5120
|
let domObjects = dom.querySelectorAll('*');
|
|
4876
5121
|
tag.XmlTag = domObjects[0];
|
|
4877
5122
|
}
|
|
4878
|
-
else {
|
|
4879
|
-
console.log('[DEBUG] Error during newVal for VariantsTable');
|
|
4880
|
-
}
|
|
4881
5123
|
}
|
|
4882
5124
|
else if (tag.Barcode == true || tag.QRCode == true) {
|
|
4883
5125
|
if (newVal != '') {
|
|
@@ -4937,7 +5179,7 @@ class DataSheetSVG {
|
|
|
4937
5179
|
if (tag.XmlTag.hasAttribute('data-type') &&
|
|
4938
5180
|
tag.XmlTag.getAttribute('data-type').includes('productTable')) {
|
|
4939
5181
|
// REPLACE TSPAN VARIABLES IN TABLE CELLS
|
|
4940
|
-
const cellTspans = tag.XmlTag.querySelectorAll('tspan');
|
|
5182
|
+
const cellTspans = tag.XmlTag.querySelectorAll('tspan, span.textAttribute, [data-type="attribute"]');
|
|
4941
5183
|
cellTspans.forEach((tspan) => {
|
|
4942
5184
|
const tspanText = tspan.textContent?.trim() ?? '';
|
|
4943
5185
|
const match = tspanText.match(/^\{\{([\w\W]+?)\}\}$/);
|
|
@@ -4958,22 +5200,94 @@ class DataSheetSVG {
|
|
|
4958
5200
|
const showPicto = tspan.getAttribute('data-show-picto') || 'false';
|
|
4959
5201
|
const separator = tspan.getAttribute('data-separator') || ', ';
|
|
4960
5202
|
const textTransform = tspan.getAttribute('data-text-transform');
|
|
4961
|
-
let cellVal = this.getNewVal(fieldForCell, jRowSku, idVal, tag, showText === 'true', showPicto === 'true', separator, keepAttributes);
|
|
5203
|
+
let cellVal = this.getNewVal(fieldForCell || '', jRowSku, idVal, tag, showText === 'true', showPicto === 'true', separator, keepAttributes);
|
|
4962
5204
|
cellVal = this.applyTextTransform(cellVal, textTransform);
|
|
4963
|
-
const
|
|
4964
|
-
|
|
4965
|
-
|
|
5205
|
+
const isEmpty = cellVal === null ||
|
|
5206
|
+
cellVal === undefined ||
|
|
5207
|
+
(typeof cellVal === 'string' && cellVal.trim() === '');
|
|
5208
|
+
if (isEmpty &&
|
|
5209
|
+
(tspan.hasAttribute('deleteline') ||
|
|
5210
|
+
tspan.getAttribute('deleteline') === 'true' ||
|
|
5211
|
+
tspan.hasAttribute('deleteblock') ||
|
|
5212
|
+
tspan.getAttribute('deleteblock') === 'true')) {
|
|
5213
|
+
let lineDiv = tspan.closest('div');
|
|
5214
|
+
if (lineDiv &&
|
|
5215
|
+
!lineDiv.classList.contains('cellContent') &&
|
|
5216
|
+
!lineDiv.classList.contains('wrap') &&
|
|
5217
|
+
lineDiv.parentElement) {
|
|
5218
|
+
lineDiv.remove();
|
|
5219
|
+
return;
|
|
5220
|
+
}
|
|
5221
|
+
else {
|
|
5222
|
+
tspan.remove();
|
|
5223
|
+
return;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
if (cellVal &&
|
|
5227
|
+
typeof cellVal === 'string' &&
|
|
5228
|
+
cellVal.includes('\n')) {
|
|
5229
|
+
cellVal = cellVal
|
|
5230
|
+
.replace(/\r\n/g, '<br/>')
|
|
5231
|
+
.replace(/\n/g, '<br/>');
|
|
5232
|
+
}
|
|
5233
|
+
if (cellVal &&
|
|
5234
|
+
typeof cellVal === 'string' &&
|
|
5235
|
+
(cellVal.includes('<br') || cellVal.includes('<'))) {
|
|
5236
|
+
const temp = document.createElement('span');
|
|
5237
|
+
temp.innerHTML = cellVal;
|
|
5238
|
+
while (temp.firstChild) {
|
|
5239
|
+
tspan.parentNode?.insertBefore(temp.firstChild, tspan);
|
|
5240
|
+
}
|
|
5241
|
+
tspan.remove();
|
|
5242
|
+
}
|
|
5243
|
+
else {
|
|
5244
|
+
const placeholder = document.createTextNode(cellVal ?? '');
|
|
5245
|
+
tspan.parentNode?.insertBefore(placeholder, tspan);
|
|
5246
|
+
tspan.remove();
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
});
|
|
5250
|
+
// ALSO handle any remaining raw {{attribute}} placeholders in table cells
|
|
5251
|
+
const cells = tag.XmlTag.querySelectorAll('td, th');
|
|
5252
|
+
cells.forEach((cell) => {
|
|
5253
|
+
if (cell.innerHTML && cell.innerHTML.includes('{{')) {
|
|
5254
|
+
cell.innerHTML = cell.innerHTML.replace(/\{\{([\w\W]+?)\}\}/g, (fullMatch, idVal) => {
|
|
5255
|
+
if (idVal.toLowerCase() === 'page' ||
|
|
5256
|
+
idVal.toLowerCase() === 'pagetotal')
|
|
5257
|
+
return fullMatch;
|
|
5258
|
+
let fieldForCell = idVal
|
|
5259
|
+
.toLowerCase()
|
|
5260
|
+
.includes('sku')
|
|
5261
|
+
? this.getPropertyOfField(idVal.replace(/sku/i, ''))
|
|
5262
|
+
: this.getPropertyOfField(idVal);
|
|
5263
|
+
let val = this.getNewVal(fieldForCell || '', jRowSku, idVal, tag, true, false, ', ', keepAttributes);
|
|
5264
|
+
if (val &&
|
|
5265
|
+
typeof val === 'string' &&
|
|
5266
|
+
val.includes('\n')) {
|
|
5267
|
+
val = val
|
|
5268
|
+
.replace(/\r\n/g, '<br/>')
|
|
5269
|
+
.replace(/\n/g, '<br/>');
|
|
5270
|
+
}
|
|
5271
|
+
return val ?? '';
|
|
5272
|
+
});
|
|
4966
5273
|
}
|
|
4967
5274
|
});
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5275
|
+
tag.XmlTag.querySelectorAll('.wrap, .cellContent').forEach((div) => {
|
|
5276
|
+
div.style.setProperty('display', 'flex', 'important');
|
|
5277
|
+
div.style.setProperty('flex-direction', 'column', 'important');
|
|
5278
|
+
div.style.setProperty('width', '100%', 'important');
|
|
5279
|
+
});
|
|
5280
|
+
// Synchronize gap between .wrap and .cellContent if present
|
|
5281
|
+
tag.XmlTag.querySelectorAll('td, th').forEach((cell) => {
|
|
5282
|
+
const wrap = cell.querySelector('.wrap');
|
|
5283
|
+
const cellContent = cell.querySelector('.cellContent');
|
|
5284
|
+
if (wrap && cellContent) {
|
|
5285
|
+
if (cellContent.style.gap && !wrap.style.gap) {
|
|
5286
|
+
wrap.style.gap = cellContent.style.gap;
|
|
5287
|
+
}
|
|
5288
|
+
else if (wrap.style.gap && !cellContent.style.gap) {
|
|
5289
|
+
cellContent.style.gap = wrap.style.gap;
|
|
4975
5290
|
}
|
|
4976
|
-
parent.removeChild(cellContent);
|
|
4977
5291
|
}
|
|
4978
5292
|
});
|
|
4979
5293
|
// FIX THE SIZE (WIDTH & HEIGHT)
|
|
@@ -5007,10 +5321,46 @@ class DataSheetSVG {
|
|
|
5007
5321
|
if (size.width) {
|
|
5008
5322
|
tag.XmlTag.setAttribute('width', String(size.width));
|
|
5009
5323
|
}
|
|
5324
|
+
const tableEl = tag.XmlTag.querySelector('table');
|
|
5325
|
+
const overflowBehavior = tableEl?.getAttribute('data-overflow-behavior') ||
|
|
5326
|
+
tag.XmlTag.getAttribute('data-overflow-behavior') ||
|
|
5327
|
+
tag.overflowBehavior ||
|
|
5328
|
+
this.DataSheet.overflowBehavior ||
|
|
5329
|
+
'none';
|
|
5330
|
+
if (overflowBehavior === 'cut_and_restart') {
|
|
5331
|
+
const tableY = parseFloat(tag.XmlTag.getAttribute('y')) ||
|
|
5332
|
+
(tag.RectPosition ? parseFloat(tag.RectPosition['y']) : 0) ||
|
|
5333
|
+
0;
|
|
5334
|
+
const tableX = parseFloat(tag.XmlTag.getAttribute('x')) ||
|
|
5335
|
+
(tag.RectPosition ? parseFloat(tag.RectPosition['x']) : 0) ||
|
|
5336
|
+
0;
|
|
5337
|
+
const headerHeight = this.DataSheet.publicationTemplateBackgroundHeightHeader || 0;
|
|
5338
|
+
const tableTopOnPage = (allBlocksHeight > 0 ? allBlocksHeight : headerHeight) +
|
|
5339
|
+
tableY;
|
|
5340
|
+
const footerY = this.DataSheet.publicationTemplateBackgroundFooterY > 0
|
|
5341
|
+
? this.DataSheet.publicationTemplateBackgroundFooterY
|
|
5342
|
+
: this.DataSheet.publicationTemplateHeight > 0
|
|
5343
|
+
? this.DataSheet.publicationTemplateHeight -
|
|
5344
|
+
(this.DataSheet.publicationTemplateBackgroundHeightFooter || 0)
|
|
5345
|
+
: this.DataSheet.backgroundHeight > 0
|
|
5346
|
+
? this.DataSheet.backgroundHeight -
|
|
5347
|
+
(this.DataSheet.backgroundMarginBottom || 0)
|
|
5348
|
+
: 1122;
|
|
5349
|
+
const availableFirstHeight = footerY - tableTopOnPage;
|
|
5350
|
+
const fullPageHeight = footerY - headerHeight;
|
|
5351
|
+
if (size.height > availableFirstHeight &&
|
|
5352
|
+
availableFirstHeight > 40) {
|
|
5353
|
+
const splitChunks = this.splitProductTable(tag.XmlTag, size.width, availableFirstHeight, fullPageHeight, tableX, tableY, tpl);
|
|
5354
|
+
if (splitChunks && splitChunks.length > 1) {
|
|
5355
|
+
tag.splitHtml = splitChunks.join('');
|
|
5356
|
+
tag.XmlTag.setAttribute('id', 'tableVariant');
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5010
5360
|
}
|
|
5011
5361
|
}
|
|
5012
5362
|
else {
|
|
5013
|
-
console.
|
|
5363
|
+
console.error('[ERROR] Getting a parameters', newVal);
|
|
5014
5364
|
tag.XmlTag = null;
|
|
5015
5365
|
}
|
|
5016
5366
|
}
|
|
@@ -5214,7 +5564,8 @@ class DataSheetSVG {
|
|
|
5214
5564
|
element.outerHTML = tagToUpdate.XmlTag.outerHTML;
|
|
5215
5565
|
}
|
|
5216
5566
|
else if (tagToUpdate.ProductTable == true) {
|
|
5217
|
-
element.outerHTML =
|
|
5567
|
+
element.outerHTML =
|
|
5568
|
+
tagToUpdate.splitHtml || tagToUpdate.XmlTag.outerHTML;
|
|
5218
5569
|
}
|
|
5219
5570
|
else if (tagToUpdate.Image == true) {
|
|
5220
5571
|
element.innerHTML = tagToUpdate.XmlTag.innerHTML;
|
|
@@ -5264,7 +5615,8 @@ class DataSheetSVG {
|
|
|
5264
5615
|
element.outerHTML = tagToUpdate.XmlTag.outerHTML;
|
|
5265
5616
|
}
|
|
5266
5617
|
else if (tagToUpdate.ProductTable == true) {
|
|
5267
|
-
element.outerHTML =
|
|
5618
|
+
element.outerHTML =
|
|
5619
|
+
tagToUpdate.splitHtml || tagToUpdate.XmlTag.outerHTML;
|
|
5268
5620
|
}
|
|
5269
5621
|
else if (tagToUpdate.Image == true) {
|
|
5270
5622
|
element.innerHTML = tagToUpdate.XmlTag.innerHTML;
|
|
@@ -5287,14 +5639,16 @@ class DataSheetSVG {
|
|
|
5287
5639
|
if (tagToUpdate.XmlTag.hasAttribute('width')) {
|
|
5288
5640
|
const w = tagToUpdate.XmlTag.getAttribute('width');
|
|
5289
5641
|
element.setAttribute('width', w);
|
|
5290
|
-
if (element.style &&
|
|
5642
|
+
if (element.style &&
|
|
5643
|
+
element.style.width) {
|
|
5291
5644
|
element.style.width = w + 'px';
|
|
5292
5645
|
}
|
|
5293
5646
|
}
|
|
5294
5647
|
if (tagToUpdate.XmlTag.hasAttribute('height')) {
|
|
5295
5648
|
const h = tagToUpdate.XmlTag.getAttribute('height');
|
|
5296
5649
|
element.setAttribute('height', h);
|
|
5297
|
-
if (element.style &&
|
|
5650
|
+
if (element.style &&
|
|
5651
|
+
element.style.height) {
|
|
5298
5652
|
element.style.height = h + 'px';
|
|
5299
5653
|
}
|
|
5300
5654
|
}
|
|
@@ -5469,6 +5823,17 @@ class DataSheetSVG {
|
|
|
5469
5823
|
gabaritSvgUpdated = gabaritSvgUpdated.replace(/<body.*?>|<\/body>/g, '');
|
|
5470
5824
|
gabaritSvgUpdated = gabaritSvgUpdated.replace(/<head.*?>|<\/head>/g, '');
|
|
5471
5825
|
tpl = gabaritSvgUpdated;
|
|
5826
|
+
const now = new Date();
|
|
5827
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
5828
|
+
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
5829
|
+
const year = now.getFullYear();
|
|
5830
|
+
const hours = String(now.getHours()).padStart(2, '0');
|
|
5831
|
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
5832
|
+
const dateStr = `${day}/${month}/${year}`;
|
|
5833
|
+
const dateCompleteStr = `${day}/${month}/${year} ${hours}:${minutes}`;
|
|
5834
|
+
tpl = tpl
|
|
5835
|
+
.replace(/\{\{(DateGeneration|Date_Generation|dateGeneration|date_generation)\}\}/gi, dateStr)
|
|
5836
|
+
.replace(/\{\{(DateCompleteGeneration|Date_Complete_Generation|dateCompleteGeneration|date_complete_generation)\}\}/gi, dateCompleteStr);
|
|
5472
5837
|
if (!keepAttributes) {
|
|
5473
5838
|
tpl = tpl.replace(/\{\{(?!(Page|PageTotal)\b)[^}]*\}\}/gi, '');
|
|
5474
5839
|
}
|
|
@@ -5691,15 +6056,23 @@ class DataSheetSVG {
|
|
|
5691
6056
|
document.body.removeChild(tempDiv);
|
|
5692
6057
|
return { width: 0, height: 0 };
|
|
5693
6058
|
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
6059
|
+
tableElement
|
|
6060
|
+
.querySelectorAll('.wrap, .cellContent')
|
|
6061
|
+
.forEach((div) => {
|
|
6062
|
+
div.style.setProperty('display', 'flex', 'important');
|
|
6063
|
+
div.style.setProperty('flex-direction', 'column', 'important');
|
|
6064
|
+
div.style.setProperty('width', '100%', 'important');
|
|
6065
|
+
});
|
|
6066
|
+
tableElement.querySelectorAll('td, th').forEach((cell) => {
|
|
6067
|
+
const wrap = cell.querySelector('.wrap');
|
|
6068
|
+
const cellContent = cell.querySelector('.cellContent');
|
|
6069
|
+
if (wrap && cellContent) {
|
|
6070
|
+
if (cellContent.style.gap && !wrap.style.gap) {
|
|
6071
|
+
wrap.style.gap = cellContent.style.gap;
|
|
6072
|
+
}
|
|
6073
|
+
else if (wrap.style.gap && !cellContent.style.gap) {
|
|
6074
|
+
cellContent.style.gap = wrap.style.gap;
|
|
5701
6075
|
}
|
|
5702
|
-
parent.removeChild(cellContent);
|
|
5703
6076
|
}
|
|
5704
6077
|
});
|
|
5705
6078
|
// 1. Lire le colgroup d'origine pour obtenir les largeurs fixes
|
|
@@ -5790,6 +6163,13 @@ class DataSheetSVG {
|
|
|
5790
6163
|
div.style.setProperty('word-break', 'break-word', 'important');
|
|
5791
6164
|
div.style.setProperty('overflow-wrap', 'break-word', 'important');
|
|
5792
6165
|
});
|
|
6166
|
+
cell
|
|
6167
|
+
.querySelectorAll('div.wrap, .cellContent')
|
|
6168
|
+
.forEach((wrap) => {
|
|
6169
|
+
wrap.style.setProperty('display', 'flex', 'important');
|
|
6170
|
+
wrap.style.setProperty('flex-direction', 'column', 'important');
|
|
6171
|
+
wrap.style.setProperty('width', '100%', 'important');
|
|
6172
|
+
});
|
|
5793
6173
|
}
|
|
5794
6174
|
});
|
|
5795
6175
|
};
|
|
@@ -5868,6 +6248,100 @@ class DataSheetSVG {
|
|
|
5868
6248
|
document.body.removeChild(tempDiv);
|
|
5869
6249
|
return { width: finalWidth, height: finalHeight };
|
|
5870
6250
|
}
|
|
6251
|
+
splitProductTable(foEl, tableWidth, availableFirstHeight, fullPageHeight, tableX, tableY, tpl) {
|
|
6252
|
+
const table = foEl.querySelector('table');
|
|
6253
|
+
if (!table)
|
|
6254
|
+
return [];
|
|
6255
|
+
const tempDiv = document.createElement('div');
|
|
6256
|
+
let stylesHtml = '';
|
|
6257
|
+
if (tpl) {
|
|
6258
|
+
const styleMatches = tpl.match(/<style[^>]*>([\s\S]*?)<\/style>/gi);
|
|
6259
|
+
if (styleMatches) {
|
|
6260
|
+
stylesHtml = styleMatches.join('');
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
if (this.DataSheet.importFontFamily) {
|
|
6264
|
+
stylesHtml += `<style>${this.DataSheet.importFontFamily}</style>`;
|
|
6265
|
+
}
|
|
6266
|
+
const tableClone = table.cloneNode(true);
|
|
6267
|
+
tempDiv.innerHTML = stylesHtml;
|
|
6268
|
+
tempDiv.appendChild(tableClone);
|
|
6269
|
+
tempDiv.style.position = 'absolute';
|
|
6270
|
+
tempDiv.style.visibility = 'hidden';
|
|
6271
|
+
tempDiv.style.pointerEvents = 'none';
|
|
6272
|
+
tempDiv.style.left = '-9999px';
|
|
6273
|
+
tempDiv.style.top = '-9999px';
|
|
6274
|
+
tempDiv.style.width = `${tableWidth}px`;
|
|
6275
|
+
document.body.appendChild(tempDiv);
|
|
6276
|
+
const thead = tableClone.querySelector('thead');
|
|
6277
|
+
const theadHeight = thead ? thead.getBoundingClientRect().height : 0;
|
|
6278
|
+
const theadHtml = thead ? thead.outerHTML : '';
|
|
6279
|
+
const colgroup = tableClone.querySelector('colgroup');
|
|
6280
|
+
const colgroupHtml = colgroup ? colgroup.outerHTML : '';
|
|
6281
|
+
const tableAttrs = [];
|
|
6282
|
+
Array.from(table.attributes).forEach((attr) => {
|
|
6283
|
+
tableAttrs.push(`${attr.name}="${attr.value.replace(/"/g, '"')}"`);
|
|
6284
|
+
});
|
|
6285
|
+
const tableAttrsStr = tableAttrs.join(' ');
|
|
6286
|
+
const tbody = tableClone.querySelector('tbody');
|
|
6287
|
+
const allRows = tbody
|
|
6288
|
+
? Array.from(tbody.querySelectorAll('tr'))
|
|
6289
|
+
: Array.from(tableClone.querySelectorAll('tr')).filter((r) => !thead || !thead.contains(r));
|
|
6290
|
+
if (allRows.length <= 1) {
|
|
6291
|
+
document.body.removeChild(tempDiv);
|
|
6292
|
+
return [];
|
|
6293
|
+
}
|
|
6294
|
+
const rowHeights = allRows.map((row) => {
|
|
6295
|
+
const h = row.getBoundingClientRect().height;
|
|
6296
|
+
return h > 0 ? Math.ceil(h) : 25;
|
|
6297
|
+
});
|
|
6298
|
+
const chunks = [];
|
|
6299
|
+
let currentChunkRows = [];
|
|
6300
|
+
let currentChunkHeight = theadHeight;
|
|
6301
|
+
let currentMaxHeight = availableFirstHeight;
|
|
6302
|
+
for (let idx = 0; idx < allRows.length; idx++) {
|
|
6303
|
+
const row = allRows[idx];
|
|
6304
|
+
const rHeight = rowHeights[idx];
|
|
6305
|
+
if (currentChunkRows.length > 0 &&
|
|
6306
|
+
currentChunkHeight + rHeight > currentMaxHeight) {
|
|
6307
|
+
chunks.push({
|
|
6308
|
+
rows: currentChunkRows,
|
|
6309
|
+
height: currentChunkHeight,
|
|
6310
|
+
});
|
|
6311
|
+
currentChunkRows = [row];
|
|
6312
|
+
currentChunkHeight = theadHeight + rHeight;
|
|
6313
|
+
currentMaxHeight = fullPageHeight;
|
|
6314
|
+
}
|
|
6315
|
+
else {
|
|
6316
|
+
currentChunkRows.push(row);
|
|
6317
|
+
currentChunkHeight += rHeight;
|
|
6318
|
+
}
|
|
6319
|
+
}
|
|
6320
|
+
if (currentChunkRows.length > 0) {
|
|
6321
|
+
chunks.push({
|
|
6322
|
+
rows: currentChunkRows,
|
|
6323
|
+
height: currentChunkHeight,
|
|
6324
|
+
});
|
|
6325
|
+
}
|
|
6326
|
+
document.body.removeChild(tempDiv);
|
|
6327
|
+
if (chunks.length <= 1) {
|
|
6328
|
+
return [];
|
|
6329
|
+
}
|
|
6330
|
+
const foChunks = [];
|
|
6331
|
+
const continuationY = this.DataSheet.publicationTemplateBackgroundHeightHeader || 0;
|
|
6332
|
+
for (let k = 0; k < chunks.length; k++) {
|
|
6333
|
+
const chunk = chunks[k];
|
|
6334
|
+
const rowsHtml = chunk.rows.map((r) => r.outerHTML).join('');
|
|
6335
|
+
const tableHtml = `<table ${tableAttrsStr}>${colgroupHtml}${theadHtml}<tbody>${rowsHtml}</tbody></table>`;
|
|
6336
|
+
const isFirst = k === 0;
|
|
6337
|
+
const posX = tableX;
|
|
6338
|
+
const posY = tableY;
|
|
6339
|
+
const continuationAttr = isFirst ? '' : ' data-split-continuation="true"';
|
|
6340
|
+
const foString = `<foreignObject id="tableVariant" data-type="productTable"${continuationAttr} x="${posX}" y="${posY}" width="${tableWidth}" height="${chunk.height}" style="overflow: visible;">${tableHtml}</foreignObject>`;
|
|
6341
|
+
foChunks.push(foString);
|
|
6342
|
+
}
|
|
6343
|
+
return foChunks;
|
|
6344
|
+
}
|
|
5871
6345
|
async deleteBlock(svg) {
|
|
5872
6346
|
try {
|
|
5873
6347
|
const parser = new DOMParser();
|
|
@@ -5893,11 +6367,14 @@ class DataSheetSVG {
|
|
|
5893
6367
|
const parser = new DOMParser();
|
|
5894
6368
|
const doc = parser.parseFromString(`<wrapper>${svg}</wrapper>`, 'text/html');
|
|
5895
6369
|
const wrapper = doc.body.firstElementChild;
|
|
5896
|
-
const tspans = wrapper.querySelectorAll('tspan[deleteline="true"], TSPAN[deleteline="true"]');
|
|
6370
|
+
const tspans = wrapper.querySelectorAll('[deleteline="true"], [deleteline], tspan[deleteline="true"], TSPAN[deleteline="true"], span[deleteline="true"], SPAN[deleteline="true"]');
|
|
5897
6371
|
tspans.forEach((tspan) => {
|
|
5898
6372
|
if (tspan.textContent.trim() === '') {
|
|
5899
6373
|
const lineDiv = tspan.closest('div');
|
|
5900
|
-
if (lineDiv &&
|
|
6374
|
+
if (lineDiv &&
|
|
6375
|
+
lineDiv !== wrapper.firstElementChild &&
|
|
6376
|
+
!lineDiv.classList.contains('wrap') &&
|
|
6377
|
+
!lineDiv.classList.contains('cellContent')) {
|
|
5901
6378
|
lineDiv.remove();
|
|
5902
6379
|
}
|
|
5903
6380
|
}
|
|
@@ -6614,7 +7091,7 @@ class DataSheetSVG {
|
|
|
6614
7091
|
return null;
|
|
6615
7092
|
}
|
|
6616
7093
|
catch (e) {
|
|
6617
|
-
console.
|
|
7094
|
+
console.error('[ERROR] An error occured during getting url', e);
|
|
6618
7095
|
return null;
|
|
6619
7096
|
}
|
|
6620
7097
|
}
|
|
@@ -6941,6 +7418,7 @@ class DataSheetSku {
|
|
|
6941
7418
|
}
|
|
6942
7419
|
let lstSkuObjects = res?.sku || [];
|
|
6943
7420
|
if (lstSkuObjects == null || lstSkuObjects.length === 0) {
|
|
7421
|
+
console.error('[DATASHEET-GENERATION][DataSheetSku] lstSkuObjects is null or empty for SKU:', sourceId, 'with productSheetGuid:', this.DataSheet.productSheetGuid);
|
|
6944
7422
|
this.DataSheet.currentStep = 99;
|
|
6945
7423
|
return [];
|
|
6946
7424
|
}
|
|
@@ -6969,68 +7447,19 @@ class DataSheetSku {
|
|
|
6969
7447
|
let pages = [];
|
|
6970
7448
|
let background = this.DataSheetSVG.getBackgroundSectionForPreview(section);
|
|
6971
7449
|
let backgroundTpl = background?.svgImage || '';
|
|
7450
|
+
if (!background || !backgroundTpl) {
|
|
7451
|
+
console.error('[DATASHEET-GENERATION][DataSheetSku] Background or SVG image is missing for section:', section, 'background object:', background);
|
|
7452
|
+
}
|
|
7453
|
+
if (backgroundTpl) {
|
|
7454
|
+
this.DataSheetSVG.parseBackgroundSvgDimensions(backgroundTpl);
|
|
7455
|
+
}
|
|
6972
7456
|
let allBackgroundTags = this.DataSheetSVG.GetSvgGroupToReplace(backgroundTpl);
|
|
6973
7457
|
let allElements = this.DataSheetSVG.GetAllTags(backgroundTpl);
|
|
6974
7458
|
let group = false;
|
|
6975
7459
|
allElements?.forEach((element) => {
|
|
6976
7460
|
const tagName = element.tagName?.toLowerCase();
|
|
6977
|
-
if (tagName === 'svg') {
|
|
6978
|
-
// HEADER HEIGHT
|
|
6979
|
-
const attrHeader = element.getAttribute('data-margin-top') ||
|
|
6980
|
-
element.getAttribute('data-header-height') ||
|
|
6981
|
-
element.getAttribute('data-margin-vertical');
|
|
6982
|
-
const parsedHeader = parseFloat(attrHeader);
|
|
6983
|
-
if (!isNaN(parsedHeader)) {
|
|
6984
|
-
this.DataSheet.publicationTemplateBackgroundHeightHeader =
|
|
6985
|
-
parsedHeader;
|
|
6986
|
-
}
|
|
6987
|
-
else {
|
|
6988
|
-
this.DataSheet.publicationTemplateBackgroundHeightHeader = 0;
|
|
6989
|
-
}
|
|
6990
|
-
// FOOTER HEIGHT
|
|
6991
|
-
const attrFooter = element.getAttribute('data-margin-bottom') ||
|
|
6992
|
-
element.getAttribute('data-footer-height') ||
|
|
6993
|
-
element.getAttribute('data-margin-vertical');
|
|
6994
|
-
const parsedFooter = parseFloat(attrFooter);
|
|
6995
|
-
if (!isNaN(parsedFooter)) {
|
|
6996
|
-
this.DataSheet.publicationTemplateBackgroundHeightFooter =
|
|
6997
|
-
parsedFooter;
|
|
6998
|
-
this.DataSheet.publicationTemplateBackgroundFooterY =
|
|
6999
|
-
this.DataSheet.publicationTemplateHeight - parsedFooter;
|
|
7000
|
-
}
|
|
7001
|
-
else {
|
|
7002
|
-
this.DataSheet.publicationTemplateBackgroundHeightFooter = 0;
|
|
7003
|
-
this.DataSheet.publicationTemplateBackgroundFooterY =
|
|
7004
|
-
this.DataSheet.publicationTemplateHeight;
|
|
7005
|
-
}
|
|
7006
|
-
// MARGIN
|
|
7007
|
-
const attrMarginLeft = element.getAttribute('data-margin-left') ||
|
|
7008
|
-
element.getAttribute('data-margin-horizontal');
|
|
7009
|
-
const attrMarginRight = element.getAttribute('data-margin-right') ||
|
|
7010
|
-
element.getAttribute('data-margin-horizontal');
|
|
7011
|
-
const parsedMarginLeft = parseFloat(attrMarginLeft);
|
|
7012
|
-
if (!isNaN(parsedMarginLeft)) {
|
|
7013
|
-
this.DataSheet.publicationTemplateBackgroundLeftMargin =
|
|
7014
|
-
parsedMarginLeft;
|
|
7015
|
-
}
|
|
7016
|
-
else {
|
|
7017
|
-
this.DataSheet.publicationTemplateBackgroundLeftMargin = 0;
|
|
7018
|
-
}
|
|
7019
|
-
const parsedMarginRight = parseFloat(attrMarginRight);
|
|
7020
|
-
if (!isNaN(parsedMarginRight)) {
|
|
7021
|
-
this.DataSheet.publicationTemplateBackgroundRightMargin =
|
|
7022
|
-
parsedMarginRight;
|
|
7023
|
-
this.DataSheet.publicationTemplateBackgroundMarginX =
|
|
7024
|
-
this.DataSheet.publicationTemplateWidth - parsedMarginRight;
|
|
7025
|
-
}
|
|
7026
|
-
else {
|
|
7027
|
-
this.DataSheet.publicationTemplateBackgroundRightMargin = 0;
|
|
7028
|
-
this.DataSheet.publicationTemplateBackgroundMarginX =
|
|
7029
|
-
this.DataSheet.publicationTemplateWidth;
|
|
7030
|
-
}
|
|
7031
|
-
}
|
|
7032
7461
|
// GROUPE <g>
|
|
7033
|
-
|
|
7462
|
+
if (tagName === 'g') {
|
|
7034
7463
|
group = true;
|
|
7035
7464
|
const tag = this.DataSheetSVG.SetAllInfos(element);
|
|
7036
7465
|
lstBackgroundTags.push(tag);
|
|
@@ -7096,19 +7525,46 @@ class DataSheetSku {
|
|
|
7096
7525
|
const pageConfig = pagesConfigs[p];
|
|
7097
7526
|
let currentBackgroundTpl = backgroundTpl;
|
|
7098
7527
|
if (pageConfig) {
|
|
7099
|
-
|
|
7100
|
-
|
|
7528
|
+
const bgGuid = pageConfig.backgroundGuid || pageConfig.background;
|
|
7529
|
+
let bg = null;
|
|
7530
|
+
if (bgGuid) {
|
|
7531
|
+
const cleanBg = String(bgGuid).trim().toLowerCase();
|
|
7532
|
+
bg = (this.DataSheet.backgrounds || []).find((b) => (b.guid && String(b.guid).toLowerCase() === cleanBg) ||
|
|
7533
|
+
(b.name && String(b.name).toLowerCase() === cleanBg) ||
|
|
7534
|
+
(b.nameNoSvg && String(b.nameNoSvg).toLowerCase() === cleanBg) ||
|
|
7535
|
+
(b.name && String(b.name).toLowerCase().replace('.svg', '') === cleanBg.replace('.svg', '')));
|
|
7101
7536
|
if (bg && bg.svgImage) {
|
|
7102
7537
|
currentBackgroundTpl = bg.svgImage;
|
|
7103
7538
|
}
|
|
7104
7539
|
}
|
|
7105
|
-
|
|
7106
|
-
|
|
7540
|
+
const gabGuid = pageConfig.gabaritGuid || pageConfig.gabarit;
|
|
7541
|
+
let gab = null;
|
|
7542
|
+
if (gabGuid) {
|
|
7543
|
+
const cleanGab = String(gabGuid).trim().toLowerCase();
|
|
7544
|
+
gab = (this.DataSheet.gabarits || []).find((g) => (g.guid && String(g.guid).toLowerCase() === cleanGab) ||
|
|
7545
|
+
(g.name && String(g.name).toLowerCase() === cleanGab) ||
|
|
7546
|
+
(g.nameNoSvg && String(g.nameNoSvg).toLowerCase() === cleanGab) ||
|
|
7547
|
+
(g.name && String(g.name).toLowerCase().replace('.svg', '') === cleanGab.replace('.svg', '')));
|
|
7548
|
+
if (gab) {
|
|
7549
|
+
this.DataSheet.defaultGabaritGuid = gab.guid || gab.name;
|
|
7550
|
+
}
|
|
7551
|
+
else {
|
|
7552
|
+
this.DataSheet.defaultGabaritGuid = gabGuid;
|
|
7553
|
+
}
|
|
7107
7554
|
}
|
|
7108
7555
|
}
|
|
7556
|
+
if (currentBackgroundTpl) {
|
|
7557
|
+
this.DataSheetSVG.parseBackgroundSvgDimensions(currentBackgroundTpl);
|
|
7558
|
+
}
|
|
7109
7559
|
let i = 0;
|
|
7110
7560
|
for (const jObject of lstSkus) {
|
|
7111
7561
|
let aJobject = [];
|
|
7562
|
+
if (pageConfig) {
|
|
7563
|
+
const gabGuid = pageConfig.gabaritGuid || pageConfig.gabarit;
|
|
7564
|
+
if (gabGuid) {
|
|
7565
|
+
jObject.gabaritName = this.DataSheet.defaultGabaritGuid;
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7112
7568
|
aJobject.push(jObject);
|
|
7113
7569
|
if (jObject && jObject.type === PublicationDataType.CALLOUT) {
|
|
7114
7570
|
const cGuid = jObject.publicationDataCallout ||
|
|
@@ -7141,7 +7597,7 @@ class DataSheetSku {
|
|
|
7141
7597
|
return arrayFiles;
|
|
7142
7598
|
}
|
|
7143
7599
|
catch (e) {
|
|
7144
|
-
console.
|
|
7600
|
+
console.error('[ERROR] Error in GenerateAllInOneExportFile:', e);
|
|
7145
7601
|
return null;
|
|
7146
7602
|
}
|
|
7147
7603
|
}
|
|
@@ -7198,7 +7654,6 @@ class DataSheetPublication {
|
|
|
7198
7654
|
else {
|
|
7199
7655
|
sections = [];
|
|
7200
7656
|
if (sections.length == 0) {
|
|
7201
|
-
console.log('[PUBLICATIONS] No pages detected try to get pages');
|
|
7202
7657
|
if (!this.publicationsService) {
|
|
7203
7658
|
throw new Error('PublicationsService instance is required');
|
|
7204
7659
|
}
|
|
@@ -7252,7 +7707,7 @@ class DataSheetPublication {
|
|
|
7252
7707
|
.toPromise();
|
|
7253
7708
|
let skus = res?.['skus'];
|
|
7254
7709
|
if (!Array.isArray(skus)) {
|
|
7255
|
-
console.
|
|
7710
|
+
console.error('[ERROR] No SKUs found for this page:', section.pageId);
|
|
7256
7711
|
skus = [];
|
|
7257
7712
|
}
|
|
7258
7713
|
for (let sku of skus) {
|
|
@@ -7769,7 +8224,7 @@ class DataSheetPublication {
|
|
|
7769
8224
|
return arrayFiles;
|
|
7770
8225
|
}
|
|
7771
8226
|
catch (e) {
|
|
7772
|
-
console.
|
|
8227
|
+
console.error('[ERROR] Error in GenerateAllInOneExportFilePublication:', e);
|
|
7773
8228
|
return null;
|
|
7774
8229
|
}
|
|
7775
8230
|
}
|
|
@@ -7939,18 +8394,37 @@ class DataSheetController {
|
|
|
7939
8394
|
}
|
|
7940
8395
|
let publication = null;
|
|
7941
8396
|
let templateGuid = '00000000-0000-0000-0000-000000000000';
|
|
7942
|
-
if (source == 2) {
|
|
8397
|
+
if (source == 2 || source == 7) {
|
|
8398
|
+
const pubGuid = source == 2 ? json.sourceGuid : json.publicationGuid;
|
|
7943
8399
|
publication = json.publication;
|
|
7944
8400
|
if (publication == null || publication == undefined) {
|
|
7945
|
-
|
|
7946
|
-
.
|
|
7947
|
-
|
|
7948
|
-
|
|
8401
|
+
try {
|
|
8402
|
+
const res = await this._publicationsService
|
|
8403
|
+
.getPublication(pubGuid)
|
|
8404
|
+
.toPromise();
|
|
8405
|
+
publication = res?.['publication'];
|
|
8406
|
+
}
|
|
8407
|
+
catch (e) {
|
|
8408
|
+
console.error('Error fetching publication info for datasheet generation:', e);
|
|
8409
|
+
}
|
|
7949
8410
|
}
|
|
7950
8411
|
if (publication) {
|
|
7951
|
-
dataSheet.
|
|
7952
|
-
|
|
7953
|
-
|
|
8412
|
+
if (!dataSheet.productSheetGuid &&
|
|
8413
|
+
(publication.publicationProductSheetGuid ||
|
|
8414
|
+
publication.publicationproductsheetguid ||
|
|
8415
|
+
publication.publicationProductSheetAssetGuid ||
|
|
8416
|
+
publication.publicationproductsheetassetguid)) {
|
|
8417
|
+
dataSheet.productSheetGuid =
|
|
8418
|
+
publication.publicationProductSheetGuid ||
|
|
8419
|
+
publication.publicationproductsheetguid ||
|
|
8420
|
+
publication.publicationProductSheetAssetGuid ||
|
|
8421
|
+
publication.publicationproductsheetassetguid;
|
|
8422
|
+
}
|
|
8423
|
+
if (source == 2) {
|
|
8424
|
+
dataSheet.currentObjectName = publication.publicationName;
|
|
8425
|
+
startPageNumber = publication.startPageNumber || 1;
|
|
8426
|
+
dataSheet.leftPage = publication.publicationPageStartLeft === true;
|
|
8427
|
+
}
|
|
7954
8428
|
if (dataSheet.language == null ||
|
|
7955
8429
|
dataSheet.language === '' ||
|
|
7956
8430
|
dataSheet.language === undefined) {
|
|
@@ -7969,16 +8443,29 @@ class DataSheetController {
|
|
|
7969
8443
|
dataSheet.priceListGuid = '00000000-0000-0000-0000-000000000000';
|
|
7970
8444
|
}
|
|
7971
8445
|
}
|
|
8446
|
+
if (publication.publicationTemplateGuid) {
|
|
8447
|
+
templateGuid = publication.publicationTemplateGuid;
|
|
8448
|
+
}
|
|
8449
|
+
const pubPages = publication.publicationPages ||
|
|
8450
|
+
publication.PublicationPages ||
|
|
8451
|
+
publication._publicationPages ||
|
|
8452
|
+
[];
|
|
8453
|
+
if ((!dataSheet.pagesSettings || dataSheet.pagesSettings.length === 0) &&
|
|
8454
|
+
pubPages.length > 0) {
|
|
8455
|
+
dataSheet.pagesSettings = pubPages.map((page) => ({
|
|
8456
|
+
backgroundGuid: page.background ||
|
|
8457
|
+
page.publicationpagebackground ||
|
|
8458
|
+
page.backgroundGuid,
|
|
8459
|
+
gabaritGuid: page.gabarit ||
|
|
8460
|
+
page.publicationpagedefaultgabarit ||
|
|
8461
|
+
page.gabaritGuid,
|
|
8462
|
+
order: page.order || page.publicationpageorder || 0,
|
|
8463
|
+
}));
|
|
8464
|
+
}
|
|
7972
8465
|
}
|
|
7973
|
-
// Template
|
|
7974
|
-
templateGuid =
|
|
7975
|
-
publication.publicationTemplateGuid ||
|
|
7976
|
-
'00000000-0000-0000-0000-000000000000';
|
|
7977
8466
|
}
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
templateGuid = json.templateGuid;
|
|
7981
|
-
}
|
|
8467
|
+
if (json.templateGuid) {
|
|
8468
|
+
templateGuid = json.templateGuid;
|
|
7982
8469
|
}
|
|
7983
8470
|
dataSheet.publicationTemplateTemplateGuid = templateGuid;
|
|
7984
8471
|
if (dataSheet.defaultGabaritGuid == null ||
|
|
@@ -8017,12 +8504,14 @@ class DataSheetController {
|
|
|
8017
8504
|
if (dataSheet.gabarits == null ||
|
|
8018
8505
|
dataSheet.gabarits == undefined ||
|
|
8019
8506
|
dataSheet.gabarits.length === 0) {
|
|
8507
|
+
console.error('[DATASHEET-GENERATION][ERROR] Gabarits is empty for templateGuid:', templateGuid);
|
|
8020
8508
|
dataSheet.currentStep = 99;
|
|
8021
8509
|
return [];
|
|
8022
8510
|
}
|
|
8023
8511
|
if (dataSheet.backgrounds == null ||
|
|
8024
8512
|
dataSheet.backgrounds == undefined ||
|
|
8025
8513
|
dataSheet.backgrounds.length === 0) {
|
|
8514
|
+
console.error('[DATASHEET-GENERATION][ERROR] Backgrounds is empty for templateGuid:', templateGuid);
|
|
8026
8515
|
dataSheet.currentStep = 99;
|
|
8027
8516
|
return [];
|
|
8028
8517
|
}
|
|
@@ -8100,6 +8589,13 @@ class DataSheetController {
|
|
|
8100
8589
|
files = await dataSheetSku.GenerateAllInOneExportFile(json.sourceGuid, json.option1PerPage, displayModeVariant, json.multiColumns);
|
|
8101
8590
|
dataSheetSku = null;
|
|
8102
8591
|
break;
|
|
8592
|
+
case 7: // Datasheet (Publication Datasheet SKU)
|
|
8593
|
+
let dataSheet7 = new DataSheetSku(dataSheetSVG, dataSheet);
|
|
8594
|
+
dataSheet7.setDataSheetsController(this);
|
|
8595
|
+
dataSheet7.setPublicationsService(this._publicationsService);
|
|
8596
|
+
files = await dataSheet7.GenerateAllInOneExportFile(json.sourceGuid, json.option1PerPage, displayModeVariant, json.multiColumns);
|
|
8597
|
+
dataSheet7 = null;
|
|
8598
|
+
break;
|
|
8103
8599
|
case 4: // Variants
|
|
8104
8600
|
for (let sourceGuid of sourceGuids) {
|
|
8105
8601
|
dataSheet.progress = 25;
|
|
@@ -8119,7 +8615,7 @@ class DataSheetController {
|
|
|
8119
8615
|
dataSheet.currentStep = 3;
|
|
8120
8616
|
if (files == null || files == undefined || files.length === 0) {
|
|
8121
8617
|
dataSheet.currentStep = 99;
|
|
8122
|
-
console.
|
|
8618
|
+
console.error('[ERROR] Files is null or undefined or empty');
|
|
8123
8619
|
return [];
|
|
8124
8620
|
}
|
|
8125
8621
|
if (dataSheet.preview) {
|