@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
@@ -1,83 +1,108 @@
1
+ import { type ControlElement, type GroupLayout, type UISchemaElement, type VerticalLayout } from "@jsonforms/core";
1
2
  import _ from "lodash";
3
+ import { DynamicObject, SimpleAppJSONSchema7Definition } from "~/types";
4
+ import { CustomFieldDataModeEnum } from "../enums/common";
2
5
  import {
3
6
  CustomFieldDataMode,
4
7
  CustomFieldMoreSchema,
5
8
  CustomFieldMoreSchemaGroup,
6
9
  } from "../types/common";
7
- import { CustomFieldDataModeEnum } from "../enums/common";
8
- import { DynamicObject, SimpleAppJSONSchema7Definition } from "~/types";
9
10
 
10
11
  export class CustomFieldService {
11
12
  // =============================== Prepare Schema Function ===============================
12
- prepareCustomFieldJsonSchema(collectionName: string) {
13
- const customFieldFromDB = this.findCustomFieldSchemaFromDB(collectionName);
14
- const customFieldFromMiniApp =
15
- this.findCustomFieldSchemaFromMiniApp(collectionName);
16
-
17
- if (customFieldFromDB && !_.isEmpty(customFieldFromDB)) {
18
- }
13
+ prepareCustomFieldJsonSchema(collectionName: string): { jsonSchema: CustomFieldMoreSchema; uiSchema: VerticalLayout | undefined } {
14
+ const fromDB = this.findCustomFieldSchemaFromDB(collectionName);
15
+ const fromMiniApp = this.findCustomFieldSchemaFromMiniApp(collectionName);
19
16
 
20
- const schema: CustomFieldMoreSchema = {
17
+ const jsonSchema: CustomFieldMoreSchema = {
21
18
  type: "object",
22
19
  properties: {
23
- ...customFieldFromDB,
24
- ...customFieldFromMiniApp,
20
+ ...fromDB.jsonSchema,
21
+ ...fromMiniApp.jsonSchema,
25
22
  },
26
23
  };
27
24
 
28
- return schema;
25
+ const uiSchema = this.buildMoreUiSchema({ ...fromDB.uiSchema, ...fromMiniApp.uiSchema });
26
+
27
+ return { jsonSchema, uiSchema };
29
28
  }
30
29
 
31
30
  prepareSchemaPatches(collectionName: string) {
32
31
  return this.findSchemaPatchFromMiniApp(collectionName);
33
32
  }
34
33
 
35
- private findCustomFieldSchemaFromDB(collectionName: string) {
34
+ private findCustomFieldSchemaFromDB(collectionName: string): { jsonSchema: CustomFieldMoreSchemaGroup; uiSchema: Record<string, VerticalLayout> } {
36
35
  const { $customFieldStore } = useNuxtApp();
37
36
  if (!$customFieldStore.data || _.isEmpty($customFieldStore.data)) {
38
- return {};
37
+ return { jsonSchema: {}, uiSchema: {} };
39
38
  }
40
39
 
41
40
  const customField = $customFieldStore.findByCollectionName(collectionName);
42
41
  if (!customField) {
43
- return {};
42
+ return { jsonSchema: {}, uiSchema: {} };
44
43
  }
45
44
 
46
- if (
47
- !customField?.form?.jsonSchema ||
48
- _.isEmpty(customField?.form?.jsonSchema)
49
- ) {
50
- return {};
45
+ if (!customField?.form?.jsonSchema || _.isEmpty(customField?.form?.jsonSchema)) {
46
+ return { jsonSchema: {}, uiSchema: {} };
51
47
  }
52
48
 
53
- const schema: CustomFieldMoreSchemaGroup = {
54
- default: {
55
- title: "Custom Field",
56
- ...customField.form.jsonSchema,
49
+ return {
50
+ jsonSchema: {
51
+ default: {
52
+ title: "Custom Field",
53
+ ...customField.form.jsonSchema,
54
+ },
57
55
  },
56
+ uiSchema: customField.form.uiSchema ? { default: customField.form.uiSchema as VerticalLayout } : {},
58
57
  };
59
-
60
- return schema;
61
58
  }
62
59
 
63
- private findCustomFieldSchemaFromMiniApp(collectionName: string) {
64
- const schema: CustomFieldMoreSchemaGroup = {};
60
+ private findCustomFieldSchemaFromMiniApp(collectionName: string): { jsonSchema: CustomFieldMoreSchemaGroup; uiSchema: Record<string, VerticalLayout> } {
61
+ const jsonSchema: CustomFieldMoreSchemaGroup = {};
62
+ const uiSchema: Record<string, VerticalLayout> = {};
65
63
 
66
64
  const { $miniAppStore } = useNuxtApp();
67
65
 
68
66
  const miniAppForms = $miniAppStore.getForm(collectionName);
69
67
  if (!miniAppForms || miniAppForms.length <= 0) {
70
- return schema;
68
+ return { jsonSchema, uiSchema };
71
69
  }
72
70
 
73
71
  for (let i = 0; i < miniAppForms.length; i++) {
74
- const miniAppItem = miniAppForms[i];
75
- const { miniAppCode, jsonSchema } = miniAppItem;
72
+ const miniAppItem = miniAppForms[i] as any;
73
+ const { miniAppCode, jsonSchema: itemJsonSchema, uiSchema: itemUiSchema } = miniAppItem;
74
+
75
+ jsonSchema[miniAppCode] = itemJsonSchema as SimpleAppJSONSchema7Definition;
76
+ if (itemUiSchema) uiSchema[miniAppCode] = itemUiSchema as VerticalLayout;
77
+ }
78
+
79
+ return { jsonSchema, uiSchema };
80
+ }
76
81
 
77
- schema[miniAppCode] = jsonSchema as SimpleAppJSONSchema7Definition;
82
+ private buildMoreUiSchema(groupUiSchemas: Record<string, VerticalLayout>): VerticalLayout | undefined {
83
+ const elements: UISchemaElement[] = [];
84
+ for (const [groupKey, uischema] of Object.entries(groupUiSchemas)) {
85
+ if (!uischema?.elements?.length) continue;
86
+ const group: GroupLayout = {
87
+ type: "Group",
88
+ label: groupKey === "default" ? "Custom Field" : groupKey,
89
+ options: { cols: "grid-cols-1" },
90
+ elements: [this.prefixElement(uischema, groupKey)],
91
+ };
92
+ elements.push(group);
78
93
  }
94
+ return elements.length ? { type: "VerticalLayout", elements } : undefined;
95
+ }
79
96
 
80
- return schema;
97
+ private prefixElement(elem: UISchemaElement, groupKey: string): UISchemaElement {
98
+ if (elem.type === "Control") {
99
+ const ctrl = elem as ControlElement;
100
+ return { ...ctrl, scope: ctrl.scope.replace("#/properties/", `#/properties/${groupKey}/properties/`) };
101
+ }
102
+ if ("elements" in elem && Array.isArray(elem.elements)) {
103
+ return { ...elem, elements: (elem as any).elements.map((e: UISchemaElement) => this.prefixElement(e, groupKey)) } as UISchemaElement;
104
+ }
105
+ return elem;
81
106
  }
82
107
 
83
108
  private findSchemaPatchFromMiniApp(collectionName: string) {
@@ -107,11 +132,7 @@ export class CustomFieldService {
107
132
  customSchema: CustomFieldMoreSchema | undefined,
108
133
  resourceData: T | undefined,
109
134
  ): T | undefined {
110
- if (
111
- !customSchema ||
112
- !customSchema?.properties ||
113
- _.isEmpty(customSchema.properties)
114
- ) {
135
+ if (!customSchema || !customSchema?.properties || _.isEmpty(customSchema.properties)) {
115
136
  return resourceData;
116
137
  }
117
138
 
@@ -125,10 +146,7 @@ export class CustomFieldService {
125
146
  return this.prepareCustomFieldWithDefaultData<T>(customSchema);
126
147
  }
127
148
 
128
- return this.prepareCustomFieldWithExistingData(
129
- customSchema,
130
- resourceData,
131
- );
149
+ return this.prepareCustomFieldWithExistingData(customSchema, resourceData);
132
150
  break;
133
151
  }
134
152
  }
@@ -137,9 +155,7 @@ export class CustomFieldService {
137
155
  customSchema: CustomFieldMoreSchema,
138
156
  ) {
139
157
  const data: DynamicObject = {};
140
- for (const [groupName, groupItem] of Object.entries(
141
- customSchema.properties,
142
- )) {
158
+ for (const [groupName, groupItem] of Object.entries(customSchema.properties)) {
143
159
  const defaultData = this.generateDefaultData(groupItem);
144
160
 
145
161
  data[groupName] = defaultData;
@@ -153,14 +169,9 @@ export class CustomFieldService {
153
169
  resourceData: T,
154
170
  ) {
155
171
  const data: DynamicObject = {};
156
- for (const [groupName, groupItem] of Object.entries(
157
- customSchema.properties,
158
- )) {
172
+ for (const [groupName, groupItem] of Object.entries(customSchema.properties)) {
159
173
  const defaultData = this.generateDefaultData(groupItem);
160
- const mergedData = this.mergeWithDefault(
161
- defaultData,
162
- resourceData?.[groupName],
163
- );
174
+ const mergedData = this.mergeWithDefault(defaultData, resourceData?.[groupName]);
164
175
 
165
176
  data[groupName] = mergedData;
166
177
  }
@@ -193,11 +204,7 @@ export class CustomFieldService {
193
204
  const arr = [];
194
205
  const itemsCount = minItems > 0 ? 1 : 0;
195
206
  for (let i = 0; i < itemsCount; i++) {
196
- arr.push(
197
- this.generateDefaultData(
198
- itemSchema as SimpleAppJSONSchema7Definition,
199
- ),
200
- );
207
+ arr.push(this.generateDefaultData(itemSchema as SimpleAppJSONSchema7Definition));
201
208
  }
202
209
  return arr;
203
210
  }
@@ -220,10 +227,7 @@ export class CustomFieldService {
220
227
  }
221
228
  }
222
229
 
223
- private mergeWithDefault<T extends DynamicObject>(
224
- defaultData: T,
225
- collectionData: T | undefined,
226
- ) {
230
+ private mergeWithDefault<T extends DynamicObject>(defaultData: T, collectionData: T | undefined) {
227
231
  if (Array.isArray(defaultData)) {
228
232
  if (Array.isArray(collectionData)) {
229
233
  if (_.isEmpty(collectionData)) {
@@ -242,16 +246,11 @@ export class CustomFieldService {
242
246
  } else if (typeof defaultData === "object" && defaultData !== null) {
243
247
  const result: any = {};
244
248
  for (const key of Object.keys(defaultData)) {
245
- result[key] = this.mergeWithDefault(
246
- defaultData[key],
247
- collectionData?.[key],
248
- );
249
+ result[key] = this.mergeWithDefault(defaultData[key], collectionData?.[key]);
249
250
  }
250
251
  return result;
251
252
  } else {
252
- return typeof collectionData !== "undefined"
253
- ? collectionData
254
- : defaultData;
253
+ return typeof collectionData !== "undefined" ? collectionData : defaultData;
255
254
  }
256
255
  }
257
256
  }
@@ -1,54 +1,48 @@
1
1
  <template>
2
2
  <LoadingLine :loading="isFetching" />
3
- <SimpleAppJsonSchemaForm
3
+ <MiniAppSettingLayout
4
4
  v-if="!_.isEmpty(schema)"
5
- :schema="schema"
6
- :data="data"
7
- #default="o"
5
+ :isFetching="isFetching"
6
+ :miniAppCode="_miniAppCode"
7
+ :miniAppTitle="miniAppTitle"
8
8
  >
9
- <MiniAppSettingLayout
10
- :isFetching="isFetching"
11
- :miniAppCode="_miniAppCode"
12
- :miniAppTitle="miniAppTitle"
13
- >
14
- <template #action>
15
- <Button class="btn-primary" @click="o.validate(validateCallBack)">
16
- {{ t("miniAppLang.saveSetting") }}
17
- </Button>
18
- </template>
9
+ <template #action>
10
+ <Button
11
+ class="btn-primary"
12
+ @click="onSave"
13
+ >
14
+ {{ t("miniAppLang.saveSetting") }}
15
+ </Button>
16
+ </template>
19
17
 
20
- <template #default>
21
- <div class="space-y-4" v-if="!_.isEmpty(schema)">
22
- <p
23
- v-if="miniApp?.integration?.customPage?.setting?.note"
24
- class="text-sm text-gray-600 whitespace-pre-line"
25
- >
26
- {{
27
- t("miniAppLang.miniAppSettingNote", {
28
- miniAppNote: miniApp.integration.customPage.setting.note ?? "",
29
- })
30
- }}
31
- </p>
32
- <CustomFieldFormField
33
- :jsonSchema="settingSchema"
34
- :data="data"
35
- :handleGetField="o.getField"
36
- schemaName="setting"
37
- hierarchy="setting"
38
- schemaSource="miniAppSetting"
39
- :isShowFieldset="false"
40
- :isHideFieldsetLegend="true"
41
- />
42
- </div>
43
- </template>
44
- </MiniAppSettingLayout>
45
- </SimpleAppJsonSchemaForm>
18
+ <template #default>
19
+ <div class="space-y-4">
20
+ <p
21
+ v-if="miniApp?.integration?.customPage?.setting?.note"
22
+ class="text-sm text-gray-600 whitespace-pre-line"
23
+ >
24
+ {{
25
+ t("miniAppLang.miniAppSettingNote", {
26
+ miniAppNote: miniApp.integration.customPage.setting.note ?? "",
27
+ })
28
+ }}
29
+ </p>
30
+ <SimpleAppJsonForms
31
+ ref="jsonForms"
32
+ v-model="data"
33
+ :schema="schema"
34
+ @change="onFormChange"
35
+ />
36
+ </div>
37
+ </template>
38
+ </MiniAppSettingLayout>
46
39
  </template>
47
40
 
48
41
  <script setup lang="ts" generic="T">
49
42
  import _ from "lodash";
43
+ import type { ErrorObject } from "ajv";
44
+ import type { SimpleAppJsonFormsRef } from "~/types/simpleApp.type";
50
45
  import MiniAppSettingLayout from "./MiniAppSettingLayout.vue";
51
- import CustomFieldFormField from "../../../customField/components/CustomFieldFormField.vue";
52
46
 
53
47
  const props = defineProps<{
54
48
  miniAppCode?: string;
@@ -56,16 +50,22 @@ const props = defineProps<{
56
50
 
57
51
  const _miniAppCode = props.miniAppCode ?? getPathPara("miniAppCode");
58
52
 
59
- const {
60
- isFetching,
61
- miniApp,
62
- miniAppTitle,
63
- schema,
64
- settingSchema,
65
- data,
66
- loadMiniAppDetail,
67
- validateCallBack,
68
- } = useMiniAppSetting(_miniAppCode);
53
+ const { isFetching, miniApp, miniAppTitle, schema, data, loadMiniAppDetail, saveSetting } =
54
+ useMiniAppSetting(_miniAppCode);
55
+
56
+ const jsonForms = ref<SimpleAppJsonFormsRef | null>(null);
57
+ const formErrors = ref<ErrorObject[]>([]);
58
+
59
+ const onFormChange = (_data: any, errors: ErrorObject[]) => {
60
+ formErrors.value = errors;
61
+ };
62
+
63
+ const onSave = async () => {
64
+ jsonForms.value?.changeValidationModeToShow();
65
+ if (!formErrors.value.length) {
66
+ await saveSetting();
67
+ }
68
+ };
69
69
 
70
70
  onMounted(async () => {
71
71
  await loadMiniAppDetail();
@@ -1,15 +0,0 @@
1
- /**
2
- * This file was automatically generated by simpleapp generator during initialization. It is changable.
3
- * --remove-this-line-to-prevent-override--
4
- * last change 2024-02-22
5
- * author: Ks Tan
6
- */
7
- export default {
8
- welcome:'欢迎',
9
- welcomeSimpleApp: '你好,欢迎来到 SimpleApp',
10
- changeHomePageMsg: '改了这面',
11
- category: '类别',
12
- /*manually fix from df.ts.eta*/
13
- }
14
-
15
- // or
@@ -1,19 +0,0 @@
1
-
2
- export default {
3
- //auto generate from lang/default.ts
4
- <%let langkeys = Object.keys(it.lang) %>
5
- <% for(let l=0; l< langkeys.length; l++){ %>
6
- <% let key = langkeys[l] %>
7
- "<%=key%>" : <% if (typeof it.lang[key] === 'object') { %><%~ JSON.stringify(it.lang[key], null, 2) %><% } else { %>"<%~ it.lang[key] %>"<% } %>,
8
- <%}%>
9
-
10
-
11
- //auto generate from schema
12
- <% for(let i=0; i< it.allfields.length; i++){ %>
13
- <% let f = it.allfields[i] %>
14
- <% if(!it.lang[f]){%>
15
- '<%= f %>' : '<%= camelCaseToWords(f) %>',
16
- <%}%>
17
- <%}%>
18
-
19
- }
@@ -1,100 +0,0 @@
1
- <template>
2
- <template v-if="validJsonSchema">
3
- <template v-if="_.isArray(validJsonSchema)"> </template>
4
- <template v-else>
5
- <template v-if="validJsonSchema.type === 'object'">
6
- <template v-if="validJsonSchema['x-foreignkey']">
7
- <CustomFieldFormFieldInput
8
- :jsonSchema="validJsonSchema"
9
- :hierarchy="hierarchy"
10
- :schemaSource="schemaSource"
11
- :handleGetField="handleGetField"
12
- v-model="data[schemaName]"
13
- />
14
- </template>
15
- <template v-else>
16
- <Fieldset class="col-span-2 rounded-xl">
17
- <template #legend>
18
- <span
19
- :class="{
20
- 'mx-2': legendTitle && legendTitle !== '',
21
- }"
22
- >
23
- {{ legendTitle }}
24
- </span>
25
- </template>
26
-
27
- <div
28
- class="grid grid-cols-2 gap-4 p-2"
29
- :class="{
30
- 'pt-4': legendTitle === undefined || legendTitle === '',
31
- }"
32
- >
33
- <template
34
- v-if="validJsonSchema.properties"
35
- v-for="(subSchema, subSchemaName) in validJsonSchema.properties"
36
- :key="subSchemaName"
37
- >
38
- <CustomFieldFormField
39
- :jsonSchema="subSchema"
40
- :data="data[schemaName]"
41
- :schemaSource="schemaSource"
42
- :schemaName="subSchemaName as string"
43
- :handleGetField="handleGetField"
44
- :hierarchy="
45
- hierarchy === '' || hierarchy === undefined
46
- ? (subSchemaName as string)
47
- : `${hierarchy}.${subSchemaName}`
48
- "
49
- />
50
- </template>
51
- </div>
52
- </Fieldset>
53
- </template>
54
- </template>
55
- <template v-else>
56
- <CustomFieldFormFieldInput
57
- :jsonSchema="validJsonSchema"
58
- :hierarchy="hierarchy"
59
- :schemaSource="schemaSource"
60
- :handleGetField="handleGetField"
61
- v-model="data[schemaName]"
62
- />
63
- </template>
64
- </template>
65
- </template>
66
- </template>
67
-
68
- <script setup lang="ts">
69
- import _ from "lodash";
70
- import { SimpleAppJSONSchema7Definition } from "~/types";
71
- import { SchemaSource } from "~/types/customField.type";
72
- import CustomFieldFormFieldInput from "./CustomFieldFormFieldInput.vue";
73
-
74
- const props = defineProps<{
75
- jsonSchema?: SimpleAppJSONSchema7Definition | undefined;
76
- data: any;
77
- hierarchy: string;
78
- schemaName: string;
79
- schemaSource: SchemaSource;
80
- isHideFieldsetLegend?: boolean;
81
- handleGetField: (path: string) => any;
82
- }>();
83
-
84
- const legendTitle = computed(() => {
85
- if (props.isHideFieldsetLegend) return "";
86
-
87
- return (
88
- (props.jsonSchema &&
89
- typeof props.jsonSchema !== "boolean" &&
90
- props.jsonSchema?.title) ??
91
- props.schemaName
92
- );
93
- });
94
- const validJsonSchema = computed(() => {
95
- if (props.jsonSchema !== undefined && typeof props.jsonSchema === "object") {
96
- return props.jsonSchema;
97
- }
98
- return false;
99
- });
100
- </script>
@@ -1,125 +0,0 @@
1
- <template>
2
- <template v-if="jsonSchema.type !== 'array'">
3
- <SimpleAppInput
4
- v-if="fieldPath"
5
- :setting="handleGetField(fieldPath)"
6
- :inputType="inputType"
7
- :hidelabel="isParentIsArray"
8
- v-model="model"
9
- />
10
- </template>
11
- <template
12
- v-else-if="
13
- jsonSchema.type === 'array' &&
14
- jsonSchema.items &&
15
- _.isObject(jsonSchema.items) &&
16
- !Array.isArray(jsonSchema.items)
17
- "
18
- >
19
- <template v-if="jsonSchema.items.type === 'object'">
20
- <div class="col-span-2">
21
- <SimpleAppInputTable
22
- :getField="handleGetField"
23
- class="col-span-4"
24
- :setting="handleGetField(fieldPath)"
25
- v-model="model"
26
- >
27
- <Column
28
- v-if="
29
- jsonSchema.items &&
30
- typeof jsonSchema.items === 'object' &&
31
- 'properties' in jsonSchema.items
32
- "
33
- v-for="(subSchema, subSchemaName) in jsonSchema.items.properties"
34
- :key="subSchemaName"
35
- :field="subSchemaName.toString()"
36
- #body="{ index }"
37
- :header="camelCaseToWords(subSchemaName.toString())"
38
- >
39
- <CustomFieldFormFieldInput
40
- v-if="typeof subSchema === 'object' && subSchema !== null"
41
- :jsonSchema="subSchema"
42
- :hierarchy="
43
- hierarchy === '' || hierarchy === undefined
44
- ? (subSchemaName as string)
45
- : `${hierarchy}.*.${subSchemaName}`
46
- "
47
- :schemaSource="schemaSource"
48
- :handleGetField="handleGetField"
49
- v-model="model[index][subSchemaName]"
50
- />
51
- </Column>
52
-
53
- <Column #body="{ index }" header="Delete">
54
- <ButtonDanger
55
- class="btn-danger"
56
- type="button"
57
- @click="model.splice(index, 1)"
58
- >
59
- X
60
- </ButtonDanger>
61
- </Column>
62
- </SimpleAppInputTable>
63
- </div>
64
- </template>
65
- <template v-else-if="jsonSchema.items.type === 'string'">
66
- <SimpleAppInput
67
- v-if="fieldPath"
68
- :setting="handleGetField(fieldPath)"
69
- :inputType="
70
- (jsonSchema?.inputType as SimpleAppInputType) ??
71
- SimpleAppInputType.chip
72
- "
73
- :hidelabel="isParentIsArray"
74
- v-model="model"
75
- />
76
- </template>
77
- </template>
78
- </template>
79
-
80
- <script setup lang="ts">
81
- import _ from "lodash";
82
- import ButtonDanger from "~/components/button/ButtonDanger.vue";
83
- import { SimpleAppInputType, SimpleAppJSONSchema7 } from "~/types";
84
- import { SchemaSource } from "~/types/customField.type";
85
-
86
- const props = defineProps<{
87
- jsonSchema: SimpleAppJSONSchema7;
88
- hierarchy: string;
89
- handleGetField: any;
90
- schemaSource: SchemaSource;
91
- }>();
92
-
93
- const model = defineModel<any>();
94
-
95
- const fieldPath = computed(() => {
96
- const hierarchies = props.hierarchy.split(".");
97
-
98
- const path = (getFieldPathPrefix() + hierarchies.join("/properties/"))
99
- .replace("properties/*", "items")
100
- .replace("*", "items");
101
-
102
- // if (props.schemaSource === "miniAppSetting") {
103
- // return path.replace("/properties/setting", "");
104
- // }
105
-
106
- return path;
107
- });
108
-
109
- const inputType = computed(() => {
110
- return getInputType(props.jsonSchema);
111
- });
112
-
113
- const isParentIsArray = computed(() => {
114
- const hierarchies = props.hierarchy.split(".");
115
- return hierarchies[hierarchies.length - 2] == "*";
116
- });
117
-
118
- function getFieldPathPrefix() {
119
- if (props.schemaSource === "customField") {
120
- return "#/properties/more/properties/";
121
- }
122
-
123
- return "#/properties/";
124
- }
125
- </script>
@@ -1,40 +0,0 @@
1
- <template>
2
- <section v-if="validProperties" class="space-y-4">
3
- <template
4
- v-for="(groupJsonSchema, groupName) in validProperties"
5
- :key="groupName"
6
- >
7
- <CustomFieldFormField
8
- v-if="isValidSchema(groupJsonSchema)"
9
- :jsonSchema="groupJsonSchema"
10
- :data="data"
11
- :handleGetField="handleGetField"
12
- :schemaName="groupName.toString()"
13
- :hierarchy="groupName.toString()"
14
- schemaSource="customField"
15
- />
16
- </template>
17
- </section>
18
- </template>
19
-
20
- <script setup lang="ts">
21
- import _ from 'lodash';
22
- import { CustomFieldMoreSchema } from '~/simpleapp/generate/features/customField/types/common';
23
- import CustomFieldFormField from './CustomFieldFormField.vue';
24
-
25
- const props = defineProps<{
26
- customFieldJsonSchema: CustomFieldMoreSchema;
27
- data: any;
28
- handleGetField: (path: string) => any;
29
- }>();
30
-
31
- const validProperties = computed(() => {
32
- if (
33
- props.customFieldJsonSchema.properties !== undefined &&
34
- typeof props.customFieldJsonSchema.properties === 'object'
35
- ) {
36
- return props.customFieldJsonSchema.properties;
37
- }
38
- return false;
39
- });
40
- </script>