@webiny/app-headless-cms 6.5.0-beta.1 → 6.5.0-beta.11

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.
Files changed (202) hide show
  1. package/ContentEntriesModule.js +14 -2
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  4. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  5. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  6. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  10. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  11. package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
  12. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +84 -0
  13. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
  14. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  15. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  16. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  17. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  18. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  19. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  20. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  21. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  22. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  23. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  24. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  25. package/admin/components/FieldEditor/Field.js +4 -4
  26. package/admin/components/FieldEditor/Field.js.map +1 -1
  27. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  28. package/features/contentEntry/CmsEntryError.js +11 -0
  29. package/features/contentEntry/CmsEntryError.js.map +1 -0
  30. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  31. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  32. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  33. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  34. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  35. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  36. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  37. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  38. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  39. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  40. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  41. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  42. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  43. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  44. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  45. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  46. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  47. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  48. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  49. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  50. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  51. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  52. package/features/contentEntry/entryValueGateways.test.js +106 -0
  53. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  54. package/features/contentEntry/feature.js +2 -0
  55. package/features/contentEntry/feature.js.map +1 -1
  56. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  57. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  58. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  59. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  60. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  61. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  62. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  63. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  64. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  65. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  66. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  67. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  68. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  69. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  70. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  71. package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
  72. package/features/formModel/CmsFormModelBuilder.js +26 -15
  73. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  74. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  75. package/features/formModel/CmsFormModelBuilder.test.js +252 -0
  76. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  77. package/features/formModel/CmsLayoutMapper.d.ts +8 -1
  78. package/features/formModel/CmsLayoutMapper.js +23 -1
  79. package/features/formModel/CmsLayoutMapper.js.map +1 -1
  80. package/features/formModel/mappers/DynamicZoneFieldMapper.js +4 -0
  81. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  82. package/features/formModel/mappers/ObjectFieldMapper.js +11 -6
  83. package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
  84. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  85. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  86. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  87. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  88. package/features/model/exportModels/abstractions.d.ts +8 -2
  89. package/features/model/exportModels/abstractions.js.map +1 -1
  90. package/package.json +26 -26
  91. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +34 -29
  92. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  93. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
  94. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +210 -0
  95. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
  96. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  97. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  98. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  99. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  100. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  101. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  102. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  103. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  104. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  105. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +58 -1
  106. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  107. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  108. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  109. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
  110. package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
  111. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
  112. package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
  113. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
  114. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
  115. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +1 -1
  116. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
  117. package/presentation/contentEntries/preview/PreviewDecorator.js +25 -6
  118. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
  119. package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
  120. package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
  121. package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
  122. package/presentation/contentEntries/preview/PreviewPane.d.ts +10 -1
  123. package/presentation/contentEntries/preview/PreviewPane.js +81 -45
  124. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
  125. package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
  126. package/presentation/contentEntries/preview/abstractions.js.map +1 -1
  127. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +21 -0
  128. package/presentation/contentEntries/preview/resolvePreviewUrl.js +50 -1
  129. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
  130. package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
  131. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
  132. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
  133. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
  134. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  135. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
  136. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
  137. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
  138. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  139. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  140. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  141. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  142. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
  143. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  144. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  145. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  146. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  147. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  148. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  149. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  150. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  151. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  152. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  153. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  154. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  155. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  156. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  157. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  158. package/presentation/contentModels/abstractions.d.ts +7 -2
  159. package/presentation/contentModels/abstractions.js.map +1 -1
  160. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  161. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  162. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  163. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  164. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  165. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  166. package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
  167. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  168. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  169. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
  170. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
  171. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
  172. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
  173. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
  174. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
  175. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
  176. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
  177. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
  178. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
  179. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  180. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  181. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  182. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  183. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  184. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  185. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  186. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  187. package/presentation/importContentModels/components/FileUpload.js +1 -1
  188. package/presentation/importContentModels/components/FileUpload.js.map +1 -1
  189. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  190. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  191. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  192. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  193. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  194. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  195. package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
  196. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  197. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  198. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  199. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  200. package/utils/normalizeIcon.d.ts +4 -0
  201. package/utils/normalizeIcon.js +9 -6
  202. package/utils/normalizeIcon.js.map +1 -1
@@ -19,6 +19,28 @@ function mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId) {
19
19
  }
20
20
  return nodes;
21
21
  }
22
+ function collectFieldIds(layout, idToFieldId) {
23
+ const fieldIds = new Set();
24
+ for (const row of layout)for (const cell of row)if ("string" == typeof cell) {
25
+ const fieldId = idToFieldId.get(cell);
26
+ if (fieldId) fieldIds.add(fieldId);
27
+ } else if (isLayoutField(cell) && "tabs" === cell.type) {
28
+ const tabsField = cell;
29
+ for (const tab of tabsField.tabs)for (const id of collectFieldIds(tab.layout, idToFieldId))fieldIds.add(id);
30
+ }
31
+ return fieldIds;
32
+ }
33
+ function mapCmsNestedLayout(cmsLayout, fields) {
34
+ if (!cmsLayout || 0 === cmsLayout.length) return;
35
+ const idToFieldId = new Map();
36
+ for (const field of fields)idToFieldId.set(field.id, field.fieldId);
37
+ const fieldIdsInLayout = collectFieldIds(cmsLayout, idToFieldId);
38
+ return (layoutBuilder)=>{
39
+ const nodes = mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId);
40
+ for (const field of fields)if (!fieldIdsInLayout.has(field.fieldId)) nodes.push(layoutBuilder.row(field.fieldId));
41
+ return nodes;
42
+ };
43
+ }
22
44
  function mapLayoutField(field, layoutBuilder, idToFieldId) {
23
45
  switch(field.type){
24
46
  case "separator":
@@ -83,6 +105,6 @@ function mapAlert(field, layoutBuilder) {
83
105
  })));
84
106
  return builder;
85
107
  }
86
- export { mapCmsLayout };
108
+ export { collectFieldIds, mapCmsLayout, mapCmsNestedLayout };
87
109
 
88
110
  //# sourceMappingURL=CmsLayoutMapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/CmsLayoutMapper.js","sources":["../../../src/features/formModel/CmsLayoutMapper.ts"],"sourcesContent":["import {\n isLayoutField,\n type CmsEditorFieldsLayout,\n type CmsLayoutField,\n type CmsSeparatorLayoutField,\n type CmsTabLayoutField,\n type CmsAlertLayoutField\n} from \"~/types.js\";\nimport type {\n ILayoutBuilder,\n ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport function mapCmsLayout(\n cmsLayout: CmsEditorFieldsLayout,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder[] {\n const nodes: ILayoutNodeBuilder[] = [];\n\n for (const row of cmsLayout) {\n if (row.length === 0) {\n continue;\n }\n\n const firstCell = row[0];\n\n if (row.length === 1 && isLayoutField(firstCell)) {\n const layoutField = firstCell as CmsLayoutField;\n const node = mapLayoutField(layoutField, layoutBuilder, idToFieldId);\n if (node) {\n nodes.push(node);\n }\n continue;\n }\n\n const fieldIds: string[] = [];\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.push(fieldId);\n }\n }\n }\n\n if (fieldIds.length > 0) {\n nodes.push(layoutBuilder.row(...fieldIds));\n }\n }\n\n return nodes;\n}\n\nfunction mapLayoutField(\n field: CmsLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder | null {\n switch (field.type) {\n case \"separator\":\n return mapSeparator(field as CmsSeparatorLayoutField, layoutBuilder);\n\n case \"tabs\":\n return mapTabs(field as CmsTabLayoutField, layoutBuilder, idToFieldId);\n\n case \"alert\":\n return mapAlert(field as CmsAlertLayoutField, layoutBuilder);\n\n default:\n return null;\n }\n}\n\nfunction mapSeparator(\n field: CmsSeparatorLayoutField,\n layoutBuilder: ILayoutBuilder\n): ILayoutNodeBuilder {\n const builder = layoutBuilder.separator();\n if (field.label) {\n builder.title(field.label);\n }\n if (field.description) {\n builder.description(field.description);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n\nfunction mapTabs(\n field: CmsTabLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder {\n const tabsBuilder = layoutBuilder.tabs(field.id);\n\n for (const tab of field.tabs) {\n tabsBuilder.tab(tab.id, t => {\n t.label(tab.label);\n if (tab.icon) {\n t.icon({ type: \"icon\", name: tab.icon });\n }\n t.layout(l => mapCmsLayout(tab.layout, l, idToFieldId));\n if (tab.rules) {\n t.rules(\n tab.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n });\n }\n\n if (field.rules) {\n tabsBuilder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n return tabsBuilder;\n}\n\nfunction mapAlert(field: CmsAlertLayoutField, layoutBuilder: ILayoutBuilder): ILayoutNodeBuilder {\n const builder = layoutBuilder.alert();\n if (field.label) {\n builder.message(field.label);\n }\n if (field.alertType) {\n builder.alertType(field.alertType);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n"],"names":["mapCmsLayout","cmsLayout","layoutBuilder","idToFieldId","nodes","row","firstCell","isLayoutField","layoutField","node","mapLayoutField","fieldIds","cell","fieldId","field","mapSeparator","mapTabs","mapAlert","builder","r","tabsBuilder","tab","t","l"],"mappings":";AAaO,SAASA,aACZC,SAAgC,EAChCC,aAA6B,EAC7BC,WAAgC;IAEhC,MAAMC,QAA8B,EAAE;IAEtC,KAAK,MAAMC,OAAOJ,UAAW;QACzB,IAAII,AAAe,MAAfA,IAAI,MAAM,EACV;QAGJ,MAAMC,YAAYD,GAAG,CAAC,EAAE;QAExB,IAAIA,AAAe,MAAfA,IAAI,MAAM,IAAUE,cAAcD,YAAY;YAC9C,MAAME,cAAcF;YACpB,MAAMG,OAAOC,eAAeF,aAAaN,eAAeC;YACxD,IAAIM,MACAL,MAAM,IAAI,CAACK;YAEf;QACJ;QAEA,MAAME,WAAqB,EAAE;QAC7B,KAAK,MAAMC,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;YAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;YAChC,IAAIC,SACAF,SAAS,IAAI,CAACE;QAEtB;QAGJ,IAAIF,SAAS,MAAM,GAAG,GAClBP,MAAM,IAAI,CAACF,cAAc,GAAG,IAAIS;IAExC;IAEA,OAAOP;AACX;AAEA,SAASM,eACLI,KAAqB,EACrBZ,aAA6B,EAC7BC,WAAgC;IAEhC,OAAQW,MAAM,IAAI;QACd,KAAK;YACD,OAAOC,aAAaD,OAAkCZ;QAE1D,KAAK;YACD,OAAOc,QAAQF,OAA4BZ,eAAeC;QAE9D,KAAK;YACD,OAAOc,SAASH,OAA8BZ;QAElD;YACI,OAAO;IACf;AACJ;AAEA,SAASa,aACLD,KAA8B,EAC9BZ,aAA6B;IAE7B,MAAMgB,UAAUhB,cAAc,SAAS;IACvC,IAAIY,MAAM,KAAK,EACXI,QAAQ,KAAK,CAACJ,MAAM,KAAK;IAE7B,IAAIA,MAAM,WA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EAAEZ,aAA6B;IACvE,MAAMgB,UAAUhB,cAAc,KAAK;IACnC,IAAIY,MAAM,KAAK,EACXI,QAAQ,OAAO,CAACJ,MAAM,KAAK;IAE/B,IAAIA,MAAM,SAAS,EACfI,QAAQ,SAAS,CAACJ,MAAM,SAAS;IAErC,IAAIA,MAAM,KAAK,EACXI,QAAQ,KAAK,CACTJ,MAAM,KAAK,CAAC,GAAG,CAACK,CAAAA,IAAM;YAClB,MAAMA,EAAE,IAAI;YACZ,QAAQA,EAAE,MAAM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAGR,OAAOD;AACX"}
1
+ {"version":3,"file":"features/formModel/CmsLayoutMapper.js","sources":["../../../src/features/formModel/CmsLayoutMapper.ts"],"sourcesContent":["import {\n isLayoutField,\n type CmsEditorFieldsLayout,\n type CmsLayoutField,\n type CmsModelField,\n type CmsSeparatorLayoutField,\n type CmsTabLayoutField,\n type CmsAlertLayoutField\n} from \"~/types.js\";\nimport type {\n ILayoutBuilder,\n ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport function mapCmsLayout(\n cmsLayout: CmsEditorFieldsLayout,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder[] {\n const nodes: ILayoutNodeBuilder[] = [];\n\n for (const row of cmsLayout) {\n if (row.length === 0) {\n continue;\n }\n\n const firstCell = row[0];\n\n if (row.length === 1 && isLayoutField(firstCell)) {\n const layoutField = firstCell as CmsLayoutField;\n const node = mapLayoutField(layoutField, layoutBuilder, idToFieldId);\n if (node) {\n nodes.push(node);\n }\n continue;\n }\n\n const fieldIds: string[] = [];\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.push(fieldId);\n }\n }\n }\n\n if (fieldIds.length > 0) {\n nodes.push(layoutBuilder.row(...fieldIds));\n }\n }\n\n return nodes;\n}\n\nexport function collectFieldIds(\n layout: CmsEditorFieldsLayout,\n idToFieldId: Map<string, string>\n): Set<string> {\n const fieldIds = new Set<string>();\n\n for (const row of layout) {\n for (const cell of row) {\n if (typeof cell === \"string\") {\n const fieldId = idToFieldId.get(cell);\n if (fieldId) {\n fieldIds.add(fieldId);\n }\n } else if (isLayoutField(cell) && cell.type === \"tabs\") {\n const tabsField = cell as { tabs: Array<{ layout: CmsEditorFieldsLayout }> };\n for (const tab of tabsField.tabs) {\n for (const id of collectFieldIds(tab.layout, idToFieldId)) {\n fieldIds.add(id);\n }\n }\n }\n }\n }\n\n return fieldIds;\n}\n\n/**\n * Maps the layout stored on an object field or a dynamic zone template. Returns `undefined`\n * when there is no layout, so the form falls back to one row per child. Children missing\n * from the layout get a row of their own at the end, so a stale layout can't hide them.\n */\nexport function mapCmsNestedLayout(\n cmsLayout: CmsEditorFieldsLayout | undefined,\n fields: CmsModelField[]\n): ((layoutBuilder: ILayoutBuilder) => ILayoutNodeBuilder[]) | undefined {\n if (!cmsLayout || cmsLayout.length === 0) {\n return undefined;\n }\n\n const idToFieldId = new Map<string, string>();\n for (const field of fields) {\n idToFieldId.set(field.id, field.fieldId);\n }\n\n const fieldIdsInLayout = collectFieldIds(cmsLayout, idToFieldId);\n\n return layoutBuilder => {\n const nodes = mapCmsLayout(cmsLayout, layoutBuilder, idToFieldId);\n for (const field of fields) {\n if (!fieldIdsInLayout.has(field.fieldId)) {\n nodes.push(layoutBuilder.row(field.fieldId));\n }\n }\n return nodes;\n };\n}\n\nfunction mapLayoutField(\n field: CmsLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder | null {\n switch (field.type) {\n case \"separator\":\n return mapSeparator(field as CmsSeparatorLayoutField, layoutBuilder);\n\n case \"tabs\":\n return mapTabs(field as CmsTabLayoutField, layoutBuilder, idToFieldId);\n\n case \"alert\":\n return mapAlert(field as CmsAlertLayoutField, layoutBuilder);\n\n default:\n return null;\n }\n}\n\nfunction mapSeparator(\n field: CmsSeparatorLayoutField,\n layoutBuilder: ILayoutBuilder\n): ILayoutNodeBuilder {\n const builder = layoutBuilder.separator();\n if (field.label) {\n builder.title(field.label);\n }\n if (field.description) {\n builder.description(field.description);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n\nfunction mapTabs(\n field: CmsTabLayoutField,\n layoutBuilder: ILayoutBuilder,\n idToFieldId: Map<string, string>\n): ILayoutNodeBuilder {\n const tabsBuilder = layoutBuilder.tabs(field.id);\n\n for (const tab of field.tabs) {\n tabsBuilder.tab(tab.id, t => {\n t.label(tab.label);\n if (tab.icon) {\n t.icon({ type: \"icon\", name: tab.icon });\n }\n t.layout(l => mapCmsLayout(tab.layout, l, idToFieldId));\n if (tab.rules) {\n t.rules(\n tab.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n });\n }\n\n if (field.rules) {\n tabsBuilder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n\n return tabsBuilder;\n}\n\nfunction mapAlert(field: CmsAlertLayoutField, layoutBuilder: ILayoutBuilder): ILayoutNodeBuilder {\n const builder = layoutBuilder.alert();\n if (field.label) {\n builder.message(field.label);\n }\n if (field.alertType) {\n builder.alertType(field.alertType);\n }\n if (field.rules) {\n builder.rules(\n field.rules.map(r => ({\n type: r.type,\n target: r.target,\n operator: r.operator,\n value: r.value ?? null,\n action: r.action as \"hide\" | \"disable\"\n }))\n );\n }\n return builder;\n}\n"],"names":["mapCmsLayout","cmsLayout","layoutBuilder","idToFieldId","nodes","row","firstCell","isLayoutField","layoutField","node","mapLayoutField","fieldIds","cell","fieldId","collectFieldIds","layout","Set","tabsField","tab","id","mapCmsNestedLayout","fields","Map","field","fieldIdsInLayout","mapSeparator","mapTabs","mapAlert","builder","r","tabsBuilder","t","l"],"mappings":";AAcO,SAASA,aACZC,SAAgC,EAChCC,aAA6B,EAC7BC,WAAgC;IAEhC,MAAMC,QAA8B,EAAE;IAEtC,KAAK,MAAMC,OAAOJ,UAAW;QACzB,IAAII,AAAe,MAAfA,IAAI,MAAM,EACV;QAGJ,MAAMC,YAAYD,GAAG,CAAC,EAAE;QAExB,IAAIA,AAAe,MAAfA,IAAI,MAAM,IAAUE,cAAcD,YAAY;YAC9C,MAAME,cAAcF;YACpB,MAAMG,OAAOC,eAAeF,aAAaN,eAAeC;YACxD,IAAIM,MACAL,MAAM,IAAI,CAACK;YAEf;QACJ;QAEA,MAAME,WAAqB,EAAE;QAC7B,KAAK,MAAMC,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;YAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;YAChC,IAAIC,SACAF,SAAS,IAAI,CAACE;QAEtB;QAGJ,IAAIF,SAAS,MAAM,GAAG,GAClBP,MAAM,IAAI,CAACF,cAAc,GAAG,IAAIS;IAExC;IAEA,OAAOP;AACX;AAEO,SAASU,gBACZC,MAA6B,EAC7BZ,WAAgC;IAEhC,MAAMQ,WAAW,IAAIK;IAErB,KAAK,MAAMX,OAAOU,OACd,KAAK,MAAMH,QAAQP,IACf,IAAI,AAAgB,YAAhB,OAAOO,MAAmB;QAC1B,MAAMC,UAAUV,YAAY,GAAG,CAACS;QAChC,IAAIC,SACAF,SAAS,GAAG,CAACE;IAErB,OAAO,IAAIN,cAAcK,SAASA,AAAc,WAAdA,KAAK,IAAI,EAAa;QACpD,MAAMK,YAAYL;QAClB,KAAK,MAAMM,OAAOD,UAAU,IAAI,CAC5B,KAAK,MAAME,MAAML,gBAAgBI,IAAI,MAAM,EAAEf,aACzCQ,SAAS,GAAG,CAACQ;IAG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AM;YAChB,UAAUA,EAAE,QAAQ;YACpB,OAAOA,EAAE,KAAK,IAAI;YAClB,QAAQA,EAAE,MAAM;QACpB;IAGR,OAAOD;AACX"}
@@ -1,4 +1,5 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
2
3
  import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
3
4
  class DynamicZoneFieldMapper {
4
5
  map(field, registry, context) {
@@ -6,6 +7,7 @@ class DynamicZoneFieldMapper {
6
7
  const templates = field.settings?.templates;
7
8
  if (templates) for (const template of templates)builder.template(template.id, (t)=>{
8
9
  t.label(template.name);
10
+ if (template.description) t.description(template.description);
9
11
  if (template.icon) {
10
12
  const icon = template.icon;
11
13
  if ("object" == typeof icon && "name" in icon) t.icon(icon);
@@ -20,6 +22,8 @@ class DynamicZoneFieldMapper {
20
22
  if (template.fields && template.fields.length > 0) for (const child of template.fields)result[child.fieldId] = context.mapField(child, childRegistry);
21
23
  return result;
22
24
  });
25
+ const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);
26
+ if (layout) t.layout(layout);
23
27
  });
24
28
  return applyFieldProps(builder, field, context.rendererMap);
25
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n if (template.fields && template.fields.length > 0) {\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n }\n return result;\n });\n });\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["DynamicZoneFieldMapper","field","registry","context","builder","templates","template","t","icon","childRegistry","result","generateAlphaNumericLowerCaseId","child","applyFieldProps"],"mappings":";;AAWO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,YAAYJ,MAAM,QAAQ,EAAE;QAClC,IAAII,WACA,KAAK,MAAMC,YAAYD,UACnBD,QAAQ,QAAQ,CAACE,SAAS,EAAE,EAAEC,CAAAA;YAC1BA,EAAE,KAAK,CAACD,SAAS,IAAI;YACrB,IAAIA,SAAS,IAAI,EAAE;gBACf,MAAME,OAAOF,SAAS,IAAI;gBAC1B,IAAI,AAAgB,YAAhB,OAAOE,QAAqB,UAAUA,MACtCD,EAAE,IAAI,CAACC;qBACJ,IAAI,AAAgB,YAAhB,OAAOA,MACdD,EAAE,IAAI,CAAC;oBAAE,MAAM;oBAAQ,MAAMC;gBAAK;YAE1C;YACAD,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,IAAIL,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5C,KAAK,MAAMM,SAASN,SAAS,MAAM,CAC/BI,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGT,QAAQ,QAAQ,CAACS,OAAOH;gBAGxD,OAAOC;YACX;QACJ;QAIR,OAAOG,gBAAgBT,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aAzCS,IAAI,GAAG;;AA0CpB"}
1
+ {"version":3,"file":"features/formModel/mappers/DynamicZoneFieldMapper.js","sources":["../../../../src/features/formModel/mappers/DynamicZoneFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField, CmsDynamicZoneTemplate } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport type { ITemplateIcon } from \"@webiny/app-admin/features/formModel/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class DynamicZoneFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"dynamicZone\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const templates = field.settings?.templates as CmsDynamicZoneTemplate[] | undefined;\n if (templates) {\n for (const template of templates) {\n builder.template(template.id, t => {\n t.label(template.name);\n if (template.description) {\n t.description(template.description);\n }\n if (template.icon) {\n const icon = template.icon;\n if (typeof icon === \"object\" && \"name\" in icon) {\n t.icon(icon as ITemplateIcon);\n } else if (typeof icon === \"string\") {\n t.icon({ type: \"icon\", name: icon });\n }\n }\n t.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n if (template.fields && template.fields.length > 0) {\n for (const child of template.fields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n }\n return result;\n });\n const layout = mapCmsNestedLayout(template.layout, template.fields ?? []);\n if (layout) {\n t.layout(layout);\n }\n });\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["DynamicZoneFieldMapper","field","registry","context","builder","templates","template","t","icon","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAYO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,YAAYJ,MAAM,QAAQ,EAAE;QAClC,IAAII,WACA,KAAK,MAAMC,YAAYD,UACnBD,QAAQ,QAAQ,CAACE,SAAS,EAAE,EAAEC,CAAAA;YAC1BA,EAAE,KAAK,CAACD,SAAS,IAAI;YACrB,IAAIA,SAAS,WAAW,EACpBC,EAAE,WAAW,CAACD,SAAS,WAAW;YAEtC,IAAIA,SAAS,IAAI,EAAE;gBACf,MAAME,OAAOF,SAAS,IAAI;gBAC1B,IAAI,AAAgB,YAAhB,OAAOE,QAAqB,UAAUA,MACtCD,EAAE,IAAI,CAACC;qBACJ,IAAI,AAAgB,YAAhB,OAAOA,MACdD,EAAE,IAAI,CAAC;oBAAE,MAAM;oBAAQ,MAAMC;gBAAK;YAE1C;YACAD,EAAE,MAAM,CAACE,CAAAA;gBACL,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,IAAIL,SAAS,MAAM,IAAIA,SAAS,MAAM,CAAC,MAAM,GAAG,GAC5C,KAAK,MAAMM,SAASN,SAAS,MAAM,CAC/BI,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGT,QAAQ,QAAQ,CAACS,OAAOH;gBAGxD,OAAOC;YACX;YACA,MAAMG,SAASC,mBAAmBR,SAAS,MAAM,EAAEA,SAAS,MAAM,IAAI,EAAE;YACxE,IAAIO,QACAN,EAAE,MAAM,CAACM;QAEjB;QAIR,OAAOE,gBAAgBX,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aAhDS,IAAI,GAAG;;AAiDpB"}
@@ -1,15 +1,20 @@
1
1
  import { applyFieldProps } from "./applyFieldProps.js";
2
+ import { mapCmsNestedLayout } from "../CmsLayoutMapper.js";
2
3
  import { generateAlphaNumericLowerCaseId } from "@webiny/utils/generateId";
3
4
  class ObjectFieldMapper {
4
5
  map(field, registry, context) {
5
6
  const builder = registry.object();
6
7
  const childFields = field.settings?.fields;
7
- if (childFields && childFields.length > 0) builder.fields((childRegistry)=>{
8
- const result = {};
9
- result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
10
- for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
11
- return result;
12
- });
8
+ if (childFields && childFields.length > 0) {
9
+ builder.fields((childRegistry)=>{
10
+ const result = {};
11
+ result["_id"] = childRegistry.text().hidden().defaultValue(()=>generateAlphaNumericLowerCaseId(12)).cloneValue(()=>generateAlphaNumericLowerCaseId(12));
12
+ for (const child of childFields)result[child.fieldId] = context.mapField(child, childRegistry);
13
+ return result;
14
+ });
15
+ const layout = mapCmsNestedLayout(field.settings?.layout, childFields);
16
+ if (layout) builder.layout(layout);
17
+ }
13
18
  return applyFieldProps(builder, field, context.rendererMap);
14
19
  }
15
20
  constructor(){
@@ -1 +1 @@
1
- {"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","generateAlphaNumericLowerCaseId","child","applyFieldProps"],"mappings":";;AAUO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,cAAcJ,MAAM,QAAQ,EAAE;QACpC,IAAII,eAAeA,YAAY,MAAM,GAAG,GACpCD,QAAQ,MAAM,CAACE,CAAAA;YACX,MAAMC,SAAwC,CAAC;YAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;YACtD,KAAK,MAAMC,SAASJ,YAChBE,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGN,QAAQ,QAAQ,CAACM,OAAOH;YAEpD,OAAOC;QACX;QAGJ,OAAOG,gBAAgBN,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aA1BS,IAAI,GAAG;;AA2BpB"}
1
+ {"version":3,"file":"features/formModel/mappers/ObjectFieldMapper.js","sources":["../../../../src/features/formModel/mappers/ObjectFieldMapper.ts"],"sourcesContent":["import type { ICmsFieldTypeMapper, ICmsFieldMapperContext } from \"../abstractions.js\";\nimport type {\n IFieldBuilder,\n IFieldBuilderRegistry,\n IObjectFieldBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { applyFieldProps } from \"./applyFieldProps.js\";\nimport { mapCmsNestedLayout } from \"../CmsLayoutMapper.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils/generateId\";\n\nexport class ObjectFieldMapper implements ICmsFieldTypeMapper {\n readonly type = \"object\";\n\n map(\n field: CmsModelField,\n registry: IFieldBuilderRegistry,\n context: ICmsFieldMapperContext\n ): IFieldBuilder {\n const builder = registry.object() as IObjectFieldBuilder;\n\n const childFields = field.settings?.fields;\n if (childFields && childFields.length > 0) {\n builder.fields(childRegistry => {\n const result: Record<string, IFieldBuilder> = {};\n result[\"_id\"] = childRegistry\n .text()\n .hidden()\n .defaultValue(() => generateAlphaNumericLowerCaseId(12))\n .cloneValue(() => generateAlphaNumericLowerCaseId(12));\n for (const child of childFields) {\n result[child.fieldId] = context.mapField(child, childRegistry);\n }\n return result;\n });\n\n const layout = mapCmsNestedLayout(field.settings?.layout, childFields);\n if (layout) {\n builder.layout(layout);\n }\n }\n\n return applyFieldProps(builder, field, context.rendererMap);\n }\n}\n"],"names":["ObjectFieldMapper","field","registry","context","builder","childFields","childRegistry","result","generateAlphaNumericLowerCaseId","child","layout","mapCmsNestedLayout","applyFieldProps"],"mappings":";;;AAWO,MAAMA;IAGT,IACIC,KAAoB,EACpBC,QAA+B,EAC/BC,OAA+B,EAClB;QACb,MAAMC,UAAUF,SAAS,MAAM;QAE/B,MAAMG,cAAcJ,MAAM,QAAQ,EAAE;QACpC,IAAII,eAAeA,YAAY,MAAM,GAAG,GAAG;YACvCD,QAAQ,MAAM,CAACE,CAAAA;gBACX,MAAMC,SAAwC,CAAC;gBAC/CA,MAAM,CAAC,MAAM,GAAGD,cACX,IAAI,GACJ,MAAM,GACN,YAAY,CAAC,IAAME,gCAAgC,KACnD,UAAU,CAAC,IAAMA,gCAAgC;gBACtD,KAAK,MAAMC,SAASJ,YAChBE,MAAM,CAACE,MAAM,OAAO,CAAC,GAAGN,QAAQ,QAAQ,CAACM,OAAOH;gBAEpD,OAAOC;YACX;YAEA,MAAMG,SAASC,mBAAmBV,MAAM,QAAQ,EAAE,QAAQI;YAC1D,IAAIK,QACAN,QAAQ,MAAM,CAACM;QAEvB;QAEA,OAAOE,gBAAgBR,SAASH,OAAOE,QAAQ,WAAW;IAC9D;;aA/BS,IAAI,GAAG;;AAgCpB"}
@@ -3,7 +3,7 @@ import { ExportModelsGateway as GatewayAbstraction } from "./abstractions.js";
3
3
  declare class ExportModelsGatewayImpl implements GatewayAbstraction.Interface {
4
4
  private client;
5
5
  constructor(client: CmsGraphQLClient.Interface);
6
- execute(models?: string[]): Promise<any>;
6
+ execute(models?: string[]): Promise<string>;
7
7
  }
8
8
  export declare const ExportModelsGateway: typeof ExportModelsGatewayImpl & {
9
9
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IExportModelsGateway>;
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data: any;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface ExportModelsVariables {\n models?: string[];\n}\n\nconst CMS_EXPORT_STRUCTURE_QUERY = /* GraphQL */ `\n query CmsExportStructure($models: [String!]) {\n exportStructure(models: $models) {\n data\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass ExportModelsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(models?: string[]) {\n const response = await this.client.execute<ExportModelsResponse, ExportModelsVariables>({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables: { models }\n });\n\n const { data, error } = response.exportStructure;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const ExportModelsGateway = GatewayAbstraction.createImplementation({\n implementation: ExportModelsGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["CMS_EXPORT_STRUCTURE_QUERY","ExportModelsGatewayImpl","client","models","response","data","error","Error","ExportModelsGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;AAeA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;AAWlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBAAEG;YAAO;QACxB;QAEA,MAAM,EAAEE,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,eAAe;QAEhD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,OAAOD;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
1
+ {"version":3,"file":"features/model/exportModels/ExportModelsGateway.js","sources":["../../../../src/features/model/exportModels/ExportModelsGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsErrorResponse } from \"~/types.js\";\nimport { ExportModelsGateway as GatewayAbstraction } from \"./abstractions.js\";\n\ninterface ExportModelsResponse {\n exportStructure: {\n data: string;\n error: CmsErrorResponse | null;\n };\n}\n\ninterface ExportModelsVariables {\n models?: string[];\n}\n\nconst CMS_EXPORT_STRUCTURE_QUERY = /* GraphQL */ `\n query CmsExportStructure($models: [String!]) {\n exportStructure(models: $models) {\n data\n error {\n message\n code\n data\n }\n }\n }\n`;\n\nclass ExportModelsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: CmsGraphQLClient.Interface) {}\n\n async execute(models?: string[]) {\n const response = await this.client.execute<ExportModelsResponse, ExportModelsVariables>({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables: { models }\n });\n\n const { data, error } = response.exportStructure;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const ExportModelsGateway = GatewayAbstraction.createImplementation({\n implementation: ExportModelsGatewayImpl,\n dependencies: [CmsGraphQLClient]\n});\n"],"names":["CMS_EXPORT_STRUCTURE_QUERY","ExportModelsGatewayImpl","client","models","response","data","error","Error","ExportModelsGateway","GatewayAbstraction","CmsGraphQLClient"],"mappings":";;AAeA,MAAMA,6BAA2C,CAAC;;;;;;;;;;;AAWlD,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAkC,CAAE;aAApCA,MAAM,GAANA;IAAqC;IAEzD,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBAAEG;YAAO;QACxB;QAEA,MAAM,EAAEE,IAAI,EAAEC,KAAK,EAAE,GAAGF,SAAS,eAAe;QAEhD,IAAIE,OACA,MAAM,IAAIC,MAAMD,MAAM,OAAO;QAGjC,OAAOD;IACX;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
@@ -4,7 +4,13 @@ class ExportModelsUseCaseImpl {
4
4
  this.gateway = gateway;
5
5
  }
6
6
  async execute(models) {
7
- return this.gateway.execute(models);
7
+ const result = await this.gateway.execute(models);
8
+ try {
9
+ return JSON.parse(result);
10
+ } catch (ex) {
11
+ console.error(ex);
12
+ return null;
13
+ }
8
14
  }
9
15
  }
10
16
  const ExportModelsUseCase_ExportModelsUseCase = ExportModelsUseCase.createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/ExportModelsUseCase.js","sources":["../../../../src/features/model/exportModels/ExportModelsUseCase.ts"],"sourcesContent":["import { ExportModelsUseCase as UseCaseAbstraction, ExportModelsGateway } from \"./abstractions.js\";\n\nclass ExportModelsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private gateway: ExportModelsGateway.Interface) {}\n\n async execute(models?: string[]) {\n return this.gateway.execute(models);\n }\n}\n\nexport const ExportModelsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ExportModelsUseCaseImpl,\n dependencies: [ExportModelsGateway]\n});\n"],"names":["ExportModelsUseCaseImpl","gateway","models","ExportModelsUseCase","UseCaseAbstraction","ExportModelsGateway"],"mappings":";AAEA,MAAMA;IACF,YAAoBC,OAAsC,CAAE;aAAxCA,OAAO,GAAPA;IAAyC;IAE7D,MAAM,QAAQC,MAAiB,EAAE;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAACA;IAChC;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBJ;IAChB,cAAc;QAACK;KAAoB;AACvC"}
1
+ {"version":3,"file":"features/model/exportModels/ExportModelsUseCase.js","sources":["../../../../src/features/model/exportModels/ExportModelsUseCase.ts"],"sourcesContent":["import { ExportModelsUseCase as UseCaseAbstraction, ExportModelsGateway } from \"./abstractions.js\";\n\nclass ExportModelsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private gateway: ExportModelsGateway.Interface) {}\n\n async execute(models?: string[]) {\n const result = await this.gateway.execute(models);\n try {\n return JSON.parse(result);\n } catch (ex) {\n console.error(ex);\n return null;\n }\n }\n}\n\nexport const ExportModelsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ExportModelsUseCaseImpl,\n dependencies: [ExportModelsGateway]\n});\n"],"names":["ExportModelsUseCaseImpl","gateway","models","result","JSON","ex","console","ExportModelsUseCase","UseCaseAbstraction","ExportModelsGateway"],"mappings":";AAEA,MAAMA;IACF,YAAoBC,OAAsC,CAAE;aAAxCA,OAAO,GAAPA;IAAyC;IAE7D,MAAM,QAAQC,MAAiB,EAAE;QAC7B,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACD;QAC1C,IAAI;YACA,OAAOE,KAAK,KAAK,CAACD;QACtB,EAAE,OAAOE,IAAI;YACTC,QAAQ,KAAK,CAACD;YACd,OAAO;QACX;IACJ;AACJ;AAEO,MAAME,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBR;IAChB,cAAc;QAACS;KAAoB;AACvC"}
@@ -1,14 +1,20 @@
1
+ import type { CmsModel, CmsGroup } from "../../../types.js";
1
2
  export interface IExportModelsGateway {
2
- execute(models?: string[]): Promise<any>;
3
+ execute(models?: string[]): Promise<string>;
4
+ }
5
+ export interface IExportModelsUseCaseResponse {
6
+ models: CmsModel[];
7
+ groups: CmsGroup[];
3
8
  }
4
9
  export declare const ExportModelsGateway: import("@webiny/di").Abstraction<IExportModelsGateway>;
5
10
  export declare namespace ExportModelsGateway {
6
11
  type Interface = IExportModelsGateway;
7
12
  }
8
13
  export interface IExportModelsUseCase {
9
- execute(models?: string[]): Promise<any>;
14
+ execute(models?: string[]): Promise<IExportModelsUseCaseResponse | null>;
10
15
  }
11
16
  export declare const ExportModelsUseCase: import("@webiny/di").Abstraction<IExportModelsUseCase>;
12
17
  export declare namespace ExportModelsUseCase {
13
18
  type Interface = IExportModelsUseCase;
19
+ type Response = IExportModelsUseCaseResponse;
14
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/model/exportModels/abstractions.js","sources":["../../../../src/features/model/exportModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface IExportModelsGateway {\n execute(models?: string[]): Promise<any>;\n}\n\nexport const ExportModelsGateway = createAbstraction<IExportModelsGateway>(\"ExportModelsGateway\");\n\nexport namespace ExportModelsGateway {\n export type Interface = IExportModelsGateway;\n}\n\nexport interface IExportModelsUseCase {\n execute(models?: string[]): Promise<any>;\n}\n\nexport const ExportModelsUseCase = createAbstraction<IExportModelsUseCase>(\"ExportModelsUseCase\");\n\nexport namespace ExportModelsUseCase {\n export type Interface = IExportModelsUseCase;\n}\n"],"names":["ExportModelsGateway","createAbstraction","ExportModelsUseCase"],"mappings":";AAMO,MAAMA,sBAAsBC,kBAAwC;AAUpE,MAAMC,sBAAsBD,kBAAwC"}
1
+ {"version":3,"file":"features/model/exportModels/abstractions.js","sources":["../../../../src/features/model/exportModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { CmsModel, CmsGroup } from \"~/types.js\";\n\nexport interface IExportModelsGateway {\n execute(models?: string[]): Promise<string>;\n}\n\nexport interface IExportModelsUseCaseResponse {\n models: CmsModel[];\n groups: CmsGroup[];\n}\n\nexport const ExportModelsGateway = createAbstraction<IExportModelsGateway>(\"ExportModelsGateway\");\n\nexport namespace ExportModelsGateway {\n export type Interface = IExportModelsGateway;\n}\n\nexport interface IExportModelsUseCase {\n execute(models?: string[]): Promise<IExportModelsUseCaseResponse | null>;\n}\n\nexport const ExportModelsUseCase = createAbstraction<IExportModelsUseCase>(\"ExportModelsUseCase\");\n\nexport namespace ExportModelsUseCase {\n export type Interface = IExportModelsUseCase;\n export type Response = IExportModelsUseCaseResponse;\n}\n"],"names":["ExportModelsGateway","createAbstraction","ExportModelsUseCase"],"mappings":";AAYO,MAAMA,sBAAsBC,kBAAwC;AAUpE,MAAMC,sBAAsBD,kBAAwC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms",
3
- "version": "6.5.0-beta.1",
3
+ "version": "6.5.0-beta.11",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -26,33 +26,33 @@
26
26
  "@fortawesome/free-regular-svg-icons": "7.3.1",
27
27
  "@fortawesome/free-solid-svg-icons": "7.3.1",
28
28
  "@fortawesome/react-fontawesome": "3.5.0",
29
- "@lexical/utils": "0.48.0",
29
+ "@lexical/utils": "0.52.0",
30
30
  "@types/react": "18.3.31",
31
- "@webiny/admin-ui": "6.5.0-beta.1",
32
- "@webiny/app": "6.5.0-beta.1",
33
- "@webiny/app-aco": "6.5.0-beta.1",
34
- "@webiny/app-admin": "6.5.0-beta.1",
35
- "@webiny/app-graphql-playground": "6.5.0-beta.1",
36
- "@webiny/app-headless-cms-common": "6.5.0-beta.1",
37
- "@webiny/cms-sdk": "6.5.0-beta.1",
38
- "@webiny/di": "1.0.2",
39
- "@webiny/feature": "6.5.0-beta.1",
40
- "@webiny/form": "6.5.0-beta.1",
41
- "@webiny/frontend-settings": "6.5.0-beta.1",
42
- "@webiny/icons": "6.5.0-beta.1",
43
- "@webiny/lexical-editor": "6.5.0-beta.1",
44
- "@webiny/lexical-nodes": "6.5.0-beta.1",
45
- "@webiny/plugins": "6.5.0-beta.1",
46
- "@webiny/react-composition": "6.5.0-beta.1",
47
- "@webiny/react-properties": "6.5.0-beta.1",
48
- "@webiny/utils": "6.5.0-beta.1",
49
- "@webiny/validation": "6.5.0-beta.1",
31
+ "@webiny/admin-ui": "6.5.0-beta.11",
32
+ "@webiny/app": "6.5.0-beta.11",
33
+ "@webiny/app-aco": "6.5.0-beta.11",
34
+ "@webiny/app-admin": "6.5.0-beta.11",
35
+ "@webiny/app-graphql-playground": "6.5.0-beta.11",
36
+ "@webiny/app-headless-cms-common": "6.5.0-beta.11",
37
+ "@webiny/cms-sdk": "6.5.0-beta.11",
38
+ "@webiny/di": "1.1.0",
39
+ "@webiny/feature": "6.5.0-beta.11",
40
+ "@webiny/form": "6.5.0-beta.11",
41
+ "@webiny/frontend-settings": "6.5.0-beta.11",
42
+ "@webiny/icons": "6.5.0-beta.11",
43
+ "@webiny/lexical-editor": "6.5.0-beta.11",
44
+ "@webiny/lexical-nodes": "6.5.0-beta.11",
45
+ "@webiny/plugins": "6.5.0-beta.11",
46
+ "@webiny/react-composition": "6.5.0-beta.11",
47
+ "@webiny/react-properties": "6.5.0-beta.11",
48
+ "@webiny/utils": "6.5.0-beta.11",
49
+ "@webiny/validation": "6.5.0-beta.11",
50
50
  "dot-prop-immutable": "2.1.1",
51
51
  "graphql": "16.14.2",
52
52
  "graphql-tag": "2.12.7",
53
53
  "lodash": "4.18.1",
54
- "mobx": "6.16.1",
55
- "mobx-react-lite": "4.1.1",
54
+ "mobx": "7.0.6",
55
+ "mobx-react-lite": "5.1.0",
56
56
  "react": "18.3.1",
57
57
  "react-dnd": "16.0.1",
58
58
  "react-dnd-html5-backend": "16.0.1",
@@ -60,13 +60,13 @@
60
60
  "react-helmet": "6.1.0",
61
61
  "slugify": "1.6.9",
62
62
  "use-deep-compare-effect": "1.8.1",
63
- "zod": "4.4.3"
63
+ "zod": "4.6.5"
64
64
  },
65
65
  "devDependencies": {
66
- "@webiny/build-tools": "6.5.0-beta.1",
66
+ "@webiny/build-tools": "6.5.0-beta.11",
67
67
  "rimraf": "6.1.3",
68
68
  "typescript": "7.0.2",
69
- "vitest": "4.1.10"
69
+ "vitest": "5.0.3"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
@@ -13,7 +13,9 @@ import { CmsModelContext } from "../../../features/contentEntry/abstractions.js"
13
13
  import { ContentEntryFormModelModifier, ContentEntryFormPresenter } from "./abstractions.js";
14
14
  import { TRASH_ENTRY_DIALOG } from "../list/ContentEntriesPresenter.js";
15
15
  import { CreateRevisionFromUseCase } from "../../../features/contentEntry/createRevisionFrom/abstractions.js";
16
+ import { toFormErrors } from "./toFormErrors.js";
16
17
  const PUBLISH_ENTRY_DIALOG = "publish-entry";
18
+ const SAVING = "Saving...";
17
19
  class ContentEntryFormPresenterImpl {
18
20
  constructor(formModelFactory, cmsFormModelBuilder, confirmation, modelAccessor, getEntryUseCase, createEntryUseCase, createRevisionFromUseCase, updateEntryUseCase, publishEntryUseCase, unpublishEntryUseCase, deleteEntryUseCase, updateRevisionDescriptionUseCase, formModelModifiers){
19
21
  this.formModelFactory = formModelFactory;
@@ -78,52 +80,55 @@ class ContentEntryFormPresenterImpl {
78
80
  }
79
81
  async saveRevision(options) {
80
82
  if (!this.form) return false;
83
+ const form = this.form;
84
+ const model = this.model;
85
+ const isCurrent = ()=>this.form === form && this.model.modelId === model.modelId;
81
86
  const skipValidation = options?.skipValidation ?? true;
82
- const data = await this.form.submit({
87
+ const data = await form.submit({
83
88
  skipValidation
84
89
  });
85
- if (!data) return false;
90
+ if (!data || !isCurrent()) return false;
91
+ const entry = this.entry;
92
+ const folderId = this.folderId;
86
93
  runInAction(()=>{
87
- this.loading = "Saving...";
94
+ this.loading = SAVING;
88
95
  });
89
96
  try {
90
- if (this.entry) {
91
- const entry = await this.saveEntry({
92
- entry: this.entry,
93
- data,
94
- skipValidation
95
- });
96
- runInAction(()=>{
97
- this.entry = entry;
98
- this.form.setData(entry.values);
99
- this.form.reset();
100
- });
101
- } else {
97
+ let savedEntry;
98
+ if (entry) savedEntry = await this.saveEntry({
99
+ model,
100
+ entry,
101
+ data,
102
+ skipValidation
103
+ });
104
+ else {
102
105
  const createData = {
103
106
  values: data
104
107
  };
105
- if (this.folderId) createData.wbyAco_location = {
106
- folderId: this.folderId
108
+ if (folderId) createData.wbyAco_location = {
109
+ folderId
107
110
  };
108
- const entry = await this.createEntryUseCase.execute({
109
- model: this.model,
111
+ savedEntry = await this.createEntryUseCase.execute({
112
+ model,
110
113
  data: createData,
111
114
  options: {
112
115
  skipValidation
113
116
  }
114
117
  });
115
- runInAction(()=>{
116
- this.entry = entry;
117
- this.form.setData(entry.values);
118
- this.form.reset();
119
- });
120
118
  }
119
+ if (!isCurrent()) return false;
120
+ runInAction(()=>{
121
+ this.entry = savedEntry;
122
+ form.setData(savedEntry.values);
123
+ form.reset();
124
+ });
121
125
  return true;
122
- } catch {
126
+ } catch (error) {
127
+ if (isCurrent()) form.setErrors(toFormErrors(error, model));
123
128
  return false;
124
129
  } finally{
125
130
  runInAction(()=>{
126
- this.loading = null;
131
+ if (this.loading === SAVING) this.loading = null;
127
132
  });
128
133
  }
129
134
  }
@@ -253,9 +258,9 @@ class ContentEntryFormPresenterImpl {
253
258
  this.form.reset();
254
259
  }
255
260
  async saveEntry(params) {
256
- const { entry, data, skipValidation } = params;
261
+ const { model, entry, data, skipValidation } = params;
257
262
  if (entry.meta.locked) return await this.createRevisionFromUseCase.execute({
258
- model: this.model,
263
+ model,
259
264
  revisionId: entry.id,
260
265
  data: {
261
266
  values: data
@@ -265,7 +270,7 @@ class ContentEntryFormPresenterImpl {
265
270
  }
266
271
  });
267
272
  return await this.updateEntryUseCase.execute({
268
- model: this.model,
273
+ model,
269
274
  revisionId: entry.id,
270
275
  data: {
271
276
  values: data
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/contentEntries/form/ContentEntryFormPresenter.js","sources":["../../../../src/presentation/contentEntries/form/ContentEntryFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction, toJS } from \"mobx\";\nimport { FormModel, FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { Confirmation } from \"@webiny/app-admin/features/confirmation/abstractions.js\";\nimport type { CmsContentEntry } from \"~/types.js\";\nimport { GetEntryUseCase } from \"~/features/contentEntry/getEntry/abstractions.js\";\nimport { CreateEntryUseCase } from \"~/features/contentEntry/createEntry/abstractions.js\";\nimport { UpdateEntryUseCase } from \"~/features/contentEntry/updateEntry/abstractions.js\";\nimport { PublishEntryUseCase } from \"~/features/contentEntry/publishEntry/abstractions.js\";\nimport { UnpublishEntryUseCase } from \"~/features/contentEntry/unpublishEntry/abstractions.js\";\nimport { DeleteEntryUseCase } from \"~/features/contentEntry/deleteEntry/abstractions.js\";\nimport { UpdateRevisionDescriptionUseCase } from \"~/features/contentEntry/updateRevisionDescription/abstractions.js\";\nimport { CmsFormModelBuilder } from \"~/features/formModel/abstractions.js\";\nimport { CmsModelContext } from \"~/features/contentEntry/abstractions.js\";\nimport {\n ContentEntryFormModelModifier,\n ContentEntryFormPresenter as Abstraction\n} from \"./abstractions.js\";\nimport { TRASH_ENTRY_DIALOG } from \"~/presentation/contentEntries/list/ContentEntriesPresenter.js\";\nimport { CreateRevisionFromUseCase } from \"~/features/contentEntry/createRevisionFrom/abstractions.js\";\n\ninterface PublishEntryDialogData {\n revisionDescription: string;\n}\n\ninterface SaveEntryParams {\n entry: CmsContentEntry;\n data: Record<string, unknown>;\n skipValidation?: boolean;\n}\n\nexport const PUBLISH_ENTRY_DIALOG = \"publish-entry\";\n\nclass ContentEntryFormPresenterImpl implements Abstraction.Interface {\n private entry: CmsContentEntry | null = null;\n private form: FormModel.Interface | null = null;\n private loading: string | null = null;\n private folderId: string | null = null;\n\n constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly cmsFormModelBuilder: CmsFormModelBuilder.Interface,\n private readonly confirmation: Confirmation.Interface,\n private readonly modelAccessor: CmsModelContext.Interface,\n private readonly getEntryUseCase: GetEntryUseCase.Interface,\n private readonly createEntryUseCase: CreateEntryUseCase.Interface,\n private readonly createRevisionFromUseCase: CreateRevisionFromUseCase.Interface,\n private readonly updateEntryUseCase: UpdateEntryUseCase.Interface,\n private readonly publishEntryUseCase: PublishEntryUseCase.Interface,\n private readonly unpublishEntryUseCase: UnpublishEntryUseCase.Interface,\n private readonly deleteEntryUseCase: DeleteEntryUseCase.Interface,\n private readonly updateRevisionDescriptionUseCase: UpdateRevisionDescriptionUseCase.Interface,\n private readonly formModelModifiers: ContentEntryFormModelModifier.Interface[]\n ) {\n makeAutoObservable<\n ContentEntryFormPresenterImpl,\n | \"formModelFactory\"\n | \"cmsFormModelBuilder\"\n | \"confirmation\"\n | \"modelAccessor\"\n | \"getEntryUseCase\"\n | \"createEntryUseCase\"\n | \"updateEntryUseCase\"\n | \"publishEntryUseCase\"\n | \"unpublishEntryUseCase\"\n | \"deleteEntryUseCase\"\n | \"updateRevisionDescriptionUseCase\"\n | \"formModelModifiers\"\n >(this, {\n formModelFactory: false,\n cmsFormModelBuilder: false,\n confirmation: false,\n modelAccessor: false,\n getEntryUseCase: false,\n createEntryUseCase: false,\n updateEntryUseCase: false,\n publishEntryUseCase: false,\n unpublishEntryUseCase: false,\n deleteEntryUseCase: false,\n updateRevisionDescriptionUseCase: false,\n formModelModifiers: false,\n vm: computed\n });\n }\n\n private get model() {\n return this.modelAccessor.getModel();\n }\n\n get vm(): Abstraction.ViewModel {\n const entry = this.entry;\n const meta = entry?.meta;\n const isLocked = meta?.locked ?? false;\n const status = meta?.status;\n /**\n * Can save if the entry is locked and published/unpublished - it will trigger create new revision.\n * Or if the entry is not locked and the form is not null (meaning we are creating a new entry or editing an existing one).\n */\n const canSave =\n (isLocked && (status === \"published\" || status === \"unpublished\")) ||\n (!isLocked && this.form !== null);\n\n return {\n loading: this.loading,\n model: this.model,\n entry: toJS(this.entry),\n form: this.form?.vm ?? null,\n canSave,\n status,\n canCreateNewRevision:\n !!status && canSave && [\"published\", \"unpublished\"].includes(status),\n canPublish: this.entry !== null && status !== \"published\",\n canUnpublish: this.entry !== null && status === \"published\",\n canDelete: this.entry !== null,\n isNewEntry: this.entry === null && this.form !== null,\n isDirty: this.form?.isDirty ?? false\n };\n }\n\n async saveRevision(options?: { skipValidation?: boolean }): Promise<boolean> {\n if (!this.form) {\n return false;\n }\n\n const skipValidation = options?.skipValidation ?? true;\n const data = await this.form.submit({ skipValidation });\n\n if (!data) {\n return false;\n }\n\n runInAction(() => {\n this.loading = \"Saving...\";\n });\n\n try {\n if (this.entry) {\n /**\n * In case the entry already exists, and it is NOT locked, we will update the existing revision.\n * If it is locked, we will create a new revision from the existing one, and then update that new revision.\n */\n const entry = await this.saveEntry({\n entry: this.entry,\n data,\n skipValidation\n });\n\n runInAction(() => {\n this.entry = entry;\n this.form!.setData(entry.values);\n this.form!.reset();\n });\n } else {\n const createData: Record<string, unknown> = { values: data };\n if (this.folderId) {\n createData.wbyAco_location = { folderId: this.folderId };\n }\n\n const entry = await this.createEntryUseCase.execute({\n model: this.model,\n data: createData,\n options: { skipValidation }\n });\n\n runInAction(() => {\n this.entry = entry;\n this.form!.setData(entry.values);\n this.form!.reset();\n });\n }\n\n return true;\n } catch {\n return false;\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n async publishRevision(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n const result = await this.confirmation.confirm<PublishEntryDialogData>(\n PUBLISH_ENTRY_DIALOG,\n { entry: this.entry }\n );\n\n if (result === false) {\n return false;\n }\n\n runInAction(() => {\n this.loading = \"Publishing...\";\n });\n\n try {\n if (result.revisionDescription) {\n await this.updateRevisionDescriptionUseCase.execute({\n model: this.model,\n id: this.entry.id,\n revisionDescription: result.revisionDescription\n });\n }\n\n const entry = await this.publishEntryUseCase.execute({\n model: this.model,\n revisionId: this.entry.id\n });\n\n runInAction(() => {\n this.entry = entry;\n });\n\n return true;\n } catch {\n return false;\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n async unpublishRevision(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n this.loading = \"Unpublishing...\";\n\n try {\n const entry = await this.unpublishEntryUseCase.execute({\n model: this.model,\n revisionId: this.entry.id\n });\n\n runInAction(() => {\n this.entry = entry;\n });\n\n return true;\n } catch {\n return false;\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n async deleteEntry(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n const model = this.model;\n const entry = this.entry;\n\n return this.confirmation.confirm(\n TRASH_ENTRY_DIALOG,\n { entryId: entry.entryId },\n async () => {\n try {\n await this.deleteEntryUseCase.execute({\n model,\n id: entry.entryId\n });\n\n runInAction(() => {\n this.entry = null;\n this.form = null;\n });\n\n return true;\n } catch {\n return false;\n }\n }\n );\n }\n\n async loadRevision(id: string): Promise<void> {\n this.loading = \"Loading entry...\";\n\n try {\n const entry = await this.getEntryUseCase.execute({\n model: this.model,\n id\n });\n\n runInAction(() => {\n this.entry = entry;\n this.buildAndPopulateForm(entry);\n });\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n setFolderId(folderId: string | null): void {\n this.folderId = folderId;\n }\n\n newEntry(initialValues?: Record<string, unknown>): void {\n this.entry = null;\n this.form = this.buildForm();\n if (initialValues) {\n this.form.setData(initialValues, { dirty: true });\n }\n }\n\n patchEntryMeta(meta: Partial<CmsContentEntry[\"meta\"]>): void {\n if (!this.entry) {\n return;\n }\n this.entry = {\n ...this.entry,\n meta: { ...this.entry.meta, ...meta }\n };\n }\n\n reset(): void {\n this.form = null;\n this.entry = null;\n }\n\n private buildForm(): FormModel.Interface {\n const formConfig = this.cmsFormModelBuilder.build(this.model);\n const form = this.formModelFactory.create(formConfig);\n for (const modifier of this.formModelModifiers) {\n modifier.modifyForm(form, this.model);\n }\n return form;\n }\n\n private buildAndPopulateForm(entry: CmsContentEntry): void {\n this.form = this.buildForm();\n this.form.setData(entry.values);\n this.form.reset();\n }\n /**\n * Depending on whether the entry is locked or not, this method will either create a new revision from the existing one and update it, or simply update the existing revision.\n */\n private async saveEntry(params: SaveEntryParams): Promise<any> {\n const { entry, data, skipValidation } = params;\n\n if (entry.meta.locked) {\n return await this.createRevisionFromUseCase.execute({\n model: this.model,\n revisionId: entry.id,\n data: {\n values: data\n },\n options: { skipValidation }\n });\n }\n return await this.updateEntryUseCase.execute({\n model: this.model,\n revisionId: entry.id,\n data: {\n values: data\n },\n options: { skipValidation }\n });\n }\n}\n\nexport const ContentEntryFormPresenter = Abstraction.createImplementation({\n implementation: ContentEntryFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n CmsFormModelBuilder,\n Confirmation,\n CmsModelContext,\n GetEntryUseCase,\n CreateEntryUseCase,\n CreateRevisionFromUseCase,\n UpdateEntryUseCase,\n PublishEntryUseCase,\n UnpublishEntryUseCase,\n DeleteEntryUseCase,\n UpdateRevisionDescriptionUseCase,\n [ContentEntryFormModelModifier, { multiple: true }]\n ]\n});\n"],"names":["PUBLISH_ENTRY_DIALOG","ContentEntryFormPresenterImpl","formModelFactory","cmsFormModelBuilder","confirmation","modelAccessor","getEntryUseCase","createEntryUseCase","createRevisionFromUseCase","updateEntryUseCase","publishEntryUseCase","unpublishEntryUseCase","deleteEntryUseCase","updateRevisionDescriptionUseCase","formModelModifiers","makeAutoObservable","computed","entry","meta","isLocked","status","canSave","toJS","options","skipValidation","data","runInAction","createData","result","model","TRASH_ENTRY_DIALOG","id","folderId","initialValues","formConfig","form","modifier","params","ContentEntryFormPresenter","Abstraction","FormModelFactory","CmsFormModelBuilder","Confirmation","CmsModelContext","GetEntryUseCase","CreateEntryUseCase","CreateRevisionFromUseCase","UpdateEntryUseCase","PublishEntryUseCase","UnpublishEntryUseCase","DeleteEntryUseCase","UpdateRevisionDescriptionUseCase","ContentEntryFormModelModifier"],"mappings":";;;;;;;;;;;;;;;AA8BO,MAAMA,uBAAuB;AAEpC,MAAMC;IAMF,YACqBC,gBAA4C,EAC5CC,mBAAkD,EAClDC,YAAoC,EACpCC,aAAwC,EACxCC,eAA0C,EAC1CC,kBAAgD,EAChDC,yBAA8D,EAC9DC,kBAAgD,EAChDC,mBAAkD,EAClDC,qBAAsD,EACtDC,kBAAgD,EAChDC,gCAA4E,EAC5EC,kBAA6D,CAChF;aAbmBZ,g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gBAAgBtC;IAChB,cAAc;QACVuC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAA+B;gBAAE,UAAU;YAAK;SAAE;KACtD;AACL"}
1
+ {"version":3,"file":"presentation/contentEntries/form/ContentEntryFormPresenter.js","sources":["../../../../src/presentation/contentEntries/form/ContentEntryFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction, toJS } from \"mobx\";\nimport { FormModel, FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { Confirmation } from \"@webiny/app-admin/features/confirmation/abstractions.js\";\nimport type { CmsContentEntry, CmsModel } from \"~/types.js\";\nimport { GetEntryUseCase } from \"~/features/contentEntry/getEntry/abstractions.js\";\nimport { CreateEntryUseCase } from \"~/features/contentEntry/createEntry/abstractions.js\";\nimport { UpdateEntryUseCase } from \"~/features/contentEntry/updateEntry/abstractions.js\";\nimport { PublishEntryUseCase } from \"~/features/contentEntry/publishEntry/abstractions.js\";\nimport { UnpublishEntryUseCase } from \"~/features/contentEntry/unpublishEntry/abstractions.js\";\nimport { DeleteEntryUseCase } from \"~/features/contentEntry/deleteEntry/abstractions.js\";\nimport { UpdateRevisionDescriptionUseCase } from \"~/features/contentEntry/updateRevisionDescription/abstractions.js\";\nimport { CmsFormModelBuilder } from \"~/features/formModel/abstractions.js\";\nimport { CmsModelContext } from \"~/features/contentEntry/abstractions.js\";\nimport {\n ContentEntryFormModelModifier,\n ContentEntryFormPresenter as Abstraction\n} from \"./abstractions.js\";\nimport { TRASH_ENTRY_DIALOG } from \"~/presentation/contentEntries/list/ContentEntriesPresenter.js\";\nimport { CreateRevisionFromUseCase } from \"~/features/contentEntry/createRevisionFrom/abstractions.js\";\nimport { toFormErrors } from \"./toFormErrors.js\";\n\ninterface PublishEntryDialogData {\n revisionDescription: string;\n}\n\ninterface SaveEntryParams {\n model: CmsModel;\n entry: CmsContentEntry;\n data: Record<string, unknown>;\n skipValidation?: boolean;\n}\n\nexport const PUBLISH_ENTRY_DIALOG = \"publish-entry\";\n\nconst SAVING = \"Saving...\";\n\nclass ContentEntryFormPresenterImpl implements Abstraction.Interface {\n private entry: CmsContentEntry | null = null;\n private form: FormModel.Interface | null = null;\n private loading: string | null = null;\n private folderId: string | null = null;\n\n constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly cmsFormModelBuilder: CmsFormModelBuilder.Interface,\n private readonly confirmation: Confirmation.Interface,\n private readonly modelAccessor: CmsModelContext.Interface,\n private readonly getEntryUseCase: GetEntryUseCase.Interface,\n private readonly createEntryUseCase: CreateEntryUseCase.Interface,\n private readonly createRevisionFromUseCase: CreateRevisionFromUseCase.Interface,\n private readonly updateEntryUseCase: UpdateEntryUseCase.Interface,\n private readonly publishEntryUseCase: PublishEntryUseCase.Interface,\n private readonly unpublishEntryUseCase: UnpublishEntryUseCase.Interface,\n private readonly deleteEntryUseCase: DeleteEntryUseCase.Interface,\n private readonly updateRevisionDescriptionUseCase: UpdateRevisionDescriptionUseCase.Interface,\n private readonly formModelModifiers: ContentEntryFormModelModifier.Interface[]\n ) {\n makeAutoObservable<\n ContentEntryFormPresenterImpl,\n | \"formModelFactory\"\n | \"cmsFormModelBuilder\"\n | \"confirmation\"\n | \"modelAccessor\"\n | \"getEntryUseCase\"\n | \"createEntryUseCase\"\n | \"updateEntryUseCase\"\n | \"publishEntryUseCase\"\n | \"unpublishEntryUseCase\"\n | \"deleteEntryUseCase\"\n | \"updateRevisionDescriptionUseCase\"\n | \"formModelModifiers\"\n >(this, {\n formModelFactory: false,\n cmsFormModelBuilder: false,\n confirmation: false,\n modelAccessor: false,\n getEntryUseCase: false,\n createEntryUseCase: false,\n updateEntryUseCase: false,\n publishEntryUseCase: false,\n unpublishEntryUseCase: false,\n deleteEntryUseCase: false,\n updateRevisionDescriptionUseCase: false,\n formModelModifiers: false,\n vm: computed\n });\n }\n\n private get model() {\n return this.modelAccessor.getModel();\n }\n\n get vm(): Abstraction.ViewModel {\n const entry = this.entry;\n const meta = entry?.meta;\n const isLocked = meta?.locked ?? false;\n const status = meta?.status;\n /**\n * Can save if the entry is locked and published/unpublished - it will trigger create new revision.\n * Or if the entry is not locked and the form is not null (meaning we are creating a new entry or editing an existing one).\n */\n const canSave =\n (isLocked && (status === \"published\" || status === \"unpublished\")) ||\n (!isLocked && this.form !== null);\n\n return {\n loading: this.loading,\n model: this.model,\n entry: toJS(this.entry),\n form: this.form?.vm ?? null,\n canSave,\n status,\n canCreateNewRevision:\n !!status && canSave && [\"published\", \"unpublished\"].includes(status),\n canPublish: this.entry !== null && status !== \"published\",\n canUnpublish: this.entry !== null && status === \"published\",\n canDelete: this.entry !== null,\n isNewEntry: this.entry === null && this.form !== null,\n isDirty: this.form?.isDirty ?? false\n };\n }\n\n async saveRevision(options?: { skipValidation?: boolean }): Promise<boolean> {\n if (!this.form) {\n return false;\n }\n\n /*\n * Saving is async, and the form can be reset or replaced by another entry before it\n * finishes. Keep hold of the form and model being saved, and only write the result back\n * while that form is still the one on screen.\n */\n const form = this.form;\n const model = this.model;\n const isCurrent = () => this.form === form && this.model.modelId === model.modelId;\n\n const skipValidation = options?.skipValidation ?? true;\n const data = await form.submit({ skipValidation });\n\n /*\n * Validation is async too. If another entry was opened in the meantime, `this.entry`\n * already points at it, and saving now would write this form's values onto that entry.\n */\n if (!data || !isCurrent()) {\n return false;\n }\n\n // Read the write target once, before the first await, so the write stays on this entry.\n const entry = this.entry;\n const folderId = this.folderId;\n\n runInAction(() => {\n this.loading = SAVING;\n });\n\n try {\n let savedEntry: CmsContentEntry;\n if (entry) {\n /**\n * In case the entry already exists, and it is NOT locked, we will update the existing revision.\n * If it is locked, we will create a new revision from the existing one, and then update that new revision.\n */\n savedEntry = await this.saveEntry({ model, entry, data, skipValidation });\n } else {\n const createData: Record<string, unknown> = { values: data };\n if (folderId) {\n createData.wbyAco_location = { folderId };\n }\n\n savedEntry = await this.createEntryUseCase.execute({\n model,\n data: createData,\n options: { skipValidation }\n });\n }\n\n /*\n * The write went to the right entry, but another form is on screen now. Leave it\n * alone and return false, so callers don't select, toast or publish the entry that\n * is open now instead of the one that was saved.\n */\n if (!isCurrent()) {\n return false;\n }\n\n runInAction(() => {\n this.entry = savedEntry;\n form.setData(savedEntry.values);\n form.reset();\n });\n\n return true;\n } catch (error) {\n if (isCurrent()) {\n form.setErrors(toFormErrors(error, model));\n }\n return false;\n } finally {\n runInAction(() => {\n // Opening another entry sets its own loading message. Don't clear that one.\n if (this.loading === SAVING) {\n this.loading = null;\n }\n });\n }\n }\n\n async publishRevision(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n const result = await this.confirmation.confirm<PublishEntryDialogData>(\n PUBLISH_ENTRY_DIALOG,\n { entry: this.entry }\n );\n\n if (result === false) {\n return false;\n }\n\n runInAction(() => {\n this.loading = \"Publishing...\";\n });\n\n try {\n if (result.revisionDescription) {\n await this.updateRevisionDescriptionUseCase.execute({\n model: this.model,\n id: this.entry.id,\n revisionDescription: result.revisionDescription\n });\n }\n\n const entry = await this.publishEntryUseCase.execute({\n model: this.model,\n revisionId: this.entry.id\n });\n\n runInAction(() => {\n this.entry = entry;\n });\n\n return true;\n } catch {\n return false;\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n async unpublishRevision(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n this.loading = \"Unpublishing...\";\n\n try {\n const entry = await this.unpublishEntryUseCase.execute({\n model: this.model,\n revisionId: this.entry.id\n });\n\n runInAction(() => {\n this.entry = entry;\n });\n\n return true;\n } catch {\n return false;\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n async deleteEntry(): Promise<boolean> {\n if (!this.entry) {\n return false;\n }\n\n const model = this.model;\n const entry = this.entry;\n\n return this.confirmation.confirm(\n TRASH_ENTRY_DIALOG,\n { entryId: entry.entryId },\n async () => {\n try {\n await this.deleteEntryUseCase.execute({\n model,\n id: entry.entryId\n });\n\n runInAction(() => {\n this.entry = null;\n this.form = null;\n });\n\n return true;\n } catch {\n return false;\n }\n }\n );\n }\n\n async loadRevision(id: string): Promise<void> {\n this.loading = \"Loading entry...\";\n\n try {\n const entry = await this.getEntryUseCase.execute({\n model: this.model,\n id\n });\n\n runInAction(() => {\n this.entry = entry;\n this.buildAndPopulateForm(entry);\n });\n } finally {\n runInAction(() => {\n this.loading = null;\n });\n }\n }\n\n setFolderId(folderId: string | null): void {\n this.folderId = folderId;\n }\n\n newEntry(initialValues?: Record<string, unknown>): void {\n this.entry = null;\n this.form = this.buildForm();\n if (initialValues) {\n this.form.setData(initialValues, { dirty: true });\n }\n }\n\n patchEntryMeta(meta: Partial<CmsContentEntry[\"meta\"]>): void {\n if (!this.entry) {\n return;\n }\n this.entry = {\n ...this.entry,\n meta: { ...this.entry.meta, ...meta }\n };\n }\n\n reset(): void {\n this.form = null;\n this.entry = null;\n }\n\n private buildForm(): FormModel.Interface {\n const formConfig = this.cmsFormModelBuilder.build(this.model);\n const form = this.formModelFactory.create(formConfig);\n for (const modifier of this.formModelModifiers) {\n modifier.modifyForm(form, this.model);\n }\n return form;\n }\n\n private buildAndPopulateForm(entry: CmsContentEntry): void {\n this.form = this.buildForm();\n this.form.setData(entry.values);\n this.form.reset();\n }\n /**\n * Depending on whether the entry is locked or not, this method will either create a new revision from the existing one and update it, or simply update the existing revision.\n */\n private async saveEntry(params: SaveEntryParams): Promise<CmsContentEntry> {\n const { model, entry, data, skipValidation } = params;\n\n if (entry.meta.locked) {\n return await this.createRevisionFromUseCase.execute({\n model,\n revisionId: entry.id,\n data: {\n values: data\n },\n options: { skipValidation }\n });\n }\n return await this.updateEntryUseCase.execute({\n model,\n revisionId: entry.id,\n data: {\n values: data\n },\n options: { skipValidation }\n });\n }\n}\n\nexport const ContentEntryFormPresenter = Abstraction.createImplementation({\n implementation: ContentEntryFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n CmsFormModelBuilder,\n Confirmation,\n CmsModelContext,\n GetEntryUseCase,\n CreateEntryUseCase,\n CreateRevisionFromUseCase,\n UpdateEntryUseCase,\n PublishEntryUseCase,\n UnpublishEntryUseCase,\n DeleteEntryUseCase,\n UpdateRevisionDescriptionUseCase,\n [ContentEntryFormModelModifier, { multiple: true }]\n ]\n});\n"],"names":["PUBLISH_ENTRY_DIALOG","SAVING","ContentEntryFormPresenterImpl","formModelFactory","cmsFormModelBuilder","confirmation","modelAccessor","getEntryUseCase","createEntryUseCase","createRevisionFromUseCase","updateEntryUseCase","publishEntryUseCase","unpublishEntryUseCase","deleteEntryUseCase","updateRevisionDescriptionUseCase","formModelModifiers","makeAutoObservable","computed","entry","meta","isLocked","status","canSave","toJS","options","form","model","isCurrent","skipValidation","data","folderId","runInAction","savedEntry","createData","error","toFormErrors","result","TRASH_ENTRY_DIALOG","id","initialValues","formConfig","modifier","params","ContentEntryFormPresenter","Abstraction","FormModelFactory","CmsFormModelBuilder","Confirmation","CmsModelContext","GetEntryUseCase","CreateEntryUseCase","CreateRevisionFromUseCase","UpdateEntryUseCase","PublishEntryUseCase","UnpublishEntryUseCase","DeleteEntryUseCase","UpdateRevisionDescriptionUseCase","ContentEntryFormModelModifier"],"mappings":";;;;;;;;;;;;;;;;AAgCO,MAAMA,uBAAuB;AAEpC,MAAMC,SAAS;AAEf,MAAMC;IAMF,YACqBC,gBAA4C,EAC5CC,mBAAkD,EAClDC,YAAoC,EACpCC,aAAwC,EACxCC,eAA0C,EAC1CC,kBAAgD,EAChDC,yBAA8D,EAC9DC,kBAAgD,EAChDC,mBAAkD,EAClDC,qBAAsD,EACtDC,kBAAgD,EAChDC,gCAA4E,EAC5EC,kBAA6D,CAChF;aAbmBZ,gBAAgB,GAAhBA;aACAC,mBAAmB,GAAnBA;aACAC,YAAY,GAAZA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,kBAAkB,GAAlBA;aACAC,yBAAyB,GAAzBA;aACAC,kBAAkB,GAAlBA;aACAC,mBAAmB,GAAnBA;aACAC,qBAAqB,GAArBA;aACA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