admin_lsac 1.2.8 → 1.2.9

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.
package/src/pages/page.ts CHANGED
@@ -1,336 +1,336 @@
1
- import { ArrayField, PageSchema } from "../schema/schema";
2
- import * as Yup from "yup";
3
-
4
- const typeAdding = (objectField: any): any => {
5
- objectField.type = "object";
6
- objectField.fields = [
7
- ...objectField.simpleFields,
8
- ...objectField.dropdownFields,
9
- ...objectField.objectFields,
10
- ...objectField.arrayFields,
11
- ];
12
-
13
- if (objectField.objectFields) {
14
- objectField.objectFields.map((objectField: any) => {
15
- objectField = typeAdding(objectField);
16
- return objectField;
17
- });
18
- }
19
-
20
- if (objectField.arrayFields) {
21
- objectField.arrayFields.map((arrayField: any) => {
22
- arrayField.element = typeAdding(arrayField.element);
23
- return arrayField;
24
- });
25
- }
26
-
27
- return objectField;
28
- };
29
-
30
- const arrayObjs = (x: number): ArrayField[] => {
31
- if (x > 0)
32
- return [
33
- {
34
- name: "simpleFields",
35
- label: "Type SimpleField",
36
- type: "array",
37
- element: {
38
- name: "",
39
- label: "",
40
- type: "object",
41
- fields: [
42
- {
43
- name: "name",
44
- label: "Name",
45
- type: "string",
46
- validationSchema: Yup.string().required(),
47
- },
48
- {
49
- name: "label",
50
- label: "Label",
51
- type: "string",
52
- validationSchema: Yup.string().required(),
53
- },
54
- {
55
- name: "type",
56
- label: "Type",
57
- type: "string",
58
- validationSchema: Yup.string().required(),
59
- },
60
- {
61
- name: "validationSchema",
62
- label: "Validation Schema",
63
- type: "string",
64
- validationSchema: Yup.string().required(),
65
- },
66
- ],
67
- },
68
- },
69
- {
70
- name: "dropdownFields",
71
- label: "Type DropdownField",
72
- type: "array",
73
- element: {
74
- name: "",
75
- label: "",
76
- type: "object",
77
- fields: [
78
- {
79
- name: "name",
80
- label: "Name",
81
- type: "string",
82
- validationSchema: Yup.string().required(),
83
- },
84
- {
85
- name: "label",
86
- label: "Label",
87
- type: "string",
88
- validationSchema: Yup.string().required(),
89
- },
90
- {
91
- name: "options",
92
- label: "Options",
93
- type: "array",
94
- element: {
95
- name: "",
96
- label: "",
97
- type: "object",
98
- fields: [
99
- {
100
- name: "value",
101
- label: "Value",
102
- type: "string",
103
- validationSchema: Yup.string().required(),
104
- },
105
- {
106
- name: "display",
107
- label: "Display",
108
- type: "string",
109
- validationSchema: Yup.string().required(),
110
- },
111
- ],
112
- },
113
- },
114
- {
115
- name: "getOptions",
116
- label: "GetOptions Function",
117
- type: "string",
118
- validationSchema: Yup.string().required(),
119
- },
120
- ],
121
- },
122
- },
123
- {
124
- name: "objectFields",
125
- label: "Type ObjectField",
126
- type: "array",
127
- element: {
128
- name: "",
129
- label: "",
130
- type: "object",
131
- fields: [
132
- {
133
- name: "name",
134
- label: "Name",
135
- type: "string",
136
- validationSchema: Yup.string().required(),
137
- },
138
- {
139
- name: "label",
140
- label: "Label",
141
- type: "string",
142
- validationSchema: Yup.string().required(),
143
- },
144
- ...arrayObjs(x - 1),
145
- ],
146
- },
147
- },
148
- {
149
- name: "arrayFields",
150
- label: "Type ArrayField",
151
- type: "array",
152
- element: {
153
- name: "",
154
- label: "",
155
- type: "object",
156
- fields: [
157
- {
158
- name: "name",
159
- label: "Name",
160
- type: "string",
161
- validationSchema: Yup.string().required(),
162
- },
163
- {
164
- name: "label",
165
- label: "Label",
166
- type: "string",
167
- validationSchema: Yup.string().required(),
168
- },
169
- ...arrayObjs(x - 1),
170
- ],
171
- },
172
- },
173
- ];
174
- else return [];
175
- };
176
-
177
- export const page: PageSchema = {
178
- name: "Pages",
179
- getRequest: async () => [],
180
- tableFields: [],
181
- actions: [
182
- {
183
- name: "Create New Page",
184
- fields: [
185
- {
186
- name: "name",
187
- label: "Page Name",
188
- type: "string",
189
- validationSchema: Yup.string().required(),
190
- },
191
- {
192
- name: "getRequest",
193
- label: "GetRequest",
194
- type: "string",
195
- validationSchema: Yup.string().required(),
196
- },
197
- {
198
- name: "tableFields",
199
- label: "TableFields",
200
- type: "array",
201
- element: {
202
- name: "",
203
- label: "",
204
- type: "object",
205
- fields: [
206
- {
207
- name: "name",
208
- label: "TableField Name",
209
- type: "string",
210
- validationSchema: Yup.string().required(),
211
- },
212
- {
213
- name: "access",
214
- label: "TableField Access Function",
215
- type: "string",
216
- validationSchema: Yup.string().required(),
217
- },
218
- ],
219
- },
220
- },
221
- {
222
- name: "actions",
223
- label: "Actions",
224
- type: "array",
225
- element: {
226
- name: "",
227
- label: "",
228
- type: "object",
229
- fields: [
230
- {
231
- name: "name",
232
- label: "Action Name",
233
- type: "string",
234
- validationSchema: Yup.string().required(),
235
- },
236
- ...arrayObjs(4),
237
- {
238
- name: "onSubmit",
239
- label: "Action OnSubmit Function",
240
- type: "string",
241
- validationSchema: Yup.string().required(),
242
- },
243
- ],
244
- },
245
- },
246
- {
247
- name: "rowActions",
248
- label: "Row Actions",
249
- type: "array",
250
- element: {
251
- name: "",
252
- label: "",
253
- type: "object",
254
- fields: [
255
- {
256
- name: "name",
257
- label: "Row Action Name",
258
- type: "string",
259
- validationSchema: Yup.string().required(),
260
- },
261
- ...arrayObjs(4),
262
- {
263
- name: "initialise",
264
- label: "Row Action Initialise Function",
265
- type: "string",
266
- validationSchema: "",
267
- },
268
- {
269
- name: "onSubmit",
270
- label: "Row Action OnSubmit Function",
271
- type: "string",
272
- validationSchema: Yup.string().required(),
273
- },
274
- ],
275
- },
276
- },
277
- ],
278
- onSubmit: async (formValues: any) => {
279
- if (Array.isArray(formValues.actions))
280
- formValues.actions.map((action: any) => {
281
- action.dropdownFields?.map(
282
- (actionField: any) => (actionField.type = "dropdown")
283
- );
284
-
285
- action.objectFields?.map(
286
- (actionField: any) => (actionField = typeAdding(actionField))
287
- );
288
-
289
- action.arrayFields?.map((actionField: any) => {
290
- actionField.type = "array";
291
- actionField.element = typeAdding(actionField.element);
292
- return actionField;
293
- });
294
-
295
- action.fields = [
296
- ...action.simpleFields,
297
- ...action.dropdownFields,
298
- ...action.objectFields,
299
- ...action.arrayFields,
300
- ];
301
- return action;
302
- });
303
-
304
- if (Array.isArray(formValues.rowActions))
305
- formValues.actions.map((rowAction: any) => {
306
- rowAction.dropdownFields?.map(
307
- (rowActionField: any) => (rowActionField.type = "dropdown")
308
- );
309
-
310
- rowAction.objectFields?.map(
311
- (rowActionField: any) =>
312
- (rowActionField = typeAdding(rowActionField))
313
- );
314
-
315
- rowAction.arrayFields?.map((rowActionField: any) => {
316
- rowActionField.type = "array";
317
- rowActionField.element = typeAdding(rowActionField.element);
318
- return rowActionField;
319
- });
320
-
321
- rowAction.fields = [
322
- ...rowAction.simpleFields,
323
- ...rowAction.dropdownFields,
324
- ...rowAction.objectFields,
325
- ...rowAction.arrayFields,
326
- ];
327
- return rowAction;
328
- });
329
-
330
- console.log(formValues);
331
- return [];
332
- },
333
- },
334
- ],
335
- rowActions: [],
336
- };
1
+ import { ArrayField, PageSchema } from "../schema/schema";
2
+ import * as Yup from "yup";
3
+
4
+ const typeAdding = (objectField: any): any => {
5
+ objectField.type = "object";
6
+ objectField.fields = [
7
+ ...objectField.simpleFields,
8
+ ...objectField.dropdownFields,
9
+ ...objectField.objectFields,
10
+ ...objectField.arrayFields,
11
+ ];
12
+
13
+ if (objectField.objectFields) {
14
+ objectField.objectFields.map((objectField: any) => {
15
+ objectField = typeAdding(objectField);
16
+ return objectField;
17
+ });
18
+ }
19
+
20
+ if (objectField.arrayFields) {
21
+ objectField.arrayFields.map((arrayField: any) => {
22
+ arrayField.element = typeAdding(arrayField.element);
23
+ return arrayField;
24
+ });
25
+ }
26
+
27
+ return objectField;
28
+ };
29
+
30
+ const arrayObjs = (x: number): ArrayField[] => {
31
+ if (x > 0)
32
+ return [
33
+ {
34
+ name: "simpleFields",
35
+ label: "Type SimpleField",
36
+ type: "array",
37
+ element: {
38
+ name: "",
39
+ label: "",
40
+ type: "object",
41
+ fields: [
42
+ {
43
+ name: "name",
44
+ label: "Name",
45
+ type: "string",
46
+ validationSchema: Yup.string().required(),
47
+ },
48
+ {
49
+ name: "label",
50
+ label: "Label",
51
+ type: "string",
52
+ validationSchema: Yup.string().required(),
53
+ },
54
+ {
55
+ name: "type",
56
+ label: "Type",
57
+ type: "string",
58
+ validationSchema: Yup.string().required(),
59
+ },
60
+ {
61
+ name: "validationSchema",
62
+ label: "Validation Schema",
63
+ type: "string",
64
+ validationSchema: Yup.string().required(),
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ {
70
+ name: "dropdownFields",
71
+ label: "Type DropdownField",
72
+ type: "array",
73
+ element: {
74
+ name: "",
75
+ label: "",
76
+ type: "object",
77
+ fields: [
78
+ {
79
+ name: "name",
80
+ label: "Name",
81
+ type: "string",
82
+ validationSchema: Yup.string().required(),
83
+ },
84
+ {
85
+ name: "label",
86
+ label: "Label",
87
+ type: "string",
88
+ validationSchema: Yup.string().required(),
89
+ },
90
+ {
91
+ name: "options",
92
+ label: "Options",
93
+ type: "array",
94
+ element: {
95
+ name: "",
96
+ label: "",
97
+ type: "object",
98
+ fields: [
99
+ {
100
+ name: "value",
101
+ label: "Value",
102
+ type: "string",
103
+ validationSchema: Yup.string().required(),
104
+ },
105
+ {
106
+ name: "display",
107
+ label: "Display",
108
+ type: "string",
109
+ validationSchema: Yup.string().required(),
110
+ },
111
+ ],
112
+ },
113
+ },
114
+ {
115
+ name: "getOptions",
116
+ label: "GetOptions Function",
117
+ type: "string",
118
+ validationSchema: Yup.string().required(),
119
+ },
120
+ ],
121
+ },
122
+ },
123
+ {
124
+ name: "objectFields",
125
+ label: "Type ObjectField",
126
+ type: "array",
127
+ element: {
128
+ name: "",
129
+ label: "",
130
+ type: "object",
131
+ fields: [
132
+ {
133
+ name: "name",
134
+ label: "Name",
135
+ type: "string",
136
+ validationSchema: Yup.string().required(),
137
+ },
138
+ {
139
+ name: "label",
140
+ label: "Label",
141
+ type: "string",
142
+ validationSchema: Yup.string().required(),
143
+ },
144
+ ...arrayObjs(x - 1),
145
+ ],
146
+ },
147
+ },
148
+ {
149
+ name: "arrayFields",
150
+ label: "Type ArrayField",
151
+ type: "array",
152
+ element: {
153
+ name: "",
154
+ label: "",
155
+ type: "object",
156
+ fields: [
157
+ {
158
+ name: "name",
159
+ label: "Name",
160
+ type: "string",
161
+ validationSchema: Yup.string().required(),
162
+ },
163
+ {
164
+ name: "label",
165
+ label: "Label",
166
+ type: "string",
167
+ validationSchema: Yup.string().required(),
168
+ },
169
+ ...arrayObjs(x - 1),
170
+ ],
171
+ },
172
+ },
173
+ ];
174
+ else return [];
175
+ };
176
+
177
+ export const page: PageSchema = {
178
+ name: "Pages",
179
+ getRequest: async () => [],
180
+ tableFields: [],
181
+ actions: [
182
+ {
183
+ name: "Create New Page",
184
+ fields: [
185
+ {
186
+ name: "name",
187
+ label: "Page Name",
188
+ type: "string",
189
+ validationSchema: Yup.string().required(),
190
+ },
191
+ {
192
+ name: "getRequest",
193
+ label: "GetRequest",
194
+ type: "string",
195
+ validationSchema: Yup.string().required(),
196
+ },
197
+ {
198
+ name: "tableFields",
199
+ label: "TableFields",
200
+ type: "array",
201
+ element: {
202
+ name: "",
203
+ label: "",
204
+ type: "object",
205
+ fields: [
206
+ {
207
+ name: "name",
208
+ label: "TableField Name",
209
+ type: "string",
210
+ validationSchema: Yup.string().required(),
211
+ },
212
+ {
213
+ name: "access",
214
+ label: "TableField Access Function",
215
+ type: "string",
216
+ validationSchema: Yup.string().required(),
217
+ },
218
+ ],
219
+ },
220
+ },
221
+ {
222
+ name: "actions",
223
+ label: "Actions",
224
+ type: "array",
225
+ element: {
226
+ name: "",
227
+ label: "",
228
+ type: "object",
229
+ fields: [
230
+ {
231
+ name: "name",
232
+ label: "Action Name",
233
+ type: "string",
234
+ validationSchema: Yup.string().required(),
235
+ },
236
+ ...arrayObjs(4),
237
+ {
238
+ name: "onSubmit",
239
+ label: "Action OnSubmit Function",
240
+ type: "string",
241
+ validationSchema: Yup.string().required(),
242
+ },
243
+ ],
244
+ },
245
+ },
246
+ {
247
+ name: "rowActions",
248
+ label: "Row Actions",
249
+ type: "array",
250
+ element: {
251
+ name: "",
252
+ label: "",
253
+ type: "object",
254
+ fields: [
255
+ {
256
+ name: "name",
257
+ label: "Row Action Name",
258
+ type: "string",
259
+ validationSchema: Yup.string().required(),
260
+ },
261
+ ...arrayObjs(4),
262
+ {
263
+ name: "initialise",
264
+ label: "Row Action Initialise Function",
265
+ type: "string",
266
+ validationSchema: "",
267
+ },
268
+ {
269
+ name: "onSubmit",
270
+ label: "Row Action OnSubmit Function",
271
+ type: "string",
272
+ validationSchema: Yup.string().required(),
273
+ },
274
+ ],
275
+ },
276
+ },
277
+ ],
278
+ onSubmit: async (formValues: any) => {
279
+ if (Array.isArray(formValues.actions))
280
+ formValues.actions.map((action: any) => {
281
+ action.dropdownFields?.map(
282
+ (actionField: any) => (actionField.type = "dropdown")
283
+ );
284
+
285
+ action.objectFields?.map(
286
+ (actionField: any) => (actionField = typeAdding(actionField))
287
+ );
288
+
289
+ action.arrayFields?.map((actionField: any) => {
290
+ actionField.type = "array";
291
+ actionField.element = typeAdding(actionField.element);
292
+ return actionField;
293
+ });
294
+
295
+ action.fields = [
296
+ ...action.simpleFields,
297
+ ...action.dropdownFields,
298
+ ...action.objectFields,
299
+ ...action.arrayFields,
300
+ ];
301
+ return action;
302
+ });
303
+
304
+ if (Array.isArray(formValues.rowActions))
305
+ formValues.actions.map((rowAction: any) => {
306
+ rowAction.dropdownFields?.map(
307
+ (rowActionField: any) => (rowActionField.type = "dropdown")
308
+ );
309
+
310
+ rowAction.objectFields?.map(
311
+ (rowActionField: any) =>
312
+ (rowActionField = typeAdding(rowActionField))
313
+ );
314
+
315
+ rowAction.arrayFields?.map((rowActionField: any) => {
316
+ rowActionField.type = "array";
317
+ rowActionField.element = typeAdding(rowActionField.element);
318
+ return rowActionField;
319
+ });
320
+
321
+ rowAction.fields = [
322
+ ...rowAction.simpleFields,
323
+ ...rowAction.dropdownFields,
324
+ ...rowAction.objectFields,
325
+ ...rowAction.arrayFields,
326
+ ];
327
+ return rowAction;
328
+ });
329
+
330
+ console.log(formValues);
331
+ return [];
332
+ },
333
+ },
334
+ ],
335
+ rowActions: [],
336
+ };