@headless-adminapp/app 0.0.17-alpha.8 → 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 (243) 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.d.ts +1 -1
  187. package/metadata/hooks/useExperienceViewCommands.js +5 -14
  188. package/metadata/hooks/useExperienceViewLookup.js +2 -11
  189. package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
  190. package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
  191. package/metadata/hooks/useMetadata.d.ts +11 -10
  192. package/metadata/hooks/useMetadata.js +4 -16
  193. package/metadata/hooks/useSchema.d.ts +1 -1
  194. package/metadata/hooks/useSchema.js +3 -0
  195. package/mutable/context.d.ts +3 -0
  196. package/mutable/context.js +8 -0
  197. package/mutable/utils.js +5 -12
  198. package/navigation/hooks/useOpenForm.js +4 -0
  199. package/package.json +6 -10
  200. package/providers/PageEntityFormProvider/index.d.ts +5 -1
  201. package/providers/PageEntityFormProvider/index.js +2 -2
  202. package/recordset/hooks/useRecordSetResult.js +4 -14
  203. package/route/RouteProvider.d.ts +2 -2
  204. package/route/RouteProvider.js +4 -1
  205. package/store/ClientAppStore.js +7 -20
  206. package/store/ComponentStore.d.ts +1 -1
  207. package/store/ComponentStore.js +6 -12
  208. package/store/EventManager.d.ts +2 -2
  209. package/store/EventManager.js +13 -29
  210. package/store/SchemaExperienceStore.js +179 -215
  211. package/store/index.d.ts +0 -1
  212. package/store/index.js +0 -1
  213. package/toast-notification/hooks/useCloseToastNotification.js +17 -15
  214. package/toast-notification/hooks/useOpenToastNotification.js +7 -5
  215. package/transport/InMemoryDataService/index.js +54 -77
  216. package/transport/RestDataService/index.d.ts +3 -3
  217. package/transport/RestDataService/index.js +68 -91
  218. package/transport/context.d.ts +2 -1
  219. package/transport/context.js +7 -1
  220. package/transport/hooks/index.d.ts +1 -0
  221. package/transport/hooks/index.js +1 -0
  222. package/transport/hooks/useFileService.d.ts +1 -0
  223. package/transport/hooks/useFileService.js +9 -0
  224. package/transport/hooks/useRetriveRecords.d.ts +33 -0
  225. package/transport/hooks/useRetriveRecords.js +110 -0
  226. package/utils/calculateColumnWidths.js +1 -1
  227. package/utils/color.d.ts +1 -0
  228. package/utils/color.js +14 -0
  229. package/utils/getAttributeFormattedValue.d.ts +4 -1
  230. package/utils/getAttributeFormattedValue.js +109 -54
  231. package/utils/phone.d.ts +13 -0
  232. package/utils/phone.js +33 -0
  233. package/appearance/context.d.ts +0 -7
  234. package/appearance/context.js +0 -5
  235. package/appearance/hooks/index.d.ts +0 -1
  236. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  237. package/appearance/hooks/useAppearanceContext.js +0 -12
  238. package/appearance/index.d.ts +0 -2
  239. package/appearance/index.js +0 -20
  240. package/builders/CommandBuilder.d.ts +0 -176
  241. package/builders/CommandBuilder.js +0 -567
  242. package/locale/types.d.ts +0 -2
  243. /package/{locale → board}/types.js +0 -0
@@ -1,567 +0,0 @@
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.CommandBuilder = void 0;
13
- exports.localizedLabel = localizedLabel;
14
- exports.createLocalizedSelector = createLocalizedSelector;
15
- const utils_1 = require("./utils");
16
- function localizedLabel(language, value, fallback) {
17
- var _a, _b, _c, _d, _e;
18
- return ((_e = (_d = (_b = (_a = value.localizedLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : (_c = fallback === null || fallback === void 0 ? void 0 : fallback.localizedLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : value.label) !== null && _e !== void 0 ? _e : fallback === null || fallback === void 0 ? void 0 : fallback.label);
19
- }
20
- function createLocalizedSelector(stringSet, localizedStringSet, language) {
21
- return function selectLocalized(selector) {
22
- if (localizedStringSet && localizedStringSet[language]) {
23
- return selector(localizedStringSet[language]);
24
- }
25
- return selector(stringSet);
26
- };
27
- }
28
- var CommandBuilder;
29
- (function (CommandBuilder) {
30
- let View;
31
- (function (View) {
32
- let EnabledRules;
33
- (function (EnabledRules) {
34
- function HasCreatePermisssion(context) {
35
- var _a;
36
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
37
- }
38
- EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
39
- function HasUpdatePermission(context) {
40
- var _a;
41
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
42
- }
43
- EnabledRules.HasUpdatePermission = HasUpdatePermission;
44
- function HasDeletePermission(context) {
45
- var _a;
46
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
47
- }
48
- EnabledRules.HasDeletePermission = HasDeletePermission;
49
- function HasSingleRecordSelected(context) {
50
- return context.primaryControl.selectedIds.length === 1;
51
- }
52
- EnabledRules.HasSingleRecordSelected = HasSingleRecordSelected;
53
- function HasAtLeastOneRecordSelected(context) {
54
- return context.primaryControl.selectedIds.length > 0;
55
- }
56
- EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
57
- })(EnabledRules || (EnabledRules = {}));
58
- function createNewRecordCommand({ Icon, text, localizedTexts, }) {
59
- return {
60
- type: 'button',
61
- Icon,
62
- text,
63
- localizedText: localizedTexts,
64
- onClick: (context) => {
65
- context.navigation.openForm({
66
- logicalName: context.primaryControl.schema.logicalName,
67
- });
68
- },
69
- hidden: (context) => {
70
- if (!EnabledRules.HasCreatePermisssion(context)) {
71
- return true;
72
- }
73
- return false;
74
- },
75
- };
76
- }
77
- View.createNewRecordCommand = createNewRecordCommand;
78
- function createEditRecordCommand({ Icon, text, localizedTexts, }) {
79
- return {
80
- type: 'button',
81
- Icon,
82
- text,
83
- localizedText: localizedTexts,
84
- isContextMenu: true,
85
- onClick: (context) => {
86
- context.primaryControl.openRecord(context.primaryControl.selectedIds[0]);
87
- },
88
- hidden: (context) => {
89
- if (!EnabledRules.HasUpdatePermission(context)) {
90
- return true;
91
- }
92
- if (!EnabledRules.HasSingleRecordSelected(context)) {
93
- return true;
94
- }
95
- return false;
96
- },
97
- };
98
- }
99
- View.createEditRecordCommand = createEditRecordCommand;
100
- function plurialize(count, singular, plural) {
101
- if (Array.isArray(singular)) {
102
- plural = singular[1];
103
- singular = singular[0];
104
- }
105
- let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
106
- msg = msg.replace('{count}', count.toString());
107
- return msg;
108
- }
109
- View.defaultDeleteRecordStringSet = {
110
- confirmation: {
111
- text: [
112
- 'Are you sure you want to delete this record?',
113
- 'Are you sure you want to delete selected records?',
114
- ],
115
- title: ['Delete record', 'Delete records'],
116
- buttonConfirm: 'Delete',
117
- buttonCancel: 'Cancel',
118
- },
119
- status: {
120
- deleting: ['Deleting record', 'Deleting records'],
121
- },
122
- successNotification: {
123
- title: ['Record deleted', 'Records deleted'],
124
- text: ['Record deleted successfully', 'Records deleted successfully'],
125
- },
126
- errorNotification: {
127
- title: 'Error',
128
- },
129
- };
130
- function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = View.defaultDeleteRecordStringSet, localizedStringSet, }) {
131
- return {
132
- type: 'button',
133
- Icon,
134
- text,
135
- localizedText,
136
- danger: true,
137
- isContextMenu: true,
138
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
139
- const recordIds = context.primaryControl.selectedIds;
140
- if (!recordIds.length) {
141
- return;
142
- }
143
- const localizeSelector = createLocalizedSelector(stringSet, localizedStringSet, context.locale.language);
144
- try {
145
- const confirmResult = yield context.utility.openConfirmDialog({
146
- title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
147
- text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
148
- cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
149
- confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
150
- });
151
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
152
- return;
153
- }
154
- context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
155
- for (const recordId of recordIds) {
156
- yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
157
- }
158
- context.utility.showNotification({
159
- title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
160
- text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
161
- type: 'success',
162
- });
163
- context.primaryControl.refresh();
164
- }
165
- catch (error) {
166
- context.utility.showNotification({
167
- title: localizeSelector((s) => s.errorNotification.title),
168
- text: error.message,
169
- type: 'error',
170
- });
171
- }
172
- finally {
173
- context.utility.hideProgressIndicator();
174
- }
175
- }),
176
- hidden: [
177
- (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
178
- (context) => !EnabledRules.HasDeletePermission(context),
179
- ],
180
- };
181
- }
182
- View.createDeleteRecordCommand = createDeleteRecordCommand;
183
- function createRefreshCommand({ Icon, localizedTexts, text, }) {
184
- return {
185
- type: 'button',
186
- Icon,
187
- text,
188
- localizedText: localizedTexts,
189
- onClick: (context) => {
190
- context.primaryControl.refresh();
191
- },
192
- };
193
- }
194
- View.createRefreshCommand = createRefreshCommand;
195
- function createExportCommand({ button, csv, excel, }) {
196
- return {
197
- type: 'menu',
198
- Icon: button.Icon,
199
- text: button.text,
200
- localizedTexts: button.localizedTexts,
201
- items: [
202
- [
203
- {
204
- Icon: excel.Icon,
205
- text: excel.text,
206
- localizedTexts: excel.localizedTexts,
207
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
208
- context.utility.showProgressIndicator('Exporting to Excel...');
209
- try {
210
- const result = yield (0, utils_1.retriveRecords)({
211
- columnFilters: context.primaryControl.columnFilter,
212
- dataService: context.dataService,
213
- gridColumns: context.primaryControl.gridColumns,
214
- schema: context.primaryControl.schema,
215
- schemaStore: context.stores.schemaStore,
216
- view: context.primaryControl.view,
217
- search: context.primaryControl.searchText,
218
- extraFilter: context.primaryControl.extraFilter,
219
- sorting: context.primaryControl.sorting,
220
- skip: 0,
221
- limit: 5000,
222
- });
223
- yield (0, utils_1.exportRecordsXLS)({
224
- fileName: context.primaryControl.view.name + '.xlsx',
225
- gridColumns: context.primaryControl.gridColumns,
226
- records: result.records,
227
- schema: context.primaryControl.schema,
228
- schemaStore: context.stores.schemaStore,
229
- });
230
- }
231
- finally {
232
- context.utility.hideProgressIndicator();
233
- }
234
- }),
235
- },
236
- {
237
- Icon: csv.Icon,
238
- text: csv.text,
239
- localizedTexts: csv.localizedTexts,
240
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
241
- context.utility.showProgressIndicator('Exporting to Excel...');
242
- try {
243
- const result = yield (0, utils_1.retriveRecords)({
244
- columnFilters: context.primaryControl.columnFilter,
245
- dataService: context.dataService,
246
- gridColumns: context.primaryControl.gridColumns,
247
- schema: context.primaryControl.schema,
248
- schemaStore: context.stores.schemaStore,
249
- view: context.primaryControl.view,
250
- search: context.primaryControl.searchText,
251
- extraFilter: context.primaryControl.extraFilter,
252
- sorting: context.primaryControl.sorting,
253
- skip: 0,
254
- limit: 5000,
255
- });
256
- yield (0, utils_1.exportRecordsCSV)({
257
- fileName: context.primaryControl.view.name + '.csv',
258
- gridColumns: context.primaryControl.gridColumns,
259
- records: result.records,
260
- schema: context.primaryControl.schema,
261
- schemaStore: context.stores.schemaStore,
262
- });
263
- }
264
- finally {
265
- context.utility.hideProgressIndicator();
266
- }
267
- }),
268
- },
269
- ],
270
- ],
271
- };
272
- }
273
- View.createExportCommand = createExportCommand;
274
- })(View = CommandBuilder.View || (CommandBuilder.View = {}));
275
- let Form;
276
- (function (Form) {
277
- function createSaveCommand({ Icon, text, localizedTexts, }) {
278
- return {
279
- type: 'button',
280
- Icon,
281
- text,
282
- localizedText: localizedTexts,
283
- isQuickAction: true,
284
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
285
- yield context.primaryControl.save('save');
286
- }),
287
- hidden: (context) => {
288
- if (context.primaryControl.readonly) {
289
- return true;
290
- }
291
- return false;
292
- },
293
- };
294
- }
295
- Form.createSaveCommand = createSaveCommand;
296
- function createSaveAndCloseCommand({ Icon, text, localizedTexts, }) {
297
- return {
298
- type: 'button',
299
- Icon,
300
- text,
301
- localizedText: localizedTexts,
302
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
303
- yield context.primaryControl.save('saveandclose');
304
- }),
305
- hidden: (context) => {
306
- if (context.primaryControl.readonly) {
307
- return true;
308
- }
309
- return false;
310
- },
311
- };
312
- }
313
- Form.createSaveAndCloseCommand = createSaveAndCloseCommand;
314
- Form.defaultDeleteRecordStringSet = {
315
- confirmation: {
316
- text: 'Are you sure you want to delete this record?',
317
- title: 'Delete record',
318
- buttonConfirm: 'Delete',
319
- buttonCancel: 'Cancel',
320
- },
321
- status: {
322
- deleting: 'Deleting record',
323
- },
324
- successNotification: {
325
- title: 'Record deleted',
326
- text: 'Record deleted successfully',
327
- },
328
- errorNotification: {
329
- title: 'Error',
330
- },
331
- };
332
- function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }) {
333
- return {
334
- Icon: Icon,
335
- type: 'button',
336
- text,
337
- localizedText: localizedTexts,
338
- danger: true,
339
- hidden: (context) => {
340
- var _a;
341
- if (!context.primaryControl.recordId) {
342
- return true;
343
- }
344
- if ((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete) {
345
- return true;
346
- }
347
- return false;
348
- },
349
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
350
- const recordId = context.primaryControl.recordId;
351
- if (!recordId) {
352
- return;
353
- }
354
- if (typeof stringSet === 'function') {
355
- stringSet = stringSet(context);
356
- }
357
- try {
358
- const confirmResult = yield context.utility.openConfirmDialog({
359
- title: stringSet.confirmation.title,
360
- text: stringSet.confirmation.text,
361
- cancelButtonLabel: stringSet.confirmation.buttonCancel,
362
- confirmButtonLabel: stringSet.confirmation.buttonConfirm,
363
- });
364
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
365
- return;
366
- }
367
- context.utility.showProgressIndicator(stringSet.status.deleting + '...');
368
- yield new Promise((resolve) => setTimeout(resolve, 2000));
369
- // await context.dataService.deleteRecord(
370
- // context.primaryControl.logicalName,
371
- // recordId
372
- // );
373
- context.utility.showNotification({
374
- title: stringSet.successNotification.title,
375
- text: stringSet.successNotification.text,
376
- type: 'success',
377
- });
378
- // context.primaryControl.close();
379
- }
380
- catch (error) {
381
- context.utility.showNotification({
382
- title: stringSet.errorNotification.title,
383
- text: error.message,
384
- type: 'error',
385
- });
386
- }
387
- finally {
388
- context.utility.hideProgressIndicator();
389
- }
390
- }),
391
- };
392
- }
393
- Form.createDeleteCommand = createDeleteCommand;
394
- function createRefreshCommand({ Icon, text, localizedTexts, }) {
395
- return {
396
- Icon,
397
- type: 'button',
398
- text,
399
- localizedText: localizedTexts,
400
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
401
- yield context.primaryControl.refresh();
402
- }),
403
- hidden: (context) => !context.primaryControl.recordId,
404
- };
405
- }
406
- Form.createRefreshCommand = createRefreshCommand;
407
- })(Form = CommandBuilder.Form || (CommandBuilder.Form = {}));
408
- let Subgrid;
409
- (function (Subgrid) {
410
- function createNewRecordCommand({ Icon, text, localizedTexts, }) {
411
- return {
412
- type: 'button',
413
- Icon,
414
- text,
415
- localizedText: localizedTexts,
416
- onClick: (context) => {
417
- console.log('New record', context);
418
- },
419
- hidden: (context) => {
420
- console.log(context);
421
- // TODO: Implement logic to hide the button
422
- return false;
423
- },
424
- };
425
- }
426
- Subgrid.createNewRecordCommand = createNewRecordCommand;
427
- function createEditRecordCommand({ Icon, text, localizedTexts, }) {
428
- return {
429
- type: 'button',
430
- Icon,
431
- text,
432
- localizedText: localizedTexts,
433
- isContextMenu: true,
434
- onClick: (context) => {
435
- console.log('Edit record', context);
436
- },
437
- // hidden: (context) => context.secondaryControl.selectedIds.length !== 1, // TODO: check permissions
438
- hidden: (context) => {
439
- console.log('temp.', context);
440
- return context.secondaryControl.selectedIds.length !== 1;
441
- },
442
- };
443
- }
444
- Subgrid.createEditRecordCommand = createEditRecordCommand;
445
- function plurialize(count, singular, plural) {
446
- if (Array.isArray(singular)) {
447
- plural = singular[1];
448
- singular = singular[0];
449
- }
450
- let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
451
- msg = msg.replace('{count}', count.toString());
452
- return msg;
453
- }
454
- Subgrid.defaultDeleteRecordStringSet = {
455
- confirmation: {
456
- text: [
457
- 'Are you sure you want to delete this record?',
458
- 'Are you sure you want to delete selected records?',
459
- ],
460
- title: ['Delete record', 'Delete records'],
461
- buttonConfirm: 'Delete',
462
- buttonCancel: 'Cancel',
463
- },
464
- status: {
465
- deleting: ['Deleting record', 'Deleting records'],
466
- },
467
- successNotification: {
468
- title: ['Record deleted', 'Records deleted'],
469
- text: ['Record deleted successfully', 'Records deleted successfully'],
470
- },
471
- errorNotification: {
472
- title: 'Error',
473
- },
474
- };
475
- function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = Subgrid.defaultDeleteRecordStringSet, localizedStringSet, }) {
476
- return {
477
- type: 'button',
478
- Icon,
479
- text,
480
- localizedText,
481
- danger: true,
482
- isContextMenu: true,
483
- hidden: [
484
- (context) => context.secondaryControl.selectedIds.length === 0,
485
- ], // TODO: check permissions
486
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
487
- const recordIds = context.secondaryControl.selectedIds;
488
- if (!recordIds.length) {
489
- return;
490
- }
491
- const localizeSelector = createLocalizedSelector(stringSet, localizedStringSet, context.locale.language);
492
- try {
493
- const confirmResult = yield context.utility.openConfirmDialog({
494
- title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
495
- text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
496
- cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
497
- confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
498
- });
499
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
500
- return;
501
- }
502
- context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
503
- yield new Promise((resolve) => setTimeout(resolve, 2000));
504
- context.utility.showNotification({
505
- title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
506
- text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
507
- type: 'success',
508
- });
509
- yield context.primaryControl.refresh();
510
- }
511
- catch (error) {
512
- context.utility.showNotification({
513
- title: localizeSelector((s) => s.errorNotification.title),
514
- text: error.message,
515
- type: 'error',
516
- });
517
- }
518
- finally {
519
- context.utility.hideProgressIndicator();
520
- }
521
- }),
522
- };
523
- }
524
- Subgrid.createDeleteRecordCommand = createDeleteRecordCommand;
525
- function createRefreshCommand({ Icon, localizedTexts, text, }) {
526
- return {
527
- type: 'button',
528
- Icon,
529
- text,
530
- localizedText: localizedTexts,
531
- onClick: (context) => {
532
- context.secondaryControl.refresh();
533
- },
534
- };
535
- }
536
- Subgrid.createRefreshCommand = createRefreshCommand;
537
- function createExportCommand({ button, csv, excel, }) {
538
- return {
539
- type: 'menu',
540
- Icon: button.Icon,
541
- text: button.text,
542
- localizedTexts: button.localizedTexts,
543
- items: [
544
- [
545
- {
546
- Icon: excel.Icon,
547
- text: excel.text,
548
- localizedTexts: excel.localizedTexts,
549
- onClick: (context) => {
550
- console.log('Export to Excel', context);
551
- },
552
- },
553
- {
554
- Icon: csv.Icon,
555
- text: csv.text,
556
- localizedTexts: csv.localizedTexts,
557
- onClick: (context) => {
558
- console.log('Export to CSV', context);
559
- },
560
- },
561
- ],
562
- ],
563
- };
564
- }
565
- Subgrid.createExportCommand = createExportCommand;
566
- })(Subgrid = CommandBuilder.Subgrid || (CommandBuilder.Subgrid = {}));
567
- })(CommandBuilder || (exports.CommandBuilder = CommandBuilder = {}));
package/locale/types.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Locale } from '@headless-adminapp/core/experience/app';
2
- export type LocaleContextState = Locale;
File without changes