@momentumcms/server-express 0.1.10 → 0.2.0
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/CHANGELOG.md +4 -0
- package/index.cjs +29 -2
- package/index.js +29 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.cjs
CHANGED
|
@@ -319,12 +319,26 @@ var ReferentialIntegrityError = class extends Error {
|
|
|
319
319
|
this.constraint = constraint;
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
|
+
function isNamedTab(tab) {
|
|
323
|
+
return typeof tab.name === "string" && tab.name.length > 0;
|
|
324
|
+
}
|
|
322
325
|
function flattenDataFields(fields) {
|
|
323
326
|
const result = [];
|
|
324
327
|
for (const field of fields) {
|
|
325
328
|
if (field.type === "tabs") {
|
|
326
329
|
for (const tab of field.tabs) {
|
|
327
|
-
|
|
330
|
+
if (isNamedTab(tab)) {
|
|
331
|
+
const syntheticGroup = {
|
|
332
|
+
name: tab.name,
|
|
333
|
+
type: "group",
|
|
334
|
+
label: tab.label,
|
|
335
|
+
description: tab.description,
|
|
336
|
+
fields: tab.fields
|
|
337
|
+
};
|
|
338
|
+
result.push(syntheticGroup);
|
|
339
|
+
} else {
|
|
340
|
+
result.push(...flattenDataFields(tab.fields));
|
|
341
|
+
}
|
|
328
342
|
}
|
|
329
343
|
} else if (field.type === "collapsible" || field.type === "row") {
|
|
330
344
|
result.push(...flattenDataFields(field.fields));
|
|
@@ -813,7 +827,20 @@ async function runFieldHooks(hookType, fields, data, req, operation) {
|
|
|
813
827
|
for (const field of fields) {
|
|
814
828
|
if (field.type === "tabs") {
|
|
815
829
|
for (const tab of field.tabs) {
|
|
816
|
-
|
|
830
|
+
if (isNamedTab(tab)) {
|
|
831
|
+
const nested = processedData[tab.name];
|
|
832
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
833
|
+
processedData[tab.name] = await runFieldHooks(
|
|
834
|
+
hookType,
|
|
835
|
+
tab.fields,
|
|
836
|
+
nested,
|
|
837
|
+
req,
|
|
838
|
+
operation
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
processedData = await runFieldHooks(hookType, tab.fields, processedData, req, operation);
|
|
843
|
+
}
|
|
817
844
|
}
|
|
818
845
|
continue;
|
|
819
846
|
}
|
package/index.js
CHANGED
|
@@ -271,12 +271,26 @@ var ReferentialIntegrityError = class extends Error {
|
|
|
271
271
|
this.constraint = constraint;
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
+
function isNamedTab(tab) {
|
|
275
|
+
return typeof tab.name === "string" && tab.name.length > 0;
|
|
276
|
+
}
|
|
274
277
|
function flattenDataFields(fields) {
|
|
275
278
|
const result = [];
|
|
276
279
|
for (const field of fields) {
|
|
277
280
|
if (field.type === "tabs") {
|
|
278
281
|
for (const tab of field.tabs) {
|
|
279
|
-
|
|
282
|
+
if (isNamedTab(tab)) {
|
|
283
|
+
const syntheticGroup = {
|
|
284
|
+
name: tab.name,
|
|
285
|
+
type: "group",
|
|
286
|
+
label: tab.label,
|
|
287
|
+
description: tab.description,
|
|
288
|
+
fields: tab.fields
|
|
289
|
+
};
|
|
290
|
+
result.push(syntheticGroup);
|
|
291
|
+
} else {
|
|
292
|
+
result.push(...flattenDataFields(tab.fields));
|
|
293
|
+
}
|
|
280
294
|
}
|
|
281
295
|
} else if (field.type === "collapsible" || field.type === "row") {
|
|
282
296
|
result.push(...flattenDataFields(field.fields));
|
|
@@ -765,7 +779,20 @@ async function runFieldHooks(hookType, fields, data, req, operation) {
|
|
|
765
779
|
for (const field of fields) {
|
|
766
780
|
if (field.type === "tabs") {
|
|
767
781
|
for (const tab of field.tabs) {
|
|
768
|
-
|
|
782
|
+
if (isNamedTab(tab)) {
|
|
783
|
+
const nested = processedData[tab.name];
|
|
784
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
785
|
+
processedData[tab.name] = await runFieldHooks(
|
|
786
|
+
hookType,
|
|
787
|
+
tab.fields,
|
|
788
|
+
nested,
|
|
789
|
+
req,
|
|
790
|
+
operation
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
processedData = await runFieldHooks(hookType, tab.fields, processedData, req, operation);
|
|
795
|
+
}
|
|
769
796
|
}
|
|
770
797
|
continue;
|
|
771
798
|
}
|