@headless-adminapp/app 0.0.17-alpha.1 → 0.0.17-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/app/AuthWrapper.d.ts +7 -0
  2. package/app/AuthWrapper.js +23 -0
  3. package/app/LayoutProvider.d.ts +22 -0
  4. package/app/LayoutProvider.js +19 -0
  5. package/app/index.d.ts +1 -0
  6. package/app/index.js +3 -1
  7. package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
  8. package/builders/CommandBuilder/CommandBuilder.js +14 -0
  9. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +81 -0
  10. package/builders/CommandBuilder/DefaultCommandBuilder.js +173 -0
  11. package/builders/CommandBuilder/FormCommandBuilder.d.ts +45 -0
  12. package/builders/CommandBuilder/FormCommandBuilder.js +145 -0
  13. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +64 -0
  14. package/builders/CommandBuilder/SubgridCommandBuilder.js +170 -0
  15. package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
  16. package/builders/CommandBuilder/ViewCommandBuilder.js +250 -0
  17. package/builders/CommandBuilder/index.d.ts +1 -0
  18. package/builders/CommandBuilder/index.js +5 -0
  19. package/builders/CommandBuilder/utils.d.ts +3 -0
  20. package/builders/CommandBuilder/utils.js +21 -0
  21. package/builders/SchemaExperienceBuilder.d.ts +2 -5
  22. package/builders/SchemaExperienceBuilder.js +16 -26
  23. package/builders/index.d.ts +1 -1
  24. package/builders/index.js +1 -2
  25. package/builders/utils.d.ts +28 -0
  26. package/builders/utils.js +185 -0
  27. package/command/hooks/useBaseCommandHandlerContext.js +9 -0
  28. package/command/hooks/useCommands.d.ts +1 -1
  29. package/command/hooks/useCommands.js +1 -1
  30. package/dataform/DataFormProvider/DataResolver.js +4 -4
  31. package/dataform/DataFormProvider/InitialValueResolver.js +0 -1
  32. package/dataform/DataFormProvider/index.js +3 -3
  33. package/dataform/hooks/useFormSave.js +2 -2
  34. package/dataform/hooks/useLoadFormGridPage.js +7 -1
  35. package/dataform/utils/index.d.ts +4 -3
  36. package/dataform/utils/index.js +23 -28
  37. package/datagrid/DataGridProvider/DataResolver.js +3 -48
  38. package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
  39. package/datagrid/DataGridProvider/utils.d.ts +7 -2
  40. package/datagrid/DataGridProvider/utils.js +52 -2
  41. package/datagrid/context.d.ts +4 -6
  42. package/datagrid/hooks/useGridCommands.d.ts +3 -0
  43. package/datagrid/hooks/useGridCommands.js +3 -0
  44. package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
  45. package/datagrid/hooks/useMainGridCommands.js +23 -146
  46. package/datagrid/hooks/useOpenRecord.d.ts +1 -0
  47. package/datagrid/hooks/useOpenRecord.js +34 -0
  48. package/datagrid/hooks/useSubGridCommands.js +15 -30
  49. package/hooks/useSystemColorScheme.d.ts +1 -1
  50. package/locale/LocaleProvider.js +1 -1
  51. package/locale/utils.d.ts +5 -0
  52. package/locale/utils.js +7 -0
  53. package/metadata/hooks/useExperienceViewCommands.js +7 -1
  54. package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
  55. package/metadata/hooks/useMetadata.d.ts +1 -0
  56. package/metadata/hooks/useMetadata.js +2 -0
  57. package/metadata/hooks/useSchema.js +2 -2
  58. package/mutable/context.js +1 -1
  59. package/navigation/hooks/index.d.ts +1 -0
  60. package/{appearance → navigation}/hooks/index.js +1 -1
  61. package/navigation/hooks/useOpenForm.d.ts +2 -4
  62. package/navigation/hooks/useOpenForm.js +7 -3
  63. package/navigation/index.d.ts +1 -0
  64. package/{appearance → navigation}/index.js +0 -3
  65. package/package.json +12 -3
  66. package/recordset/RecordSetProvider.js +1 -1
  67. package/recordset/hooks/useRecordSetResult.js +1 -2
  68. package/store/SchemaExperienceStore.d.ts +3 -3
  69. package/appearance/context.d.ts +0 -7
  70. package/appearance/context.js +0 -5
  71. package/appearance/hooks/index.d.ts +0 -1
  72. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  73. package/appearance/hooks/useAppearanceContext.js +0 -12
  74. package/appearance/index.d.ts +0 -2
  75. package/builders/CommandBuilder.d.ts +0 -176
  76. package/builders/CommandBuilder.js +0 -474
  77. package/locale/types.d.ts +0 -2
  78. package/locale/types.js +0 -2
@@ -0,0 +1,170 @@
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
+ var SubgridCommandBuilder;
15
+ (function (SubgridCommandBuilder) {
16
+ function createNewRecordCommand({ Icon, text, localizedTexts, }) {
17
+ return {
18
+ type: 'button',
19
+ Icon,
20
+ text,
21
+ localizedText: localizedTexts,
22
+ onClick: (context) => {
23
+ console.log('New record', context);
24
+ },
25
+ hidden: (context) => {
26
+ console.log(context);
27
+ // TODO: Implement logic to hide the button
28
+ return false;
29
+ },
30
+ };
31
+ }
32
+ SubgridCommandBuilder.createNewRecordCommand = createNewRecordCommand;
33
+ function createEditRecordCommand({ Icon, text, localizedTexts, }) {
34
+ return {
35
+ type: 'button',
36
+ Icon,
37
+ text,
38
+ localizedText: localizedTexts,
39
+ isContextMenu: true,
40
+ onClick: (context) => {
41
+ console.log('Edit record', context);
42
+ },
43
+ // hidden: (context) => context.secondaryControl.selectedIds.length !== 1, // TODO: check permissions
44
+ hidden: (context) => {
45
+ console.log('temp.', context);
46
+ return context.secondaryControl.selectedIds.length !== 1;
47
+ },
48
+ };
49
+ }
50
+ SubgridCommandBuilder.createEditRecordCommand = createEditRecordCommand;
51
+ function plurialize(count, singular, plural) {
52
+ if (Array.isArray(singular)) {
53
+ plural = singular[1];
54
+ singular = singular[0];
55
+ }
56
+ let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
57
+ msg = msg.replace('{count}', count.toString());
58
+ return msg;
59
+ }
60
+ SubgridCommandBuilder.defaultDeleteRecordStringSet = {
61
+ confirmation: {
62
+ text: [
63
+ 'Are you sure you want to delete this record?',
64
+ 'Are you sure you want to delete selected records?',
65
+ ],
66
+ title: ['Delete record', 'Delete records'],
67
+ buttonConfirm: 'Delete',
68
+ buttonCancel: 'Cancel',
69
+ },
70
+ status: {
71
+ deleting: ['Deleting record', 'Deleting records'],
72
+ },
73
+ successNotification: {
74
+ title: ['Record deleted', 'Records deleted'],
75
+ text: ['Record deleted successfully', 'Records deleted successfully'],
76
+ },
77
+ errorNotification: {
78
+ title: 'Error',
79
+ },
80
+ };
81
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = SubgridCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
82
+ return {
83
+ type: 'button',
84
+ Icon,
85
+ text,
86
+ localizedText,
87
+ danger: true,
88
+ isContextMenu: true,
89
+ hidden: [(context) => context.secondaryControl.selectedIds.length === 0], // TODO: check permissions
90
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
91
+ const recordIds = context.secondaryControl.selectedIds;
92
+ if (!recordIds.length) {
93
+ return;
94
+ }
95
+ const localizeSelector = (0, utils_1.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
96
+ try {
97
+ const confirmResult = yield context.utility.openConfirmDialog({
98
+ title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
99
+ text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
100
+ cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
101
+ confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
102
+ });
103
+ if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
104
+ return;
105
+ }
106
+ context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
107
+ yield new Promise((resolve) => setTimeout(resolve, 2000));
108
+ context.utility.showNotification({
109
+ title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
110
+ text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
111
+ type: 'success',
112
+ });
113
+ yield context.primaryControl.refresh();
114
+ }
115
+ catch (error) {
116
+ context.utility.showNotification({
117
+ title: localizeSelector((s) => s.errorNotification.title),
118
+ text: error.message,
119
+ type: 'error',
120
+ });
121
+ }
122
+ finally {
123
+ context.utility.hideProgressIndicator();
124
+ }
125
+ }),
126
+ };
127
+ }
128
+ SubgridCommandBuilder.createDeleteRecordCommand = createDeleteRecordCommand;
129
+ function createRefreshCommand({ Icon, localizedTexts, text, }) {
130
+ return {
131
+ type: 'button',
132
+ Icon,
133
+ text,
134
+ localizedText: localizedTexts,
135
+ onClick: (context) => {
136
+ context.secondaryControl.refresh();
137
+ },
138
+ };
139
+ }
140
+ SubgridCommandBuilder.createRefreshCommand = createRefreshCommand;
141
+ function createExportCommand({ button, csv, excel, }) {
142
+ return {
143
+ type: 'menu',
144
+ Icon: button.Icon,
145
+ text: button.text,
146
+ localizedTexts: button.localizedTexts,
147
+ items: [
148
+ [
149
+ {
150
+ Icon: excel.Icon,
151
+ text: excel.text,
152
+ localizedTexts: excel.localizedTexts,
153
+ onClick: (context) => {
154
+ console.log('Export to Excel', context);
155
+ },
156
+ },
157
+ {
158
+ Icon: csv.Icon,
159
+ text: csv.text,
160
+ localizedTexts: csv.localizedTexts,
161
+ onClick: (context) => {
162
+ console.log('Export to CSV', context);
163
+ },
164
+ },
165
+ ],
166
+ ],
167
+ };
168
+ }
169
+ SubgridCommandBuilder.createExportCommand = createExportCommand;
170
+ })(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,250 @@
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 => {
74
+ if (!EnabledRules.HasUpdatePermission(context)) {
75
+ return true;
76
+ }
77
+ if (!EnabledRules.HasSingleRecordSelected(context)) {
78
+ return true;
79
+ }
80
+ return false;
81
+ },
82
+ };
83
+ }
84
+ ViewCommandBuilder.createEditRecordCommand = createEditRecordCommand;
85
+ ViewCommandBuilder.defaultDeleteRecordStringSet = {
86
+ confirmation: {
87
+ text: [
88
+ 'Are you sure you want to delete this record?',
89
+ 'Are you sure you want to delete selected records?',
90
+ ],
91
+ title: ['Delete record', 'Delete records'],
92
+ buttonConfirm: 'Delete',
93
+ buttonCancel: 'Cancel',
94
+ },
95
+ status: {
96
+ deleting: ['Deleting record', 'Deleting records'],
97
+ },
98
+ successNotification: {
99
+ title: ['Record deleted', 'Records deleted'],
100
+ text: ['Record deleted successfully', 'Records deleted successfully'],
101
+ },
102
+ errorNotification: {
103
+ title: 'Error',
104
+ },
105
+ };
106
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
107
+ return {
108
+ type: 'button',
109
+ Icon,
110
+ text,
111
+ localizedText,
112
+ danger: true,
113
+ isContextMenu: true,
114
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
115
+ const recordIds = context.primaryControl.selectedIds;
116
+ if (!recordIds.length) {
117
+ return;
118
+ }
119
+ const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
120
+ try {
121
+ const confirmResult = yield context.utility.openConfirmDialog({
122
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector(s => s.confirmation.title)),
123
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector(s => s.confirmation.text)),
124
+ cancelButtonLabel: localizeSelector(s => s.confirmation.buttonCancel),
125
+ confirmButtonLabel: localizeSelector(s => s.confirmation.buttonConfirm),
126
+ });
127
+ if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
128
+ return;
129
+ }
130
+ context.utility.showProgressIndicator((0, utils_2.plurialize)(recordIds.length, localizeSelector(s => s.status.deleting)) + '...');
131
+ for (const recordId of recordIds) {
132
+ yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
133
+ }
134
+ context.utility.showNotification({
135
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector(s => s.successNotification.title)),
136
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector(s => s.successNotification.text)),
137
+ type: 'success',
138
+ });
139
+ context.primaryControl.refresh();
140
+ }
141
+ catch (error) {
142
+ context.utility.showNotification({
143
+ title: localizeSelector(s => s.errorNotification.title),
144
+ text: error.message,
145
+ type: 'error',
146
+ });
147
+ }
148
+ finally {
149
+ context.utility.hideProgressIndicator();
150
+ }
151
+ }),
152
+ hidden: [
153
+ context => !EnabledRules.HasAtLeastOneRecordSelected(context),
154
+ context => !EnabledRules.HasDeletePermission(context),
155
+ ],
156
+ };
157
+ }
158
+ ViewCommandBuilder.createDeleteRecordCommand = createDeleteRecordCommand;
159
+ function createRefreshCommand({ Icon, localizedTexts, text, }) {
160
+ return {
161
+ type: 'button',
162
+ Icon,
163
+ text,
164
+ localizedText: localizedTexts,
165
+ onClick: context => {
166
+ context.primaryControl.refresh();
167
+ },
168
+ };
169
+ }
170
+ ViewCommandBuilder.createRefreshCommand = createRefreshCommand;
171
+ function createExportCommand({ button, csv, excel, }) {
172
+ return {
173
+ type: 'menu',
174
+ Icon: button.Icon,
175
+ text: button.text,
176
+ localizedTexts: button.localizedTexts,
177
+ items: [
178
+ [
179
+ {
180
+ Icon: excel.Icon,
181
+ text: excel.text,
182
+ localizedTexts: excel.localizedTexts,
183
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
184
+ context.utility.showProgressIndicator('Exporting to Excel...');
185
+ try {
186
+ const result = yield (0, utils_1.retriveRecords)({
187
+ columnFilters: context.primaryControl.columnFilter,
188
+ dataService: context.dataService,
189
+ gridColumns: context.primaryControl.gridColumns,
190
+ schema: context.primaryControl.schema,
191
+ schemaStore: context.stores.schemaStore,
192
+ view: context.primaryControl.view,
193
+ search: context.primaryControl.searchText,
194
+ extraFilter: context.primaryControl.extraFilter,
195
+ sorting: context.primaryControl.sorting,
196
+ skip: 0,
197
+ limit: 5000,
198
+ });
199
+ yield (0, utils_1.exportRecordsXLS)({
200
+ fileName: context.primaryControl.view.name + '.xlsx',
201
+ gridColumns: context.primaryControl.gridColumns,
202
+ records: result.records,
203
+ schema: context.primaryControl.schema,
204
+ schemaStore: context.stores.schemaStore,
205
+ });
206
+ }
207
+ finally {
208
+ context.utility.hideProgressIndicator();
209
+ }
210
+ }),
211
+ },
212
+ {
213
+ Icon: csv.Icon,
214
+ text: csv.text,
215
+ localizedTexts: csv.localizedTexts,
216
+ onClick: (context) => __awaiter(this, void 0, void 0, function* () {
217
+ context.utility.showProgressIndicator('Exporting to Excel...');
218
+ try {
219
+ const result = yield (0, utils_1.retriveRecords)({
220
+ columnFilters: context.primaryControl.columnFilter,
221
+ dataService: context.dataService,
222
+ gridColumns: context.primaryControl.gridColumns,
223
+ schema: context.primaryControl.schema,
224
+ schemaStore: context.stores.schemaStore,
225
+ view: context.primaryControl.view,
226
+ search: context.primaryControl.searchText,
227
+ extraFilter: context.primaryControl.extraFilter,
228
+ sorting: context.primaryControl.sorting,
229
+ skip: 0,
230
+ limit: 5000,
231
+ });
232
+ yield (0, utils_1.exportRecordsCSV)({
233
+ fileName: context.primaryControl.view.name + '.csv',
234
+ gridColumns: context.primaryControl.gridColumns,
235
+ records: result.records,
236
+ schema: context.primaryControl.schema,
237
+ schemaStore: context.stores.schemaStore,
238
+ });
239
+ }
240
+ finally {
241
+ context.utility.hideProgressIndicator();
242
+ }
243
+ }),
244
+ },
245
+ ],
246
+ ],
247
+ };
248
+ }
249
+ ViewCommandBuilder.createExportCommand = createExportCommand;
250
+ })(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,9 +29,6 @@ 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 {
@@ -36,17 +36,17 @@ class BaseSchemaExperienceBuilder {
36
36
  if (!this.defaultLookupId) {
37
37
  throw new Error('Default lookup is required');
38
38
  }
39
- if (!this.views.find((v) => v.id === this.defaultViewId)) {
39
+ if (!this.views.find(v => v.id === this.defaultViewId)) {
40
40
  throw new Error('Default view not found');
41
41
  }
42
- if (!this.forms.find((f) => f.id === this.defaultFormId)) {
42
+ if (!this.forms.find(f => f.id === this.defaultFormId)) {
43
43
  throw new Error('Default form not found');
44
44
  }
45
- if (!this.lookups.find((l) => l.id === this.defaultLookupId)) {
45
+ if (!this.lookups.find(l => l.id === this.defaultLookupId)) {
46
46
  throw new Error('Default lookup not found');
47
47
  }
48
48
  if (this.defaultQuickCreateFormId &&
49
- !this.quickCreateForms.find((f) => f.id === this.defaultQuickCreateFormId)) {
49
+ !this.quickCreateForms.find(f => f.id === this.defaultQuickCreateFormId)) {
50
50
  throw new Error('Default quick create form not found');
51
51
  }
52
52
  return {
@@ -61,12 +61,6 @@ class BaseSchemaExperienceBuilder {
61
61
  quickCreateForms: this.quickCreateForms,
62
62
  };
63
63
  }
64
- // public createView(view: Omit<View<S>, 'logicalName'>): View<S> {
65
- // return {
66
- // logicalName: this.logicalName,
67
- // ...view,
68
- // };
69
- // }
70
64
  defineFormExperience(formExperience) {
71
65
  return formExperience;
72
66
  }
@@ -164,9 +158,9 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
164
158
  var _a;
165
159
  const langugesSet = new Set();
166
160
  this.schema.localizedPluralLabels &&
167
- Object.keys(this.schema.localizedPluralLabels).forEach((key) => langugesSet.add(key));
161
+ Object.keys(this.schema.localizedPluralLabels).forEach(key => langugesSet.add(key));
168
162
  ((_a = this.defaults) === null || _a === void 0 ? void 0 : _a.localizedViewNames) &&
169
- Object.keys(this.defaults.localizedViewNames).forEach((key) => langugesSet.add(key));
163
+ Object.keys(this.defaults.localizedViewNames).forEach(key => langugesSet.add(key));
170
164
  const localizedLabels = Array.from(langugesSet).reduce((acc, key) => {
171
165
  var _a, _b, _c, _d, _e, _f;
172
166
  const localizedPluralName = (_c = (_b = (_a = this.schema.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : this.schema.pluralLabel.toLowerCase();
@@ -184,17 +178,13 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
184
178
  if (!defaultId) {
185
179
  return data[0].id;
186
180
  }
187
- if (!data.find((x) => x.id === defaultId)) {
181
+ if (!data.find(x => x.id === defaultId)) {
188
182
  return data[0].id;
189
183
  }
190
184
  return defaultId;
191
185
  }
192
186
  defineExperience(experience) {
193
- // if (!experience.defaultFormId) {
194
- // throw new Error('Default form is required');
195
- // }
196
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
197
- // console.log('experience', experience);
187
+ var _a, _b, _c, _d, _e, _f, _g, _h;
198
188
  let lookups = experience.lookups;
199
189
  let views = experience.views;
200
190
  let forms = experience.forms;
@@ -253,14 +243,14 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
253
243
  defaultViewId,
254
244
  defaultLookupId,
255
245
  defaultAssociatedViewId,
256
- quickCreateForms: (_d = (_c = experience.quickCreateForms) === null || _c === void 0 ? void 0 : _c.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _d !== void 0 ? _d : [],
257
- views: (_e = views.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _e !== void 0 ? _e : [],
258
- forms: (_f = forms.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _f !== void 0 ? _f : [],
259
- lookups: (_g = lookups.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _g !== void 0 ? _g : [],
260
- associatedViews: (_h = associatedViews.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _h !== void 0 ? _h : [],
261
- 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 : [],
262
- 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 : [],
263
- 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 : [],
246
+ quickCreateForms: (_d = (_c = experience.quickCreateForms) === null || _c === void 0 ? void 0 : _c.map(x => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _d !== void 0 ? _d : [],
247
+ views: (_e = views.map(x => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _e !== void 0 ? _e : [],
248
+ forms: (_f = forms.map(x => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _f !== void 0 ? _f : [],
249
+ lookups: (_g = lookups.map(x => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _g !== void 0 ? _g : [],
250
+ associatedViews: (_h = associatedViews.map(x => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _h !== void 0 ? _h : [],
251
+ formCommands: experience.formCommands,
252
+ subgridCommands: experience.subgridCommands,
253
+ viewCommands: experience.viewCommands,
264
254
  };
265
255
  }
266
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; } });