@acorex/platform-generator 18.0.11 → 18.0.13

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 (18) hide show
  1. package/package.json +1 -1
  2. package/src/generators/app-module/files/project.json.template +0 -116
  3. package/src/generators/app-module/files/src/app/app.module.ts.template +5 -2
  4. package/src/generators/app-module/files/src/app/basic-interceptor.interceptor.ts.template +62 -0
  5. package/src/generators/app-module/files/src/app/modules/auth/auth-root.module.ts.template +1 -1
  6. package/src/generators/app-module/files/src/app/modules/layout/entity.loader.ts.template +5 -4
  7. package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template +26 -29
  8. package/src/generators/app-module/files/src/app/modules/layout/menu.loader.ts.template +1 -1
  9. package/src/generators/app-module/files/src/app/modules/root/mock.data.ts.template +14 -0
  10. package/src/generators/app-module/files/src/app/modules/root/sample/sample.entity.ts.template +456 -159
  11. package/src/generators/app-module/files/src/assets/i18n/en/common.json +41 -0
  12. package/src/generators/app-module/files/src/assets/i18n/fa/auth.json +50 -0
  13. package/src/generators/app-module/files/src/assets/i18n/fa/common.json +220 -0
  14. package/src/generators/app-module/files/src/app/header-interceptor.interceptor.ts.template +0 -33
  15. package/src/generators/app-module/files/src/environments/environment.local.ts.template +0 -19
  16. package/src/generators/app-module/files/src/environments/environment.prod.ts.template +0 -19
  17. package/src/generators/app-module/files/src/environments/environment.test.local.ts.template +0 -19
  18. package/src/generators/app-module/files/src/environments/environment.test.ts.template +0 -19
@@ -1,184 +1,481 @@
1
- import { AXDataSourceQuery } from '@acorex/components/common';
2
1
  import { applyFilterArray, applySortArray } from '@acorex/modules/backend';
3
2
  import {
4
- AXPEntityConfig,
5
- AXPEntityListDisplayColumnConfig,
6
- convertPropertiesToColumns,
7
- AXPEntityPropertyConfig,
8
- widgetSchemas,
3
+ AXPDataGenerator,
4
+ AXPEntity,
5
+ AXPEntityCommandScope,
6
+ AXPEntityDataProviderImpl,
7
+ AXPEntityQueryType,
8
+ AXPStorageService,
9
9
  } from '@acorex/platform/common';
10
+ import { AXPWidgetsCatalog } from '@acorex/platform/layout/builder';
10
11
  import { Injector } from '@angular/core';
12
+ import { USERS } from '../mock.data';
11
13
 
12
- const properties: AXPEntityPropertyConfig[] = [
13
- {
14
+ export async function entityFactory(injector: Injector): Promise<AXPEntity | null> {
15
+ const storageService = injector.get(AXPStorageService);
16
+ const dataProvider = new AXPEntityDataProviderImpl<any>(storageService, 'users');
17
+ await dataProvider.initial(USERS);
18
+
19
+ const entityDef: AXPEntity = {
20
+ module: '<%= name %>',
21
+ name: 'sample',
22
+ source: '<%= name %>.sample',
23
+ title: 'Sample Entity',
24
+ formats: {
25
+ individual: 'sample',
26
+ plural: 'sample',
27
+ },
28
+ relatedEntities: [],
29
+ groups: [
30
+ {
31
+ id: 'personal',
32
+ title: 'Personal',
33
+ },
34
+ {
35
+ id: 'contact',
36
+ title: 'Contact',
37
+ },
38
+ {
39
+ id: 'address',
40
+ title: 'Address',
41
+ },
42
+ ],
43
+ properties: [
44
+ {
45
+ name: 'id',
46
+ title: 'ID',
47
+ schema: {
48
+ dataType: 'uuid',
49
+ hidden: true,
50
+ nullable: false,
51
+ readonly: true,
52
+ unique: {
53
+ enabled: true,
54
+ },
55
+ },
56
+ },
57
+ {
14
58
  name: 'firstname',
15
59
  title: 'First Name',
16
- schema: widgetSchemas.text,
17
- canEdit: true,
18
- canInsert: true,
19
- canInlineFilter: true,
20
- validationRules: [
21
- {
22
- rule: 'required',
60
+ groupId: 'personal',
61
+ schema: {
62
+ dataType: 'string',
63
+ interface: {
64
+ type: AXPWidgetsCatalog.text,
65
+ },
66
+ },
67
+ options: {
68
+ filter: {
69
+ inline: {
70
+ enabled: true,
23
71
  },
72
+ },
73
+ sort: {
74
+ enabled: true,
75
+ },
76
+ },
77
+ validations: [
78
+ {
79
+ rule: 'required',
80
+ },
24
81
  ],
25
- layout: {
26
- positions: {
27
- default: {
28
- start: 0,
29
- span: 6,
30
- },
82
+ },
83
+ {
84
+ name: 'lastname',
85
+ title: 'Last Name',
86
+ groupId: 'personal',
87
+ schema: {
88
+ dataType: 'string',
89
+ interface: {
90
+ type: AXPWidgetsCatalog.text,
91
+ },
92
+ },
93
+ options: {
94
+ filter: {
95
+ inline: {
96
+ enabled: true,
31
97
  },
98
+ },
99
+ sort: {
100
+ enabled: true,
101
+ },
32
102
  },
103
+ validations: [
104
+ {
105
+ rule: 'required',
106
+ },
107
+ ],
108
+ },
109
+ {
110
+ name: 'email',
111
+ title: 'Email',
112
+ groupId: 'contact',
113
+ schema: {
114
+ dataType: 'string',
115
+ interface: {
116
+ type: AXPWidgetsCatalog.text,
117
+ options: {
118
+ multiple: false,
119
+ hasLabel: false,
120
+ },
121
+ },
122
+ },
123
+ validations: [
124
+ {
125
+ rule: 'required',
126
+ },
127
+ ],
128
+ },
129
+ {
130
+ name: 'phone',
131
+ title: 'Phone',
132
+ groupId: 'contact',
133
+ schema: {
134
+ dataType: 'string',
135
+ interface: {
136
+ type: AXPWidgetsCatalog.phone,
137
+ options: {
138
+ multiple: false,
139
+ hasLabel: false,
140
+ },
141
+ },
142
+ },
143
+ validations: [
144
+ {
145
+ rule: 'required',
146
+ },
147
+ ],
148
+ },
149
+ {
150
+ name: 'address',
151
+ title: 'Address',
152
+ groupId: 'address',
153
+ schema: {
154
+ dataType: 'string',
155
+ interface: {
156
+ type: AXPWidgetsCatalog.text,
157
+ options: {
158
+ multiple: false,
159
+ hasLabel: false,
160
+ },
161
+ },
162
+ },
163
+ },
164
+ ],
165
+ columns: [{ name: 'firstname' }, { name: 'lastname' }, { name: 'email' }, { name: 'phone' }, { name: 'address' }],
166
+ commands: {
167
+ create: {
168
+ execute: async (data: any) => {
169
+ console.log('CREATE', data);
170
+ const entity = Object.assign(data, { id: AXPDataGenerator.uuid() });
171
+ dataProvider.insertOne(entity);
172
+ return Promise.resolve(entity);
173
+ },
174
+ },
175
+ delete: {
176
+ execute: async (id: any) => {
177
+ console.log('DELETE', id);
178
+ await await dataProvider.deleteOne(id);
179
+ return Promise.resolve();
180
+ },
181
+ },
182
+ update: {
183
+ execute: async (data: any) => {
184
+ console.log('UPDATE', data);
185
+ return new Promise((resolve) => {
186
+ setTimeout(async () => {
187
+ await dataProvider.updateOne(data.id, data);
188
+ resolve(data);
189
+ }, 1000);
190
+ });
191
+ },
192
+ },
33
193
  },
34
- {
35
- name: 'lastname',
36
- title: 'Last Name',
37
- schema: widgetSchemas.text,
38
- canEdit: true,
39
- canInsert: true,
40
- canInlineFilter: true,
41
- validationRules: [
194
+ queries: {
195
+ byKey: {
196
+ execute: async (id: string) => {
197
+ console.log('users=>byKey', id);
198
+ return new Promise((resolve) => {
199
+ setTimeout(async () => {
200
+ const entity = await dataProvider.getOne(id);
201
+ resolve(entity);
202
+ }, 500);
203
+ });
204
+ },
205
+ type: AXPEntityQueryType.Single,
206
+ },
207
+ list: {
208
+ execute: async (e: any) => {
209
+ console.log('users=>list', e);
210
+ const list = await dataProvider.getAll();
211
+ const sortedItems = applySortArray(list, e.sort);
212
+ const filteredItems = applyFilterArray(sortedItems, e.filter ? [e.filter] : []);
213
+ return Promise.resolve({
214
+ total: filteredItems.length,
215
+ items: filteredItems.slice(e.skip, (e.skip ?? 0) + (e.take ?? 0)),
216
+ });
217
+ },
218
+ type: AXPEntityQueryType.List,
219
+ },
220
+ },
221
+ interfaces: {
222
+ master: {
223
+ create: {
224
+ sections: [
42
225
  {
43
- rule: 'required',
226
+ id: 'personal',
44
227
  },
45
- ],
46
- layout: {
47
- positions: {
48
- default: {
49
- start: 6,
50
- span: 6,
228
+ {
229
+ id: 'contact',
230
+ },
231
+ {
232
+ id: 'address',
233
+ },
234
+ ],
235
+ properties: [
236
+ {
237
+ name: 'firstname',
238
+ layout: {
239
+ positions: {
240
+ lg: {
241
+ colSpan: 6,
242
+ },
243
+ },
244
+ },
245
+ },
246
+ {
247
+ name: 'lastname',
248
+ layout: {
249
+ positions: {
250
+ lg: {
251
+ colSpan: 6,
252
+ },
253
+ },
254
+ },
255
+ },
256
+ {
257
+ name: 'email',
258
+ layout: {
259
+ positions: {
260
+ lg: {
261
+ colSpan: 6,
262
+ },
263
+ },
264
+ },
265
+ },
266
+ {
267
+ name: 'phone',
268
+ layout: {
269
+ positions: {
270
+ lg: {
271
+ colSpan: 6,
272
+ },
51
273
  },
274
+ },
52
275
  },
276
+ {
277
+ name: 'address',
278
+ layout: {
279
+ positions: {
280
+ lg: {
281
+ colSpan: 12,
282
+ },
283
+ },
284
+ },
285
+ },
286
+ ],
53
287
  },
54
- },
55
- {
56
- name: 'birthDate',
57
- title: 'Birth Date',
58
- schema: widgetSchemas.date,
59
- canEdit: true,
60
- canInsert: true,
61
- validationRules: [
288
+ update: {
289
+ sections: [
62
290
  {
63
- rule: 'required',
291
+ id: 'personal',
64
292
  },
65
- ],
66
- },
67
- {
68
- name: 'notify',
69
- title: 'Notification',
70
- schema: widgetSchemas.toggle,
71
- canEdit: true,
72
- canInsert: false,
73
- component: {
74
- common: {
75
- options: {
76
- trulyText: 'Enabled',
77
- falsyText: 'Disabled',
293
+ {
294
+ id: 'contact',
295
+ },
296
+ {
297
+ id: 'address',
298
+ },
299
+ ],
300
+ properties: [
301
+ {
302
+ name: 'firstname',
303
+ layout: {
304
+ positions: {
305
+ lg: {
306
+ colSpan: 6,
307
+ },
78
308
  },
309
+ },
79
310
  },
311
+ {
312
+ name: 'lastname',
313
+ layout: {
314
+ positions: {
315
+ lg: {
316
+ colSpan: 6,
317
+ },
318
+ },
319
+ },
320
+ },
321
+ {
322
+ name: 'email',
323
+ layout: {
324
+ positions: {
325
+ lg: {
326
+ colSpan: 6,
327
+ },
328
+ },
329
+ },
330
+ },
331
+ {
332
+ name: 'phone',
333
+ layout: {
334
+ positions: {
335
+ lg: {
336
+ colSpan: 6,
337
+ },
338
+ },
339
+ },
340
+ },
341
+ {
342
+ name: 'address',
343
+ layout: {
344
+ positions: {
345
+ lg: {
346
+ colSpan: 12,
347
+ },
348
+ },
349
+ },
350
+ },
351
+ ],
352
+ },
353
+ single: {
354
+ title: '{{firstname}} {{lastname}}',
355
+ sections: [
356
+ {
357
+ id: 'personal',
358
+ layout: {
359
+ positions: {
360
+ lg: {
361
+ colSpan: 8,
362
+ },
363
+ },
364
+ },
365
+ },
366
+ {
367
+ id: 'contact',
368
+ layout: {
369
+ positions: {
370
+ lg: {
371
+ colSpan: 4,
372
+ },
373
+ },
374
+ },
375
+ },
376
+ {
377
+ id: 'address',
378
+ },
379
+ ],
380
+ properties: [
381
+ {
382
+ name: 'firstname',
383
+ layout: {
384
+ positions: {
385
+ lg: {
386
+ colSpan: 6,
387
+ },
388
+ },
389
+ },
390
+ },
391
+ {
392
+ name: 'lastname',
393
+ layout: {
394
+ positions: {
395
+ lg: {
396
+ colSpan: 6,
397
+ },
398
+ },
399
+ },
400
+ },
401
+ {
402
+ name: 'email',
403
+ layout: {
404
+ positions: {
405
+ lg: {
406
+ colSpan: 12,
407
+ },
408
+ },
409
+ },
410
+ },
411
+ {
412
+ name: 'phone',
413
+ layout: {
414
+ positions: {
415
+ lg: {
416
+ colSpan: 12,
417
+ },
418
+ },
419
+ },
420
+ },
421
+ {
422
+ name: 'address',
423
+ layout: {
424
+ positions: {
425
+ lg: {
426
+ colSpan: 12,
427
+ },
428
+ },
429
+ },
430
+ },
431
+ ],
432
+ actions: [],
433
+ },
434
+ list: {
435
+ actions: [
436
+ {
437
+ title: 'Create New',
438
+ command: 'create-entity',
439
+ priority: 'primary',
440
+ type: 'create',
441
+ scope: AXPEntityCommandScope.TypeLevel,
442
+ },
443
+ {
444
+ title: 'Delete Items',
445
+ command: 'delete-entity',
446
+ priority: 'primary',
447
+ type: 'delete',
448
+ scope: AXPEntityCommandScope.Selected,
449
+ },
450
+ {
451
+ title: 'Details',
452
+ command: 'open-entity',
453
+ priority: 'primary',
454
+ type: 'view',
455
+ scope: AXPEntityCommandScope.Individual,
456
+ },
457
+ {
458
+ title: 'Delete',
459
+ command: 'delete-entity',
460
+ priority: 'primary',
461
+ type: 'delete',
462
+ scope: AXPEntityCommandScope.Individual,
463
+ },
464
+ ],
465
+ views: [
466
+ {
467
+ name: 'all',
468
+ title: 'All Items',
469
+ fixed: true,
470
+ columns: [],
471
+ conditions: [],
472
+ sorts: [{ name: 'firstname', dir: 'asc' }],
473
+ },
474
+ ],
80
475
  },
476
+ },
81
477
  },
82
- ];
83
-
84
- const result = Array.from({ length: 30 }).map((_, i) => ({
85
- id: i,
86
- firstname: ['John', 'Allen', 'Jak', 'Rose', 'Kate'][Math.floor(Math.random() * 5)],
87
- lastname: ['Gates', 'Jonsen', 'Smith', 'Ford', 'Jakson'][Math.floor(Math.random() * 5)],
88
- birthDate: new Date(),
89
- phone: `123456789${i}`,
90
- email: `example@gmail.com`,
91
- notify: Math.floor(Math.random() * 5) % 3 == 0,
92
- }));
93
-
94
- const entityName = 'sample';
95
-
96
- const columns: AXPEntityListDisplayColumnConfig[] = convertPropertiesToColumns(...properties);
97
-
98
- export async function entityFactory(injector: Injector): Promise<AXPEntityConfig> {
99
-
100
- const entity: AXPEntityConfig = {
101
- module: '<%= name %>',
102
- name: entityName,
103
- title: 'Sample Entity',
104
- properties: properties,
105
- formats: {
106
- default: '{{firstname}} {{lastname}}',
107
- },
108
- dataSource: {
109
- key: 'id',
110
- pageSize: 20,
111
- load: async (e: AXDataSourceQuery) => {
112
- const sortedItems = applySortArray(result, e.sort);
113
- const filteredItems = applyFilterArray(sortedItems, e.filter?.filters);
114
- return new Promise((resolve) => {
115
- setTimeout(() => {
116
- resolve({
117
- items: filteredItems.slice(e.skip, (e.skip ?? 0) + (e.take ?? 0)),
118
- total: filteredItems.length,
119
- });
120
- }, 100);
121
- });
122
- },
123
- byKey: (id: any) => {
124
- return new Promise((resolve) => {
125
- setTimeout(() => {
126
- resolve(result.find((c) => c.id.toString() == id));
127
- }, 100);
128
- });
129
- },
130
- },
131
- views: {
132
- list: {
133
- title: 'Sample Entity List',
134
- views: [
135
- {
136
- name: 'all',
137
- title: 'All Items',
138
- fixed: true,
139
- columns: columns,
140
- conditions: [],
141
- sorts: [
142
- {
143
- name: 'firstname',
144
- dir: 'asc',
145
- },
146
- {
147
- name: 'lastname',
148
- dir: 'asc',
149
- },
150
- ],
151
- },
152
- ],
153
- },
154
- quickView: {
155
- root: {
156
- properties: properties.map((c) => c.name),
157
- },
158
- },
159
- detailView: {
160
- root: {
161
- properties: properties.map((c) => c.name),
162
- },
163
- },
164
- createView: {
165
- root: {
166
- properties: properties.slice(0, properties.length - 1).map((c) => c.name),
167
- },
168
- },
169
- },
170
- commands: {
171
- create: async (values) => {
172
- return Promise.resolve({ id: Math.floor(Math.random() * 10000) });
173
- },
174
- update: async (id: string, values) => {
175
- return Promise.resolve();
176
- },
177
- delete: (id: string) => {
178
- return Promise.resolve();
179
- },
180
- }
181
- };
478
+ };
182
479
 
183
- return entity;
480
+ return entityDef;
184
481
  }
@@ -20,6 +20,7 @@
20
20
  "searching": "searching ...",
21
21
  "save": "Save",
22
22
  "save-as": "Save As...",
23
+ "save-changes": "Save Changes",
23
24
  "title": "Title",
24
25
  "description": "Description",
25
26
  "name": "Name",
@@ -41,6 +42,18 @@
41
42
  "viewLess": "View Less",
42
43
  "processing": "Processing...",
43
44
  "redirecting": "Redirecting...",
45
+ "apply": "Apply",
46
+ "reset": "Reset",
47
+ "create-new": "Create New",
48
+ "continue": "Continue",
49
+ "discard": "Discard",
50
+ "overview": "Overview",
51
+ "history": "History",
52
+ "comments": "Comments",
53
+ "authentication": {
54
+ "with-google": "Sign in with Google",
55
+ "with-apple": "Sign in with Apple"
56
+ },
44
57
  "dateTime": {
45
58
  "weekdays": {
46
59
  "short": {
@@ -150,6 +163,7 @@
150
163
  "required": "This field is required",
151
164
  "email": "Please enter a valid email address!",
152
165
  "phone": "Please enter a valid phone number!",
166
+ "url": "Please enter a valid url!",
153
167
  "invalid-rull-name": "Invalid rule name: &nbsp<b>\"{{ name }}\"</b>"
154
168
  }
155
169
  },
@@ -175,5 +189,32 @@
175
189
  },
176
190
  "action-sheet": {
177
191
  "title": "Action Sheet..."
192
+ },
193
+ "entity": {
194
+ "home": "Home",
195
+ "public-view": "Public Views",
196
+ "action": "Action",
197
+ "actions": "Actions",
198
+ "columns": "Columns",
199
+ "sort": "Sort",
200
+ "no-sort": "No Sorts Selected",
201
+ "ask-sort": "Please select field(s) that you want to sort",
202
+ "add-field": "Add Field",
203
+ "modify": "Modify"
204
+ },
205
+ "widget": {
206
+ "phone": {
207
+ "mobile": "Mobile",
208
+ "home": "Home",
209
+ "work": "Work",
210
+ "other": "Other"
211
+ },
212
+ "lookup": {
213
+ "search": "Search on "
214
+ }
215
+ },
216
+ "profile": {
217
+ "edit": "Edit Profile",
218
+ "logout": "Logout"
178
219
  }
179
220
  }