@simitgroup/simpleapp-generator 2.0.3-h-alpha → 2.0.3-j-alpha

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 (21) hide show
  1. package/ReleaseNote.md +9 -0
  2. package/dist/buildinschemas/customfield.d.ts.map +1 -1
  3. package/dist/buildinschemas/customfield.js +4 -0
  4. package/dist/buildinschemas/customfield.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/buildinschemas/customfield.ts +4 -0
  7. package/templates/nuxt/components/simpleApp/SimpleAppCalendarInput.vue.eta +4 -7
  8. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +17 -16
  9. package/templates/nuxt/components/simpleApp/SimpleAppJsonSchemaForm.vue.eta +138 -136
  10. package/templates/nuxt/components/simpleApp/SimpleAppRemoteSelect.vue.eta +7 -10
  11. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +19 -25
  12. package/templates/nuxt/simpleapp/generate/features/customField/services/CustomFieldService.ts.eta +68 -69
  13. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppSettingPage.vue.eta +51 -51
  14. package/templates/nuxt/lang/cn.ts._eta +0 -15
  15. package/templates/nuxt/lang/en.ts.eta +0 -19
  16. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldFormField.vue.eta +0 -100
  17. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldFormFieldInput.vue.eta +0 -125
  18. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldFormSection.vue.eta +0 -40
  19. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldViewFormField.vue.eta +0 -96
  20. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldViewFormFieldInput.vue.eta +0 -150
  21. package/templates/nuxt/simpleapp/generate/features/customField/components/CustomFieldViewFormSection.vue.eta +0 -38
package/ReleaseNote.md CHANGED
@@ -1,3 +1,12 @@
1
+ [2.0.3j-alpha]
2
+ 1. Replace CustomFieldFormField with SimpleAppJsonForms in MiniAppSettingPage
3
+ 2. Remove redundant custom field form templates
4
+
5
+ [2.0.3i-alpha]
6
+ 1. Add uiSchema for custom field
7
+ 2. Remove unused lang template files (cn.ts._eta, en.ts.eta)
8
+ 3. Migrate getValidateService import to @simtrain/shared
9
+
1
10
  [2.0.3h-alpha]
2
11
  1. Split monolithic simpleapp-event plugin into focused plugins
3
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"customfield.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/customfield.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,UA6CzB,CAAC"}
1
+ {"version":3,"file":"customfield.d.ts","sourceRoot":"","sources":["../../src/buildinschemas/customfield.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,UAiDzB,CAAC"}
@@ -32,6 +32,10 @@ exports.customfield = {
32
32
  jsonSchema: {
33
33
  type: 'object',
34
34
  properties: {}
35
+ },
36
+ uiSchema: {
37
+ type: 'object',
38
+ properties: {}
35
39
  }
36
40
  }
37
41
  },
@@ -1 +1 @@
1
- {"version":3,"file":"customfield.js","sourceRoot":"","sources":["../../src/buildinschemas/customfield.ts"],"names":[],"mappings":";;;AAAA,kCAAiE;AAEpD,QAAA,WAAW,GAAe;IACrC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE;QACpB,YAAY,EAAE,aAAa;QAC3B,YAAY,EAAE,aAAa;QAC3B,aAAa,EAAE,oBAAa,CAAC,MAAM;QACnC,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,gBAAgB;QAC/B,QAAQ,EAAE,UAAU;QACpB,YAAY,EAAE,aAAa;KAC5B;IACD,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACzC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACtC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACzC,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,CAAC;SACb;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;aACF;SACF;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"customfield.js","sourceRoot":"","sources":["../../src/buildinschemas/customfield.ts"],"names":[],"mappings":";;;AAAA,kCAAiE;AAEpD,QAAA,WAAW,GAAe;IACrC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE;QACpB,YAAY,EAAE,aAAa;QAC3B,YAAY,EAAE,aAAa;QAC3B,aAAa,EAAE,oBAAa,CAAC,MAAM;QACnC,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,gBAAgB;QAC/B,QAAQ,EAAE,UAAU;QACpB,YAAY,EAAE,aAAa;KAC5B;IACD,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACzC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACtC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;QACzC,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,CAAC;SACb;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;aACF;SACF;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;KACF;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.3h-alpha",
3
+ "version": "2.0.3j-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -30,6 +30,10 @@ export const customfield: SchemaType = {
30
30
  jsonSchema: {
31
31
  type: 'object',
32
32
  properties: {}
33
+ },
34
+ uiSchema: {
35
+ type: 'object',
36
+ properties: {}
33
37
  }
34
38
  }
35
39
  },
@@ -14,6 +14,7 @@
14
14
  v-bind="<CalendarProps>componentProps"
15
15
  :select-other-months="true"
16
16
  pt:pcInputText:root="w-full"
17
+ class="w-full"
17
18
  @update:model-value="updateDateTime"
18
19
  />
19
20
  </template>
@@ -37,14 +38,10 @@ const modelValue = defineModel<string>({ required: true });
37
38
  const datetimevalue = ref<Date>();
38
39
 
39
40
  const refreshFromParent = () => {
40
- if (modelValue.value === undefined || modelValue.value == "")
41
- datetimevalue.value = undefined;
41
+ if (modelValue.value === undefined || modelValue.value == "") datetimevalue.value = undefined;
42
42
  else if (props.type == "time")
43
- datetimevalue.value = stringToDate(
44
- "2000-01-01 " + (modelValue.value ?? "00:00:00"),
45
- );
46
- else if (props.type == "date")
47
- datetimevalue.value = stringToDate(modelValue.value + "T00:00:00");
43
+ datetimevalue.value = stringToDate("2000-01-01 " + (modelValue.value ?? "00:00:00"));
44
+ else if (props.type == "date") datetimevalue.value = stringToDate(modelValue.value + "T00:00:00");
48
45
  else datetimevalue.value = stringToDate(modelValue.value);
49
46
  };
50
47
 
@@ -1,12 +1,18 @@
1
1
  <template>
2
- <form class="simpleapp-form" @submit.prevent="true">
3
- <slot name="default" :data="document.getData()" :getField="getField"></slot>
2
+ <form
3
+ class="simpleapp-form"
4
+ @submit.prevent="true"
5
+ >
6
+ <slot
7
+ name="default"
8
+ :data="document.getData()"
9
+ :getField="getField"
10
+ ></slot>
4
11
  <slot name="customField">
5
- <CustomFieldFormSection
12
+ <SimpleAppCustomFieldForm
6
13
  v-if="document.schema.properties.more"
7
- :customFieldJsonSchema="document.schema.properties.more"
8
- :data="document.getData().more"
9
- :handleGetField="getField"
14
+ :document="document"
15
+ :readonly="isreadonly"
10
16
  />
11
17
  </slot>
12
18
  </form>
@@ -18,12 +24,12 @@
18
24
  * last change 2023-10-28
19
25
  * Author: Ks Tan
20
26
  */
27
+ import type { JSONSchema7 } from "json-schema";
21
28
  import jsonpath from "jsonpath";
29
+ import _ from "lodash";
22
30
  import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
23
- import type { JSONSchema7, JSONSchema7Definition } from "json-schema";
24
31
  import * as alldefaults from "~/simpleapp/generate/defaults";
25
- import _, { upperFirst } from "lodash";
26
- import CustomFieldFormSection from "~/simpleapp/generate/features/customField/components/CustomFieldFormSection.vue";
32
+
27
33
  const props = defineProps<{
28
34
  document: SimpleAppClient<any, any>;
29
35
  readonly?: boolean;
@@ -32,9 +38,7 @@ if (!props.document) {
32
38
  throw "undefine SimpleAppForm property 'document'";
33
39
  }
34
40
 
35
- const isreadonly = computed(() =>
36
- props.readonly ? props.readonly : props.document.isReadOnly(),
37
- );
41
+ const isreadonly = computed(() => (props.readonly ? props.readonly : props.document.isReadOnly()));
38
42
 
39
43
  // const obj = {schema:props.schema,data: props.schema}
40
44
  const getField = (path: string) => {
@@ -121,10 +125,7 @@ const getInstancePath = (schema: any, path: string) => {
121
125
  // let paths = path.replace('#/','').split('/')
122
126
  // return '/'+paths[1]
123
127
  };
124
- const getPathObject = (
125
- schema: JSONSchema7,
126
- path: string,
127
- ): JSONSchema7 | undefined => {
128
+ const getPathObject = (schema: JSONSchema7, path: string): JSONSchema7 | undefined => {
128
129
  // console.log("path",path)
129
130
  if (!path || !path.includes("#/properties")) {
130
131
  console.error("unknown path");
@@ -1,161 +1,163 @@
1
1
  <template>
2
- <form class="simpleapp-form" @submit.prevent="true">
3
- <slot name="header"><h3 class="flex flex-col">{{ title }}</h3></slot>
4
- <slot name="default" :getField="getField" :validate="validate"></slot>
5
- </form>
2
+ <form
3
+ class="simpleapp-form"
4
+ @submit.prevent="true"
5
+ >
6
+ <slot name="header"
7
+ ><h3 class="flex flex-col">{{ title }}</h3></slot
8
+ >
9
+ <slot
10
+ name="default"
11
+ :getField="getField"
12
+ :validate="validate"
13
+ ></slot>
14
+ </form>
6
15
  </template>
7
- <script setup lang="ts" >
16
+ <script setup lang="ts">
8
17
  /**
9
18
  * This file was automatically generated by simpleapp generator. Every
10
19
  * MODIFICATION OVERRIDE BY GENERATEOR
11
20
  * last change 2023-10-28
12
21
  * Author: Ks Tan
13
22
  */
14
- import type { JSONSchema7,JSONSchema7Definition } from 'json-schema';
15
- import { getValidateService } from "~/simpleapp/generate/sharelibs/validate";
16
- import _ from 'lodash'
23
+ import { getValidateService } from "@simtrain/shared";
24
+ import type { JSONSchema7, JSONSchema7Definition } from "json-schema";
25
+ import _ from "lodash";
17
26
 
18
- const props = defineProps<{
19
- title?:string,
20
- schema:JSONSchema7,
21
- data:any,
22
- // document: SimpleAppClient<any,any>
23
- readonly?:boolean
24
- }>()
25
- if(!props.schema){
26
- throw "undefine jsonschema property 'schema'"
27
- }
28
- const formerrors = ref<any>({})
29
- const getField = (path:string)=>{
30
- const schema = props.schema
31
- const fieldsetting = getPathObject(schema,path)
32
-
33
- return {
34
- path: path,
35
- key: _.last(path.split('/')),
36
- instancepath: getInstancePath(schema,path),
37
- fieldsetting: fieldsetting,
38
- isrequired: getIsRequired(schema,path),
39
- errors: formerrors,
40
- readonly: props.readonly
41
- } //as SimpleAppFieldSetting
42
- }
27
+ const props = defineProps<{
28
+ title?: string;
29
+ schema: JSONSchema7;
30
+ data: any;
31
+ // document: SimpleAppClient<any,any>
32
+ readonly?: boolean;
33
+ }>();
34
+ if (!props.schema) {
35
+ throw "undefine jsonschema property 'schema'";
36
+ }
37
+ const formerrors = ref<any>({});
38
+ const getField = (path: string) => {
39
+ const schema = props.schema;
40
+ const fieldsetting = getPathObject(schema, path);
43
41
 
44
-
45
- const getIsRequired=(schema:any,path:string)=>{
46
- if(!path){
47
- console.error('unknown path')
48
- return 'xx'
49
- }
42
+ return {
43
+ path: path,
44
+ key: _.last(path.split("/")),
45
+ instancepath: getInstancePath(schema, path),
46
+ fieldsetting: fieldsetting,
47
+ isrequired: getIsRequired(schema, path),
48
+ errors: formerrors,
49
+ readonly: props.readonly,
50
+ }; //as SimpleAppFieldSetting
51
+ };
50
52
 
51
- try{
52
- let paths = path.replace('#/','').split('/')
53
- const fieldname = paths[paths.length-1]
54
- paths = paths.slice(0, -2);
55
- let tmp = schema
56
- for(let i=0;i<paths.length;i++){
57
- tmp = tmp[paths[i]]
58
-
59
- }
60
- if(Array.isArray(tmp['required']) ) {
61
- const arr:string[] = tmp['required']
62
- return arr.includes (fieldname)
63
- }else{
64
- return false
65
- }
53
+ const getIsRequired = (schema: any, path: string) => {
54
+ if (!path) {
55
+ console.error("unknown path");
56
+ return "xx";
57
+ }
66
58
 
67
- // console.log("get instance path",instancepath)
68
-
69
- // return tmp
70
- }catch(err:any){
71
- console.error(err.message)
72
- }
59
+ try {
60
+ let paths = path.replace("#/", "").split("/");
61
+ const fieldname = paths[paths.length - 1];
62
+ paths = paths.slice(0, -2);
63
+ let tmp = schema;
64
+ for (let i = 0; i < paths.length; i++) {
65
+ tmp = tmp[paths[i]];
73
66
  }
74
- const getInstancePath=(schema:any,path:string)=>{
75
- if(!path){
76
- console.error('unknown path')
77
- return 'yy'
67
+ if (Array.isArray(tmp["required"])) {
68
+ const arr: string[] = tmp["required"];
69
+ return arr.includes(fieldname);
70
+ } else {
71
+ return false;
78
72
  }
79
- try{
80
- let paths = path.replace('#/','').split('/')
81
- let tmp = schema
82
- let instancepath=''
83
- for(let i=0;i<paths.length;i++){
84
- tmp = tmp[paths[i]]
85
- if(tmp['type'] && paths[i] !='items'){
86
- instancepath=instancepath+'/'+paths[i]
87
- }
88
- }
89
73
 
90
- // console.log("get instance path",instancepath)
91
- return instancepath
92
- // return tmp
93
- }catch(err:any){
94
- console.error(err.message)
74
+ // console.log("get instance path",instancepath)
75
+
76
+ // return tmp
77
+ } catch (err: any) {
78
+ console.error(err.message);
79
+ }
80
+ };
81
+ const getInstancePath = (schema: any, path: string) => {
82
+ if (!path) {
83
+ console.error("unknown path");
84
+ return "yy";
85
+ }
86
+ try {
87
+ let paths = path.replace("#/", "").split("/");
88
+ let tmp = schema;
89
+ let instancepath = "";
90
+ for (let i = 0; i < paths.length; i++) {
91
+ tmp = tmp[paths[i]];
92
+ if (tmp["type"] && paths[i] != "items") {
93
+ instancepath = instancepath + "/" + paths[i];
94
+ }
95
95
  }
96
96
 
97
+ // console.log("get instance path",instancepath)
98
+ return instancepath;
99
+ // return tmp
100
+ } catch (err: any) {
101
+ console.error(err.message);
102
+ }
97
103
 
98
- // let paths = path.replace('#/','').split('/')
99
- // return '/'+paths[1]
100
- }
101
- const getPathObject=(schema:JSONSchema7,path:string):JSONSchema7|undefined=>{
102
- // console.log("path",path)
103
- if(!path){
104
- console.error('unknown path')
105
- return undefined
104
+ // let paths = path.replace('#/','').split('/')
105
+ // return '/'+paths[1]
106
+ };
107
+ const getPathObject = (schema: JSONSchema7, path: string): JSONSchema7 | undefined => {
108
+ // console.log("path",path)
109
+ if (!path) {
110
+ console.error("unknown path");
111
+ return undefined;
112
+ }
113
+ try {
114
+ let paths: string[] = path.replace("#/", "").split("/");
115
+ let tmp: JSONSchema7Definition = schema;
116
+ // console.log(path)
117
+ for (let i = 0; i < paths.length; i++) {
118
+ //silly code, but it seems require to avoid typescript complaint.
119
+ //ultimately it is to obtain result as "tmp=tmp[path[i]]"
120
+ const key1 = paths[i] as keyof JSONSchema7;
121
+ let jsonkey: keyof JSONSchema7 = key1;
122
+ let obj: JSONSchema7 = {} as JSONSchema7;
123
+ Object.assign(obj, tmp[jsonkey]);
124
+ tmp = { ...obj };
106
125
  }
107
- try{
108
- let paths:string[] = path.replace('#/','').split('/')
109
- let tmp :JSONSchema7Definition= schema
110
- // console.log(path)
111
- for(let i=0;i<paths.length;i++){
112
-
113
- //silly code, but it seems require to avoid typescript complaint.
114
- //ultimately it is to obtain result as "tmp=tmp[path[i]]"
115
- const key1 = paths[i] as keyof JSONSchema7
116
- let jsonkey: keyof JSONSchema7 = key1
117
- let obj:JSONSchema7 = {} as JSONSchema7
118
- Object.assign(obj,tmp[jsonkey])
119
- tmp = {...obj}
120
- }
121
- // console.log('final ',path,tmp)
122
- return tmp
123
- }catch(err:any){
124
- console.error(err.message)
125
-
126
- }
127
- }
126
+ // console.log('final ',path,tmp)
127
+ return tmp;
128
+ } catch (err: any) {
129
+ console.error(err.message);
130
+ }
131
+ };
128
132
 
133
+ const validate = (callback: Function) => {
134
+ const ajv = getValidateService();
129
135
 
130
- const validate=(callback:Function) => {
131
- const ajv = getValidateService();
132
-
133
- // this.errorlist.value = {};
134
- // this.hook('pre-validation', this.data.value);
135
- const validate = ajv.compile(props.schema);
136
- // console.log("validate data",props.data)
137
- const valid = validate(props.data);
138
- if (!valid) {
139
- const errors = validate.errors;
140
- const tmp: { [key: string]: any } = {};
141
- if (errors) {
142
- for (let i = 0; i < errors?.length; i++) {
143
- const key: string = errors[i]['instancePath'];
144
- if (!tmp[key]) {
145
- tmp[key] = [];
146
- }
147
- tmp[key].push(errors[i]);
136
+ // this.errorlist.value = {};
137
+ // this.hook('pre-validation', this.data.value);
138
+ const validate = ajv.compile(props.schema);
139
+ // console.log("validate data",props.data)
140
+ const valid = validate(props.data);
141
+ if (!valid) {
142
+ const errors = validate.errors;
143
+ const tmp: { [key: string]: any } = {};
144
+ if (errors) {
145
+ for (let i = 0; i < errors?.length; i++) {
146
+ const key: string = errors[i]["instancePath"];
147
+ if (!tmp[key]) {
148
+ tmp[key] = [];
148
149
  }
150
+ tmp[key].push(errors[i]);
149
151
  }
150
- formerrors.value = tmp;
151
- console.error(formerrors.value );
152
-
153
- // return validate.errors;
154
- callback(formerrors.value )
155
- } else {
156
- // this.hook('post-validation', this.data.value);
157
- callback(false)
158
152
  }
159
- }
153
+ formerrors.value = tmp;
154
+ console.error(formerrors.value);
160
155
 
161
- </script>
156
+ // return validate.errors;
157
+ callback(formerrors.value);
158
+ } else {
159
+ // this.hook('post-validation', this.data.value);
160
+ callback(false);
161
+ }
162
+ };
163
+ </script>
@@ -36,28 +36,25 @@ function handleChange(newValue: any) {
36
36
  const actions = remoteConfig?.onChangeAction ?? [];
37
37
  if (!Array.isArray(actions) || actions.length === 0) return;
38
38
 
39
- const modelObject = props.setting.modelObject ?? {};
40
- const selectedOption = options.value.find(
41
- (opt: any) => opt.value === newValue,
42
- );
39
+ const selectedOption = options.value.find((opt: any) => opt.value === newValue);
43
40
 
44
41
  for (const action of actions) {
45
42
  if (!action.updateField) continue;
46
43
 
47
44
  let updateVal: any = action.updateValue;
48
45
 
49
- if (
50
- typeof updateVal === "string" &&
51
- updateVal.startsWith("{") &&
52
- updateVal.endsWith("}")
53
- ) {
46
+ if (typeof updateVal === "string" && updateVal.startsWith("{") && updateVal.endsWith("}")) {
54
47
  // ✅ Replace {path.to.value} using selectedOption
55
48
  const path = updateVal.slice(1, -1).trim();
56
49
  const resolvedVal = resolvePath(selectedOption ?? {}, path);
57
50
  updateVal = resolvedVal !== undefined ? resolvedVal : "";
58
51
  }
59
52
 
60
- setPath(modelObject, action.updateField, updateVal);
53
+ if (props.setting.handleFieldChange) {
54
+ props.setting.handleFieldChange(action.updateField, updateVal);
55
+ } else {
56
+ setPath(props.setting.modelObject ?? {}, action.updateField, updateVal);
57
+ }
61
58
  }
62
59
  }
63
60
 
@@ -4,23 +4,23 @@
4
4
  * last change 2024-03-08
5
5
  * Author: Ks Tan
6
6
  */
7
- import { ref } from "vue";
8
- import type { Ref } from "vue";
7
+ import type { VerticalLayout } from "@jsonforms/core";
8
+ import { getValidateService } from "@simtrain/shared";
9
9
  import type { AxiosResponse } from "axios";
10
+ import { cloneDeep, isEmpty } from "lodash";
11
+ import type { Ref } from "vue";
12
+ import { ref, WatchHandle } from "vue";
10
13
  import {
11
- SearchBody,
12
- TextSearchBody,
14
+ DynamicObject,
15
+ FormActions,
13
16
  NotificationStatus,
14
17
  SchemaType,
15
- FormActions,
16
- DynamicObject,
18
+ SearchBody,
19
+ TextSearchBody,
17
20
  } from "~/types";
18
- import { getValidateService } from "~/simpleapp/generate/sharelibs/validate";
19
- import { WatchHandle } from "vue";
21
+ import { CustomFieldDataModeEnum } from "../features/customField/enums/common";
20
22
  import { CustomFieldService } from "../features/customField/services/CustomFieldService";
21
23
  import { CustomFieldDataMode } from "../features/customField/types/common";
22
- import { CustomFieldDataModeEnum } from "../features/customField/enums/common";
23
- import { cloneDeep, isEmpty } from "lodash";
24
24
 
25
25
  // import { useToast, } from 'primevue/usetoast';
26
26
  // import type { ToastMessageOptions } from 'primevue/toast';
@@ -58,6 +58,7 @@ export class SimpleAppClient<
58
58
  // FLAG::CUSTOM_FIELD
59
59
  protected _customFieldWatch: WatchHandle | null = null;
60
60
  private _customFieldService = new CustomFieldService();
61
+ public customFieldUiSchema: VerticalLayout | undefined = undefined;
61
62
 
62
63
  constructor(apiobj: TApi, doctype: string, docname: string) {
63
64
  this.docapi = apiobj;
@@ -67,10 +68,8 @@ export class SimpleAppClient<
67
68
  }
68
69
  isReady = () => this.ready;
69
70
  getDocType = () => this.doctype;
70
- getDocName = (capFirst: boolean = false) =>
71
- capFirst ? upperFirst(this.docname) : this.docname;
72
- getResourceName = () =>
73
- upperFirst(this.schema["x-simpleapp-config"]?.resourceName ?? "");
71
+ getDocName = (capFirst: boolean = false) => (capFirst ? upperFirst(this.docname) : this.docname);
72
+ getResourceName = () => upperFirst(this.schema["x-simpleapp-config"]?.resourceName ?? "");
74
73
  setNew = () => {};
75
74
  isNew = () => this.data.value?.created == "";
76
75
  setSchema = (schema: SchemaType) => (this.schema = schema);
@@ -115,9 +114,7 @@ export class SimpleAppClient<
115
114
  const attributeName = keys[keys.length - 1];
116
115
  if (allowedPatchAttributes.includes(attributeName)) {
117
116
  if (attributeName === "required" && Array.isArray(value)) {
118
- target.required = Array.from(
119
- new Set([...(target.required ?? []), ...value]),
120
- );
117
+ target.required = Array.from(new Set([...(target.required ?? []), ...value]));
121
118
  } else {
122
119
  target[attributeName] = value;
123
120
  }
@@ -132,16 +129,13 @@ export class SimpleAppClient<
132
129
  prepareCustomFieldJsonSchema() {
133
130
  this.prepareSchemaPatches();
134
131
 
135
- const resp = this._customFieldService.prepareCustomFieldJsonSchema(
136
- this.docname,
137
- );
138
- this.schema.properties.more = resp;
132
+ const { jsonSchema, uiSchema } = this._customFieldService.prepareCustomFieldJsonSchema(this.docname);
133
+ this.schema.properties.more = jsonSchema;
134
+ this.customFieldUiSchema = uiSchema;
139
135
  }
140
136
 
141
- prepareCustomFieldData<T extends DynamicObject>(
142
- mode: CustomFieldDataMode,
143
- data: T,
144
- ) {
137
+ prepareCustomFieldData<T extends DynamicObject>(mode: CustomFieldDataMode, data: T) {
138
+ if (!data || typeof data !== "object") return data;
145
139
  const customFieldData = this._customFieldService.prepareCustomFieldData(
146
140
  this.docname,
147
141
  mode,