rerobe-js-orm 3.3.1 → 3.3.3

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.
@@ -15,7 +15,10 @@ export default class Product extends Base {
15
15
  updateSelfFromTranslatedTextArray(translatedTextArray?: string[]): void;
16
16
  autoCreateTitle(): string;
17
17
  autoCreateMetaDataTitle(): string;
18
- autoCreateDescriptionHTML(): string;
18
+ autoCreateDescriptionHTML(t?: (text: string) => string, additionalSections?: {
19
+ title: string;
20
+ attributes: string[];
21
+ }[]): string;
19
22
  autoCreateMetaDescription(): string;
20
23
  generateSchemaForTypesense(name?: string): {
21
24
  default_sorting_field: string;
@@ -454,28 +454,82 @@ class Product extends Base_1.default {
454
454
  }
455
455
  return this.utilities.capitalizeString(result).trim();
456
456
  }
457
- autoCreateDescriptionHTML() {
457
+ autoCreateDescriptionHTML(t = (str) => str, additionalSections = []) {
458
458
  var _a;
459
- const { color, productStyle, condition } = this.filterAttributes;
459
+ const { compareAtPrice } = this.attributes;
460
+ const { color, productCategory, productType, productStyle, condition, size, gender } = this.filterAttributes;
461
+ const { productRemarks, conditionRemarks, purchasePrice, yearPurchased, sizeComment, majorDefects, minorDefects } = this.consignmentAttributes;
460
462
  const measurements = this.measurementsJoinedString(this.filterAttributes.measurements);
461
- const { productRemarks, conditionRemarks, purchasePrice, yearPurchased, sizeComment } = this.consignmentAttributes;
462
463
  const materials = this.materialCompJoinedString();
463
464
  const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
464
465
  const joinedProductStyle = productStyle.join(', ');
465
- const attributesList = [
466
- fit && `<li>Fit: ${fit}</li>`,
467
- condition && `<li>Condition: ${condition}</li>`,
468
- conditionRemarks && `<li>Condition Remarks: ${conditionRemarks}</li>`,
469
- color && `<li>Color: ${color}</li>`,
470
- productStyle.length > 0 && `<li>Style: ${joinedProductStyle}</li>`,
471
- materials && `<li>Material: ${materials}</li>`,
472
- measurements && `<li>Measurements: ${measurements}</li>`,
473
- productRemarks && `<li>Remarks: ${productRemarks}</li>`,
474
- purchasePrice && `<li>Purchase price: ${purchasePrice}</li>`,
475
- yearPurchased && `<li>Year purchased: ${yearPurchased}</li>`,
476
- ].filter(Boolean); // Removes any falsey values
477
- const descriptionHTML = attributesList.length > 0 ? `<ul>\n${attributesList.join('\n')}\n</ul>` : '';
478
- return this.attributes.description + (descriptionHTML ? `\n${descriptionHTML}` : '');
466
+ const joinedMajorDefects = majorDefects.join(', ');
467
+ const joinedMinorDefects = minorDefects.join(', ');
468
+ // Group the base attributes
469
+ const baseAttributeSections = [
470
+ {
471
+ title: 'Product Details',
472
+ attributes: [
473
+ productCategory && `${t('Category')}: ${t(productCategory)}`,
474
+ productType && `${t('Type')}: ${t(productType)}`,
475
+ size && `${t('Size')}: ${t(size)}`,
476
+ gender && `${t('Gender')}: ${t(gender)}`,
477
+ ].filter(Boolean),
478
+ },
479
+ {
480
+ title: 'Style & Condition',
481
+ attributes: [
482
+ fit && `${t('Fit')}: ${t(fit)}`,
483
+ condition && `${t('Condition')}: ${t(condition)}`,
484
+ conditionRemarks && `${t('Condition Remarks')}: ${t(conditionRemarks)}`,
485
+ color && `${t('Color')}: ${t(color)}`,
486
+ productStyle.length > 0 && `${t('Style')}: ${t(joinedProductStyle)}`,
487
+ ].filter(Boolean),
488
+ },
489
+ {
490
+ title: 'Material & Measurements',
491
+ attributes: [
492
+ materials && `${t('Material')}: ${t(materials)}`,
493
+ measurements && `${t('Measurements')}: ${t(measurements)}`,
494
+ ].filter(Boolean),
495
+ },
496
+ {
497
+ title: 'Purchase Details',
498
+ attributes: [
499
+ compareAtPrice && `${t('Original price')}: ${t(purchasePrice)}`,
500
+ purchasePrice && `${t('Purchase price')}: ${t(purchasePrice)}`,
501
+ yearPurchased && `${t('Year purchased')}: ${t(yearPurchased)}`,
502
+ ].filter(Boolean),
503
+ },
504
+ {
505
+ title: 'Additional Remarks',
506
+ attributes: [
507
+ productRemarks && `${t('Remarks')}: ${t(productRemarks)}`,
508
+ majorDefects.length > 0 && `${t('Major Defects')}: ${t(joinedMajorDefects)}`,
509
+ minorDefects.length > 0 && `${t('Minor Defects')}: ${t(joinedMinorDefects)}`,
510
+ ].filter(Boolean),
511
+ },
512
+ ];
513
+ let descriptionHTML = '';
514
+ // Generate HTML for base attribute sections
515
+ baseAttributeSections.forEach((section) => {
516
+ const sectionHTML = section.attributes
517
+ .map((attribute) => (attribute ? `<li>${attribute}</li>` : ''))
518
+ .filter(Boolean) // Removes any falsey values
519
+ .join('\n');
520
+ descriptionHTML += sectionHTML ? `<strong>${t(section.title)}</strong>\n<ul>\n${sectionHTML}\n</ul>` : '';
521
+ });
522
+ // Generate HTML for additional sections
523
+ additionalSections.forEach((section) => {
524
+ if (section.title && section.attributes && section.attributes.length > 0) {
525
+ const sectionHTML = section.attributes
526
+ .map((attribute) => (attribute ? `<li>${t(attribute)}</li>` : ''))
527
+ .filter(Boolean) // Removes any falsey values
528
+ .join('\n');
529
+ descriptionHTML += sectionHTML ? `<strong>${t(section.title)}</strong>\n<ul>\n${sectionHTML}\n</ul>` : '';
530
+ }
531
+ });
532
+ return t(this.attributes.description) + (descriptionHTML ? `\n${descriptionHTML}` : '');
479
533
  }
480
534
  autoCreateMetaDescription() {
481
535
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",