nextjs-cms 0.5.88 → 0.5.90
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.
|
@@ -408,10 +408,10 @@ export const deleteSectionItem = async (session, sectionName, sectionItemId, rec
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
411
|
-
*
|
|
411
|
+
* Delete the rows from the destination table if they exist
|
|
412
412
|
*/
|
|
413
|
-
const
|
|
414
|
-
for (const fieldConfig of
|
|
413
|
+
const fieldsWithDestinationDbTable = section.fieldConfigs.filter((fieldConfig) => ['select_multiple', 'select', 'tags'].includes(fieldConfig.type));
|
|
414
|
+
for (const fieldConfig of fieldsWithDestinationDbTable) {
|
|
415
415
|
const field = fieldConfig.build();
|
|
416
416
|
if (field.destinationDb) {
|
|
417
417
|
const columns = await MysqlTableChecker.getColumns(field.destinationDb.table);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldFactory.d.ts","sourceRoot":"","sources":["../../../src/core/factories/FieldFactory.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,KAAK,eAAe,GACd;IACI,IAAI,EAAE,KAAK,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,KAAK,CAAA;CACjB,GACD;IACI,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CAC1B,CAAA;AAEP,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,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AAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAY;IAEjD;;OAEG;gBACS,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,eAAe;IASnE;;OAEG;IACU,UAAU;YAUT,aAAa;YASb,qBAAqB;IAwFnC;;;;OAIG;YACW,qBAAqB;IAuCnC;;;;OAIG;YACW,cAAc;IAuB5B;;;;;OAKG;YACW,YAAY;IAiB1B,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACU,cAAc;IAqB3B;;;OAGG;IACH,OAAO,CAAC,UAAU;IA4ElB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;;OAGG;IACI,gBAAgB;;;;;;;;;;;;;;;IAmEvB,IAAI,WAAW,IAAI,OAAO,GAAG,SAAS,CAErC;IACD,IAAI,YAAY,IAAI,MAAM,CAEzB;IACD,IAAI,KAAK,IAAI,OAAO,CAEnB;CACJ"}
|
|
@@ -2,7 +2,7 @@ import { sql } from 'drizzle-orm';
|
|
|
2
2
|
import { db } from '../../db/client.js';
|
|
3
3
|
import { SectionFactory } from './SectionFactory.js';
|
|
4
4
|
import { SimpleSection, HasItemsSection, CategorySection } from '../sections/index.js';
|
|
5
|
-
import { checkboxField, SelectField, SelectMultipleField } from '../fields/index.js';
|
|
5
|
+
import { checkboxField, SelectField, SelectMultipleField, TagsField } from '../fields/index.js';
|
|
6
6
|
import { is } from '../helpers/index.js';
|
|
7
7
|
import { cloneDeep } from 'lodash-es';
|
|
8
8
|
import chalk from 'chalk';
|
|
@@ -96,6 +96,21 @@ export class FieldFactory {
|
|
|
96
96
|
}
|
|
97
97
|
this._values[field.name] = values;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Handle TagsField with destinationDb
|
|
101
|
+
* Tags are raw string values stored directly in the destination table (no JOIN needed)
|
|
102
|
+
*/
|
|
103
|
+
if (field.destinationDb && is(field, TagsField)) {
|
|
104
|
+
const [_rows] = await db.execute(sql `SELECT ${sql.raw(field.destinationDb.selectIdentifier)} FROM ${sql.raw(field.destinationDb.table)} WHERE ${sql.raw(field.destinationDb.itemIdentifier)} = ${this.itemId}`);
|
|
105
|
+
const tags = [];
|
|
106
|
+
if (Array.isArray(_rows)) {
|
|
107
|
+
for (const row of _rows) {
|
|
108
|
+
tags.push(row[field.destinationDb.selectIdentifier]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Tags are stored as comma-separated string in the field value
|
|
112
|
+
this._values[field.name] = tags.join(',');
|
|
113
|
+
}
|
|
99
114
|
}
|
|
100
115
|
/**
|
|
101
116
|
* If the section item is not found, set the `_error` property to true
|