impaktapps-ui-builder 0.0.346 → 0.0.348

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.
@@ -5,7 +5,7 @@ declare const _default: (store: any, dynamicData: any, submitHandler: any, servi
5
5
  getFormdata: () => any;
6
6
  getSchema: () => any;
7
7
  okHandler: () => void;
8
- savePageHandler: () => Promise<void>;
8
+ saveHandler: () => Promise<void>;
9
9
  onChange: () => void;
10
10
  editComponents: () => void;
11
11
  deleteComponents: () => void;
@@ -76,9 +76,9 @@ declare const _default: (store: any, dynamicData: any, submitHandler: any, servi
76
76
  };
77
77
  required: string[];
78
78
  };
79
- savePageHandler: () => Promise<void>;
80
- onChange: () => void;
81
79
  okHandler: () => void;
80
+ saveHandler: () => Promise<void>;
81
+ onChange: () => void;
82
82
  addEvent: () => void;
83
83
  editEvent: () => void;
84
84
  deleteEvent: () => void;
@@ -1,4 +1,6 @@
1
- export declare function saveHandler(store: any, service: any, submitHandler: any, config: any): Promise<boolean>;
1
+ export declare function saveHandler(store: any, service: any, submitHandler: any, pageName?: string): Promise<void>;
2
+ export declare const navigateHandler: (store: any, isSubmitted: any, pageName?: string | boolean) => void;
3
+ export declare function okHandler(store: any): void;
2
4
  interface funcParamsProps {
3
5
  store: any;
4
6
  dynamicData: any;
@@ -50,7 +52,7 @@ declare const _default: (funcParams: funcParamsProps) => {
50
52
  };
51
53
  backHandler: () => void;
52
54
  onAddClickHandler: () => void;
53
- savePageHandler: () => Promise<void>;
55
+ saveHandler: () => Promise<void>;
54
56
  Edit_Components: () => void;
55
57
  Delete_Components: () => void;
56
58
  eventAddHandler: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.346",
3
+ "version": "0.0.348",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -278,7 +278,7 @@ export const componentBasicUiSchema: any = {
278
278
  variant: "contained",
279
279
  color: "info",
280
280
  type: "text",
281
- onClick: "savePageHandler",
281
+ onClick: "saveHandler",
282
282
  size: "small",
283
283
  },
284
284
  style: {
@@ -375,7 +375,7 @@ export const PageMasterUiSchema: any = {
375
375
  variant: "contained",
376
376
  color: "info",
377
377
  type: "text",
378
- onClick: "savePageHandler",
378
+ onClick: "saveHandler",
379
379
  size: "small",
380
380
  },
381
381
  style: {
@@ -297,7 +297,7 @@ export const EventUiSchema: any = {
297
297
  variant: "contained",
298
298
  color: "info",
299
299
  type: "text",
300
- onClick: "savePageHandler",
300
+ onClick: "saveHandler",
301
301
  size: "small",
302
302
  },
303
303
  style: {
@@ -9,7 +9,7 @@ import { StyleSection } from "../build/uischema/styleSection";
9
9
  import { TableSection } from "../build/uischema/tableSection";
10
10
  import { ValueTab } from "../build/uischema/valueTab";
11
11
  import { ValidationSection } from "../build/uischema/validationSections";
12
- import { saveHandler } from "./pageMaster";
12
+ import { navigateHandler, okHandler, saveHandler } from "./pageMaster";
13
13
  const sectionLabels = {
14
14
  Select: ["Core", "Properties","Value", "style", "Event","Validation"],
15
15
  MultipleSelect: ["Core", "Properties","Value", "style", "Event","Validation"],
@@ -77,46 +77,8 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
77
77
  getSchema: function () {
78
78
  return ComponentSchema;
79
79
  },
80
- okHandler: function () {
81
- const path = store.searchParams?.get("path");
82
- console.log(store.ctx.core.errors)
83
- if (_.isEmpty(store.ctx.core.errors)) {
84
- saveFormdataInLocalStorage(store.ctx.core.data,path)
85
- store.navigate(-1)
86
- store.setNotify({
87
- SuccessMessage: "Save Successfully",
88
- Success: true,
89
- });
90
- } else {
91
- store.setValidation("ValidateAndShow");
92
- store.setNotify({
93
- Fail:true,
94
- FailMessage:"Errors on Page"
95
- })
96
- }
97
- },
98
- savePageHandler: async () => {
99
- const id = store.searchParams?.get("id");
100
- const path = store.searchParams?.get("path");
101
- saveFormdataInLocalStorage(store.ctx.core.data, path);
102
- const config = JSON.parse(localStorage.getItem("pageFormdata"));
103
- const isSubmitted = await saveHandler(store, service, submitHandler,config);
104
- if (isSubmitted) {
105
- localStorage.removeItem("pageFormdata");
106
- store.navigate(`/PageMaster?id=${id}`);
107
- store.setNotify({
108
- SuccessMessage: "Submit Successfully",
109
- Success: true,
110
- });
111
- } else {
112
- store.setValidation("ValidateAndShow");
113
- store.setNotify({
114
- Fail: true,
115
- FailMessage: "Errors on Page"
116
- });
117
- }
118
- },
119
-
80
+ okHandler:()=>okHandler(store),
81
+ saveHandler: async ()=> await saveHandler(store,service,submitHandler,"PageMaster"),
120
82
  onChange: function () {
121
83
  if (
122
84
  store?.formData?.type !== store?.newData?.type &&
@@ -1,9 +1,9 @@
1
- import { EventSchema } from "../elements/UiSchema/event/schema";
1
+ import { EventSchema } from "../elements/UiSchema/event/schema";
2
2
  import { EventUiSchema } from "../elements/UiSchema/event/uiSchema";
3
3
  import Component from "./component";
4
4
  import { saveFormdataInLocalStorage } from "./saveHandler";
5
5
  import { APISection } from "../build/uischema/apiSection";
6
- import { saveHandler } from "./pageMaster";
6
+ import { okHandler, saveHandler } from "./pageMaster";
7
7
  import { getSelectField, getTextArea } from "../build/uischema/buildPropertiesSection";
8
8
  import { refreshSectionUiSchema } from "../build/uischema/refresh";
9
9
  import _ from "lodash";
@@ -11,7 +11,7 @@ import _ from "lodash";
11
11
  export default (
12
12
  store: any,
13
13
  dynamicData: any,
14
- submitHandler: any,
14
+ submitHandler: any,
15
15
  service: any
16
16
  ) => {
17
17
  return {
@@ -20,76 +20,54 @@ export default (
20
20
  store.setFormdata(formdata);
21
21
  const schema = await this.getSchema();
22
22
  store.setSchema(schema);
23
- this.refreshPage(formdata.Handler,store)
23
+ this.refreshPage(formdata.Handler, store)
24
24
  },
25
25
  refreshPage: (handlerType: any, store: any) => {
26
26
  const uiSchema = _.cloneDeep(EventUiSchema);
27
- const schema:any = _.cloneDeep(EventSchema)
27
+ const schema: any = _.cloneDeep(EventSchema)
28
28
  if (handlerType) {
29
29
  if (handlerType === "custom") {
30
30
  uiSchema.elements[1].elements[0].elements[2] = getTextArea("eventCode", "Write Custom Code", false)
31
- schema.required = ["eventType","Handler","eventCode"]
31
+ schema.required = ["eventType", "Handler", "eventCode"]
32
32
 
33
33
  } else if (handlerType === "api") {
34
34
  uiSchema.elements[1].elements[0].elements[2] = APISection;
35
- schema.required = ["eventType","Handler","method","path"]
35
+ schema.required = ["eventType", "Handler", "method", "path"]
36
36
  } else if (handlerType === "inBuiltFunction") {
37
37
  uiSchema.elements[1].elements[0].elements[2] = getSelectField("inBuiltFunctionType", "Function Name", [
38
38
  { label: "RankProvider", value: "RankProvider" },
39
39
  { label: "Download File", value: "downloadFile" },
40
40
  ])
41
41
  uiSchema.elements[1].elements[0].elements[3] = getTextArea("funcParametersCode", "Write Custom Code for Functions Parameter", true, { xs: 12, sm: 12, md: 6 });
42
- schema.required = ["eventType","Handler","inBuiltFunctionType"]
42
+ schema.required = ["eventType", "Handler", "inBuiltFunctionType"]
43
43
  } else if (handlerType === "refresh") {
44
44
  uiSchema.elements[1].elements[0].elements[2] = refreshSectionUiSchema;
45
45
  schema.properties.refreshElements.required = ["value"]
46
46
  schema.properties.refreshElements.items.required = ["value"]
47
- schema.required = ["eventType","Handler","refreshElements"]
47
+ schema.required = ["eventType", "Handler", "refreshElements"]
48
48
  }
49
49
  }
50
50
  store.setSchema(schema)
51
51
  store.setUiSchema(uiSchema)
52
52
  },
53
53
 
54
- getFormData: Component(store, dynamicData,submitHandler,service).getFormdata,
54
+ getFormData: Component(store, dynamicData, submitHandler, service).getFormdata,
55
55
  getUiSchema: function () {
56
56
  return EventUiSchema;
57
57
  },
58
58
  getSchema: () => {
59
59
  return EventSchema;
60
60
  },
61
- savePageHandler: async () => {
62
- const id = store.searchParams?.get("id");
63
- const path = store.searchParams?.get("path");
64
- saveFormdataInLocalStorage(store.ctx.core.data,path);
65
- const config = JSON.parse(localStorage.getItem("pageFormdata"));
66
- const isSubmitted = await saveHandler(store, service, submitHandler,config);
67
- if (isSubmitted) {
68
- localStorage.removeItem("pageFormdata");
69
- store.navigate(`/PageMaster?id=${id}`);
70
- store.setNotify({
71
- SuccessMessage: "Submit Successfully",
72
- Success: true,
73
- });
74
- } else {
75
- store.setValidation("ValidateAndShow");
76
- store.setNotify({
77
- Fail: true,
78
- FailMessage: "Errors on Page"
79
- });
80
- }
81
- },
82
-
61
+ okHandler: () => okHandler(store),
62
+ saveHandler: async () => await saveHandler(store, service, submitHandler,"PageMaster"),
83
63
  onChange: function () {
84
64
  if (
85
65
  store?.formData?.Handler !== store?.newData?.Handler &&
86
66
  store?.newData?.Handler !== undefined
87
67
  ) {
88
- this.refreshPage(store.newData.Handler||store.formdata.Handler,store)
68
+ this.refreshPage(store.newData.Handler || store.formdata.Handler, store)
89
69
  }
90
70
  },
91
-
92
- okHandler: Component(store, dynamicData,submitHandler,service).okHandler,
93
71
  addEvent: function () {
94
72
  const path = store.searchParams?.get("path");
95
73
  if (!Array.isArray(store.formData.events)) {
@@ -111,7 +89,7 @@ export default (
111
89
  this.setPage()
112
90
 
113
91
  },
114
- deleteEvent: Component(store, dynamicData,submitHandler,service).deleteEvent,
92
+ deleteEvent: Component(store, dynamicData, submitHandler, service).deleteEvent,
115
93
  backHandler: function () {
116
94
  store.navigate(-1)
117
95
  },
@@ -5,18 +5,55 @@ import Component from "./component";
5
5
  import { getFormdataFromLocalStorage, saveFormdataInLocalStorage } from "./saveHandler";
6
6
  import { schema } from "../build/buildUiSchema";
7
7
 
8
- export async function saveHandler(store, service, submitHandler, config) {
9
- let isTrue = false;
8
+ export async function saveHandler(store, service, submitHandler,pageName?:string) {
9
+ const id = store.searchParams?.get("id");
10
+ const path = store.searchParams?.get("path");
11
+ saveFormdataInLocalStorage(store.ctx.core.data, path);
12
+ const config = JSON.parse(localStorage.getItem("pageFormdata"));
10
13
  if (_.isEmpty(store.ctx.core.errors)) {
11
14
  try {
12
- const saveReturn = await submitHandler(store, service,config);
13
- isTrue = true;
15
+ const saveReturn = await submitHandler(store, service, config);
16
+ navigateHandler(store,true,pageName?`/${pageName}?id=${id}`:false)
14
17
  } catch (err) {
15
- isTrue = false;
18
+ navigateHandler(store,false)
16
19
  }
17
20
  }
18
- return isTrue;
19
21
  }
22
+ export const navigateHandler = (store, isSubmitted, pageName?: string | boolean) => {
23
+ if (isSubmitted) {
24
+ localStorage.removeItem("pageFormdata");
25
+ store.navigate(pageName || -1)
26
+ store.setNotify({
27
+ SuccessMessage: "Submit Successfully",
28
+ Success: true,
29
+ });
30
+ } else {
31
+ store.setValidation("ValidateAndShow");
32
+ store.setNotify({
33
+ Fail: true,
34
+ FailMessage: "Errors on Page"
35
+ });
36
+ }
37
+ };
38
+ export function okHandler (store) {
39
+ const path = store.searchParams?.get("path");
40
+ console.log(store.ctx.core.errors)
41
+ if (_.isEmpty(store.ctx.core.errors)) {
42
+ saveFormdataInLocalStorage(store.ctx.core.data,path)
43
+ store.navigate(-1)
44
+ store.setNotify({
45
+ SuccessMessage: "Save Successfully",
46
+ Success: true,
47
+ });
48
+ } else {
49
+ store.setValidation("ValidateAndShow");
50
+ store.setNotify({
51
+ Fail:true,
52
+ FailMessage:"Errors on Page"
53
+ })
54
+ }
55
+ }
56
+
20
57
  interface funcParamsProps {
21
58
  store: any,
22
59
  dynamicData: any,
@@ -65,25 +102,7 @@ export default (funcParams: funcParamsProps) => {
65
102
  `/Component?path=${`elements[${response?.elements.length}]`}&id=${id}`
66
103
  );
67
104
  },
68
- savePageHandler: async () => {
69
- saveFormdataInLocalStorage(store.ctx.core.data);
70
- const config = JSON.parse(localStorage.getItem("pageFormdata"));
71
- const isSubmitted = await saveHandler(store, service, submitHandler,config);
72
- if (isSubmitted) {
73
- localStorage.removeItem("pageFormdata");
74
- store.navigate('/PageMasterRecords');
75
- store.setNotify({
76
- SuccessMessage: "Submit Successfully",
77
- Success: true,
78
- });
79
- } else {
80
- store.setValidation("ValidateAndShow");
81
- store.setNotify({
82
- Fail: true,
83
- FailMessage: "Errors on Page"
84
- });
85
- }
86
- },
105
+ saveHandler: async ()=> await saveHandler(store,service,submitHandler),
87
106
  Edit_Components: Component(store, dynamicData, submitHandler, service).editComponents,
88
107
  Delete_Components: Component(store, dynamicData, submitHandler, service).deleteComponents,
89
108
  eventAddHandler: function () {