admin_lsac 1.1.3 → 1.2.1

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.
@@ -0,0 +1,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 = [...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,6 +1,8 @@
1
1
  import { PageSchema } from "./schema";
2
2
  import { event } from "../pages/event";
3
+ import { page } from "../pages/page";
3
4
 
4
5
  export const pages: PageSchema[] = [
5
6
  event, // example schema
7
+ page,
6
8
  ];