@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,240 @@
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.SubgridCommandBuilder = void 0;
13
+ const utils_1 = require("../utils");
14
+ const utils_2 = require("./utils");
15
+ const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
16
+ var EnabledRules;
17
+ (function (EnabledRules) {
18
+ function HasCreatePermisssion(context) {
19
+ var _a;
20
+ return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
21
+ }
22
+ EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
23
+ function HasUpdatePermission(context) {
24
+ var _a;
25
+ return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
26
+ }
27
+ EnabledRules.HasUpdatePermission = HasUpdatePermission;
28
+ function HasDeletePermission(context) {
29
+ var _a;
30
+ return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
31
+ }
32
+ EnabledRules.HasDeletePermission = HasDeletePermission;
33
+ function HasSingleRecordSelected(context) {
34
+ return context.secondaryControl.selectedIds.length === 1;
35
+ }
36
+ EnabledRules.HasSingleRecordSelected = HasSingleRecordSelected;
37
+ function HasAtLeastOneRecordSelected(context) {
38
+ return context.secondaryControl.selectedIds.length > 0;
39
+ }
40
+ EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
41
+ })(EnabledRules || (EnabledRules = {}));
42
+ var SubgridCommandBuilder;
43
+ (function (SubgridCommandBuilder) {
44
+ function createNewRecordCommand({ Icon, text, localizedTexts, }) {
45
+ return {
46
+ type: 'button',
47
+ Icon,
48
+ text,
49
+ localizedText: localizedTexts,
50
+ onClick: (context) => {
51
+ if (context.secondaryControl.associated) {
52
+ context.navigation.openForm({
53
+ logicalName: context.secondaryControl.schema.logicalName,
54
+ parameters: {
55
+ [context.secondaryControl.associated.refAttributeName]: {
56
+ id: context.secondaryControl.associated.id,
57
+ logicalName: context.secondaryControl.associated.logicalName,
58
+ name: context.secondaryControl.associated.name,
59
+ },
60
+ },
61
+ });
62
+ }
63
+ else {
64
+ context.navigation.openForm({
65
+ logicalName: context.secondaryControl.schema.logicalName,
66
+ });
67
+ }
68
+ },
69
+ hidden: (context) => !EnabledRules.HasCreatePermisssion(context),
70
+ };
71
+ }
72
+ SubgridCommandBuilder.createNewRecordCommand = createNewRecordCommand;
73
+ function createEditRecordCommand({ Icon, text, localizedTexts, }) {
74
+ return {
75
+ type: 'button',
76
+ Icon,
77
+ text,
78
+ localizedText: localizedTexts,
79
+ isContextMenu: true,
80
+ onClick: (context) => {
81
+ context.secondaryControl.openRecord(context.secondaryControl.selectedIds[0]);
82
+ },
83
+ hidden: [(context) => !EnabledRules.HasSingleRecordSelected(context)],
84
+ };
85
+ }
86
+ SubgridCommandBuilder.createEditRecordCommand = createEditRecordCommand;
87
+ function plurialize(count, singular, plural) {
88
+ if (Array.isArray(singular)) {
89
+ plural = singular[1];
90
+ singular = singular[0];
91
+ }
92
+ let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
93
+ msg = msg.replace('{count}', count.toString());
94
+ return msg;
95
+ }
96
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
97
+ return {
98
+ type: 'button',
99
+ Icon,
100
+ text,
101
+ localizedText,
102
+ danger: true,
103
+ isContextMenu: true,
104
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
105
+ const recordIds = context.secondaryControl.selectedIds;
106
+ if (!recordIds.length) {
107
+ return;
108
+ }
109
+ const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
110
+ try {
111
+ const confirmResult = yield context.utility.openConfirmDialog({
112
+ title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
113
+ text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
114
+ cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
115
+ confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
116
+ });
117
+ if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
118
+ return;
119
+ }
120
+ context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
121
+ for (const recordId of recordIds) {
122
+ yield context.dataService.deleteRecord(context.secondaryControl.logicalName, recordId);
123
+ }
124
+ context.utility.showNotification({
125
+ title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
126
+ text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
127
+ type: 'success',
128
+ });
129
+ context.secondaryControl.refresh();
130
+ }
131
+ catch (error) {
132
+ context.utility.showNotification({
133
+ title: localizeSelector((s) => s.errorNotification.title),
134
+ text: error.message,
135
+ type: 'error',
136
+ });
137
+ }
138
+ finally {
139
+ context.utility.hideProgressIndicator();
140
+ }
141
+ }),
142
+ hidden: [
143
+ (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
144
+ (context) => !EnabledRules.HasDeletePermission(context),
145
+ ],
146
+ };
147
+ }
148
+ SubgridCommandBuilder.createDeleteRecordCommand = createDeleteRecordCommand;
149
+ function createRefreshCommand({ Icon, localizedTexts, text, }) {
150
+ return {
151
+ type: 'button',
152
+ Icon,
153
+ text,
154
+ localizedText: localizedTexts,
155
+ onClick: (context) => {
156
+ context.secondaryControl.refresh();
157
+ },
158
+ };
159
+ }
160
+ SubgridCommandBuilder.createRefreshCommand = createRefreshCommand;
161
+ function createExportCommand({ button, csv, excel, }) {
162
+ return {
163
+ type: 'menu',
164
+ Icon: button.Icon,
165
+ text: button.text,
166
+ localizedTexts: button.localizedTexts,
167
+ items: [
168
+ [
169
+ {
170
+ Icon: excel.Icon,
171
+ text: excel.text,
172
+ localizedTexts: excel.localizedTexts,
173
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
174
+ context.utility.showProgressIndicator('Exporting to Excel...');
175
+ try {
176
+ const result = yield (0, utils_1.retriveRecords)({
177
+ columnFilters: context.secondaryControl.columnFilter,
178
+ dataService: context.dataService,
179
+ gridColumns: context.secondaryControl.gridColumns,
180
+ schema: context.secondaryControl.schema,
181
+ schemaStore: context.stores.schemaStore,
182
+ view: context.secondaryControl.view,
183
+ search: context.secondaryControl.searchText,
184
+ extraFilter: context.secondaryControl.extraFilter,
185
+ sorting: context.secondaryControl.sorting,
186
+ skip: 0,
187
+ limit: 5000,
188
+ });
189
+ yield (0, utils_1.exportRecordsXLS)({
190
+ fileName: context.secondaryControl.view.name + '.xlsx',
191
+ gridColumns: context.secondaryControl.gridColumns,
192
+ records: result.records,
193
+ schema: context.secondaryControl.schema,
194
+ schemaStore: context.stores.schemaStore,
195
+ });
196
+ }
197
+ finally {
198
+ context.utility.hideProgressIndicator();
199
+ }
200
+ }),
201
+ },
202
+ {
203
+ Icon: csv.Icon,
204
+ text: csv.text,
205
+ localizedTexts: csv.localizedTexts,
206
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
207
+ context.utility.showProgressIndicator('Exporting to CSV...');
208
+ try {
209
+ const result = yield (0, utils_1.retriveRecords)({
210
+ columnFilters: context.secondaryControl.columnFilter,
211
+ dataService: context.dataService,
212
+ gridColumns: context.secondaryControl.gridColumns,
213
+ schema: context.secondaryControl.schema,
214
+ schemaStore: context.stores.schemaStore,
215
+ view: context.secondaryControl.view,
216
+ search: context.secondaryControl.searchText,
217
+ extraFilter: context.secondaryControl.extraFilter,
218
+ sorting: context.secondaryControl.sorting,
219
+ skip: 0,
220
+ limit: 5000,
221
+ });
222
+ yield (0, utils_1.exportRecordsCSV)({
223
+ fileName: context.secondaryControl.view.name + '.csv',
224
+ gridColumns: context.secondaryControl.gridColumns,
225
+ records: result.records,
226
+ schema: context.secondaryControl.schema,
227
+ schemaStore: context.stores.schemaStore,
228
+ });
229
+ }
230
+ finally {
231
+ context.utility.hideProgressIndicator();
232
+ }
233
+ }),
234
+ },
235
+ ],
236
+ ],
237
+ };
238
+ }
239
+ SubgridCommandBuilder.createExportCommand = createExportCommand;
240
+ })(SubgridCommandBuilder || (exports.SubgridCommandBuilder = SubgridCommandBuilder = {}));
@@ -0,0 +1,63 @@
1
+ import { EntityMainGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
2
+ import { Localized } from '@headless-adminapp/core/types';
3
+ import { Icon } from '@headless-adminapp/icons';
4
+ export declare namespace ViewCommandBuilder {
5
+ function createNewRecordCommand({ Icon, text, localizedTexts, }: {
6
+ Icon: Icon;
7
+ text: string;
8
+ localizedTexts?: Record<string, string>;
9
+ }): EntityMainGridCommandItemExperience;
10
+ function createEditRecordCommand({ Icon, text, localizedTexts, }: {
11
+ Icon: Icon;
12
+ text: string;
13
+ localizedTexts?: Record<string, string>;
14
+ }): EntityMainGridCommandItemExperience;
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 createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
35
+ Icon: Icon;
36
+ text: string;
37
+ localizedText?: Record<string, string>;
38
+ stringSet?: DeleteRecordCommandStringSet;
39
+ localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
40
+ }): EntityMainGridCommandItemExperience;
41
+ function createRefreshCommand({ Icon, localizedTexts, text, }: {
42
+ Icon: Icon;
43
+ text: string;
44
+ localizedTexts?: Record<string, string>;
45
+ }): EntityMainGridCommandItemExperience;
46
+ function createExportCommand({ button, csv, excel, }: {
47
+ button: {
48
+ Icon: Icon;
49
+ text: string;
50
+ localizedTexts?: Record<string, string>;
51
+ };
52
+ excel: {
53
+ Icon: Icon;
54
+ text: string;
55
+ localizedTexts?: Record<string, string>;
56
+ };
57
+ csv: {
58
+ Icon: Icon;
59
+ text: string;
60
+ localizedTexts?: Record<string, string>;
61
+ };
62
+ }): EntityMainGridCommandItemExperience;
63
+ }
@@ -0,0 +1,242 @@
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.ViewCommandBuilder = void 0;
13
+ const utils_1 = require("../utils");
14
+ const utils_2 = require("./utils");
15
+ var EnabledRules;
16
+ (function (EnabledRules) {
17
+ function HasCreatePermisssion(context) {
18
+ var _a;
19
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
20
+ }
21
+ EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
22
+ function HasUpdatePermission(context) {
23
+ var _a;
24
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
25
+ }
26
+ EnabledRules.HasUpdatePermission = HasUpdatePermission;
27
+ function HasDeletePermission(context) {
28
+ var _a;
29
+ return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
30
+ }
31
+ EnabledRules.HasDeletePermission = HasDeletePermission;
32
+ function HasSingleRecordSelected(context) {
33
+ return context.primaryControl.selectedIds.length === 1;
34
+ }
35
+ EnabledRules.HasSingleRecordSelected = HasSingleRecordSelected;
36
+ function HasAtLeastOneRecordSelected(context) {
37
+ return context.primaryControl.selectedIds.length > 0;
38
+ }
39
+ EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
40
+ })(EnabledRules || (EnabledRules = {}));
41
+ var ViewCommandBuilder;
42
+ (function (ViewCommandBuilder) {
43
+ function createNewRecordCommand({ Icon, text, localizedTexts, }) {
44
+ return {
45
+ type: 'button',
46
+ Icon,
47
+ text,
48
+ localizedText: localizedTexts,
49
+ onClick: (context) => {
50
+ context.navigation.openForm({
51
+ logicalName: context.primaryControl.schema.logicalName,
52
+ });
53
+ },
54
+ hidden: (context) => {
55
+ if (!EnabledRules.HasCreatePermisssion(context)) {
56
+ return true;
57
+ }
58
+ return false;
59
+ },
60
+ };
61
+ }
62
+ ViewCommandBuilder.createNewRecordCommand = createNewRecordCommand;
63
+ function createEditRecordCommand({ Icon, text, localizedTexts, }) {
64
+ return {
65
+ type: 'button',
66
+ Icon,
67
+ text,
68
+ localizedText: localizedTexts,
69
+ isContextMenu: true,
70
+ onClick: (context) => {
71
+ context.primaryControl.openRecord(context.primaryControl.selectedIds[0]);
72
+ },
73
+ hidden: [(context) => !EnabledRules.HasSingleRecordSelected(context)],
74
+ };
75
+ }
76
+ ViewCommandBuilder.createEditRecordCommand = createEditRecordCommand;
77
+ ViewCommandBuilder.defaultDeleteRecordStringSet = {
78
+ confirmation: {
79
+ text: [
80
+ 'Are you sure you want to delete this record?',
81
+ 'Are you sure you want to delete selected records?',
82
+ ],
83
+ title: ['Delete record', 'Delete records'],
84
+ buttonConfirm: 'Delete',
85
+ buttonCancel: 'Cancel',
86
+ },
87
+ status: {
88
+ deleting: ['Deleting record', 'Deleting records'],
89
+ },
90
+ successNotification: {
91
+ title: ['Record deleted', 'Records deleted'],
92
+ text: ['Record deleted successfully', 'Records deleted successfully'],
93
+ },
94
+ errorNotification: {
95
+ title: 'Error',
96
+ },
97
+ };
98
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
99
+ return {
100
+ type: 'button',
101
+ Icon,
102
+ text,
103
+ localizedText,
104
+ danger: true,
105
+ isContextMenu: true,
106
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
107
+ const recordIds = context.primaryControl.selectedIds;
108
+ if (!recordIds.length) {
109
+ return;
110
+ }
111
+ const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
112
+ try {
113
+ const confirmResult = yield context.utility.openConfirmDialog({
114
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.confirmation.title)),
115
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.confirmation.text)),
116
+ cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
117
+ confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
118
+ });
119
+ if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
120
+ return;
121
+ }
122
+ context.utility.showProgressIndicator((0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
123
+ for (const recordId of recordIds) {
124
+ yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
125
+ }
126
+ context.utility.showNotification({
127
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.successNotification.title)),
128
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.successNotification.text)),
129
+ type: 'success',
130
+ });
131
+ context.primaryControl.refresh();
132
+ }
133
+ catch (error) {
134
+ context.utility.showNotification({
135
+ title: localizeSelector((s) => s.errorNotification.title),
136
+ text: error.message,
137
+ type: 'error',
138
+ });
139
+ }
140
+ finally {
141
+ context.utility.hideProgressIndicator();
142
+ }
143
+ }),
144
+ hidden: [
145
+ (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
146
+ (context) => !EnabledRules.HasDeletePermission(context),
147
+ ],
148
+ };
149
+ }
150
+ ViewCommandBuilder.createDeleteRecordCommand = createDeleteRecordCommand;
151
+ function createRefreshCommand({ Icon, localizedTexts, text, }) {
152
+ return {
153
+ type: 'button',
154
+ Icon,
155
+ text,
156
+ localizedText: localizedTexts,
157
+ onClick: (context) => {
158
+ context.primaryControl.refresh();
159
+ },
160
+ };
161
+ }
162
+ ViewCommandBuilder.createRefreshCommand = createRefreshCommand;
163
+ function createExportCommand({ button, csv, excel, }) {
164
+ return {
165
+ type: 'menu',
166
+ Icon: button.Icon,
167
+ text: button.text,
168
+ localizedTexts: button.localizedTexts,
169
+ items: [
170
+ [
171
+ {
172
+ Icon: excel.Icon,
173
+ text: excel.text,
174
+ localizedTexts: excel.localizedTexts,
175
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
176
+ context.utility.showProgressIndicator('Exporting to Excel...');
177
+ try {
178
+ const result = yield (0, utils_1.retriveRecords)({
179
+ columnFilters: context.primaryControl.columnFilter,
180
+ dataService: context.dataService,
181
+ gridColumns: context.primaryControl.gridColumns,
182
+ schema: context.primaryControl.schema,
183
+ schemaStore: context.stores.schemaStore,
184
+ view: context.primaryControl.view,
185
+ search: context.primaryControl.searchText,
186
+ extraFilter: context.primaryControl.extraFilter,
187
+ sorting: context.primaryControl.sorting,
188
+ skip: 0,
189
+ limit: 5000,
190
+ });
191
+ yield (0, utils_1.exportRecordsXLS)({
192
+ fileName: context.primaryControl.view.name + '.xlsx',
193
+ gridColumns: context.primaryControl.gridColumns,
194
+ records: result.records,
195
+ schema: context.primaryControl.schema,
196
+ schemaStore: context.stores.schemaStore,
197
+ });
198
+ }
199
+ finally {
200
+ context.utility.hideProgressIndicator();
201
+ }
202
+ }),
203
+ },
204
+ {
205
+ Icon: csv.Icon,
206
+ text: csv.text,
207
+ localizedTexts: csv.localizedTexts,
208
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
209
+ context.utility.showProgressIndicator('Exporting to CSV...');
210
+ try {
211
+ const result = yield (0, utils_1.retriveRecords)({
212
+ columnFilters: context.primaryControl.columnFilter,
213
+ dataService: context.dataService,
214
+ gridColumns: context.primaryControl.gridColumns,
215
+ schema: context.primaryControl.schema,
216
+ schemaStore: context.stores.schemaStore,
217
+ view: context.primaryControl.view,
218
+ search: context.primaryControl.searchText,
219
+ extraFilter: context.primaryControl.extraFilter,
220
+ sorting: context.primaryControl.sorting,
221
+ skip: 0,
222
+ limit: 5000,
223
+ });
224
+ yield (0, utils_1.exportRecordsCSV)({
225
+ fileName: context.primaryControl.view.name + '.csv',
226
+ gridColumns: context.primaryControl.gridColumns,
227
+ records: result.records,
228
+ schema: context.primaryControl.schema,
229
+ schemaStore: context.stores.schemaStore,
230
+ });
231
+ }
232
+ finally {
233
+ context.utility.hideProgressIndicator();
234
+ }
235
+ }),
236
+ },
237
+ ],
238
+ ],
239
+ };
240
+ }
241
+ ViewCommandBuilder.createExportCommand = createExportCommand;
242
+ })(ViewCommandBuilder || (exports.ViewCommandBuilder = ViewCommandBuilder = {}));
@@ -0,0 +1 @@
1
+ export { CommandBuilder } from './CommandBuilder';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandBuilder = void 0;
4
+ var CommandBuilder_1 = require("./CommandBuilder");
5
+ Object.defineProperty(exports, "CommandBuilder", { enumerable: true, get: function () { return CommandBuilder_1.CommandBuilder; } });
@@ -0,0 +1,3 @@
1
+ import { Localized } from '@headless-adminapp/core/types';
2
+ export declare function createLocalizedSelector<T>(stringSet: T, localizedStringSet: Localized<T> | undefined, language: string): <U>(selector: (stringSet: T) => U) => U;
3
+ export declare function plurialize(count: number, singular: string | [string, string], plural?: string): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLocalizedSelector = createLocalizedSelector;
4
+ exports.plurialize = plurialize;
5
+ function createLocalizedSelector(stringSet, localizedStringSet, language) {
6
+ return function selectLocalized(selector) {
7
+ if (localizedStringSet && localizedStringSet[language]) {
8
+ return selector(localizedStringSet[language]);
9
+ }
10
+ return selector(stringSet);
11
+ };
12
+ }
13
+ function plurialize(count, singular, plural) {
14
+ if (Array.isArray(singular)) {
15
+ plural = singular[1];
16
+ singular = singular[0];
17
+ }
18
+ let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
19
+ msg = msg.replace('{count}', count.toString());
20
+ return msg;
21
+ }
@@ -1,6 +1,6 @@
1
- import { AsyncForm, AsyncQuickCreateForm, EntityMainFormCommandItemExperience, Form, FormExperience, QuickCreateForm } from '@headless-adminapp/core/experience/form';
1
+ import { AsyncForm, AsyncQuickCreateForm, Form, FormExperience, QuickCreateForm } from '@headless-adminapp/core/experience/form';
2
2
  import { SchemaExperience } from '@headless-adminapp/core/experience/schema';
3
- import { AsyncView, EntityMainGridCommandItemExperience, SubGridCommandItemExperience, View, ViewExperience } from '@headless-adminapp/core/experience/view';
3
+ import { AsyncView, View, ViewExperience } from '@headless-adminapp/core/experience/view';
4
4
  import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
5
5
  declare abstract class BaseSchemaExperienceBuilder<S extends SchemaAttributes> {
6
6
  protected readonly logicalName: string;
@@ -29,17 +29,14 @@ declare abstract class BaseSchemaExperienceBuilder<S extends SchemaAttributes> {
29
29
  defineFormExperience(formExperience: FormExperience<S>): FormExperience<S>;
30
30
  }
31
31
  export interface SchemaExperienceBuilderDefaults {
32
- formCommands?: EntityMainFormCommandItemExperience[][];
33
- viewCommands?: EntityMainGridCommandItemExperience[][];
34
- subgridCommands?: SubGridCommandItemExperience[][];
35
32
  localizedViewNames?: Record<string, string>;
36
33
  }
37
34
  interface SchemaExperienceBuilderOptions {
38
35
  }
39
36
  export declare class SchemaExperienceBuilder<S extends SchemaAttributes = SchemaAttributes> extends BaseSchemaExperienceBuilder<S> {
40
- private schema;
41
- private defaults?;
42
- private options?;
37
+ private readonly schema;
38
+ private readonly defaults?;
39
+ private readonly options?;
43
40
  constructor(schema: Schema<S>, defaults?: SchemaExperienceBuilderDefaults | undefined, options?: SchemaExperienceBuilderOptions | undefined);
44
41
  defineViewExperience(viewExperience: Pick<ViewExperience<S>, 'filter' | 'defaultSorting'> & {
45
42
  card?: ViewExperience<S>['card'];
@@ -184,7 +184,7 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
184
184
  return defaultId;
185
185
  }
186
186
  defineExperience(experience) {
187
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
187
+ var _a, _b, _c, _d, _e, _f, _g, _h;
188
188
  let lookups = experience.lookups;
189
189
  let views = experience.views;
190
190
  let forms = experience.forms;
@@ -248,9 +248,9 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
248
248
  forms: (_f = forms.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _f !== void 0 ? _f : [],
249
249
  lookups: (_g = lookups.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _g !== void 0 ? _g : [],
250
250
  associatedViews: (_h = associatedViews.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _h !== void 0 ? _h : [],
251
- formCommands: (_l = (_j = experience.formCommands) !== null && _j !== void 0 ? _j : (_k = this.defaults) === null || _k === void 0 ? void 0 : _k.formCommands) !== null && _l !== void 0 ? _l : [],
252
- subgridCommands: (_p = (_m = experience.subgridCommands) !== null && _m !== void 0 ? _m : (_o = this.defaults) === null || _o === void 0 ? void 0 : _o.subgridCommands) !== null && _p !== void 0 ? _p : [],
253
- viewCommands: (_s = (_q = experience.viewCommands) !== null && _q !== void 0 ? _q : (_r = this.defaults) === null || _r === void 0 ? void 0 : _r.viewCommands) !== null && _s !== void 0 ? _s : [],
251
+ formCommands: experience.formCommands,
252
+ subgridCommands: experience.subgridCommands,
253
+ viewCommands: experience.viewCommands,
254
254
  };
255
255
  }
256
256
  }
@@ -1,2 +1,2 @@
1
1
  export { SchemaExperienceBuilder, type SchemaExperienceBuilderDefaults, } from './SchemaExperienceBuilder';
2
- export { CommandBuilder, localizedLabel } from './CommandBuilder';
2
+ export { CommandBuilder } from './CommandBuilder';
package/builders/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localizedLabel = exports.CommandBuilder = exports.SchemaExperienceBuilder = void 0;
3
+ exports.CommandBuilder = exports.SchemaExperienceBuilder = void 0;
4
4
  var SchemaExperienceBuilder_1 = require("./SchemaExperienceBuilder");
5
5
  Object.defineProperty(exports, "SchemaExperienceBuilder", { enumerable: true, get: function () { return SchemaExperienceBuilder_1.SchemaExperienceBuilder; } });
6
6
  var CommandBuilder_1 = require("./CommandBuilder");
7
7
  Object.defineProperty(exports, "CommandBuilder", { enumerable: true, get: function () { return CommandBuilder_1.CommandBuilder; } });
8
- Object.defineProperty(exports, "localizedLabel", { enumerable: true, get: function () { return CommandBuilder_1.localizedLabel; } });