@headless-adminapp/app 0.0.17-alpha.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/app/AppProvider.d.ts +0 -3
  2. package/app/AppProvider.js +10 -33
  3. package/app/AuthWrapper.d.ts +1 -1
  4. package/app/AuthWrapper.js +4 -1
  5. package/app/LayoutProvider.d.ts +8 -7
  6. package/app/LayoutProvider.js +28 -2
  7. package/app/context.d.ts +1 -1
  8. package/auth/AuthProvider.d.ts +1 -1
  9. package/auth/AuthProvider.js +30 -23
  10. package/auth/context.d.ts +2 -0
  11. package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
  12. package/auth/hooks/useIsSkipAuthCheck.js +8 -0
  13. package/auth/hooks/useLogout.js +1 -1
  14. package/board/BoardColumnDataResolver.d.ts +1 -0
  15. package/board/BoardColumnDataResolver.js +64 -0
  16. package/board/BoardColumnProvider.d.ts +7 -0
  17. package/board/BoardColumnProvider.js +36 -0
  18. package/board/context.d.ts +19 -0
  19. package/board/context.js +6 -0
  20. package/board/hooks/index.d.ts +6 -0
  21. package/board/hooks/index.js +15 -0
  22. package/board/hooks/useBoardColumnConfig.d.ts +2 -0
  23. package/board/hooks/useBoardColumnConfig.js +8 -0
  24. package/board/hooks/useBoardColumnData.d.ts +3 -0
  25. package/board/hooks/useBoardColumnData.js +9 -0
  26. package/board/hooks/useBoardColumnDataState.d.ts +5 -0
  27. package/board/hooks/useBoardColumnDataState.js +9 -0
  28. package/board/hooks/useBoardConfig.d.ts +3 -0
  29. package/board/hooks/useBoardConfig.js +8 -0
  30. package/board/hooks/useBoardSchema.d.ts +2 -0
  31. package/board/hooks/useBoardSchema.js +7 -0
  32. package/board/hooks/useSearchText.d.ts +1 -0
  33. package/board/hooks/useSearchText.js +14 -0
  34. package/board/types.d.ts +47 -0
  35. package/board/utils.d.ts +3 -0
  36. package/board/utils.js +6 -0
  37. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +15 -6
  38. package/builders/CommandBuilder/DefaultCommandBuilder.js +42 -20
  39. package/builders/CommandBuilder/FormCommandBuilder.d.ts +14 -13
  40. package/builders/CommandBuilder/FormCommandBuilder.js +66 -52
  41. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
  42. package/builders/CommandBuilder/SubgridCommandBuilder.js +115 -57
  43. package/builders/CommandBuilder/ViewCommandBuilder.js +32 -52
  44. package/builders/CommandBuilder/utils.js +1 -1
  45. package/builders/DefineFormExperience.d.ts +27 -0
  46. package/builders/DefineFormExperience.js +99 -0
  47. package/builders/DefineViewExperience.d.ts +13 -0
  48. package/builders/DefineViewExperience.js +33 -0
  49. package/builders/SchemaExperienceBuilder.d.ts +9 -7
  50. package/builders/SchemaExperienceBuilder.js +62 -40
  51. package/builders/utils.js +30 -44
  52. package/calendar/baseEventAttributes.d.ts +35 -0
  53. package/calendar/baseEventAttributes.js +38 -0
  54. package/calendar/context.d.ts +6 -0
  55. package/calendar/context.js +5 -0
  56. package/calendar/hooks/index.d.ts +1 -0
  57. package/{appearance → calendar}/hooks/index.js +1 -1
  58. package/calendar/hooks/useConfig.d.ts +3 -0
  59. package/calendar/hooks/useConfig.js +8 -0
  60. package/calendar/types.d.ts +41 -0
  61. package/calendar/types.js +2 -0
  62. package/calendar/utils.d.ts +3 -0
  63. package/calendar/utils.js +6 -0
  64. package/command/hooks/useBaseCommandHandlerContext.js +15 -6
  65. package/command/hooks/useCommands.js +1 -1
  66. package/command/utils/index.js +34 -9
  67. package/components/ScrollView/index.d.ts +1 -1
  68. package/components/ScrollView/index.js +2 -2
  69. package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
  70. package/components/ScrollbarWithMoreDataRequest/index.js +32 -0
  71. package/dataform/DataFormProvider/CustomHookExecuter.d.ts +5 -0
  72. package/dataform/DataFormProvider/CustomHookExecuter.js +14 -0
  73. package/dataform/DataFormProvider/DataResolver.d.ts +6 -4
  74. package/dataform/DataFormProvider/DataResolver.js +11 -94
  75. package/dataform/DataFormProvider/InitialValueResolver.js +3 -2
  76. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +2 -3
  77. package/dataform/DataFormProvider/getRecord.d.ts +3 -0
  78. package/dataform/DataFormProvider/getRecord.js +56 -0
  79. package/dataform/DataFormProvider/index.d.ts +4 -0
  80. package/dataform/DataFormProvider/index.js +34 -12
  81. package/dataform/DataFormProvider/types.d.ts +13 -0
  82. package/dataform/DataFormProvider/types.js +2 -0
  83. package/dataform/DataFormProvider/utils.d.ts +23 -0
  84. package/dataform/DataFormProvider/utils.js +105 -0
  85. package/dataform/FormManager.d.ts +57 -0
  86. package/dataform/FormManager.js +247 -0
  87. package/dataform/constants.d.ts +1 -0
  88. package/dataform/constants.js +4 -0
  89. package/dataform/context.d.ts +26 -1
  90. package/dataform/hooks/index.d.ts +11 -0
  91. package/dataform/hooks/index.js +11 -0
  92. package/dataform/hooks/useContextKey.d.ts +1 -0
  93. package/dataform/hooks/useContextKey.js +8 -0
  94. package/dataform/hooks/useDisabledControlsManager.d.ts +6 -0
  95. package/dataform/hooks/useDisabledControlsManager.js +46 -0
  96. package/dataform/hooks/useEventManager.d.ts +1 -0
  97. package/dataform/hooks/useEventManager.js +8 -0
  98. package/dataform/hooks/useFormManager.d.ts +2 -0
  99. package/dataform/hooks/useFormManager.js +13 -0
  100. package/dataform/hooks/useFormNotifications.js +2 -2
  101. package/dataform/hooks/useFormSave.js +28 -31
  102. package/dataform/hooks/useHiddenControlsManager.d.ts +7 -0
  103. package/dataform/hooks/useHiddenControlsManager.js +50 -0
  104. package/dataform/hooks/useIsControlDisabled.d.ts +1 -0
  105. package/dataform/hooks/useIsControlDisabled.js +27 -0
  106. package/dataform/hooks/useIsControlHiddenByAttributeName.d.ts +1 -0
  107. package/dataform/hooks/useIsControlHiddenByAttributeName.js +17 -0
  108. package/dataform/hooks/useIsControlHiddenByKey.d.ts +1 -0
  109. package/dataform/hooks/useIsControlHiddenByKey.js +17 -0
  110. package/dataform/hooks/useIsFieldRequired.d.ts +1 -0
  111. package/dataform/hooks/useIsFieldRequired.js +25 -0
  112. package/dataform/hooks/useLoadFormGridPage.js +8 -17
  113. package/dataform/hooks/useMainFormCommands.d.ts +1 -12
  114. package/dataform/hooks/useMainFormCommands.js +13 -3
  115. package/dataform/hooks/useOnFieldValueChangeListener.d.ts +1 -0
  116. package/dataform/hooks/useOnFieldValueChangeListener.js +30 -0
  117. package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
  118. package/dataform/hooks/useProcessFlowSteps.js +45 -0
  119. package/dataform/hooks/useRecordTitle.d.ts +3 -1
  120. package/dataform/hooks/useRecordTitle.js +12 -5
  121. package/dataform/hooks/useRequiredFieldManager.d.ts +6 -0
  122. package/dataform/hooks/useRequiredFieldManager.js +49 -0
  123. package/dataform/test.d.ts +57 -0
  124. package/dataform/test.js +247 -0
  125. package/dataform/utils/defaultParameters.d.ts +6 -0
  126. package/dataform/utils/defaultParameters.js +54 -0
  127. package/dataform/utils/index.d.ts +6 -24
  128. package/dataform/utils/index.js +164 -190
  129. package/dataform/utils/saveRecord.d.ts +27 -0
  130. package/dataform/utils/saveRecord.js +163 -0
  131. package/datagrid/DataGridProvider/DataResolver.js +38 -109
  132. package/datagrid/DataGridProvider/index.d.ts +6 -0
  133. package/datagrid/DataGridProvider/index.js +18 -8
  134. package/datagrid/DataGridProvider/transformViewColumns.js +10 -2
  135. package/datagrid/DataGridProvider/utils.js +8 -8
  136. package/datagrid/column-filter/constants.js +38 -3
  137. package/datagrid/column-filter/utils.js +7 -1
  138. package/datagrid/context.d.ts +6 -0
  139. package/datagrid/hooks/useChangeView.js +1 -1
  140. package/datagrid/hooks/useGridColumnFilter.js +4 -1
  141. package/datagrid/hooks/useGridDisabled.d.ts +1 -0
  142. package/datagrid/hooks/useGridDisabled.js +8 -0
  143. package/datagrid/hooks/useLoadMainGridPage.js +1 -1
  144. package/datagrid/hooks/useMainGridCommands.js +23 -9
  145. package/datagrid/hooks/useOpenRecord.js +2 -2
  146. package/datagrid/hooks/useSubGridCommands.js +23 -45
  147. package/defaults.d.ts +2 -0
  148. package/defaults.js +5 -0
  149. package/dialog/hooks/useCloseDialog.js +17 -15
  150. package/dialog/hooks/useOpenAlertDialog.js +8 -3
  151. package/dialog/hooks/useOpenConfirmDialog.js +10 -4
  152. package/dialog/hooks/useOpenDialog.js +7 -5
  153. package/dialog/hooks/useOpenErrorDialog.js +8 -3
  154. package/dialog/hooks/useOpenPromptDialog.js +10 -4
  155. package/form/FormValidationStringContext.d.ts +1 -0
  156. package/form/FormValidationStringContext.js +1 -0
  157. package/hooks/index.d.ts +1 -0
  158. package/hooks/index.js +3 -0
  159. package/hooks/useDebouncedValue.js +0 -1
  160. package/hooks/useElementLayout.js +1 -1
  161. package/hooks/useIsMobile.js +0 -1
  162. package/hooks/useItemsWithKey.d.ts +7 -0
  163. package/hooks/useItemsWithKey.js +13 -0
  164. package/hooks/useStorageState.js +1 -2
  165. package/hooks/useSystemColorScheme.d.ts +1 -1
  166. package/hooks/useSystemColorScheme.js +0 -1
  167. package/insights/InsightsProvider.d.ts +8 -0
  168. package/insights/InsightsProvider.js +27 -0
  169. package/locale/LocaleProvider.d.ts +2 -1
  170. package/locale/LocaleProvider.js +3 -3
  171. package/locale/index.d.ts +1 -0
  172. package/locale/index.js +1 -0
  173. package/locale/useCurrencySymbol.d.ts +1 -0
  174. package/locale/useCurrencySymbol.js +12 -0
  175. package/locale/utils.js +4 -2
  176. package/metadata/MetadataProvider.d.ts +8 -4
  177. package/metadata/MetadataProvider.js +23 -17
  178. package/metadata/context.d.ts +3 -2
  179. package/metadata/hooks/index.d.ts +1 -1
  180. package/metadata/hooks/index.js +1 -1
  181. package/metadata/hooks/useAppExperience.d.ts +1 -0
  182. package/metadata/hooks/useAppExperience.js +8 -0
  183. package/metadata/hooks/useAppStore.d.ts +1 -1
  184. package/metadata/hooks/useAppStore.js +3 -3
  185. package/metadata/hooks/useExperienceView.js +2 -11
  186. package/metadata/hooks/useExperienceViewCommands.js +5 -14
  187. package/metadata/hooks/useExperienceViewLookup.js +2 -11
  188. package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
  189. package/metadata/hooks/useMetadata.d.ts +11 -10
  190. package/metadata/hooks/useMetadata.js +4 -16
  191. package/metadata/hooks/useSchema.d.ts +1 -1
  192. package/metadata/hooks/useSchema.js +3 -0
  193. package/mutable/context.d.ts +3 -0
  194. package/mutable/context.js +8 -0
  195. package/mutable/utils.js +5 -12
  196. package/navigation/hooks/useOpenForm.js +4 -0
  197. package/package.json +6 -10
  198. package/providers/PageEntityFormProvider/index.d.ts +5 -1
  199. package/providers/PageEntityFormProvider/index.js +2 -2
  200. package/recordset/hooks/useRecordSetResult.js +4 -14
  201. package/route/RouteProvider.d.ts +2 -2
  202. package/route/RouteProvider.js +4 -1
  203. package/store/ClientAppStore.js +7 -20
  204. package/store/ComponentStore.d.ts +1 -1
  205. package/store/ComponentStore.js +6 -12
  206. package/store/EventManager.d.ts +2 -2
  207. package/store/EventManager.js +13 -29
  208. package/store/SchemaExperienceStore.js +179 -215
  209. package/store/index.d.ts +0 -1
  210. package/store/index.js +0 -1
  211. package/toast-notification/hooks/useCloseToastNotification.js +17 -15
  212. package/toast-notification/hooks/useOpenToastNotification.js +7 -5
  213. package/transport/InMemoryDataService/index.js +54 -77
  214. package/transport/RestDataService/index.d.ts +3 -3
  215. package/transport/RestDataService/index.js +68 -91
  216. package/transport/context.d.ts +2 -1
  217. package/transport/context.js +7 -1
  218. package/transport/hooks/index.d.ts +1 -0
  219. package/transport/hooks/index.js +1 -0
  220. package/transport/hooks/useFileService.d.ts +1 -0
  221. package/transport/hooks/useFileService.js +9 -0
  222. package/transport/hooks/useRetriveRecords.d.ts +33 -0
  223. package/transport/hooks/useRetriveRecords.js +110 -0
  224. package/utils/calculateColumnWidths.js +1 -1
  225. package/utils/color.d.ts +1 -0
  226. package/utils/color.js +14 -0
  227. package/utils/getAttributeFormattedValue.d.ts +4 -1
  228. package/utils/getAttributeFormattedValue.js +109 -54
  229. package/utils/phone.d.ts +13 -0
  230. package/utils/phone.js +33 -0
  231. package/appearance/context.d.ts +0 -7
  232. package/appearance/context.js +0 -5
  233. package/appearance/hooks/index.d.ts +0 -1
  234. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  235. package/appearance/hooks/useAppearanceContext.js +0 -12
  236. package/appearance/index.d.ts +0 -2
  237. package/appearance/index.js +0 -20
  238. package/builders/CommandBuilder.d.ts +0 -176
  239. package/builders/CommandBuilder.js +0 -567
  240. package/locale/types.d.ts +0 -2
  241. /package/{locale → board}/types.js +0 -0
@@ -0,0 +1,47 @@
1
+ import { CommandContextBase } from '@headless-adminapp/core/experience/command';
2
+ import { SortingState, View } from '@headless-adminapp/core/experience/view';
3
+ import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
4
+ import { Filter } from '@headless-adminapp/core/transport';
5
+ import { FC } from 'react';
6
+ import { UtilityContextState } from '../command';
7
+ export interface ItemUpdateContext extends CommandContextBase {
8
+ primaryControl: {
9
+ logicalName: string;
10
+ id: string;
11
+ schema: Schema;
12
+ };
13
+ utility: UtilityContextState;
14
+ }
15
+ export interface Column {
16
+ view: View<SchemaAttributes>;
17
+ accept: string[];
18
+ update?: (context: ItemUpdateContext) => Promise<void>;
19
+ }
20
+ export type BoardColumnCardPreviewFC = FC<{
21
+ record: any;
22
+ }>;
23
+ export interface DragItem {
24
+ id: string;
25
+ columnId: string;
26
+ record: any;
27
+ }
28
+ export interface BoardColumnConfig {
29
+ columnId: string;
30
+ title: string;
31
+ maxRecords?: number;
32
+ filter: Filter;
33
+ acceptSourceIds: string[];
34
+ updateFn: (context: ItemUpdateContext) => Promise<void>;
35
+ }
36
+ export interface BoardConfig<S extends SchemaAttributes = SchemaAttributes> {
37
+ title: string;
38
+ description: string;
39
+ schema: Schema<S>;
40
+ sorting: SortingState<S>;
41
+ projection: {
42
+ columns: Array<keyof S>;
43
+ expand?: Partial<Record<keyof S, string[]>>;
44
+ };
45
+ columnConfigs: BoardColumnConfig[];
46
+ PreviewComponent: BoardColumnCardPreviewFC;
47
+ }
@@ -0,0 +1,3 @@
1
+ import { SchemaAttributes } from '@headless-adminapp/core/schema';
2
+ import { BoardConfig } from './types';
3
+ export declare function defineBoardConfig<S extends SchemaAttributes = SchemaAttributes>(config: BoardConfig<S>): BoardConfig<S>;
package/board/utils.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineBoardConfig = defineBoardConfig;
4
+ function defineBoardConfig(config) {
5
+ return config;
6
+ }
@@ -1,5 +1,8 @@
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { EntityMainGridCommandItemExperience, SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
1
3
  import { Localized } from '@headless-adminapp/core/types';
2
4
  import { Icon } from '@headless-adminapp/icons';
5
+ import { FormCommandBuilder } from './FormCommandBuilder';
3
6
  import { ViewCommandBuilder } from './ViewCommandBuilder';
4
7
  export declare namespace DefaultCommandBuilder {
5
8
  interface CreateDefaultViewCommandStrings {
@@ -26,35 +29,41 @@ export declare namespace DefaultCommandBuilder {
26
29
  strings?: CreateDefaultViewCommandStrings;
27
30
  localizedSrings?: Localized<CreateDefaultViewCommandStrings>;
28
31
  }
29
- export function createDefaultViewCommands({ icons, strings, localizedSrings, }: CreateDefaultViewCommandOptions): import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[][];
32
+ export function createDefaultViewCommands({ icons, strings, localizedSrings, }: CreateDefaultViewCommandOptions): EntityMainGridCommandItemExperience[][];
30
33
  interface CreateDefaultFormCommandStrings {
31
34
  save: string;
32
35
  saveAndClose: string;
33
36
  refresh: string;
37
+ delete: string;
38
+ deleteRecordCommandStringSet: FormCommandBuilder.DeleteRecordCommandStringSet;
34
39
  }
35
40
  interface CreateDefaultFormCommandOptions {
36
41
  icons: {
37
42
  Save: Icon;
38
43
  SaveAndClose: Icon;
39
44
  Refresh: Icon;
45
+ Delete: Icon;
40
46
  };
41
47
  strings?: CreateDefaultFormCommandStrings;
42
48
  localizedSrings?: Localized<CreateDefaultFormCommandStrings>;
43
49
  }
44
50
  export const defaultFormCommandStrings: CreateDefaultFormCommandStrings;
45
- export function createDefaultFormCommands({ icons, strings, localizedSrings, }: CreateDefaultFormCommandOptions): import("@headless-adminapp/core/experience/form").EntityMainFormCommandItemExperience[][];
51
+ export function createDefaultFormCommands({ icons, strings, localizedSrings, }: CreateDefaultFormCommandOptions): EntityMainFormCommandItemExperience[][];
46
52
  interface CreateDefaultSubgridCommandStrings {
47
53
  new: string;
48
54
  edit: string;
55
+ delete: string;
49
56
  refresh: string;
50
57
  export: string;
51
58
  exportCsv: string;
52
59
  exportExcel: string;
60
+ deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
53
61
  }
54
62
  interface CreateDefaultSubgridCommandOptions {
55
63
  icons: {
56
64
  New: Icon;
57
65
  Edit: Icon;
66
+ Delete: Icon;
58
67
  Refresh: Icon;
59
68
  Export: Icon;
60
69
  ExportCsv: Icon;
@@ -63,7 +72,7 @@ export declare namespace DefaultCommandBuilder {
63
72
  strings?: CreateDefaultSubgridCommandStrings;
64
73
  localizedSrings?: Localized<CreateDefaultSubgridCommandStrings>;
65
74
  }
66
- export function createDefaultSubgridCommands({ icons, strings, localizedSrings, }: CreateDefaultSubgridCommandOptions): (import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[] | import("@headless-adminapp/core/experience/view").SubGridCommandItemExperience[])[];
75
+ export function createDefaultSubgridCommands({ icons, strings, localizedSrings, }: CreateDefaultSubgridCommandOptions): SubGridCommandItemExperience[][];
67
76
  type CreateDefaultCommandStrings = CreateDefaultViewCommandStrings & CreateDefaultFormCommandStrings & CreateDefaultSubgridCommandStrings;
68
77
  interface CreateDefaultCommandOptions {
69
78
  icons: CreateDefaultViewCommandOptions['icons'] & CreateDefaultFormCommandOptions['icons'] & CreateDefaultSubgridCommandOptions['icons'];
@@ -71,9 +80,9 @@ export declare namespace DefaultCommandBuilder {
71
80
  localizedSrings?: Localized<CreateDefaultCommandStrings>;
72
81
  }
73
82
  export function createDefaultCommands({ icons, strings, localizedSrings, }: CreateDefaultCommandOptions): {
74
- view: import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[][];
75
- form: import("@headless-adminapp/core/experience/form").EntityMainFormCommandItemExperience[][];
76
- subgrid: (import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[] | import("@headless-adminapp/core/experience/view").SubGridCommandItemExperience[])[];
83
+ view: EntityMainGridCommandItemExperience[][];
84
+ form: EntityMainFormCommandItemExperience[][];
85
+ subgrid: SubGridCommandItemExperience[][];
77
86
  };
78
87
  export {};
79
88
  }
@@ -31,24 +31,24 @@ var DefaultCommandBuilder;
31
31
  ViewCommandBuilder_1.ViewCommandBuilder.createNewRecordCommand({
32
32
  Icon: icons.New,
33
33
  text: strings.new,
34
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.new),
34
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
35
35
  }),
36
36
  ViewCommandBuilder_1.ViewCommandBuilder.createEditRecordCommand({
37
37
  Icon: icons.Edit,
38
38
  text: strings.edit,
39
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.edit),
39
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
40
40
  }),
41
41
  ViewCommandBuilder_1.ViewCommandBuilder.createDeleteRecordCommand({
42
42
  Icon: icons.Delete,
43
43
  text: strings.delete,
44
- localizedText: extractLocalizedStrings(localizedSrings, x => x.delete),
44
+ localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
45
45
  stringSet: strings.deleteRecordCommandStringSet,
46
- localizedStringSet: extractLocalizedStrings(localizedSrings, x => x.deleteRecordCommandStringSet),
46
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
47
47
  }),
48
48
  ViewCommandBuilder_1.ViewCommandBuilder.createRefreshCommand({
49
49
  Icon: icons.Refresh,
50
50
  text: strings.refresh,
51
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
51
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
52
52
  }),
53
53
  ],
54
54
  [
@@ -56,17 +56,17 @@ var DefaultCommandBuilder;
56
56
  button: {
57
57
  Icon: icons.Export,
58
58
  text: strings.export,
59
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.export),
59
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
60
60
  },
61
61
  csv: {
62
62
  Icon: icons.ExportCsv,
63
63
  text: strings.exportCsv,
64
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportCsv),
64
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
65
65
  },
66
66
  excel: {
67
67
  Icon: icons.ExportExcel,
68
- text: strings.exportCsv,
69
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportExcel),
68
+ text: strings.exportExcel,
69
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
70
70
  },
71
71
  }),
72
72
  ],
@@ -77,6 +77,8 @@ var DefaultCommandBuilder;
77
77
  save: 'Save',
78
78
  saveAndClose: 'Save & Close',
79
79
  refresh: 'Refresh',
80
+ delete: 'Delete',
81
+ deleteRecordCommandStringSet: FormCommandBuilder_1.FormCommandBuilder.defaultDeleteRecordStringSet,
80
82
  };
81
83
  function createDefaultFormCommands({ icons, strings = DefaultCommandBuilder.defaultFormCommandStrings, localizedSrings, }) {
82
84
  return [
@@ -84,17 +86,24 @@ var DefaultCommandBuilder;
84
86
  FormCommandBuilder_1.FormCommandBuilder.createSaveCommand({
85
87
  Icon: icons.Save,
86
88
  text: strings.save,
87
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.save),
89
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.save),
88
90
  }),
89
91
  FormCommandBuilder_1.FormCommandBuilder.createSaveAndCloseCommand({
90
92
  Icon: icons.SaveAndClose,
91
93
  text: strings.saveAndClose,
92
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.saveAndClose),
94
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.saveAndClose),
93
95
  }),
94
96
  FormCommandBuilder_1.FormCommandBuilder.createRefreshCommand({
95
97
  Icon: icons.Refresh,
96
98
  text: strings.refresh,
97
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
99
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
100
+ }),
101
+ FormCommandBuilder_1.FormCommandBuilder.createDeleteCommand({
102
+ Icon: icons.Delete,
103
+ text: 'Delete',
104
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.delete),
105
+ stringSet: strings.deleteRecordCommandStringSet,
106
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
98
107
  }),
99
108
  ],
100
109
  ];
@@ -103,10 +112,12 @@ var DefaultCommandBuilder;
103
112
  const defaultSubgridCommandStrings = {
104
113
  new: 'New',
105
114
  edit: 'Edit',
115
+ delete: 'Delete',
106
116
  refresh: 'Refresh',
107
117
  export: 'Export',
108
118
  exportCsv: 'CSV',
109
119
  exportExcel: 'Excel',
120
+ deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
110
121
  };
111
122
  function createDefaultSubgridCommands({ icons, strings = defaultSubgridCommandStrings, localizedSrings, }) {
112
123
  return [
@@ -114,42 +125,53 @@ var DefaultCommandBuilder;
114
125
  SubgridCommandBuilder_1.SubgridCommandBuilder.createNewRecordCommand({
115
126
  Icon: icons.New,
116
127
  text: strings.new,
117
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.new),
128
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
118
129
  }),
119
130
  SubgridCommandBuilder_1.SubgridCommandBuilder.createEditRecordCommand({
120
131
  Icon: icons.Edit,
121
132
  text: strings.edit,
122
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.edit),
133
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
134
+ }),
135
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createDeleteRecordCommand({
136
+ Icon: icons.Delete,
137
+ text: strings.delete,
138
+ localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
139
+ stringSet: strings.deleteRecordCommandStringSet,
140
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
123
141
  }),
124
142
  SubgridCommandBuilder_1.SubgridCommandBuilder.createRefreshCommand({
125
143
  Icon: icons.Refresh,
126
144
  text: strings.refresh,
127
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
145
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
128
146
  }),
129
147
  ],
130
148
  [
131
- ViewCommandBuilder_1.ViewCommandBuilder.createExportCommand({
149
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createExportCommand({
132
150
  button: {
133
151
  Icon: icons.Export,
134
152
  text: strings.export,
135
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.export),
153
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
136
154
  },
137
155
  csv: {
138
156
  Icon: icons.ExportCsv,
139
157
  text: strings.exportCsv,
140
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportCsv),
158
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
141
159
  },
142
160
  excel: {
143
161
  Icon: icons.ExportExcel,
144
162
  text: strings.exportExcel,
145
- localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportExcel),
163
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
146
164
  },
147
165
  }),
148
166
  ],
149
167
  ];
150
168
  }
151
169
  DefaultCommandBuilder.createDefaultSubgridCommands = createDefaultSubgridCommands;
152
- const defaultCreateCommandStrings = Object.assign(Object.assign(Object.assign({}, DefaultCommandBuilder.defaultViewCommandStrings), DefaultCommandBuilder.defaultFormCommandStrings), defaultSubgridCommandStrings);
170
+ const defaultCreateCommandStrings = {
171
+ ...DefaultCommandBuilder.defaultViewCommandStrings,
172
+ ...DefaultCommandBuilder.defaultFormCommandStrings,
173
+ ...defaultSubgridCommandStrings,
174
+ };
153
175
  function createDefaultCommands({ icons, strings = defaultCreateCommandStrings, localizedSrings, }) {
154
176
  return {
155
177
  view: createDefaultViewCommands({
@@ -1,45 +1,46 @@
1
- import { EntityFormCommandContext, EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { Localized } from '@headless-adminapp/core/types';
2
3
  import { Icon } from '@headless-adminapp/icons';
3
4
  export declare namespace FormCommandBuilder {
4
- export function createSaveCommand({ Icon, text, localizedTexts, }: {
5
+ function createSaveCommand({ Icon, text, localizedTexts, }: {
5
6
  Icon: Icon;
6
7
  text: string;
7
8
  localizedTexts?: Record<string, string>;
8
9
  }): EntityMainFormCommandItemExperience;
9
- export function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
10
+ function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
10
11
  Icon: Icon;
11
12
  text: string;
12
13
  localizedTexts?: Record<string, string>;
13
14
  }): EntityMainFormCommandItemExperience;
14
15
  interface DeleteRecordCommandStringSet {
15
16
  confirmation: {
16
- title: string;
17
- text: string;
17
+ title: string | [string, string];
18
+ text: string | [string, string];
18
19
  buttonCancel: string;
19
20
  buttonConfirm: string;
20
21
  };
21
22
  status: {
22
- deleting: string;
23
+ deleting: string | [string, string];
23
24
  };
24
25
  successNotification: {
25
- title: string;
26
- text: string;
26
+ title: string | [string, string];
27
+ text: string | [string, string];
27
28
  };
28
29
  errorNotification: {
29
30
  title: string;
30
31
  };
31
32
  }
32
- export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
33
- export function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }: {
33
+ const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
34
+ function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }: {
34
35
  Icon: Icon;
35
36
  text: string;
36
37
  localizedTexts?: Record<string, string>;
37
- stringSet: DeleteRecordCommandStringSet | ((context: EntityFormCommandContext) => DeleteRecordCommandStringSet);
38
+ stringSet: DeleteRecordCommandStringSet;
39
+ localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
38
40
  }): EntityMainFormCommandItemExperience;
39
- export function createRefreshCommand({ Icon, text, localizedTexts, }: {
41
+ function createRefreshCommand({ Icon, text, localizedTexts, }: {
40
42
  Icon: Icon;
41
43
  text: string;
42
44
  localizedTexts?: Record<string, string>;
43
45
  }): EntityMainFormCommandItemExperience;
44
- export {};
45
46
  }
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.FormCommandBuilder = void 0;
4
+ const utils_1 = require("./utils");
5
+ var EnabledRules;
6
+ (function (EnabledRules) {
7
+ function HasCreatePermisssion(context) {
8
+ return !context.primaryControl.schema.restrictions?.disableCreate;
9
+ }
10
+ EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
11
+ function HasUpdatePermission(context) {
12
+ return !context.primaryControl.schema.restrictions?.disableUpdate;
13
+ }
14
+ EnabledRules.HasUpdatePermission = HasUpdatePermission;
15
+ function HasDeletePermission(context) {
16
+ return !context.primaryControl.schema.restrictions?.disableDelete;
17
+ }
18
+ EnabledRules.HasDeletePermission = HasDeletePermission;
19
+ })(EnabledRules || (EnabledRules = {}));
13
20
  var FormCommandBuilder;
14
21
  (function (FormCommandBuilder) {
15
22
  function createSaveCommand({ Icon, text, localizedTexts, }) {
@@ -19,15 +26,22 @@ var FormCommandBuilder;
19
26
  text,
20
27
  localizedText: localizedTexts,
21
28
  isQuickAction: true,
22
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
23
- yield context.primaryControl.save('save');
24
- }),
25
- hidden: (context) => {
26
- if (context.primaryControl.readonly) {
27
- return true;
28
- }
29
- return false;
29
+ onClick: async (context) => {
30
+ await context.primaryControl.save('save');
30
31
  },
32
+ hidden: [
33
+ (context) => {
34
+ if (context.primaryControl.readonly) {
35
+ return true;
36
+ }
37
+ if (context.primaryControl.recordId) {
38
+ return !EnabledRules.HasUpdatePermission(context);
39
+ }
40
+ else {
41
+ return !EnabledRules.HasCreatePermisssion(context);
42
+ }
43
+ },
44
+ ],
31
45
  };
32
46
  }
33
47
  FormCommandBuilder.createSaveCommand = createSaveCommand;
@@ -37,15 +51,22 @@ var FormCommandBuilder;
37
51
  Icon,
38
52
  text,
39
53
  localizedText: localizedTexts,
40
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
41
- yield context.primaryControl.save('saveandclose');
42
- }),
43
- hidden: (context) => {
44
- if (context.primaryControl.readonly) {
45
- return true;
46
- }
47
- return false;
54
+ onClick: async (context) => {
55
+ await context.primaryControl.save('saveandclose');
48
56
  },
57
+ hidden: [
58
+ (context) => {
59
+ if (context.primaryControl.readonly) {
60
+ return true;
61
+ }
62
+ if (context.primaryControl.recordId) {
63
+ return !EnabledRules.HasUpdatePermission(context);
64
+ }
65
+ else {
66
+ return !EnabledRules.HasCreatePermisssion(context);
67
+ }
68
+ },
69
+ ],
49
70
  };
50
71
  }
51
72
  FormCommandBuilder.createSaveAndCloseCommand = createSaveAndCloseCommand;
@@ -67,7 +88,7 @@ var FormCommandBuilder;
67
88
  title: 'Error',
68
89
  },
69
90
  };
70
- function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }) {
91
+ function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }) {
71
92
  return {
72
93
  Icon: Icon,
73
94
  type: 'button',
@@ -75,45 +96,38 @@ var FormCommandBuilder;
75
96
  localizedText: localizedTexts,
76
97
  danger: true,
77
98
  hidden: (context) => {
78
- var _a;
79
99
  if (!context.primaryControl.recordId) {
80
100
  return true;
81
101
  }
82
- if ((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete) {
83
- return true;
84
- }
85
- return false;
102
+ return !EnabledRules.HasDeletePermission(context);
86
103
  },
87
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
104
+ onClick: async (context) => {
88
105
  const recordId = context.primaryControl.recordId;
89
106
  if (!recordId) {
90
107
  return;
91
108
  }
92
- if (typeof stringSet === 'function') {
93
- stringSet = stringSet(context);
94
- }
109
+ // if (typeof stringSet === 'function') {
110
+ // stringSet = stringSet(context);
111
+ // }
112
+ const localizeSelector = (0, utils_1.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
95
113
  try {
96
- const confirmResult = yield context.utility.openConfirmDialog({
97
- title: stringSet.confirmation.title,
98
- text: stringSet.confirmation.text,
114
+ const confirmResult = await context.utility.openConfirmDialog({
115
+ title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.title)),
116
+ text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.text)),
99
117
  cancelButtonLabel: stringSet.confirmation.buttonCancel,
100
118
  confirmButtonLabel: stringSet.confirmation.buttonConfirm,
101
119
  });
102
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
120
+ if (!confirmResult?.confirmed) {
103
121
  return;
104
122
  }
105
- context.utility.showProgressIndicator(stringSet.status.deleting + '...');
106
- yield new Promise((resolve) => setTimeout(resolve, 2000));
107
- // await context.dataService.deleteRecord(
108
- // context.primaryControl.logicalName,
109
- // recordId
110
- // );
123
+ context.utility.showProgressIndicator((0, utils_1.plurialize)(1, localizeSelector((s) => s.status.deleting)) + '...');
124
+ await context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
111
125
  context.utility.showNotification({
112
- title: stringSet.successNotification.title,
113
- text: stringSet.successNotification.text,
126
+ title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.title)),
127
+ text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.text)),
114
128
  type: 'success',
115
129
  });
116
- // context.primaryControl.close();
130
+ context.primaryControl.close();
117
131
  }
118
132
  catch (error) {
119
133
  context.utility.showNotification({
@@ -125,7 +139,7 @@ var FormCommandBuilder;
125
139
  finally {
126
140
  context.utility.hideProgressIndicator();
127
141
  }
128
- }),
142
+ },
129
143
  };
130
144
  }
131
145
  FormCommandBuilder.createDeleteCommand = createDeleteCommand;
@@ -135,9 +149,9 @@ var FormCommandBuilder;
135
149
  type: 'button',
136
150
  text,
137
151
  localizedText: localizedTexts,
138
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
139
- yield context.primaryControl.refresh();
140
- }),
152
+ onClick: async (context) => {
153
+ await context.primaryControl.refresh();
154
+ },
141
155
  hidden: (context) => !context.primaryControl.recordId,
142
156
  };
143
157
  }
@@ -1,49 +1,31 @@
1
1
  import { SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
2
2
  import { Localized } from '@headless-adminapp/core/types';
3
3
  import { Icon } from '@headless-adminapp/icons';
4
+ import { ViewCommandBuilder } from './ViewCommandBuilder';
4
5
  export declare namespace SubgridCommandBuilder {
5
- export function createNewRecordCommand({ Icon, text, localizedTexts, }: {
6
+ function createNewRecordCommand({ Icon, text, localizedTexts, }: {
6
7
  Icon: Icon;
7
8
  text: string;
8
9
  localizedTexts?: Record<string, string>;
9
10
  }): SubGridCommandItemExperience;
10
- export function createEditRecordCommand({ Icon, text, localizedTexts, }: {
11
+ function createEditRecordCommand({ Icon, text, localizedTexts, }: {
11
12
  Icon: Icon;
12
13
  text: string;
13
14
  localizedTexts?: Record<string, string>;
14
15
  }): SubGridCommandItemExperience;
15
- interface DeleteRecordCommandStringSet {
16
- confirmation: {
17
- title: string | string[];
18
- text: string | string[];
19
- buttonCancel: string;
20
- buttonConfirm: string;
21
- };
22
- status: {
23
- deleting: string | string[];
24
- };
25
- successNotification: {
26
- title: string | string[];
27
- text: string | string[];
28
- };
29
- errorNotification: {
30
- title: string;
31
- };
32
- }
33
- export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
34
- export function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
16
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
35
17
  Icon: Icon;
36
18
  text: string;
37
19
  localizedText?: Record<string, string>;
38
- stringSet?: DeleteRecordCommandStringSet;
39
- localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
20
+ stringSet?: ViewCommandBuilder.DeleteRecordCommandStringSet;
21
+ localizedStringSet?: Localized<ViewCommandBuilder.DeleteRecordCommandStringSet>;
40
22
  }): SubGridCommandItemExperience;
41
- export function createRefreshCommand({ Icon, localizedTexts, text, }: {
23
+ function createRefreshCommand({ Icon, localizedTexts, text, }: {
42
24
  Icon: Icon;
43
25
  text: string;
44
26
  localizedTexts?: Record<string, string>;
45
27
  }): SubGridCommandItemExperience;
46
- export function createExportCommand({ button, csv, excel, }: {
28
+ function createExportCommand({ button, csv, excel, }: {
47
29
  button: {
48
30
  Icon: Icon;
49
31
  text: string;
@@ -60,5 +42,4 @@ export declare namespace SubgridCommandBuilder {
60
42
  localizedTexts?: Record<string, string>;
61
43
  };
62
44
  }): SubGridCommandItemExperience;
63
- export {};
64
45
  }