@simitgroup/simpleapp-generator 1.2.8 → 1.3.0-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.
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +3 -1
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +3 -8
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +14 -14
- package/dist/generate.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/organization.ts +3 -1
- package/src/framework.ts +4 -8
- package/src/generate.ts +17 -16
- package/templates/basic/nest/controller.ts.eta +17 -0
- package/templates/basic/nest/default.ts.eta +6 -2
- package/templates/basic/nuxt/default.ts.eta +10 -6
- package/templates/basic/nuxt/pages.[id].vue.eta +9 -7
- package/templates/basic/nuxt/pages.form.vue.eta +16 -36
- package/templates/basic/nuxt/pages.landing.vue.eta +42 -35
- package/templates/basic/nuxt/pages.viewer.vue.eta +4 -6
- package/templates/nest/.env._eta +0 -1
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +14 -2
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +32 -18
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +76 -13
- package/templates/nuxt/assets/css/style.css._eta +19 -7
- package/templates/nuxt/assets/primevue/passthrough.ts._eta +20 -9
- package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
- package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
- package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
- package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
- package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
- package/templates/nuxt/components/form/readme.md.eta +1 -0
- package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +13 -11
- package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +11 -17
- package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
- package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
- package/templates/nuxt/components/list/ListView.vue.eta +129 -60
- package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
- package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
- package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
- package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
- package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
- package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
- package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
- package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +201 -174
- package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +115 -111
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -263
- package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
- package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
- package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
- package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
- package/templates/nuxt/composables/date.generate.ts.eta +14 -9
- package/templates/nuxt/i18n.config.ts.eta +1 -1
- package/templates/nuxt/lang/en.ts.eta +16 -0
- package/templates/nuxt/layouts/default.vue._eta +32 -17
- package/templates/nuxt/layouts/mobile.vue._eta +35 -12
- package/templates/nuxt/nuxt.config.ts._eta +3 -7
- package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
- package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
- package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
- package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
- package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +38 -4
- package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +29 -292
- package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
- package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
- package/templates/nuxt/pages/[xorg]/user.vue.eta +88 -78
- package/templates/nuxt/pages/profile.vue.eta +12 -3
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +2 -3
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +41 -2
- package/templates/nuxt/types/documentlist.ts.eta +0 -9
- package/templates/nuxt/types/events.ts.eta +1 -0
- package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
- package/templates/nuxt/types/user.ts.eta +2 -0
- package/templates/project/lang/default._json +5 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
- package/templates/nuxt/lang/en.ts._eta +0 -6
- package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
- package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
- package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
- /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
|
@@ -1,193 +1,220 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="!readonly" class="relative">
|
|
3
|
+
<div
|
|
4
|
+
class="absolute h-full top-0 right-10 text-right dark:text-white z-10 align-middle p-3"
|
|
5
|
+
v-if="modelValue?._id"
|
|
6
|
+
>
|
|
7
|
+
<span
|
|
8
|
+
class="pi pi-times rounded-full bg-slate-500 p-1 cursor-pointer text-xs"
|
|
9
|
+
@click="clear"
|
|
10
|
+
></span>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<AutoComplete
|
|
14
|
+
class="w-full"
|
|
15
|
+
v-model="modelValue"
|
|
16
|
+
ref="autocompleteinput"
|
|
17
|
+
forceSelection
|
|
18
|
+
optionLabel="label"
|
|
19
|
+
@focus="setFocus"
|
|
20
|
+
@item-select="pickAutoComplete"
|
|
21
|
+
@complete="getListFromAutocompleteApi"
|
|
22
|
+
:placeholder="placeholdertxt"
|
|
23
|
+
:dropdown="true"
|
|
24
|
+
@clear="clear"
|
|
25
|
+
:dropdown-mode="'current'"
|
|
26
|
+
:pt="pt"
|
|
27
|
+
:delay="500"
|
|
28
|
+
:disabled="readonly"
|
|
29
|
+
:suggestions="list"
|
|
30
|
+
@blur="onBlurAutocomplete"
|
|
31
|
+
:inputId="inputId"
|
|
32
|
+
:path="setting.instancepath"
|
|
33
|
+
:readonly="readonly"
|
|
34
|
+
>
|
|
35
|
+
<template #header>
|
|
36
|
+
<slot name="header">
|
|
37
|
+
<div class="flex flex-row font font-bold dark:text-white">
|
|
38
|
+
<div class="w w-1/3">{{ t(codefield) ?? t("code") }}</div>
|
|
39
|
+
<div class="w w-2/3">{{ t(labelfield) ?? t("label") }}</div>
|
|
40
|
+
</div>
|
|
41
|
+
</slot>
|
|
42
|
+
</template>
|
|
43
|
+
<template #content>
|
|
44
|
+
<div class="bg-red-300">content</div>
|
|
45
|
+
</template>
|
|
46
|
+
<template #option="{ index, option }">
|
|
47
|
+
<slot name="option" :index="index" :option="option">
|
|
48
|
+
<div class="flex flex-row dark:text-white">
|
|
49
|
+
<div class="w w-1/3">{{ option.code }}</div>
|
|
50
|
+
<div class="w w-2/3">{{ option.label }}</div>
|
|
51
|
+
</div>
|
|
52
|
+
</slot>
|
|
53
|
+
</template>
|
|
54
|
+
<!-- </slot> -->
|
|
55
|
+
</AutoComplete>
|
|
56
|
+
</div>
|
|
57
|
+
<div
|
|
58
|
+
v-else
|
|
59
|
+
class="p-3 border rounded-lg border-gray-300 dark:border-blue-900/40"
|
|
60
|
+
>
|
|
61
|
+
<span
|
|
62
|
+
:readonly="readonly"
|
|
63
|
+
class="cursor-pointer text-primary-600 dark:text-primary-400"
|
|
64
|
+
tabindex="0"
|
|
65
|
+
@click="openViewer(true)"
|
|
66
|
+
>{{ modelValue && modelValue.label ? modelValue.label : "-" }}</span
|
|
67
|
+
>
|
|
68
|
+
</div>
|
|
43
69
|
</template>
|
|
44
70
|
<script setup lang="ts">
|
|
45
|
-
import { isNull } from
|
|
46
|
-
import * as jsonpath from
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const labelfield = schema['x-simpleapp-config'].documentTitle as string
|
|
69
|
-
const codefield = schema['x-simpleapp-config'].uniqueKey as string
|
|
70
|
-
const docname = props.setting.fieldsetting['x-foreignkey']
|
|
71
|
-
|
|
72
|
-
const emptyautocomplete = computed(():autocompletetype=> queryresult)
|
|
71
|
+
import { isNull } from "lodash";
|
|
72
|
+
import * as jsonpath from "jsonpath";
|
|
73
|
+
import { AutoCompleteDropdownClickEvent } from "primevue/autocomplete";
|
|
74
|
+
import { autocompletetype, SchemaConfig, SchemaType } from "~/types";
|
|
75
|
+
const autocompleteinput = ref<autocompletetype|undefined>();
|
|
76
|
+
const { $event } = useNuxtApp();
|
|
77
|
+
const list = ref<any[]>([]);
|
|
78
|
+
const props = withDefaults(
|
|
79
|
+
defineProps<{
|
|
80
|
+
setting: any;
|
|
81
|
+
allowAddNew?: boolean;
|
|
82
|
+
showNull?: boolean;
|
|
83
|
+
readonly?: boolean;
|
|
84
|
+
placeholder?:string;
|
|
85
|
+
hidelabel?:boolean;
|
|
86
|
+
inputId: string;
|
|
87
|
+
pt?: any;
|
|
88
|
+
}>(),
|
|
89
|
+
{
|
|
90
|
+
allowAddNew: true,
|
|
91
|
+
showNull: true,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
73
94
|
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
const path = "$" + props.setting.instancepath;
|
|
96
|
+
const modifiedpath = path.replaceAll("/", ".");
|
|
97
|
+
const queryresult = jsonpath.query(props.setting.defaultValue, modifiedpath)[0];
|
|
98
|
+
const remotedoc = getDocument(props.setting.fieldsetting["x-foreignkey"]);
|
|
99
|
+
const schema: SchemaType = <SchemaType>remotedoc?.docClass.getSchema();
|
|
100
|
+
const labelfield = schema["x-simpleapp-config"].documentTitle as string;
|
|
101
|
+
const codefield = schema["x-simpleapp-config"].uniqueKey as string;
|
|
102
|
+
const docname = props.setting.fieldsetting["x-foreignkey"];
|
|
103
|
+
const placeholdertxt = computed(()=> props.placeholder ?? t(docname) )
|
|
104
|
+
const emptyautocomplete = computed((): autocompletetype => queryresult);
|
|
105
|
+
const cancelShowList = ref(false);
|
|
106
|
+
const autocompleteitem = ref<autocompletetype|undefined>(emptyautocomplete.value);
|
|
107
|
+
const modelValue = defineModel<autocompletetype|undefined>({ required: true });
|
|
108
|
+
if (modelValue.value && modelValue.value._id) {
|
|
109
|
+
autocompleteitem.value = { ...modelValue.value };
|
|
78
110
|
}
|
|
79
111
|
//clear auto complete auto set value = empty
|
|
80
|
-
const clear = ()=>{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const buttonClass=computed(()=>modelValue.value?._id ? 'pi pi-link' : 'pi pi-angle-down')
|
|
112
|
+
const clear = () => {
|
|
113
|
+
autocompleteitem.value = undefined
|
|
114
|
+
modelValue.value = undefined
|
|
115
|
+
};
|
|
85
116
|
|
|
86
117
|
//if record picked, click button show record info instead
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
118
|
+
const openlink = () => {
|
|
119
|
+
if (modelValue.value?._id) {
|
|
120
|
+
openViewer(true);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
93
124
|
//recorrect data if lose focus
|
|
94
|
-
const onBlurAutocomplete = ()=>{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
125
|
+
const onBlurAutocomplete = () => {
|
|
126
|
+
if (autocompleteitem.value === null) {
|
|
127
|
+
autocompleteitem.value = emptyautocomplete.value;
|
|
128
|
+
}
|
|
129
|
+
if (isNull(modelValue.value)) {
|
|
130
|
+
modelValue.value = autocompleteitem.value;
|
|
131
|
+
} else if (typeof modelValue.value == "object") {
|
|
132
|
+
} else {
|
|
133
|
+
modelValue.value = autocompleteitem.value;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
107
136
|
|
|
108
137
|
//obtain remote data
|
|
109
|
-
const getListFromAutocompleteApi =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
const getListFromAutocompleteApi = (event: any) => {
|
|
139
|
+
const keyword = event.query ?? "";
|
|
140
|
+
const targetDocument = props.setting.fieldsetting["x-foreignkey"];
|
|
141
|
+
getDocumentApi(targetDocument)
|
|
142
|
+
.autoComplete(keyword)
|
|
143
|
+
.then((res: any) => {
|
|
144
|
+
list.value = res.data;
|
|
113
145
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
146
|
+
if (props.allowAddNew) {
|
|
147
|
+
list.value = list.value.concat({
|
|
148
|
+
_id: "new",
|
|
149
|
+
label: "<" + t("new") + ">",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
121
154
|
|
|
122
155
|
//on select
|
|
123
|
-
const pickAutoComplete = (event:any)=>{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const emits = defineEmits(['change','update:modelValue','update:docNoFormat'])
|
|
140
|
-
watch(modelValue ,(newvalue:any)=>{
|
|
141
|
-
|
|
142
|
-
emitChanges()
|
|
143
|
-
|
|
144
|
-
})
|
|
145
|
-
const emitChanges = () =>{
|
|
146
|
-
|
|
147
|
-
emits('change',modelValue.value)
|
|
148
|
-
|
|
149
|
-
}
|
|
156
|
+
const pickAutoComplete = (event: any) => {
|
|
157
|
+
if (event.value._id === "") {
|
|
158
|
+
modelValue.value = emptyautocomplete.value;
|
|
159
|
+
autocompleteitem.value = emptyautocomplete.value;
|
|
160
|
+
} else if (event.value._id === "new") {
|
|
161
|
+
modelValue.value = emptyautocomplete.value;
|
|
162
|
+
autocompleteitem.value = emptyautocomplete.value;
|
|
163
|
+
openViewer(false);
|
|
164
|
+
} else if (typeof event.value.query == "undefined") {
|
|
165
|
+
modelValue.value = event.value;
|
|
166
|
+
autocompleteitem.value = event.value;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
150
169
|
|
|
170
|
+
const emits = defineEmits([
|
|
171
|
+
"change",
|
|
172
|
+
"update:modelValue",
|
|
173
|
+
"update:docNoFormat",
|
|
174
|
+
]);
|
|
175
|
+
watch(modelValue, (newvalue: any) => {
|
|
176
|
+
emitChanges();
|
|
177
|
+
});
|
|
178
|
+
const emitChanges = () => {
|
|
179
|
+
emits("change", modelValue.value);
|
|
180
|
+
};
|
|
151
181
|
|
|
152
|
-
const setFocus = (ev:any) => {
|
|
153
|
-
|
|
154
|
-
}
|
|
182
|
+
const setFocus = (ev: any) => {
|
|
183
|
+
if (!isMobile()) ev.target.select();
|
|
184
|
+
};
|
|
155
185
|
|
|
156
186
|
//pop up records
|
|
157
|
-
const openViewer = (readonly:boolean) =>{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
const openViewer = (readonly: boolean) => {
|
|
188
|
+
if (remotedoc) {
|
|
189
|
+
$event("ViewRecord", {
|
|
190
|
+
_id: modelValue.value?._id as string,
|
|
191
|
+
eventId: randomUUID(),
|
|
192
|
+
label: (readonly
|
|
193
|
+
? modelValue.value?.label
|
|
194
|
+
: `${t("new") + " " + t(docname)}`) as string,
|
|
195
|
+
readonly: readonly,
|
|
196
|
+
viewer: getDocument(docname)?.viewer,
|
|
197
|
+
documentName: docname,
|
|
168
198
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
}
|
|
199
|
+
//after create, auto copy value into auto complete
|
|
200
|
+
after: (eventType: string, data: any, result: any) => {
|
|
201
|
+
autocompleteitem.value = {
|
|
202
|
+
_id: data._id,
|
|
203
|
+
code: data[codefield],
|
|
204
|
+
label: data[labelfield],
|
|
205
|
+
};
|
|
206
|
+
if (schema["x-simpleapp-config"].additionalAutoCompleteFields) {
|
|
207
|
+
const addfields =
|
|
208
|
+
schema["x-simpleapp-config"].additionalAutoCompleteFields;
|
|
209
|
+
for (let i = 0; i < addfields.length; i++) {
|
|
210
|
+
const fieldname = addfields[i] as string;
|
|
211
|
+
autocompleteitem.value[fieldname] = data[fieldname];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
modelValue.value = { ...autocompleteitem.value };
|
|
215
|
+
emitChanges();
|
|
216
|
+
},
|
|
217
|
+
});
|
|
191
218
|
}
|
|
192
|
-
|
|
193
|
-
</script>
|
|
219
|
+
};
|
|
220
|
+
</script>
|
|
@@ -1,130 +1,134 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<div v-if="schema" :class="getLayoutClass()">
|
|
3
|
+
<label v-if="hidelabel"></label>
|
|
4
|
+
<label v-else :for="uuid" :class="getLabelClass()"
|
|
5
|
+
>{{ fieldlabel }}
|
|
6
|
+
<span
|
|
7
|
+
v-if="props.setting.isrequired && fieldlabel"
|
|
8
|
+
class="text-danger-600 dark:text-danger-400"
|
|
9
|
+
>*</span
|
|
10
|
+
></label
|
|
11
|
+
>
|
|
12
|
+
<!-- <label v-else-if="error" class="simpleapp-input-label text-danger-600 overflow-hidden" :for="uuid">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label>
|
|
6
13
|
<label v-else :for="uuid" class="simpleapp-input-label whitespace-nowrap text-gray-500 truncate">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label> -->
|
|
7
|
-
|
|
8
|
-
<!-- <div :uuid="uuid" >{{ modelValue }}</div> -->
|
|
9
|
-
<!-- <div v-if="typeof modelValue =='object' && typeof modelValue['_id']!='undefined' && typeof modelValue['label']!='undefined' && readonly ==true " :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue['label'] }}</div> -->
|
|
10
|
-
<!-- <div v-else-if="readonly==true" :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue }}</div> -->
|
|
11
|
-
<!-- <slot v-else name="default" :uuid="uuid" :error="error"></slot> -->
|
|
12
|
-
<slot name="default" :uuid="uuid" :error="error"></slot>
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</div>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
<!-- <div :uuid="uuid" >{{ modelValue }}</div> -->
|
|
16
|
+
<!-- <div v-if="typeof modelValue =='object' && typeof modelValue['_id']!='undefined' && typeof modelValue['label']!='undefined' && readonly ==true " :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue['label'] }}</div> -->
|
|
17
|
+
<!-- <div v-else-if="readonly==true" :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue }}</div> -->
|
|
18
|
+
<!-- <slot v-else name="default" :uuid="uuid" :error="error"></slot> -->
|
|
19
|
+
<slot name="default" :uuid="uuid" :error="error"></slot>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<small v-if="error" class="text-danger-600 dark:text-danger-400">{{ error }}</small>
|
|
23
|
+
<small v-else class="input-desc">{{ fielddesc }}</small>
|
|
24
|
+
</div>
|
|
25
|
+
<div v-else :class="defaultcssclass">
|
|
26
|
+
<label class="etext-danger-600 dark:text-danger-400">wrong path in getField()</label>
|
|
27
|
+
<div class="text-danger-600 dark:text-danger-400">{{ props.setting.path }}</div>
|
|
28
|
+
</div>
|
|
21
29
|
</template>
|
|
22
30
|
<script setup lang="ts">
|
|
23
|
-
import SimpleAppValue from
|
|
31
|
+
import SimpleAppValue from "./SimpleAppValue.vue";
|
|
24
32
|
// import {camelCaseToWords} from './helper'
|
|
25
33
|
// import {computed,setBlockTracking,watch} from 'vue'
|
|
26
34
|
|
|
27
|
-
import {ref} from
|
|
28
|
-
|
|
35
|
+
import { ref } from "vue";
|
|
29
36
|
|
|
30
|
-
const uuid =
|
|
37
|
+
const uuid = randomUUID();
|
|
31
38
|
// const fieldlabel = ref('')
|
|
32
39
|
// const fielddesc = ref('')
|
|
33
|
-
const defaultcssclass=
|
|
34
|
-
const fieldcontainerclass = ref(defaultcssclass)
|
|
35
|
-
let instancepath = ref(
|
|
40
|
+
const defaultcssclass = "simpleapp-input-container";
|
|
41
|
+
const fieldcontainerclass = ref(defaultcssclass);
|
|
42
|
+
let instancepath = ref("");
|
|
36
43
|
const props = defineProps<{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}>()
|
|
46
|
-
|
|
47
|
-
const readonly = computed(()=>{
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const modelValue = defineModel<any>() //this model value support all kind of data, string, number, autocomplete and etc
|
|
52
|
-
const readonlyclass="simpleapp-value-readonly"
|
|
44
|
+
label?: string;
|
|
45
|
+
inputType: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
instancepath?: string;
|
|
48
|
+
hidelabel?: boolean;
|
|
49
|
+
readonly?: boolean;
|
|
50
|
+
// error?:string,
|
|
51
|
+
setting: any;
|
|
52
|
+
}>();
|
|
53
|
+
|
|
54
|
+
const readonly = computed(() => {
|
|
55
|
+
return props.readonly ?? props.setting.readonly ?? false;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const modelValue = defineModel<any>(); //this model value support all kind of data, string, number, autocomplete and etc
|
|
59
|
+
const readonlyclass = "simpleapp-value-readonly";
|
|
53
60
|
// console.log('props.setting',modelValue.value,props.setting)
|
|
54
|
-
let schema:any
|
|
61
|
+
let schema: any;
|
|
55
62
|
|
|
56
|
-
const getLayoutClass = () =>
|
|
63
|
+
const getLayoutClass = () =>
|
|
64
|
+
`simpleapp-input-container flex ${
|
|
65
|
+
props.inputType == "checkbox"
|
|
66
|
+
? " flex-row gap-4 mt-1 ml-1 "
|
|
67
|
+
: "flex flex-col "
|
|
68
|
+
}`;
|
|
57
69
|
|
|
58
70
|
const getLabelClass = () => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
let class1 =
|
|
72
|
+
"simpleapp-input-label text-left text-gray-500 dark:text-gray-200 ";
|
|
73
|
+
|
|
74
|
+
if (!isMobile()) class1 += "whitespace-nowrap truncate";
|
|
75
|
+
else if (props.inputType == "checkbox") class1 += " ml-1 dark:text-gray-200";
|
|
76
|
+
else if (props.inputType != "autocomplete" && modelValue.value)
|
|
77
|
+
class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
|
|
78
|
+
else if (props.inputType == "autocomplete" && modelValue.value?.label)
|
|
79
|
+
class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
|
|
80
|
+
else if (modelValue.value !== undefined)
|
|
81
|
+
class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
|
|
82
|
+
else class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100 hidden";
|
|
83
|
+
return class1;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const fielddesc = computed(() => {
|
|
87
|
+
return props.description ?? "";
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (props.setting.fieldsetting && props.setting.fieldsetting.type) {
|
|
91
|
+
schema = props.setting.fieldsetting;
|
|
92
|
+
// console.log("schema setting",props.setting,schema)
|
|
93
|
+
if (props?.instancepath) instancepath.value = props.instancepath;
|
|
94
|
+
else if (props.setting?.instancepath)
|
|
95
|
+
instancepath.value = props.setting.instancepath;
|
|
96
|
+
else instancepath.value = "/unknown";
|
|
97
|
+
|
|
98
|
+
const fieldnamearr = instancepath.value.split("/");
|
|
99
|
+
const fieldname = camelCaseToWords(fieldnamearr[fieldnamearr.length - 1]);
|
|
100
|
+
|
|
101
|
+
// if(props.description)fielddesc.value = props.description
|
|
102
|
+
// else if (schema?.description != 'undefined') fielddesc.value=schema.description
|
|
103
|
+
// else fielddesc.value=''
|
|
67
104
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// if(props.description)fielddesc.value = props.description
|
|
90
|
-
// else if (schema?.description != 'undefined') fielddesc.value=schema.description
|
|
91
|
-
// else fielddesc.value=''
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const fieldlabel = computed(()=>{
|
|
97
|
-
|
|
98
|
-
if(props.label){
|
|
99
|
-
return t(props.label)
|
|
100
|
-
}
|
|
101
|
-
else if (schema.title ) {
|
|
102
|
-
return t(schema.title)
|
|
103
|
-
}
|
|
104
|
-
else{
|
|
105
|
-
return t(props.setting.key)
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
const errormsg = computed(()=>{
|
|
109
|
-
|
|
110
|
-
props.setting.errors[instancepath.value]
|
|
111
|
-
})
|
|
112
|
-
const error = ref("")
|
|
113
|
-
watch(props.setting.errors,(newvalue,oldvalue)=>{
|
|
114
|
-
//it is array
|
|
115
|
-
error.value=''
|
|
116
|
-
if(newvalue[instancepath.value]){
|
|
117
|
-
const errlist:any[] = newvalue[instancepath.value]
|
|
118
|
-
for(let i=0;i<errlist.length;i++){
|
|
119
|
-
error.value += errlist[i].message +','
|
|
120
|
-
}
|
|
121
|
-
fieldcontainerclass.value=defaultcssclass + ' input-error'
|
|
122
|
-
}else{
|
|
123
|
-
error.value=''
|
|
124
|
-
fieldcontainerclass.value=defaultcssclass
|
|
105
|
+
const fieldlabel = computed(() => {
|
|
106
|
+
if (props.label) {
|
|
107
|
+
return t(props.label);
|
|
108
|
+
} else if (schema.title) {
|
|
109
|
+
return t(schema.title);
|
|
110
|
+
} else {
|
|
111
|
+
return t(props.setting.key);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const errormsg = computed(() => {
|
|
115
|
+
props.setting.errors[instancepath.value];
|
|
116
|
+
});
|
|
117
|
+
const error = ref("");
|
|
118
|
+
watch(props.setting.errors, (newvalue, oldvalue) => {
|
|
119
|
+
//it is array
|
|
120
|
+
error.value = "";
|
|
121
|
+
if (newvalue[instancepath.value]) {
|
|
122
|
+
const errlist: any[] = newvalue[instancepath.value];
|
|
123
|
+
for (let i = 0; i < errlist.length; i++) {
|
|
124
|
+
error.value += errlist[i].message + ",";
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
fieldcontainerclass.value = defaultcssclass + " input-error";
|
|
127
|
+
} else {
|
|
128
|
+
error.value = "";
|
|
129
|
+
fieldcontainerclass.value = defaultcssclass;
|
|
130
|
+
}
|
|
131
|
+
// console.log("validation result",props.setting.instancepath,)
|
|
132
|
+
// error.value = newvalue[props.setting.instancepath].message
|
|
133
|
+
});
|
|
130
134
|
</script>
|