admin_lsac 1.2.3 → 1.2.5

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