@headless-adminapp/app 0.0.17-alpha.5 → 0.0.17-alpha.52

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 (168) hide show
  1. package/app/AppProvider.js +2 -1
  2. package/app/AuthWrapper.d.ts +1 -1
  3. package/app/AuthWrapper.js +4 -1
  4. package/app/LayoutProvider.d.ts +8 -7
  5. package/app/LayoutProvider.js +37 -2
  6. package/auth/AuthProvider.d.ts +1 -1
  7. package/auth/AuthProvider.js +23 -3
  8. package/auth/context.d.ts +1 -0
  9. package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
  10. package/auth/hooks/useIsSkipAuthCheck.js +8 -0
  11. package/board/BoardColumnDataResolver.d.ts +1 -0
  12. package/board/BoardColumnDataResolver.js +64 -0
  13. package/board/BoardColumnProvider.d.ts +7 -0
  14. package/board/BoardColumnProvider.js +36 -0
  15. package/board/context.d.ts +19 -0
  16. package/board/context.js +6 -0
  17. package/board/hooks/index.d.ts +6 -0
  18. package/board/hooks/index.js +15 -0
  19. package/board/hooks/useBoardColumnConfig.d.ts +2 -0
  20. package/board/hooks/useBoardColumnConfig.js +8 -0
  21. package/board/hooks/useBoardColumnData.d.ts +1 -0
  22. package/board/hooks/useBoardColumnData.js +9 -0
  23. package/board/hooks/useBoardColumnDataState.d.ts +5 -0
  24. package/board/hooks/useBoardColumnDataState.js +9 -0
  25. package/board/hooks/useBoardConfig.d.ts +3 -0
  26. package/board/hooks/useBoardConfig.js +8 -0
  27. package/board/hooks/useBoardSchema.d.ts +2 -0
  28. package/board/hooks/useBoardSchema.js +7 -0
  29. package/board/hooks/useSearchText.d.ts +1 -0
  30. package/board/hooks/useSearchText.js +14 -0
  31. package/board/types.d.ts +47 -0
  32. package/board/utils.d.ts +3 -0
  33. package/board/utils.js +6 -0
  34. package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
  35. package/builders/CommandBuilder/CommandBuilder.js +14 -0
  36. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +88 -0
  37. package/builders/CommandBuilder/DefaultCommandBuilder.js +191 -0
  38. package/builders/CommandBuilder/FormCommandBuilder.d.ts +46 -0
  39. package/builders/CommandBuilder/FormCommandBuilder.js +171 -0
  40. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +45 -0
  41. package/builders/CommandBuilder/SubgridCommandBuilder.js +240 -0
  42. package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
  43. package/builders/CommandBuilder/ViewCommandBuilder.js +242 -0
  44. package/builders/CommandBuilder/index.d.ts +1 -0
  45. package/builders/CommandBuilder/index.js +5 -0
  46. package/builders/CommandBuilder/utils.d.ts +3 -0
  47. package/builders/CommandBuilder/utils.js +21 -0
  48. package/builders/SchemaExperienceBuilder.d.ts +5 -8
  49. package/builders/SchemaExperienceBuilder.js +4 -4
  50. package/builders/index.d.ts +1 -1
  51. package/builders/index.js +1 -2
  52. package/builders/utils.d.ts +28 -0
  53. package/builders/utils.js +185 -0
  54. package/command/hooks/useBaseCommandHandlerContext.js +22 -4
  55. package/command/hooks/useCommands.d.ts +1 -1
  56. package/command/hooks/useCommands.js +1 -1
  57. package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
  58. package/components/ScrollbarWithMoreDataRequest/index.js +33 -0
  59. package/dataform/DataFormProvider/DataResolver.js +6 -6
  60. package/dataform/DataFormProvider/InitialValueResolver.js +4 -2
  61. package/dataform/DataFormProvider/index.js +3 -3
  62. package/dataform/hooks/index.d.ts +1 -0
  63. package/dataform/hooks/index.js +1 -0
  64. package/dataform/hooks/useFormSave.js +9 -2
  65. package/dataform/hooks/useLoadFormGridPage.js +8 -2
  66. package/dataform/hooks/useMainFormCommands.d.ts +1 -12
  67. package/dataform/hooks/useMainFormCommands.js +9 -1
  68. package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
  69. package/dataform/hooks/useProcessFlowSteps.js +44 -0
  70. package/dataform/hooks/useRecordTitle.d.ts +1 -1
  71. package/dataform/hooks/useRecordTitle.js +9 -2
  72. package/dataform/utils/defaultParameters.d.ts +3 -0
  73. package/dataform/utils/defaultParameters.js +37 -0
  74. package/dataform/utils/index.d.ts +3 -22
  75. package/dataform/utils/index.js +88 -134
  76. package/dataform/utils/saveRecord.d.ts +25 -0
  77. package/dataform/utils/saveRecord.js +167 -0
  78. package/datagrid/DataGridProvider/DataResolver.js +25 -149
  79. package/datagrid/DataGridProvider/index.d.ts +5 -0
  80. package/datagrid/DataGridProvider/index.js +8 -0
  81. package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
  82. package/datagrid/DataGridProvider/utils.d.ts +7 -2
  83. package/datagrid/DataGridProvider/utils.js +52 -2
  84. package/datagrid/column-filter/constants.js +38 -3
  85. package/datagrid/context.d.ts +9 -6
  86. package/datagrid/hooks/useGridCommands.d.ts +3 -0
  87. package/datagrid/hooks/useGridCommands.js +3 -0
  88. package/datagrid/hooks/useLoadMainGridPage.js +1 -1
  89. package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
  90. package/datagrid/hooks/useMainGridCommands.js +38 -26
  91. package/datagrid/hooks/useOpenRecord.d.ts +1 -0
  92. package/datagrid/hooks/useOpenRecord.js +34 -0
  93. package/datagrid/hooks/useSubGridCommands.js +25 -65
  94. package/defaults.d.ts +2 -0
  95. package/defaults.js +5 -0
  96. package/dialog/hooks/useCloseDialog.js +17 -15
  97. package/dialog/hooks/useOpenDialog.js +2 -4
  98. package/form/FormValidationStringContext.d.ts +1 -0
  99. package/form/FormValidationStringContext.js +1 -0
  100. package/hooks/index.d.ts +1 -0
  101. package/hooks/index.js +3 -0
  102. package/hooks/useDebouncedValue.js +0 -1
  103. package/hooks/useElementLayout.js +1 -1
  104. package/hooks/useIsMobile.js +0 -1
  105. package/hooks/useItemsWithKey.d.ts +7 -0
  106. package/hooks/useItemsWithKey.js +13 -0
  107. package/hooks/useSystemColorScheme.d.ts +1 -1
  108. package/hooks/useSystemColorScheme.js +0 -1
  109. package/insights/InsightsProvider.d.ts +8 -0
  110. package/insights/InsightsProvider.js +27 -0
  111. package/locale/LocaleProvider.d.ts +2 -1
  112. package/locale/LocaleProvider.js +3 -3
  113. package/locale/index.d.ts +1 -0
  114. package/locale/index.js +1 -0
  115. package/locale/useCurrencySymbol.d.ts +1 -0
  116. package/locale/useCurrencySymbol.js +13 -0
  117. package/locale/utils.d.ts +5 -0
  118. package/locale/utils.js +7 -0
  119. package/metadata/MetadataProvider.d.ts +8 -4
  120. package/metadata/MetadataProvider.js +23 -16
  121. package/metadata/hooks/useExperienceViewCommands.js +7 -1
  122. package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
  123. package/metadata/hooks/useMetadata.d.ts +2 -4
  124. package/metadata/hooks/useMetadata.js +2 -6
  125. package/metadata/hooks/useSchema.d.ts +1 -1
  126. package/metadata/hooks/useSchema.js +5 -2
  127. package/mutable/context.js +1 -1
  128. package/mutable/utils.js +5 -12
  129. package/navigation/hooks/index.d.ts +1 -0
  130. package/{appearance → navigation}/hooks/index.js +1 -1
  131. package/navigation/hooks/useOpenForm.d.ts +2 -4
  132. package/navigation/hooks/useOpenForm.js +11 -3
  133. package/navigation/index.d.ts +1 -0
  134. package/{appearance → navigation}/index.js +0 -3
  135. package/package.json +6 -2
  136. package/recordset/RecordSetProvider.js +1 -1
  137. package/recordset/hooks/useRecordSetResult.js +1 -1
  138. package/route/RouteProvider.d.ts +2 -2
  139. package/route/RouteProvider.js +4 -1
  140. package/store/ComponentStore.d.ts +1 -1
  141. package/store/ComponentStore.js +5 -9
  142. package/store/SchemaExperienceStore.d.ts +3 -3
  143. package/toast-notification/hooks/useCloseToastNotification.js +17 -15
  144. package/toast-notification/hooks/useOpenToastNotification.js +2 -4
  145. package/transport/RestDataService/index.d.ts +1 -1
  146. package/transport/RestDataService/index.js +17 -16
  147. package/transport/context.d.ts +3 -1
  148. package/transport/context.js +16 -1
  149. package/transport/hooks/index.d.ts +1 -0
  150. package/transport/hooks/index.js +1 -0
  151. package/transport/hooks/useFileService.d.ts +1 -0
  152. package/transport/hooks/useFileService.js +12 -0
  153. package/transport/hooks/useRetriveRecords.d.ts +32 -0
  154. package/transport/hooks/useRetriveRecords.js +120 -0
  155. package/utils/color.d.ts +1 -0
  156. package/utils/color.js +14 -0
  157. package/utils/getAttributeFormattedValue.d.ts +3 -1
  158. package/utils/getAttributeFormattedValue.js +108 -54
  159. package/appearance/context.d.ts +0 -7
  160. package/appearance/context.js +0 -5
  161. package/appearance/hooks/index.d.ts +0 -1
  162. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  163. package/appearance/hooks/useAppearanceContext.js +0 -12
  164. package/appearance/index.d.ts +0 -2
  165. package/builders/CommandBuilder.d.ts +0 -176
  166. package/builders/CommandBuilder.js +0 -474
  167. package/locale/types.d.ts +0 -2
  168. /package/{locale → board}/types.js +0 -0
@@ -0,0 +1,88 @@
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { EntityMainGridCommandItemExperience, SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
3
+ import { Localized } from '@headless-adminapp/core/types';
4
+ import { Icon } from '@headless-adminapp/icons';
5
+ import { FormCommandBuilder } from './FormCommandBuilder';
6
+ import { ViewCommandBuilder } from './ViewCommandBuilder';
7
+ export declare namespace DefaultCommandBuilder {
8
+ interface CreateDefaultViewCommandStrings {
9
+ new: string;
10
+ edit: string;
11
+ delete: string;
12
+ refresh: string;
13
+ export: string;
14
+ exportCsv: string;
15
+ exportExcel: string;
16
+ deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
17
+ }
18
+ export const defaultViewCommandStrings: CreateDefaultViewCommandStrings;
19
+ interface CreateDefaultViewCommandOptions {
20
+ icons: {
21
+ New: Icon;
22
+ Edit: Icon;
23
+ Delete: Icon;
24
+ Refresh: Icon;
25
+ Export: Icon;
26
+ ExportCsv: Icon;
27
+ ExportExcel: Icon;
28
+ };
29
+ strings?: CreateDefaultViewCommandStrings;
30
+ localizedSrings?: Localized<CreateDefaultViewCommandStrings>;
31
+ }
32
+ export function createDefaultViewCommands({ icons, strings, localizedSrings, }: CreateDefaultViewCommandOptions): EntityMainGridCommandItemExperience[][];
33
+ interface CreateDefaultFormCommandStrings {
34
+ save: string;
35
+ saveAndClose: string;
36
+ refresh: string;
37
+ delete: string;
38
+ deleteRecordCommandStringSet: FormCommandBuilder.DeleteRecordCommandStringSet;
39
+ }
40
+ interface CreateDefaultFormCommandOptions {
41
+ icons: {
42
+ Save: Icon;
43
+ SaveAndClose: Icon;
44
+ Refresh: Icon;
45
+ Delete: Icon;
46
+ };
47
+ strings?: CreateDefaultFormCommandStrings;
48
+ localizedSrings?: Localized<CreateDefaultFormCommandStrings>;
49
+ }
50
+ export const defaultFormCommandStrings: CreateDefaultFormCommandStrings;
51
+ export function createDefaultFormCommands({ icons, strings, localizedSrings, }: CreateDefaultFormCommandOptions): EntityMainFormCommandItemExperience[][];
52
+ interface CreateDefaultSubgridCommandStrings {
53
+ new: string;
54
+ edit: string;
55
+ delete: string;
56
+ refresh: string;
57
+ export: string;
58
+ exportCsv: string;
59
+ exportExcel: string;
60
+ deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
61
+ }
62
+ interface CreateDefaultSubgridCommandOptions {
63
+ icons: {
64
+ New: Icon;
65
+ Edit: Icon;
66
+ Delete: Icon;
67
+ Refresh: Icon;
68
+ Export: Icon;
69
+ ExportCsv: Icon;
70
+ ExportExcel: Icon;
71
+ };
72
+ strings?: CreateDefaultSubgridCommandStrings;
73
+ localizedSrings?: Localized<CreateDefaultSubgridCommandStrings>;
74
+ }
75
+ export function createDefaultSubgridCommands({ icons, strings, localizedSrings, }: CreateDefaultSubgridCommandOptions): SubGridCommandItemExperience[][];
76
+ type CreateDefaultCommandStrings = CreateDefaultViewCommandStrings & CreateDefaultFormCommandStrings & CreateDefaultSubgridCommandStrings;
77
+ interface CreateDefaultCommandOptions {
78
+ icons: CreateDefaultViewCommandOptions['icons'] & CreateDefaultFormCommandOptions['icons'] & CreateDefaultSubgridCommandOptions['icons'];
79
+ strings?: CreateDefaultCommandStrings;
80
+ localizedSrings?: Localized<CreateDefaultCommandStrings>;
81
+ }
82
+ export function createDefaultCommands({ icons, strings, localizedSrings, }: CreateDefaultCommandOptions): {
83
+ view: EntityMainGridCommandItemExperience[][];
84
+ form: EntityMainFormCommandItemExperience[][];
85
+ subgrid: SubGridCommandItemExperience[][];
86
+ };
87
+ export {};
88
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCommandBuilder = void 0;
4
+ const FormCommandBuilder_1 = require("./FormCommandBuilder");
5
+ const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
6
+ const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
7
+ var DefaultCommandBuilder;
8
+ (function (DefaultCommandBuilder) {
9
+ DefaultCommandBuilder.defaultViewCommandStrings = {
10
+ new: 'New',
11
+ edit: 'Edit',
12
+ delete: 'Delete',
13
+ deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
14
+ refresh: 'Refresh',
15
+ export: 'Export',
16
+ exportCsv: 'CSV',
17
+ exportExcel: 'Excel',
18
+ };
19
+ function extractLocalizedStrings(localizedStrings, selector) {
20
+ if (!localizedStrings) {
21
+ return;
22
+ }
23
+ return Object.keys(localizedStrings).reduce((p, key) => {
24
+ p[key] = selector(localizedStrings[key]);
25
+ return p;
26
+ }, {});
27
+ }
28
+ function createDefaultViewCommands({ icons, strings = DefaultCommandBuilder.defaultViewCommandStrings, localizedSrings, }) {
29
+ return [
30
+ [
31
+ ViewCommandBuilder_1.ViewCommandBuilder.createNewRecordCommand({
32
+ Icon: icons.New,
33
+ text: strings.new,
34
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
35
+ }),
36
+ ViewCommandBuilder_1.ViewCommandBuilder.createEditRecordCommand({
37
+ Icon: icons.Edit,
38
+ text: strings.edit,
39
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
40
+ }),
41
+ ViewCommandBuilder_1.ViewCommandBuilder.createDeleteRecordCommand({
42
+ Icon: icons.Delete,
43
+ text: strings.delete,
44
+ localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
45
+ stringSet: strings.deleteRecordCommandStringSet,
46
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
47
+ }),
48
+ ViewCommandBuilder_1.ViewCommandBuilder.createRefreshCommand({
49
+ Icon: icons.Refresh,
50
+ text: strings.refresh,
51
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
52
+ }),
53
+ ],
54
+ [
55
+ ViewCommandBuilder_1.ViewCommandBuilder.createExportCommand({
56
+ button: {
57
+ Icon: icons.Export,
58
+ text: strings.export,
59
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
60
+ },
61
+ csv: {
62
+ Icon: icons.ExportCsv,
63
+ text: strings.exportCsv,
64
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
65
+ },
66
+ excel: {
67
+ Icon: icons.ExportExcel,
68
+ text: strings.exportExcel,
69
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
70
+ },
71
+ }),
72
+ ],
73
+ ];
74
+ }
75
+ DefaultCommandBuilder.createDefaultViewCommands = createDefaultViewCommands;
76
+ DefaultCommandBuilder.defaultFormCommandStrings = {
77
+ save: 'Save',
78
+ saveAndClose: 'Save & Close',
79
+ refresh: 'Refresh',
80
+ delete: 'Delete',
81
+ deleteRecordCommandStringSet: FormCommandBuilder_1.FormCommandBuilder.defaultDeleteRecordStringSet,
82
+ };
83
+ function createDefaultFormCommands({ icons, strings = DefaultCommandBuilder.defaultFormCommandStrings, localizedSrings, }) {
84
+ return [
85
+ [
86
+ FormCommandBuilder_1.FormCommandBuilder.createSaveCommand({
87
+ Icon: icons.Save,
88
+ text: strings.save,
89
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.save),
90
+ }),
91
+ FormCommandBuilder_1.FormCommandBuilder.createSaveAndCloseCommand({
92
+ Icon: icons.SaveAndClose,
93
+ text: strings.saveAndClose,
94
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.saveAndClose),
95
+ }),
96
+ FormCommandBuilder_1.FormCommandBuilder.createRefreshCommand({
97
+ Icon: icons.Refresh,
98
+ text: strings.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),
107
+ }),
108
+ ],
109
+ ];
110
+ }
111
+ DefaultCommandBuilder.createDefaultFormCommands = createDefaultFormCommands;
112
+ const defaultSubgridCommandStrings = {
113
+ new: 'New',
114
+ edit: 'Edit',
115
+ delete: 'Delete',
116
+ refresh: 'Refresh',
117
+ export: 'Export',
118
+ exportCsv: 'CSV',
119
+ exportExcel: 'Excel',
120
+ deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
121
+ };
122
+ function createDefaultSubgridCommands({ icons, strings = defaultSubgridCommandStrings, localizedSrings, }) {
123
+ return [
124
+ [
125
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createNewRecordCommand({
126
+ Icon: icons.New,
127
+ text: strings.new,
128
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
129
+ }),
130
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createEditRecordCommand({
131
+ Icon: icons.Edit,
132
+ text: strings.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),
141
+ }),
142
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createRefreshCommand({
143
+ Icon: icons.Refresh,
144
+ text: strings.refresh,
145
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
146
+ }),
147
+ ],
148
+ [
149
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createExportCommand({
150
+ button: {
151
+ Icon: icons.Export,
152
+ text: strings.export,
153
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
154
+ },
155
+ csv: {
156
+ Icon: icons.ExportCsv,
157
+ text: strings.exportCsv,
158
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
159
+ },
160
+ excel: {
161
+ Icon: icons.ExportExcel,
162
+ text: strings.exportExcel,
163
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
164
+ },
165
+ }),
166
+ ],
167
+ ];
168
+ }
169
+ DefaultCommandBuilder.createDefaultSubgridCommands = createDefaultSubgridCommands;
170
+ const defaultCreateCommandStrings = Object.assign(Object.assign(Object.assign({}, DefaultCommandBuilder.defaultViewCommandStrings), DefaultCommandBuilder.defaultFormCommandStrings), defaultSubgridCommandStrings);
171
+ function createDefaultCommands({ icons, strings = defaultCreateCommandStrings, localizedSrings, }) {
172
+ return {
173
+ view: createDefaultViewCommands({
174
+ icons,
175
+ strings,
176
+ localizedSrings,
177
+ }),
178
+ form: createDefaultFormCommands({
179
+ icons,
180
+ strings,
181
+ localizedSrings,
182
+ }),
183
+ subgrid: createDefaultSubgridCommands({
184
+ icons,
185
+ strings,
186
+ localizedSrings,
187
+ }),
188
+ };
189
+ }
190
+ DefaultCommandBuilder.createDefaultCommands = createDefaultCommands;
191
+ })(DefaultCommandBuilder || (exports.DefaultCommandBuilder = DefaultCommandBuilder = {}));
@@ -0,0 +1,46 @@
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { Localized } from '@headless-adminapp/core/types';
3
+ import { Icon } from '@headless-adminapp/icons';
4
+ export declare namespace FormCommandBuilder {
5
+ function createSaveCommand({ Icon, text, localizedTexts, }: {
6
+ Icon: Icon;
7
+ text: string;
8
+ localizedTexts?: Record<string, string>;
9
+ }): EntityMainFormCommandItemExperience;
10
+ function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
11
+ Icon: Icon;
12
+ text: string;
13
+ localizedTexts?: Record<string, string>;
14
+ }): EntityMainFormCommandItemExperience;
15
+ interface DeleteRecordCommandStringSet {
16
+ confirmation: {
17
+ title: string | [string, string];
18
+ text: string | [string, string];
19
+ buttonCancel: string;
20
+ buttonConfirm: string;
21
+ };
22
+ status: {
23
+ deleting: string | [string, string];
24
+ };
25
+ successNotification: {
26
+ title: string | [string, string];
27
+ text: string | [string, string];
28
+ };
29
+ errorNotification: {
30
+ title: string;
31
+ };
32
+ }
33
+ const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
34
+ function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }: {
35
+ Icon: Icon;
36
+ text: string;
37
+ localizedTexts?: Record<string, string>;
38
+ stringSet: DeleteRecordCommandStringSet;
39
+ localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
40
+ }): EntityMainFormCommandItemExperience;
41
+ function createRefreshCommand({ Icon, text, localizedTexts, }: {
42
+ Icon: Icon;
43
+ text: string;
44
+ localizedTexts?: Record<string, string>;
45
+ }): EntityMainFormCommandItemExperience;
46
+ }
@@ -0,0 +1,171 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FormCommandBuilder = void 0;
13
+ const utils_1 = require("./utils");
14
+ var EnabledRules;
15
+ (function (EnabledRules) {
16
+ function HasCreatePermisssion(context) {
17
+ var _a;
18
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
19
+ }
20
+ EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
21
+ function HasUpdatePermission(context) {
22
+ var _a;
23
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
24
+ }
25
+ EnabledRules.HasUpdatePermission = HasUpdatePermission;
26
+ function HasDeletePermission(context) {
27
+ var _a;
28
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
29
+ }
30
+ EnabledRules.HasDeletePermission = HasDeletePermission;
31
+ })(EnabledRules || (EnabledRules = {}));
32
+ var FormCommandBuilder;
33
+ (function (FormCommandBuilder) {
34
+ function createSaveCommand({ Icon, text, localizedTexts, }) {
35
+ return {
36
+ type: 'button',
37
+ Icon,
38
+ text,
39
+ localizedText: localizedTexts,
40
+ isQuickAction: true,
41
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
42
+ yield context.primaryControl.save('save');
43
+ }),
44
+ hidden: [
45
+ (context) => {
46
+ if (context.primaryControl.readonly) {
47
+ return true;
48
+ }
49
+ if (context.primaryControl.recordId) {
50
+ return !EnabledRules.HasUpdatePermission(context);
51
+ }
52
+ else {
53
+ return !EnabledRules.HasCreatePermisssion(context);
54
+ }
55
+ },
56
+ ],
57
+ };
58
+ }
59
+ FormCommandBuilder.createSaveCommand = createSaveCommand;
60
+ function createSaveAndCloseCommand({ Icon, text, localizedTexts, }) {
61
+ return {
62
+ type: 'button',
63
+ Icon,
64
+ text,
65
+ localizedText: localizedTexts,
66
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
67
+ yield context.primaryControl.save('saveandclose');
68
+ }),
69
+ hidden: [
70
+ (context) => {
71
+ if (context.primaryControl.readonly) {
72
+ return true;
73
+ }
74
+ if (context.primaryControl.recordId) {
75
+ return !EnabledRules.HasUpdatePermission(context);
76
+ }
77
+ else {
78
+ return !EnabledRules.HasCreatePermisssion(context);
79
+ }
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ FormCommandBuilder.createSaveAndCloseCommand = createSaveAndCloseCommand;
85
+ FormCommandBuilder.defaultDeleteRecordStringSet = {
86
+ confirmation: {
87
+ text: 'Are you sure you want to delete this record?',
88
+ title: 'Delete record',
89
+ buttonConfirm: 'Delete',
90
+ buttonCancel: 'Cancel',
91
+ },
92
+ status: {
93
+ deleting: 'Deleting record',
94
+ },
95
+ successNotification: {
96
+ title: 'Record deleted',
97
+ text: 'Record deleted successfully',
98
+ },
99
+ errorNotification: {
100
+ title: 'Error',
101
+ },
102
+ };
103
+ function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }) {
104
+ return {
105
+ Icon: Icon,
106
+ type: 'button',
107
+ text,
108
+ localizedText: localizedTexts,
109
+ danger: true,
110
+ hidden: (context) => {
111
+ if (!context.primaryControl.recordId) {
112
+ return true;
113
+ }
114
+ return !EnabledRules.HasDeletePermission(context);
115
+ },
116
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
117
+ const recordId = context.primaryControl.recordId;
118
+ if (!recordId) {
119
+ return;
120
+ }
121
+ // if (typeof stringSet === 'function') {
122
+ // stringSet = stringSet(context);
123
+ // }
124
+ const localizeSelector = (0, utils_1.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
125
+ try {
126
+ const confirmResult = yield context.utility.openConfirmDialog({
127
+ title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.title)),
128
+ text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.text)),
129
+ cancelButtonLabel: stringSet.confirmation.buttonCancel,
130
+ confirmButtonLabel: stringSet.confirmation.buttonConfirm,
131
+ });
132
+ if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
133
+ return;
134
+ }
135
+ context.utility.showProgressIndicator((0, utils_1.plurialize)(1, localizeSelector((s) => s.status.deleting)) + '...');
136
+ yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
137
+ context.utility.showNotification({
138
+ title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.title)),
139
+ text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.text)),
140
+ type: 'success',
141
+ });
142
+ context.primaryControl.close();
143
+ }
144
+ catch (error) {
145
+ context.utility.showNotification({
146
+ title: stringSet.errorNotification.title,
147
+ text: error.message,
148
+ type: 'error',
149
+ });
150
+ }
151
+ finally {
152
+ context.utility.hideProgressIndicator();
153
+ }
154
+ }),
155
+ };
156
+ }
157
+ FormCommandBuilder.createDeleteCommand = createDeleteCommand;
158
+ function createRefreshCommand({ Icon, text, localizedTexts, }) {
159
+ return {
160
+ Icon,
161
+ type: 'button',
162
+ text,
163
+ localizedText: localizedTexts,
164
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
165
+ yield context.primaryControl.refresh();
166
+ }),
167
+ hidden: (context) => !context.primaryControl.recordId,
168
+ };
169
+ }
170
+ FormCommandBuilder.createRefreshCommand = createRefreshCommand;
171
+ })(FormCommandBuilder || (exports.FormCommandBuilder = FormCommandBuilder = {}));
@@ -0,0 +1,45 @@
1
+ import { SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
2
+ import { Localized } from '@headless-adminapp/core/types';
3
+ import { Icon } from '@headless-adminapp/icons';
4
+ import { ViewCommandBuilder } from './ViewCommandBuilder';
5
+ export declare namespace SubgridCommandBuilder {
6
+ function createNewRecordCommand({ Icon, text, localizedTexts, }: {
7
+ Icon: Icon;
8
+ text: string;
9
+ localizedTexts?: Record<string, string>;
10
+ }): SubGridCommandItemExperience;
11
+ function createEditRecordCommand({ Icon, text, localizedTexts, }: {
12
+ Icon: Icon;
13
+ text: string;
14
+ localizedTexts?: Record<string, string>;
15
+ }): SubGridCommandItemExperience;
16
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
17
+ Icon: Icon;
18
+ text: string;
19
+ localizedText?: Record<string, string>;
20
+ stringSet?: ViewCommandBuilder.DeleteRecordCommandStringSet;
21
+ localizedStringSet?: Localized<ViewCommandBuilder.DeleteRecordCommandStringSet>;
22
+ }): SubGridCommandItemExperience;
23
+ function createRefreshCommand({ Icon, localizedTexts, text, }: {
24
+ Icon: Icon;
25
+ text: string;
26
+ localizedTexts?: Record<string, string>;
27
+ }): SubGridCommandItemExperience;
28
+ function createExportCommand({ button, csv, excel, }: {
29
+ button: {
30
+ Icon: Icon;
31
+ text: string;
32
+ localizedTexts?: Record<string, string>;
33
+ };
34
+ excel: {
35
+ Icon: Icon;
36
+ text: string;
37
+ localizedTexts?: Record<string, string>;
38
+ };
39
+ csv: {
40
+ Icon: Icon;
41
+ text: string;
42
+ localizedTexts?: Record<string, string>;
43
+ };
44
+ }): SubGridCommandItemExperience;
45
+ }