@webiny/app-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (527) hide show
  1. package/ContentEntriesModule.js +23 -6
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/HeadlessCMS.js +7 -2
  4. package/HeadlessCMS.js.map +1 -1
  5. package/admin/RoutesConfig.js +19 -2
  6. package/admin/RoutesConfig.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionDelete.js +2 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  10. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.d.ts +1 -0
  11. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js +125 -0
  12. package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js.map +1 -0
  13. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  14. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  15. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  16. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  17. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  18. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  19. package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
  20. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +85 -0
  21. package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
  22. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  23. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  24. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  25. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  26. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  27. package/admin/components/ContentEntries/Table/Cells/CellLive.js +9 -2
  28. package/admin/components/ContentEntries/Table/Cells/CellLive.js.map +1 -1
  29. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  30. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  31. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
  32. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
  33. package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
  34. package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
  35. package/admin/components/ContentModelEditor/evaluateExpression.d.ts +1 -1
  36. package/admin/components/ContentModelEditor/evaluateExpression.js +10 -0
  37. package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
  38. package/admin/components/ContentModelEditor/operatorOptions.js +12 -0
  39. package/admin/components/ContentModelEditor/operatorOptions.js.map +1 -1
  40. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  41. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  42. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  43. package/admin/components/Dialogs/EditRevisionNoteDialog.d.ts +2 -0
  44. package/admin/components/Dialogs/EditRevisionNoteDialog.js +33 -0
  45. package/admin/components/Dialogs/EditRevisionNoteDialog.js.map +1 -0
  46. package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
  47. package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
  48. package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
  49. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
  50. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
  51. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
  52. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
  53. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
  54. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  55. package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
  56. package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
  57. package/admin/components/FieldEditor/Field.js +5 -5
  58. package/admin/components/FieldEditor/Field.js.map +1 -1
  59. package/admin/components/FieldEditor/FieldEditor.js +2 -2
  60. package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
  61. package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
  62. package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
  63. package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
  64. package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
  65. package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
  66. package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
  67. package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
  68. package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
  69. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
  70. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
  71. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
  72. package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
  73. package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
  74. package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
  75. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
  76. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
  77. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
  78. package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
  79. package/admin/config/contentEntries/list/Browser/index.js +2 -0
  80. package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
  81. package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
  82. package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
  83. package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
  84. package/admin/graphql/contentModels.d.ts +2 -2
  85. package/admin/graphql/contentModels.js +3 -1
  86. package/admin/graphql/contentModels.js.map +1 -1
  87. package/admin/hooks/usePermission.js +6 -34
  88. package/admin/hooks/usePermission.js.map +1 -1
  89. package/admin/plugins/editor/defaultBar/Name/Name.d.ts +0 -5
  90. package/admin/plugins/editor/defaultBar/Name/Name.js +0 -2
  91. package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
  92. package/admin/plugins/editor/formSettings/components/GeneralSettings.js +8 -1
  93. package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
  94. package/domain/permissions/checkCmsPermission.d.ts +14 -0
  95. package/domain/permissions/checkCmsPermission.js +20 -0
  96. package/domain/permissions/checkCmsPermission.js.map +1 -0
  97. package/domain/permissions/hasAccessForModel.d.ts +11 -0
  98. package/domain/permissions/hasAccessForModel.js +20 -0
  99. package/domain/permissions/hasAccessForModel.js.map +1 -0
  100. package/domain/permissions/isModelAllowed.d.ts +2 -0
  101. package/domain/permissions/isModelAllowed.js +11 -0
  102. package/domain/permissions/isModelAllowed.js.map +1 -0
  103. package/exports/admin/cms/entry/editor.d.ts +1 -0
  104. package/exports/admin/cms/entry/editor.js +1 -0
  105. package/exports/admin/cms/entry/list.d.ts +2 -0
  106. package/exports/admin/cms/entry/list.js +2 -0
  107. package/exports/admin/cms.d.ts +2 -0
  108. package/exports/admin/cms.js +2 -0
  109. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  110. package/features/contentEntry/CmsEntryError.js +11 -0
  111. package/features/contentEntry/CmsEntryError.js.map +1 -0
  112. package/features/contentEntry/EntryGraphQLFields.js +1 -1
  113. package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
  114. package/features/contentEntry/bulkAction/BulkActionGateway.js +6 -1
  115. package/features/contentEntry/bulkAction/BulkActionGateway.js.map +1 -1
  116. package/features/contentEntry/bulkAction/BulkActionGateway.test.d.ts +1 -0
  117. package/features/contentEntry/bulkAction/BulkActionGateway.test.js +134 -0
  118. package/features/contentEntry/bulkAction/BulkActionGateway.test.js.map +1 -0
  119. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  120. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  121. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  122. package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
  123. package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
  124. package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
  125. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  126. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  127. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  128. package/features/contentEntry/deleteEntry/DeleteEntryGateway.js +6 -1
  129. package/features/contentEntry/deleteEntry/DeleteEntryGateway.js.map +1 -1
  130. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.d.ts +1 -0
  131. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js +116 -0
  132. package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js.map +1 -0
  133. package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
  134. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
  135. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
  136. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js +6 -1
  137. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js.map +1 -1
  138. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.d.ts +1 -0
  139. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js +112 -0
  140. package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js.map +1 -0
  141. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  142. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  143. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  144. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  145. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  146. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  147. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  148. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  149. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  150. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  151. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  152. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  153. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  154. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  155. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  156. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  157. package/features/contentEntry/entryValueGateways.test.js +106 -0
  158. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  159. package/features/contentEntry/feature.js +4 -2
  160. package/features/contentEntry/feature.js.map +1 -1
  161. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js +6 -1
  162. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js.map +1 -1
  163. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.d.ts +1 -0
  164. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js +130 -0
  165. package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js.map +1 -0
  166. package/features/contentEntry/refTypes.d.ts +7 -0
  167. package/features/contentEntry/refTypes.js.map +1 -1
  168. package/features/contentEntry/referenceTitles/ReferenceTitles.d.ts +18 -0
  169. package/features/contentEntry/referenceTitles/ReferenceTitles.js +58 -0
  170. package/features/contentEntry/referenceTitles/ReferenceTitles.js.map +1 -0
  171. package/features/contentEntry/referenceTitles/ReferenceTitles.test.d.ts +1 -0
  172. package/features/contentEntry/referenceTitles/ReferenceTitles.test.js +173 -0
  173. package/features/contentEntry/referenceTitles/ReferenceTitles.test.js.map +1 -0
  174. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.d.ts +22 -0
  175. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js +40 -0
  176. package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js.map +1 -0
  177. package/features/contentEntry/referenceTitles/abstractions.d.ts +16 -0
  178. package/features/contentEntry/referenceTitles/abstractions.js +5 -0
  179. package/features/contentEntry/referenceTitles/abstractions.js.map +1 -0
  180. package/features/contentEntry/referenceTitles/feature.d.ts +3 -0
  181. package/features/contentEntry/referenceTitles/feature.js +20 -0
  182. package/features/contentEntry/referenceTitles/feature.js.map +1 -0
  183. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  184. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  185. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  186. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  187. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  188. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  189. package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
  190. package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
  191. package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
  192. package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js +7 -2
  193. package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js.map +1 -1
  194. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  195. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  196. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  197. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  198. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  199. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  200. package/features/contentEntry/valueTransformers/ObjectValueTransformer.js +16 -2
  201. package/features/contentEntry/valueTransformers/ObjectValueTransformer.js.map +1 -1
  202. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  203. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  204. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  205. package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
  206. package/features/formModel/CmsFormModelBuilder.js +26 -15
  207. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  208. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  209. package/features/formModel/CmsFormModelBuilder.test.js +465 -0
  210. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  211. package/features/formModel/CmsLayoutMapper.d.ts +8 -1
  212. package/features/formModel/CmsLayoutMapper.js +27 -5
  213. package/features/formModel/CmsLayoutMapper.js.map +1 -1
  214. package/features/formModel/CmsRefFieldValueFormatter.d.ts +12 -0
  215. package/features/formModel/CmsRefFieldValueFormatter.js +29 -0
  216. package/features/formModel/CmsRefFieldValueFormatter.js.map +1 -0
  217. package/features/formModel/CmsValidationMapper.d.ts +9 -0
  218. package/features/formModel/CmsValidationMapper.js +25 -19
  219. package/features/formModel/CmsValidationMapper.js.map +1 -1
  220. package/features/formModel/feature.js +2 -2
  221. package/features/formModel/feature.js.map +1 -1
  222. package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
  223. package/features/formModel/mappers/AssetFieldMapper.js +13 -0
  224. package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
  225. package/features/formModel/mappers/DateTimeFieldMapper.js +3 -0
  226. package/features/formModel/mappers/DateTimeFieldMapper.js.map +1 -1
  227. package/features/formModel/mappers/DynamicZoneFieldMapper.js +8 -2
  228. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  229. package/features/formModel/mappers/ObjectFieldMapper.js +12 -5
  230. package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
  231. package/features/formModel/mappers/applyFieldProps.js +2 -1
  232. package/features/formModel/mappers/applyFieldProps.js.map +1 -1
  233. package/features/formModel/mappers/applyFieldProps.test.d.ts +1 -0
  234. package/features/formModel/mappers/applyFieldProps.test.js +59 -0
  235. package/features/formModel/mappers/applyFieldProps.test.js.map +1 -0
  236. package/features/formModel/mappers/index.js +2 -0
  237. package/features/formModel/mappers/index.js.map +1 -1
  238. package/features/model/deleteModel/DeleteModelGateway.js +6 -1
  239. package/features/model/deleteModel/DeleteModelGateway.js.map +1 -1
  240. package/features/model/deleteModel/DeleteModelGateway.test.d.ts +1 -0
  241. package/features/model/deleteModel/DeleteModelGateway.test.js +71 -0
  242. package/features/model/deleteModel/DeleteModelGateway.test.js.map +1 -0
  243. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  244. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  245. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  246. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  247. package/features/model/exportModels/abstractions.d.ts +8 -2
  248. package/features/model/exportModels/abstractions.js.map +1 -1
  249. package/features/model/updateModel/UpdateModelGateway.js +1 -0
  250. package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
  251. package/index.d.ts +1 -1
  252. package/index.js +1 -1
  253. package/package.json +30 -28
  254. package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
  255. package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
  256. package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
  257. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.d.ts +1 -1
  258. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js +6 -1
  259. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js.map +1 -1
  260. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.d.ts +1 -0
  261. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js +124 -0
  262. package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js.map +1 -0
  263. package/presentation/contentEntries/bulkActions/abstractions.d.ts +1 -1
  264. package/presentation/contentEntries/bulkActions/abstractions.js.map +1 -1
  265. package/presentation/contentEntries/form/ContentEntryFormPresenter.d.ts +2 -0
  266. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.d.ts +1 -0
  267. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js +107 -0
  268. package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js.map +1 -0
  269. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +47 -30
  270. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  271. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
  272. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +244 -0
  273. package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
  274. package/presentation/contentEntries/form/abstractions.d.ts +1 -0
  275. package/presentation/contentEntries/form/abstractions.js.map +1 -1
  276. package/presentation/contentEntries/form/getFieldBuilders.test.js +4 -2
  277. package/presentation/contentEntries/form/getFieldBuilders.test.js.map +1 -1
  278. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  279. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  280. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  281. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  282. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  283. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  284. package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
  285. package/presentation/contentEntries/list/ContentEntriesDataSource.js +16 -4
  286. package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
  287. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  288. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  289. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  290. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +134 -5
  291. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  292. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  293. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  294. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +7 -0
  295. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
  296. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
  297. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +25 -0
  298. package/presentation/contentEntries/preview/LivePreviewPresenter.js +76 -0
  299. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
  300. package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
  301. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
  302. package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
  303. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
  304. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +30 -0
  305. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
  306. package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
  307. package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
  308. package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
  309. package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
  310. package/presentation/contentEntries/preview/PreviewDecorator.js +68 -0
  311. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
  312. package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
  313. package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
  314. package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
  315. package/presentation/contentEntries/preview/PreviewPane.d.ts +18 -0
  316. package/presentation/contentEntries/preview/PreviewPane.js +217 -0
  317. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
  318. package/presentation/contentEntries/preview/abstractions.d.ts +24 -0
  319. package/presentation/contentEntries/preview/abstractions.js +5 -0
  320. package/presentation/contentEntries/preview/abstractions.js.map +1 -0
  321. package/presentation/contentEntries/preview/feature.d.ts +3 -0
  322. package/presentation/contentEntries/preview/feature.js +17 -0
  323. package/presentation/contentEntries/preview/feature.js.map +1 -0
  324. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +26 -0
  325. package/presentation/contentEntries/preview/resolvePreviewUrl.js +81 -0
  326. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
  327. package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
  328. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
  329. package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
  330. package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
  331. package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
  332. package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
  333. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.d.ts +21 -2
  334. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js +143 -6
  335. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js.map +1 -1
  336. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.d.ts +1 -0
  337. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js +384 -0
  338. package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js.map +1 -0
  339. package/presentation/contentEntries/revisionsList/abstractions.d.ts +16 -0
  340. package/presentation/contentEntries/revisionsList/abstractions.js.map +1 -1
  341. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
  342. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  343. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
  344. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
  345. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
  346. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  347. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  348. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
  349. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
  350. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
  351. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  352. package/presentation/contentEntries/views/ContentEntriesListLayout.js +4 -2
  353. package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
  354. package/presentation/contentEntries/views/ContentEntriesView.js +2 -0
  355. package/presentation/contentEntries/views/ContentEntriesView.js.map +1 -1
  356. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  357. package/presentation/contentEntries/views/ContentEntryFormView.js +8 -6
  358. package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
  359. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +4 -0
  360. package/presentation/contentEntries/views/OlderRevisionAlert.js +43 -0
  361. package/presentation/contentEntries/views/OlderRevisionAlert.js.map +1 -0
  362. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  363. package/presentation/contentEntries/views/RevisionDrawer.js +4 -0
  364. package/presentation/contentEntries/views/RevisionDrawer.js.map +1 -1
  365. package/presentation/contentEntries/views/RevisionListItem.d.ts +3 -3
  366. package/presentation/contentEntries/views/RevisionListItem.js +82 -14
  367. package/presentation/contentEntries/views/RevisionListItem.js.map +1 -1
  368. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  369. package/presentation/contentEntries/views/RevisionsList.js +3 -3
  370. package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
  371. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  372. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  373. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  374. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
  375. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js.map +1 -1
  376. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  377. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  378. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  379. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  380. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  381. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  382. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  383. package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
  384. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
  385. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
  386. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  387. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  388. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  389. package/presentation/contentModels/abstractions.d.ts +7 -2
  390. package/presentation/contentModels/abstractions.js.map +1 -1
  391. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  392. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  393. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  394. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  395. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  396. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  397. package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js +8 -3
  398. package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js.map +1 -1
  399. package/presentation/contentModels/components/fullDelete/dialog/Content.js +7 -2
  400. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  401. package/presentation/contentModels/components/fullDelete/dialog/Content.test.d.ts +1 -0
  402. package/presentation/contentModels/components/fullDelete/dialog/Content.test.js +54 -0
  403. package/presentation/contentModels/components/fullDelete/dialog/Content.test.js.map +1 -0
  404. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.d.ts +25 -0
  405. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js +9 -0
  406. package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js.map +1 -0
  407. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  408. package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
  409. package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
  410. package/presentation/fieldEditor/groups/AppearanceGroup.js +12 -0
  411. package/presentation/fieldEditor/groups/AppearanceGroup.js.map +1 -1
  412. package/presentation/fieldEditor/groups/GeneralGroup.d.ts +5 -5
  413. package/presentation/fieldEditor/groups/GeneralGroup.js +5 -1
  414. package/presentation/fieldEditor/groups/GeneralGroup.js.map +1 -1
  415. package/presentation/fieldEditor/groups/GeneralGroup.test.d.ts +1 -0
  416. package/presentation/fieldEditor/groups/GeneralGroup.test.js +68 -0
  417. package/presentation/fieldEditor/groups/GeneralGroup.test.js.map +1 -0
  418. package/presentation/fieldEditor/groups/ValidationsGroup.d.ts +2 -0
  419. package/presentation/fieldEditor/groups/ValidationsGroup.js +21 -7
  420. package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
  421. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
  422. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
  423. package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js +2 -2
  424. package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js.map +1 -1
  425. package/presentation/fieldRenderers/feature.js +2 -1
  426. package/presentation/fieldRenderers/feature.js.map +1 -1
  427. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
  428. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
  429. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
  430. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
  431. package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js +1 -0
  432. package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js.map +1 -1
  433. package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js +1 -0
  434. package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js.map +1 -1
  435. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
  436. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
  437. package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
  438. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
  439. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
  440. package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
  441. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
  442. package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
  443. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
  444. package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
  445. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
  446. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
  447. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
  448. package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
  449. package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
  450. package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
  451. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  452. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  453. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  454. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
  455. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
  456. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
  457. package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
  458. package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
  459. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
  460. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
  461. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
  462. package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
  463. package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
  464. package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
  465. package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
  466. package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
  467. package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
  468. package/presentation/fieldTypes/abstractions.d.ts +12 -0
  469. package/presentation/fieldTypes/abstractions.js.map +1 -1
  470. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
  471. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
  472. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.d.ts +15 -0
  473. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js +19 -0
  474. package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js.map +1 -0
  475. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
  476. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
  477. package/presentation/fieldTypes/renderers/index.d.ts +1 -0
  478. package/presentation/fieldTypes/renderers/index.js +1 -0
  479. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
  480. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
  481. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
  482. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
  483. package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
  484. package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
  485. package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
  486. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
  487. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
  488. package/presentation/fieldValidators/abstractions.d.ts +7 -0
  489. package/presentation/fieldValidators/abstractions.js.map +1 -1
  490. package/presentation/fieldValidators/validators/DateGteValidator.d.ts +6 -0
  491. package/presentation/fieldValidators/validators/DateGteValidator.js +17 -25
  492. package/presentation/fieldValidators/validators/DateGteValidator.js.map +1 -1
  493. package/presentation/fieldValidators/validators/DateLteValidator.d.ts +6 -0
  494. package/presentation/fieldValidators/validators/DateLteValidator.js +17 -25
  495. package/presentation/fieldValidators/validators/DateLteValidator.js.map +1 -1
  496. package/presentation/fieldValidators/validators/dateLimitSettings.d.ts +20 -0
  497. package/presentation/fieldValidators/validators/dateLimitSettings.js +124 -0
  498. package/presentation/fieldValidators/validators/dateLimitSettings.js.map +1 -0
  499. package/presentation/fieldValidators/validators/dateLimitSettings.test.d.ts +1 -0
  500. package/presentation/fieldValidators/validators/dateLimitSettings.test.js +111 -0
  501. package/presentation/fieldValidators/validators/dateLimitSettings.test.js.map +1 -0
  502. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  503. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  504. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  505. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  506. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  507. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  508. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  509. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  510. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  511. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  512. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  513. package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
  514. package/presentation/modelGroup/ModelGroupPresenter.js +8 -11
  515. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  516. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  517. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  518. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  519. package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
  520. package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
  521. package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
  522. package/utils/normalizeIcon.d.ts +4 -0
  523. package/utils/normalizeIcon.js +9 -6
  524. package/utils/normalizeIcon.js.map +1 -1
  525. package/features/formModel/CmsAccessControlRuleEvaluator.d.ts +0 -9
  526. package/features/formModel/CmsAccessControlRuleEvaluator.js +0 -16
  527. package/features/formModel/CmsAccessControlRuleEvaluator.js.map +0 -1
@@ -0,0 +1,124 @@
1
+ import { z } from "zod";
2
+ import { parseDateExpression } from "@webiny/utils";
3
+ const isDateOnly = (field)=>{
4
+ const type = field.settings ? field.settings.type : "date";
5
+ return !type || "date" === type;
6
+ };
7
+ const isLiveDateOnly = (form)=>{
8
+ try {
9
+ const type = form.field("general.settingsType").getValue();
10
+ return "string" != typeof type || "date" === type;
11
+ } catch {
12
+ return true;
13
+ }
14
+ };
15
+ const isRelative = ({ field, form })=>isLiveDateOnly(form) && "relative" === field.parent().field("mode").getValue();
16
+ function buildDateLimitSettingsForm(form, context, options) {
17
+ const type = context.field.settings ? context.field.settings.type : "date";
18
+ const relativeAllowed = isDateOnly(context.field);
19
+ form.fields((fields)=>{
20
+ const valueField = fields.datetime().label("Value").description(options.valueDescription);
21
+ switch(type){
22
+ case "time":
23
+ valueField.timeOnly();
24
+ break;
25
+ case "dateTimeWithTimezone":
26
+ valueField.withTimezone();
27
+ break;
28
+ case "dateTimeWithoutTimezone":
29
+ valueField.withoutTimezone();
30
+ break;
31
+ default:
32
+ valueField.dateOnly();
33
+ break;
34
+ }
35
+ if (!relativeAllowed) return {
36
+ value: valueField
37
+ };
38
+ return {
39
+ mode: fields.text().label("Limit").description("A date relative to today is worked out from the current date every time the value is checked.").options([
40
+ {
41
+ value: "fixed",
42
+ label: "Fixed date"
43
+ },
44
+ {
45
+ value: "relative",
46
+ label: "Relative to today"
47
+ }
48
+ ]).defaultValue("fixed").hiddenWhen(({ form })=>!isLiveDateOnly(form)),
49
+ value: valueField.hiddenWhen(isRelative),
50
+ amount: fields.number().label("Amount").required("Enter a number.").schema(z.number().int("Use a whole number.").min(0, "Use 0 or more.")).hiddenWhen((params)=>!isRelative(params)),
51
+ unit: fields.text().label("Unit").options([
52
+ {
53
+ value: "d",
54
+ label: "Days"
55
+ },
56
+ {
57
+ value: "m",
58
+ label: "Months"
59
+ },
60
+ {
61
+ value: "y",
62
+ label: "Years"
63
+ }
64
+ ]).defaultValue("y").hiddenWhen((params)=>!isRelative(params)),
65
+ direction: fields.text().label("Direction").options([
66
+ {
67
+ value: "before",
68
+ label: "Before today"
69
+ },
70
+ {
71
+ value: "after",
72
+ label: "After today"
73
+ }
74
+ ]).defaultValue("before").hiddenWhen((params)=>!isRelative(params))
75
+ };
76
+ });
77
+ form.layout((layout)=>relativeAllowed ? [
78
+ layout.row("mode"),
79
+ layout.row("value"),
80
+ layout.row("amount", "unit", "direction")
81
+ ] : [
82
+ layout.row("value")
83
+ ]);
84
+ }
85
+ function dateLimitSettingsToForm(settings, context) {
86
+ if (!isDateOnly(context.field)) return settings;
87
+ const { expression, ...rest } = settings;
88
+ const parsed = "string" == typeof expression ? parseDateExpression(expression) : null;
89
+ if (!parsed) return {
90
+ ...rest,
91
+ mode: "fixed",
92
+ unit: "y",
93
+ direction: "before"
94
+ };
95
+ const direction = parsed.amount > 0 ? "after" : "before";
96
+ return {
97
+ ...rest,
98
+ mode: "relative",
99
+ amount: Math.abs(parsed.amount),
100
+ unit: 0 === parsed.amount ? "y" : parsed.unit,
101
+ direction
102
+ };
103
+ }
104
+ function dateLimitSettingsFromForm(settings) {
105
+ const { mode, amount, unit, direction, value, expression: _expression, ...rest } = settings;
106
+ if ("relative" === mode) {
107
+ if ("number" != typeof amount) return rest;
108
+ return {
109
+ ...rest,
110
+ expression: toDateExpression(amount, unit, direction)
111
+ };
112
+ }
113
+ return null == value ? rest : {
114
+ ...rest,
115
+ value
116
+ };
117
+ }
118
+ function toDateExpression(amount, unit, direction) {
119
+ if (0 === amount) return "today";
120
+ return `today${"after" === direction ? "+" : "-"}${amount}${unit}`;
121
+ }
122
+ export { buildDateLimitSettingsForm, dateLimitSettingsFromForm, dateLimitSettingsToForm, toDateExpression };
123
+
124
+ //# sourceMappingURL=dateLimitSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation/fieldValidators/validators/dateLimitSettings.js","sources":["../../../../src/presentation/fieldValidators/validators/dateLimitSettings.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { parseDateExpression, type DateExpressionUnit } from \"@webiny/utils\";\nimport type { FormModel, FormModelFactory } from \"@webiny/app-admin\";\nimport type { CmsModelField } from \"~/types.js\";\nimport type { ICmsFieldValidatorFormBuilder, ICmsFieldValidatorContext } from \"../abstractions.js\";\n\n/**\n * The settings form of the `dateGte`/`dateLte` validators. On a date-only field, a limit is a\n * fixed date or relative to today: a number, a unit and a direction, which the form turns into\n * a date expression (`today-18y`) when the field is saved, and back when it's opened.\n */\n\ntype DateLimitDirection = \"before\" | \"after\";\n\ninterface DateLimitFormOptions {\n /** The Value field's description, for a fixed limit. */\n valueDescription: string;\n}\n\nconst isDateOnly = (field: Pick<CmsModelField, \"settings\">): boolean => {\n const type = field.settings ? field.settings.type : \"date\";\n return !type || type === \"date\";\n};\n\n/**\n * The field's Format as it is in the open dialog, which can differ from the saved one on a new\n * field. Only date/time fields have it, and `form.field()` throws for a path the form doesn't\n * have.\n */\nconst isLiveDateOnly = (form: FormModel.Interface): boolean => {\n try {\n const type = form.field(\"general.settingsType\").getValue();\n return typeof type !== \"string\" || type === \"date\";\n } catch {\n return true;\n }\n};\n\nconst isRelative = ({ field, form }: FormModel.CallbackParams): boolean =>\n isLiveDateOnly(form) && field.parent().field(\"mode\").getValue() === \"relative\";\n\nexport function buildDateLimitSettingsForm(\n form: ICmsFieldValidatorFormBuilder,\n context: ICmsFieldValidatorContext,\n options: DateLimitFormOptions\n): void {\n const type = context.field.settings ? context.field.settings.type : \"date\";\n const relativeAllowed = isDateOnly(context.field);\n\n form.fields((fields): Record<string, FormModelFactory.FieldBuilder> => {\n const valueField = fields.datetime().label(\"Value\").description(options.valueDescription);\n\n switch (type) {\n case \"time\":\n valueField.timeOnly();\n break;\n case \"dateTimeWithTimezone\":\n valueField.withTimezone();\n break;\n case \"dateTimeWithoutTimezone\":\n valueField.withoutTimezone();\n break;\n default:\n valueField.dateOnly();\n break;\n }\n\n if (!relativeAllowed) {\n return { value: valueField };\n }\n\n return {\n mode: fields\n .text()\n .label(\"Limit\")\n .description(\n \"A date relative to today is worked out from the current date every time the value is checked.\"\n )\n .options([\n { value: \"fixed\", label: \"Fixed date\" },\n { value: \"relative\", label: \"Relative to today\" }\n ])\n .defaultValue(\"fixed\")\n .hiddenWhen(({ form }: FormModel.CallbackParams) => !isLiveDateOnly(form)),\n value: valueField.hiddenWhen(isRelative),\n amount: fields\n .number()\n .label(\"Amount\")\n .required(\"Enter a number.\")\n .schema(z.number().int(\"Use a whole number.\").min(0, \"Use 0 or more.\"))\n .hiddenWhen(params => !isRelative(params)),\n unit: fields\n .text()\n .label(\"Unit\")\n .options([\n { value: \"d\", label: \"Days\" },\n { value: \"m\", label: \"Months\" },\n { value: \"y\", label: \"Years\" }\n ])\n .defaultValue(\"y\")\n .hiddenWhen(params => !isRelative(params)),\n direction: fields\n .text()\n .label(\"Direction\")\n .options([\n { value: \"before\", label: \"Before today\" },\n { value: \"after\", label: \"After today\" }\n ])\n .defaultValue(\"before\")\n .hiddenWhen(params => !isRelative(params))\n };\n });\n\n form.layout(layout =>\n relativeAllowed\n ? [layout.row(\"mode\"), layout.row(\"value\"), layout.row(\"amount\", \"unit\", \"direction\")]\n : [layout.row(\"value\")]\n );\n}\n\n/** Stored settings (`{ value }` or `{ expression }`) as the settings form's values. */\nexport function dateLimitSettingsToForm(\n settings: Record<string, unknown>,\n context: ICmsFieldValidatorContext\n): Record<string, unknown> {\n if (!isDateOnly(context.field)) {\n return settings;\n }\n const { expression, ...rest } = settings;\n const parsed = typeof expression === \"string\" ? parseDateExpression(expression) : null;\n if (!parsed) {\n return { ...rest, mode: \"fixed\", unit: \"y\", direction: \"before\" };\n }\n const direction: DateLimitDirection = parsed.amount > 0 ? \"after\" : \"before\";\n return {\n ...rest,\n mode: \"relative\",\n amount: Math.abs(parsed.amount),\n // Plain `today` parses as 0 days; years is the form's default unit.\n unit: parsed.amount === 0 ? \"y\" : parsed.unit,\n direction\n };\n}\n\n/** The settings form's values as stored settings: a fixed `value` or an `expression`. */\nexport function dateLimitSettingsFromForm(\n settings: Record<string, unknown>\n): Record<string, unknown> {\n const { mode, amount, unit, direction, value, expression: _expression, ...rest } = settings;\n if (mode === \"relative\") {\n if (typeof amount !== \"number\") {\n return rest;\n }\n return {\n ...rest,\n expression: toDateExpression(\n amount,\n unit as DateExpressionUnit,\n direction as DateLimitDirection\n )\n };\n }\n return value == null ? rest : { ...rest, value };\n}\n\n/** `today`, or `today` plus or minus the amount: 18 years before today is `today-18y`. */\nexport function toDateExpression(\n amount: number,\n unit: DateExpressionUnit,\n direction: DateLimitDirection\n): string {\n if (amount === 0) {\n return \"today\";\n }\n return `today${direction === \"after\" ? \"+\" : \"-\"}${amount}${unit}`;\n}\n"],"names":["isDateOnly","field","type","isLiveDateOnly","form","isRelative","buildDateLimitSettingsForm","context","options","relativeAllowed","fields","valueField","z","params","layout","dateLimitSettingsToForm","settings","expression","rest","parsed","parseDateExpression","direction","Math","dateLimitSettingsFromForm","mode","amount","unit","value","_expression","toDateExpression"],"mappings":";;AAmBA,MAAMA,aAAa,CAACC;IAChB,MAAMC,OAAOD,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAG;IACpD,OAAO,CAACC,QAAQA,AAAS,WAATA;AACpB;AAOA,MAAMC,iBAAiB,CAACC;IACpB,IAAI;QACA,MAAMF,OAAOE,KAAK,KAAK,CAAC,wBAAwB,QAAQ;QACxD,OAAO,AAAgB,YAAhB,OAAOF,QAAqBA,AAAS,WAATA;IACvC,EAAE,OAAM;QACJ,OAAO;IACX;AACJ;AAEA,MAAMG,aAAa,CAAC,EAAEJ,KAAK,EAAEG,IAAI,EAA4B,GACzDD,eAAeC,SAASH,AAA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AOP;QAEX,OAAO;YACH,GAAGA,IAAI;YACP,YAAYW,iBACRJ,QACAC,MACAL;QAER;IACJ;IACA,OAAOM,AAAS,QAATA,QAAgBT,OAAO;QAAE,GAAGA,IAAI;QAAES;IAAM;AACnD;AAGO,SAASE,iBACZJ,MAAc,EACdC,IAAwB,EACxBL,SAA6B;IAE7B,IAAII,AAAW,MAAXA,QACA,OAAO;IAEX,OAAO,CAAC,KAAK,EAAEJ,AAAc,YAAdA,YAAwB,MAAM,MAAMI,SAASC,MAAM;AACtE"}
@@ -0,0 +1,111 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { dateLimitSettingsFromForm, dateLimitSettingsToForm, toDateExpression } from "./dateLimitSettings.js";
3
+ const context = (type)=>({
4
+ field: {
5
+ type: "datetime",
6
+ settings: type ? {
7
+ type
8
+ } : {}
9
+ }
10
+ });
11
+ describe("date limit settings", ()=>{
12
+ it("opens a relative limit as an amount, a unit and a direction", ()=>{
13
+ expect(dateLimitSettingsToForm({
14
+ expression: "today-18y"
15
+ }, context("date"))).toEqual({
16
+ mode: "relative",
17
+ amount: 18,
18
+ unit: "y",
19
+ direction: "before"
20
+ });
21
+ expect(dateLimitSettingsToForm({
22
+ expression: "today+1d"
23
+ }, context("date"))).toEqual({
24
+ mode: "relative",
25
+ amount: 1,
26
+ unit: "d",
27
+ direction: "after"
28
+ });
29
+ expect(dateLimitSettingsToForm({
30
+ expression: "today"
31
+ }, context())).toMatchObject({
32
+ mode: "relative",
33
+ amount: 0
34
+ });
35
+ });
36
+ it("opens a fixed limit as a fixed date", ()=>{
37
+ expect(dateLimitSettingsToForm({
38
+ value: "2000-12-31"
39
+ }, context("date"))).toEqual({
40
+ value: "2000-12-31",
41
+ mode: "fixed",
42
+ unit: "y",
43
+ direction: "before"
44
+ });
45
+ });
46
+ it("leaves the settings of a time or datetime field as they are", ()=>{
47
+ expect(dateLimitSettingsToForm({
48
+ value: "10:00:00"
49
+ }, context("time"))).toEqual({
50
+ value: "10:00:00"
51
+ });
52
+ });
53
+ it("saves a relative limit as an expression, without the form's own values", ()=>{
54
+ expect(dateLimitSettingsFromForm({
55
+ mode: "relative",
56
+ value: "2000-12-31",
57
+ amount: 18,
58
+ unit: "y",
59
+ direction: "before"
60
+ })).toEqual({
61
+ expression: "today-18y"
62
+ });
63
+ expect(dateLimitSettingsFromForm({
64
+ mode: "relative",
65
+ amount: 0,
66
+ unit: "d",
67
+ direction: "after"
68
+ })).toEqual({
69
+ expression: "today"
70
+ });
71
+ });
72
+ it("saves a fixed limit as a value, dropping an earlier expression", ()=>{
73
+ expect(dateLimitSettingsFromForm({
74
+ mode: "fixed",
75
+ value: "2000-12-31",
76
+ expression: "today-18y",
77
+ amount: 18,
78
+ unit: "y",
79
+ direction: "before"
80
+ })).toEqual({
81
+ value: "2000-12-31"
82
+ });
83
+ expect(dateLimitSettingsFromForm({
84
+ value: "10:00:00"
85
+ })).toEqual({
86
+ value: "10:00:00"
87
+ });
88
+ });
89
+ it("round-trips what it opens", ()=>{
90
+ for (const expression of [
91
+ "today-18y",
92
+ "today+3m",
93
+ "today-100y",
94
+ "today+1d"
95
+ ]){
96
+ const form = dateLimitSettingsToForm({
97
+ expression
98
+ }, context("date"));
99
+ expect(dateLimitSettingsFromForm(form)).toEqual({
100
+ expression
101
+ });
102
+ }
103
+ });
104
+ it("builds expressions", ()=>{
105
+ expect(toDateExpression(18, "y", "before")).toBe("today-18y");
106
+ expect(toDateExpression(2, "m", "after")).toBe("today+2m");
107
+ expect(toDateExpression(0, "y", "before")).toBe("today");
108
+ });
109
+ });
110
+
111
+ //# sourceMappingURL=dateLimitSettings.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation/fieldValidators/validators/dateLimitSettings.test.js","sources":["../../../../src/presentation/fieldValidators/validators/dateLimitSettings.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport type { CmsModelField } from \"~/types.js\";\nimport {\n dateLimitSettingsFromForm,\n dateLimitSettingsToForm,\n toDateExpression\n} from \"./dateLimitSettings.js\";\n\nconst context = (type?: string) => ({\n field: { type: \"datetime\", settings: type ? { type } : {} } as unknown as CmsModelField\n});\n\ndescribe(\"date limit settings\", () => {\n it(\"opens a relative limit as an amount, a unit and a direction\", () => {\n expect(dateLimitSettingsToForm({ expression: \"today-18y\" }, context(\"date\"))).toEqual({\n mode: \"relative\",\n amount: 18,\n unit: \"y\",\n direction: \"before\"\n });\n expect(dateLimitSettingsToForm({ expression: \"today+1d\" }, context(\"date\"))).toEqual({\n mode: \"relative\",\n amount: 1,\n unit: \"d\",\n direction: \"after\"\n });\n expect(dateLimitSettingsToForm({ expression: \"today\" }, context())).toMatchObject({\n mode: \"relative\",\n amount: 0\n });\n });\n\n it(\"opens a fixed limit as a fixed date\", () => {\n expect(dateLimitSettingsToForm({ value: \"2000-12-31\" }, context(\"date\"))).toEqual({\n value: \"2000-12-31\",\n mode: \"fixed\",\n unit: \"y\",\n direction: \"before\"\n });\n });\n\n it(\"leaves the settings of a time or datetime field as they are\", () => {\n expect(dateLimitSettingsToForm({ value: \"10:00:00\" }, context(\"time\"))).toEqual({\n value: \"10:00:00\"\n });\n });\n\n it(\"saves a relative limit as an expression, without the form's own values\", () => {\n expect(\n dateLimitSettingsFromForm({\n mode: \"relative\",\n value: \"2000-12-31\",\n amount: 18,\n unit: \"y\",\n direction: \"before\"\n })\n ).toEqual({ expression: \"today-18y\" });\n expect(\n dateLimitSettingsFromForm({\n mode: \"relative\",\n amount: 0,\n unit: \"d\",\n direction: \"after\"\n })\n ).toEqual({ expression: \"today\" });\n });\n\n it(\"saves a fixed limit as a value, dropping an earlier expression\", () => {\n expect(\n dateLimitSettingsFromForm({\n mode: \"fixed\",\n value: \"2000-12-31\",\n expression: \"today-18y\",\n amount: 18,\n unit: \"y\",\n direction: \"before\"\n })\n ).toEqual({ value: \"2000-12-31\" });\n // A time or datetime field's form has only the value.\n expect(dateLimitSettingsFromForm({ value: \"10:00:00\" })).toEqual({ value: \"10:00:00\" });\n });\n\n it(\"round-trips what it opens\", () => {\n for (const expression of [\"today-18y\", \"today+3m\", \"today-100y\", \"today+1d\"]) {\n const form = dateLimitSettingsToForm({ expression }, context(\"date\"));\n expect(dateLimitSettingsFromForm(form)).toEqual({ expression });\n }\n });\n\n it(\"builds expressions\", () => {\n expect(toDateExpression(18, \"y\", \"before\")).toBe(\"today-18y\");\n expect(toDateExpression(2, \"m\", \"after\")).toBe(\"today+2m\");\n expect(toDateExpression(0, \"y\", \"before\")).toBe(\"today\");\n });\n});\n"],"names":["context","type","describe","it","expect","dateLimitSettingsToForm","dateLimitSettingsFromForm","expression","form","toDateExpression"],"mappings":";;AAQA,MAAMA,UAAU,CAACC,OAAmB;QAChC,OAAO;YAAE,MAAM;YAAY,UAAUA,OAAO;gBAAEA;YAAK,IAAI,CAAC;QAAE;IAC9D;AAEAC,SAAS,uBAAuB;IAC5BC,GAAG,+DAA+D;QAC9DC,OAAOC,wBAAwB;YAAE,YAAY;QAAY,GAAGL,QAAQ,UAAU,OAAO,CAAC;YAClF,MAAM;YACN,QAAQ;YACR,MAAM;YACN,WAAW;QACf;QACAI,OAAOC,wBAAwB;YAAE,YAAY;QAAW,GAAGL,QAAQ,UAAU,OAAO,CAAC;YACjF,MAAM;YACN,QAAQ;YACR,MAAM;YACN,WAAW;QACf;QACAI,OAAOC,wBAAwB;YAAE,YAAY;QAAQ,GAAGL,YAAY,aAAa,CAAC;YAC9E,MAAM;YACN,QAAQ;QACZ;IACJ;IAEAG,GAAG,uCAAuC;QACtCC,OAAOC,wBAAwB;YAAE,OAAO;QAAa,GAAGL,QAAQ,UAAU,OAAO,CAAC;YAC9E,OAAO;YACP,MAAM;YACN,MAAM;YACN,WAAW;QACf;IACJ;IAEAG,GAAG,+DAA+D;QAC9DC,OAAOC,wBAAwB;YAAE,OAAO;QAAW,GAAGL,QAAQ,UAAU,OAAO,CAAC;YAC5E,OAAO;QACX;IACJ;IAEAG,GAAG,0EAA0E;QACzEC,OACIE,0BAA0B;YACtB,MAAM;YACN,OAAO;YACP,QAAQ;YACR,MAAM;YACN,WAAW;QACf,IACF,OAAO,CAAC;YAAE,YAAY;QAAY;QACpCF,OACIE,0BAA0B;YACtB,MAAM;YACN,QAAQ;YACR,MAAM;YACN,WAAW;QACf,IACF,OAAO,CAAC;YAAE,YAAY;QAAQ;IACpC;IAEAH,GAAG,kEAAkE;QACjEC,OACIE,0BAA0B;YACtB,MAAM;YACN,OAAO;YACP,YAAY;YACZ,QAAQ;YACR,MAAM;YACN,WAAW;QACf,IACF,OAAO,CAAC;YAAE,OAAO;QAAa;QAEhCF,OAAOE,0BAA0B;YAAE,OAAO;QAAW,IAAI,OAAO,CAAC;YAAE,OAAO;QAAW;IACzF;IAEAH,GAAG,6BAA6B;QAC5B,KAAK,MAAMI,cAAc;YAAC;YAAa;YAAY;YAAc;SAAW,CAAE;YAC1E,MAAMC,OAAOH,wBAAwB;gBAAEE;YAAW,GAAGP,QAAQ;YAC7DI,OAAOE,0BAA0BE,OAAO,OAAO,CAAC;gBAAED;YAAW;QACjE;IACJ;IAEAJ,GAAG,sBAAsB;QACrBC,OAAOK,iBAAiB,IAAI,KAAK,WAAW,IAAI,CAAC;QACjDL,OAAOK,iBAAiB,GAAG,KAAK,UAAU,IAAI,CAAC;QAC/CL,OAAOK,iBAAiB,GAAG,KAAK,WAAW,IAAI,CAAC;IACpD;AACJ"}
@@ -2,6 +2,6 @@ import React from "react";
2
2
  export interface ImportContentModelsDialogProps {
3
3
  onClose: () => void;
4
4
  }
5
- export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & {
6
- displayName: string;
5
+ export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & React.NamedExoticComponent<ImportContentModelsDialogProps> & {
6
+ readonly type: (props: ImportContentModelsDialogProps) => React.JSX.Element;
7
7
  };
@@ -9,7 +9,7 @@ const createSelected = (params)=>{
9
9
  for (const id of item.related){
10
10
  const model = models.find((model)=>model.id === id);
11
11
  if (!model) continue;
12
- if (selected.has(model.id) || model.imported) continue;
12
+ else if (selected.has(model.id) || model.imported) continue;
13
13
  const related = createSelected({
14
14
  previous: selected,
15
15
  models,
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;QACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,CACtD;aAFUD,eAAe,GAAfA;aACAC,aAAa,GAAbA;aAXJ,IAAI,GAAgB;aACpB,OAAO,GAAG;aACV,MAAM,GAAsB,EAAE;aAC9B,MAAM,GAAsB,EAAE;aAC9B,IAAI,GAAgB;aACpB,MAAM,GAAa,EAAE;aACrB,SAAS,GAAG;aACZ,QAAQ,GAAa,IAAIN;QAM7BO,mBACI,IAAI,EACJ;YACI,iBAAiB;YACjB,eAAe;QACnB;IAER;IAEA,IAAI,KAA6C;QAC7C,OAAO;YACH,MAAM,IAAI,CAAC,IAAI;YACf,SAAS,IAAI,CAAC,OAAO;YACrB,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQ,IAAI,CAAC,MAAM;YACnB,MAAM,IAAI,CAAC,IAAI;YACf,QAAQ,IAAI,CAAC,MAAM;YACnB,WAAW,IAAI,CAAC,SAAS;QAC7B;IACJ;I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K,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
1
+ {"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;aACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,CACtD;aAFUD,eAAe,GAAfA;aACAC,aAAa,GAAbA;aAXJ,IAAI,GAAgB;aACpB,OAAO,GAAG;aACV,MAAM,GAAsB,EAAE;aAC9B,MAAM,GAAsB,EAAE;aAC9B,IAAI,GAAgB;aACpB,MAAM,GAAa,EAAE;aACrB,SAAS,GAAG;aACZ,QAAQ,GAAa,IAAIN;QAM7BO,mBACI,IA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,MAAM,IAAI,CAACC,OAAO,MAAM;YAChC,QAAQD,MAAM,IAAI,CAACvB,OAAO,MAAM;QACpC;IACJ;IAEQ,iBAAiB6B,OAAqC,EAAQ;QAClE,IAAI,CAACA,SACD,MAAM,IAAIC,MAAM;QAEpB,MAAMC,MACFF,mBAAmBG,cAAcC,OAAO,IAAI,CAACJ,SAAS,QAAQ,CAAC,UAAUA;QAE7E,IAAIb,OAA4B,CAAC;QACjC,IAAI;YACAA,OAAOkB,KAAK,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- export declare const DataList: (() => React.JSX.Element | null) & {
3
- displayName: string;
2
+ export declare const DataList: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element | null;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- export declare const FileUpload: (() => React.JSX.Element) & {
3
- displayName: string;
2
+ export declare const FileUpload: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element;
4
4
  };
@@ -72,9 +72,9 @@ const Checkbox = ({ model, toggle, selected })=>{
72
72
  };
73
73
  const Container = ({ model, children })=>{
74
74
  if (model.imported) return /*#__PURE__*/ react.createElement(ContainerImported, null, children);
75
- if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
76
- if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
77
- if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
75
+ else if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
76
+ else if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
77
+ else if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
78
78
  return /*#__PURE__*/ react.createElement(ContainerBase, null, children);
79
79
  };
80
80
  const DataListModelItem = ({ model, toggle, selected })=>/*#__PURE__*/ react.createElement(Container, {
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eAAe,IACnC,EAAC;AAEZ,MAAMK,iBAAiBJ,OAAOD,eAAe,IAClC,EAAC;AAGZ,MAAMM,iBAAiBL,OAAO,OAAO;IACjC,SAAS;IACT,OAAO;IACP,eAAe;IACf,YAAY;IACZ,gBAAgB;AACpB;AACA,MAAMM,OAAON,OAAO,MAAM;IACtB,UAAU;IACV,MAAM;IACN,YAAY;AAChB;AACA,MAAMO,oBAAoBP,OAAO,OAAO;IACpC,OAAO;IACP,WAAW;IACX,eAAe;AACnB;AAEA,MAAMQ,SAASR,OAAO,UAAU;IAC5B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,iBAAiB;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AIA,MAAM,EAAE,GAC5BA,MAAM,KAAK,GAAG,WAAH,GACR,oBAACQ,wBAAsBA;QAAC,OAAOR,MAAM,KAAK;uBAE1C,oBAACS,uBAAqBA;QAAC,OAAOT;SAGrCA,MAAM,QAAQ,GAAG,WAAH,GACX,oBAACF,UAAQA,QAAAA,WAAAA,GAET,oBAACC,UAAQA;QAAC,OAAOC;QAAO,QAAQC;QAAQ,UAAUC"}
1
+ {"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eAAe,IACnC,EAAC;AAEZ,MAAMK,iBAAiBJ,OAAOD,eAAe,IAClC,EAAC;AAGZ,MAAMM,iBAAiBL,OAAO,OAAO;IACjC,SAAS;IACT,OAAO;IACP,eAAe;IACf,YAAY;IACZ,gBAAgB;AACpB;AACA,MAAMM,OAAON,OAAO,MAAM;IACtB,UAAU;IACV,MAAM;IACN,YAAY;AAChB;AACA,MAAMO,oBAAoBP,OAAO,OAAO;IACpC,OAAO;IACP,WAAW;IACX,eAAe;AACnB;AAEA,MAAMQ,SAASR,OAAO,UAAU;IAC5B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,cAAc;QACV,QAAQ;IACZ;AACJ;AAEA,MAAMS,eAAeT,OAAO,OAAO;IAC/B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ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CA,MAAM,QAAQ,GAAG,WAAH,GACX,oBAACF,UAAQA,QAAAA,WAAAA,GAET,oBAACC,UAAQA;QAAC,OAAOC;QAAO,QAAQC;QAAQ,UAAUC"}
@@ -9,8 +9,8 @@ const Text = styled("p")({
9
9
  });
10
10
  const getText = (action)=>{
11
11
  if ("create" === action) return "Model will be created.";
12
- if ("update" === action) return "Model will be updated.";
13
- if ("code" === action) return "Model cannot be updated because it was created via code.";
12
+ else if ("update" === action) return "Model will be updated.";
13
+ else if ("code" === action) return "Model cannot be updated because it was created via code.";
14
14
  return `Unknown action: ${action}`;
15
15
  };
16
16
  const DataListModelItemInfo = ({ model })=>{
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;IACJ,IAAIA,AAAW,aAAXA,QACP,OAAO;IACJ,IAAIA,AAAW,WAAXA,QACP,OAAO;IAEX,OAAO,CAAC,gBAAgB,EAAEA,QAAQ;AACtC;AAMO,MAAMC,wBAAwB,CAAC,EAAEC,KAAK,EAA8B;IACvE,MAAM,EAAEF,MAAM,EAAE,GAAGE;IAEnB,OAAO,WAAP,GAAO,oBAACL,MAAIA,MAAEE,QAAQC;AAC1B"}
1
+ {"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;SACJ,IAAIA,AAAW,aAAXA,QACP,OAAO;SACJ,IAAIA,AAAW,WAAXA,QACP,OAAO;IAEX,OAAO,CAAC,gBAAgB,EAAEA,QAAQ;AACtC;AAMO,MAAMC,wBAAwB,CAAC,EAAEC,KAAK,EAA8B;IACvE,MAAM,EAAEF,MAAM,EAAE,GAAGE;IAEnB,OAAO,WAAP,GAAO,oBAACL,MAAIA,MAAEE,QAAQC;AAC1B"}
@@ -3,7 +3,7 @@ import type { ImportModelData } from "../../types.js";
3
3
  interface DataListModelsProps {
4
4
  models: ImportModelData[];
5
5
  }
6
- export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & React.NamedExoticComponent<DataListModelsProps> & {
7
+ readonly type: ({ models }: DataListModelsProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & {
3
- displayName: string;
2
+ export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element | null;
4
4
  };
@@ -1,3 +1,4 @@
1
+ import { StringFormatter } from "@webiny/app-admin/features/stringFormatter/abstractions.js";
1
2
  import { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
2
3
  import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
3
4
  import type { ModelGroupDto } from "../../features/modelGroup/listModelGroups/abstractions.js";
@@ -17,12 +18,13 @@ declare class ModelGroupPresenterImpl implements IModelGroupPresenter {
17
18
  private updateModelGroupUseCase;
18
19
  private deleteModelGroupUseCase;
19
20
  private cache;
21
+ private stringFormatter;
20
22
  private selectedGroup;
21
23
  private loading;
22
24
  private saving;
23
25
  private showForm;
24
26
  private form;
25
- constructor(listPresenter: ListPresenter.Interface<ModelGroupDto>, formModelFactory: FormModelFactory.Interface, listModelGroupsUseCase: ListModelGroupsUseCase.Interface, getRoleUseCase: GetModelGroupUseCase.Interface, createModelGroupUseCase: CreateModelGroupUseCase.Interface, updateModelGroupUseCase: UpdateModelGroupUseCase.Interface, deleteModelGroupUseCase: DeleteModelGroupUseCase.Interface, cache: ModelGroupsCache.Interface);
27
+ constructor(listPresenter: ListPresenter.Interface<ModelGroupDto>, formModelFactory: FormModelFactory.Interface, listModelGroupsUseCase: ListModelGroupsUseCase.Interface, getRoleUseCase: GetModelGroupUseCase.Interface, createModelGroupUseCase: CreateModelGroupUseCase.Interface, updateModelGroupUseCase: UpdateModelGroupUseCase.Interface, deleteModelGroupUseCase: DeleteModelGroupUseCase.Interface, cache: ModelGroupsCache.Interface, stringFormatter: StringFormatter.Interface);
26
28
  get vm(): IModelGroupPresenterViewModel;
27
29
  get list(): ListPresenter.Interface<ModelGroupDto>;
28
30
  init(): void;
@@ -1,5 +1,5 @@
1
1
  import { computed, makeAutoObservable, runInAction } from "mobx";
2
- import slugify from "slugify";
2
+ import { StringFormatter } from "@webiny/app-admin/features/stringFormatter/abstractions.js";
3
3
  import { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
4
4
  import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
5
5
  import { ListModelGroupsUseCase } from "../../features/modelGroup/listModelGroups/abstractions.js";
@@ -22,7 +22,7 @@ function toIconValue(name) {
22
22
  };
23
23
  }
24
24
  class ModelGroupPresenterImpl {
25
- constructor(listPresenter, formModelFactory, listModelGroupsUseCase, getRoleUseCase, createModelGroupUseCase, updateModelGroupUseCase, deleteModelGroupUseCase, cache){
25
+ constructor(listPresenter, formModelFactory, listModelGroupsUseCase, getRoleUseCase, createModelGroupUseCase, updateModelGroupUseCase, deleteModelGroupUseCase, cache, stringFormatter){
26
26
  this.listPresenter = listPresenter;
27
27
  this.formModelFactory = formModelFactory;
28
28
  this.listModelGroupsUseCase = listModelGroupsUseCase;
@@ -31,6 +31,7 @@ class ModelGroupPresenterImpl {
31
31
  this.updateModelGroupUseCase = updateModelGroupUseCase;
32
32
  this.deleteModelGroupUseCase = deleteModelGroupUseCase;
33
33
  this.cache = cache;
34
+ this.stringFormatter = stringFormatter;
34
35
  this.selectedGroup = null;
35
36
  this.loading = false;
36
37
  this.saving = false;
@@ -44,6 +45,7 @@ class ModelGroupPresenterImpl {
44
45
  updateModelGroupUseCase: false,
45
46
  deleteModelGroupUseCase: false,
46
47
  cache: false,
48
+ stringFormatter: false,
47
49
  vm: computed
48
50
  });
49
51
  }
@@ -133,8 +135,7 @@ class ModelGroupPresenterImpl {
133
135
  this.selectedGroup = group;
134
136
  });
135
137
  return group;
136
- }
137
- {
138
+ } else {
138
139
  const group = await this.createModelGroupUseCase.execute({
139
140
  name: data.name,
140
141
  slug: data.slug,
@@ -176,12 +177,7 @@ class ModelGroupPresenterImpl {
176
177
  name: fields.text().label("Name").required("Name is required.").disabled(!canModify).onBlur((value, { form })=>{
177
178
  const slugValue = form.field("slug").getValue();
178
179
  if (slugValue || !value) return;
179
- form.field("slug").setValue(slugify(String(value), {
180
- replacement: "-",
181
- lower: true,
182
- remove: /[*#?<>_{}[\]+~.()'"!:;@]/g,
183
- trim: false
184
- }));
180
+ form.field("slug").setValue(this.stringFormatter.slugify(String(value)));
185
181
  }),
186
182
  slug: fields.text().label("Slug").required("Slug is required.").disabled(!isNew || !canModify),
187
183
  icon: fields.text().label("Group icon").required("Icon is required.").disabled(!canModify).renderer("cmsIconPicker"),
@@ -206,7 +202,8 @@ const ModelGroupPresenter_ModelGroupPresenter = ModelGroupPresenter.createImplem
206
202
  CreateModelGroupUseCase,
207
203
  UpdateModelGroupUseCase,
208
204
  DeleteModelGroupUseCase,
209
- ModelGroupsCache
205
+ ModelGroupsCache,
206
+ StringFormatter
210
207
  ]
211
208
  });
212
209
  export { ModelGroupPresenter_ModelGroupPresenter as ModelGroupPresenter };