@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.
Files changed (84) hide show
  1. package/dist/buildinschemas/organization.d.ts.map +1 -1
  2. package/dist/buildinschemas/organization.js +3 -1
  3. package/dist/buildinschemas/organization.js.map +1 -1
  4. package/dist/framework.d.ts.map +1 -1
  5. package/dist/framework.js +3 -8
  6. package/dist/framework.js.map +1 -1
  7. package/dist/generate.js +14 -14
  8. package/dist/generate.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/buildinschemas/organization.ts +3 -1
  11. package/src/framework.ts +4 -8
  12. package/src/generate.ts +17 -16
  13. package/templates/basic/nest/controller.ts.eta +17 -0
  14. package/templates/basic/nest/default.ts.eta +6 -2
  15. package/templates/basic/nuxt/default.ts.eta +10 -6
  16. package/templates/basic/nuxt/pages.[id].vue.eta +9 -7
  17. package/templates/basic/nuxt/pages.form.vue.eta +16 -36
  18. package/templates/basic/nuxt/pages.landing.vue.eta +42 -35
  19. package/templates/basic/nuxt/pages.viewer.vue.eta +4 -6
  20. package/templates/nest/.env._eta +0 -1
  21. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +14 -2
  22. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +32 -18
  23. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +76 -13
  24. package/templates/nuxt/assets/css/style.css._eta +19 -7
  25. package/templates/nuxt/assets/primevue/passthrough.ts._eta +20 -9
  26. package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
  27. package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
  28. package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
  29. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
  30. package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
  31. package/templates/nuxt/components/form/readme.md.eta +1 -0
  32. package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +13 -11
  33. package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +11 -17
  34. package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
  35. package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
  36. package/templates/nuxt/components/list/ListView.vue.eta +129 -60
  37. package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
  38. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
  39. package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
  40. package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
  41. package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
  42. package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
  43. package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
  44. package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
  45. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +201 -174
  46. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +115 -111
  47. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
  48. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -263
  49. package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
  50. package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
  51. package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
  52. package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
  53. package/templates/nuxt/composables/date.generate.ts.eta +14 -9
  54. package/templates/nuxt/i18n.config.ts.eta +1 -1
  55. package/templates/nuxt/lang/en.ts.eta +16 -0
  56. package/templates/nuxt/layouts/default.vue._eta +32 -17
  57. package/templates/nuxt/layouts/mobile.vue._eta +35 -12
  58. package/templates/nuxt/nuxt.config.ts._eta +3 -7
  59. package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
  60. package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
  61. package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
  62. package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
  63. package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +38 -4
  64. package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
  65. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +29 -292
  66. package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
  67. package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
  68. package/templates/nuxt/pages/[xorg]/user.vue.eta +88 -78
  69. package/templates/nuxt/pages/profile.vue.eta +12 -3
  70. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +2 -3
  71. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
  72. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +41 -2
  73. package/templates/nuxt/types/documentlist.ts.eta +0 -9
  74. package/templates/nuxt/types/events.ts.eta +1 -0
  75. package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
  76. package/templates/nuxt/types/user.ts.eta +2 -0
  77. package/templates/project/lang/default._json +5 -0
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
  80. package/templates/nuxt/lang/en.ts._eta +0 -6
  81. package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
  82. package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
  83. package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
  84. /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
@@ -1,193 +1,220 @@
1
- <template>
2
- <AutoComplete v-model="modelValue" v-if="!readonly" ref="autocompleteinput"
3
- forceSelection optionLabel="label"
4
- @focus="setFocus"
5
- @item-select="pickAutoComplete"
6
- @complete="getListFromAutocompleteApi"
7
- :placeholder="t('keyword')"
8
- :dropdown="true"
9
- :dropdown-icon="buttonClass"
10
- @before-show="beforeShow"
11
- @clear = "clear"
12
- :dropdown-mode="'current'"
13
- :pt="pt"
14
- :delay="500"
15
- :disabled="readonly"
16
- :suggestions="list"
17
- @blur="onBlurAutocomplete"
18
- :inputId="inputId" :path="setting.instancepath"
19
- :readonly="readonly"
20
- >
21
- <template #header>
22
- <slot name="header">
23
- <div class="flex flex-row font font-bold dark:text-white">
24
- <div class="w w-1/3">{{ t(codefield) ?? t('code') }}</div>
25
- <div class="w w-2/3" >{{ t(labelfield) ?? t('label') }}</div>
26
- </div>
27
- </slot>
28
- </template>
29
- <template #option="{index,option}">
30
- <slot name="option" :index="index" :option="option">
31
- <div class="flex flex-row dark:text-white">
32
- <div class="w w-1/3" >{{ option.code }}</div>
33
- <div class="w w-2/3" >{{ option.label }}</div>
34
- </div>
35
- </slot>
36
- </template>
37
- <!-- </slot> -->
38
- </AutoComplete>
39
- <div v-else class="p-3 border rounded-lg border-gray-300 dark:border-blue-900/40 ">
40
- <span :readonly="readonly" class="cursor-pointer text-primary-600 dark:text-primary-400 "
41
- tabindex="0" @click="openViewer(true)">{{ modelValue && modelValue.label ? modelValue.label:'-' }}</span>
42
- </div>
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 'lodash';
46
- import * as jsonpath from 'jsonpath';
47
- import {autocompletetype,SchemaConfig,SchemaType} from '~/types'
48
- const autocompleteinput = ref()
49
- const {$event} = useNuxtApp()
50
- const list = ref<any[]>([])
51
- const props = withDefaults(defineProps<{
52
- setting:any
53
- allowAddNew?:boolean
54
- showNull?:boolean
55
- readonly?:boolean
56
- inputId:string
57
- pt?:any
58
- }>(),{
59
- allowAddNew:true,showNull:true
60
- })
61
-
62
- const path = '$'+props.setting.instancepath
63
- const modifiedpath = path.replaceAll('/','.')
64
- const queryresult = jsonpath.query(props.setting.defaultValue,modifiedpath)[0]
65
- const remotedoc = getDocument(props.setting.fieldsetting['x-foreignkey'])
66
- const schema:SchemaType = <SchemaType>remotedoc?.docClass.getSchema()
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 autocompleteitem = ref<autocompletetype>(emptyautocomplete.value)
75
- const modelValue = defineModel<autocompletetype>({required:true})
76
- if(modelValue.value && modelValue.value._id){
77
- autocompleteitem.value={...modelValue.value}
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
- autocompleteitem.value = emptyautocomplete.value
82
- modelValue.value = emptyautocomplete.value
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 beforeShow = ()=>{
88
- if(modelValue.value?._id ){
89
- openViewer(true)
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
- if( autocompleteitem.value === null){
96
- autocompleteitem.value = emptyautocomplete.value
97
- }
98
- if(isNull(modelValue.value )){
99
- modelValue.value = autocompleteitem.value
100
- }
101
- else if(typeof modelValue.value =='object'){
102
-
103
- }else{
104
- modelValue.value = autocompleteitem.value
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 = (event:any)=>{
110
- const keyword = event.query??''
111
- const targetDocument = props.setting.fieldsetting['x-foreignkey']
112
- getDocumentApi(targetDocument).autoComplete(keyword).then((res:any)=>{
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
- list.value = res.data
115
-
116
- if(props.allowAddNew){
117
- list.value = list.value.concat({_id:'new',label:'<'+t('new')+'>'})
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
- if(event.value._id===''){
125
- modelValue.value = emptyautocomplete.value
126
- autocompleteitem.value = emptyautocomplete.value
127
- } else if(event.value._id==='new'){
128
-
129
- modelValue.value = emptyautocomplete.value
130
- autocompleteitem.value = emptyautocomplete.value
131
- openViewer(false)
132
- }
133
- else if(typeof event.value.query == 'undefined'){
134
- modelValue.value=event.value
135
- autocompleteitem.value = event.value
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
- if(!isMobile()) ev.target.select()
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
- if(remotedoc){
160
-
161
- $event('ViewRecord',{
162
- _id: modelValue.value?._id as string,
163
- eventId: randomUUID(),
164
- label: (readonly ? modelValue.value?.label : `${t('new') + ' '+ t(docname) }`) as string,
165
- readonly:readonly,
166
- viewer : getDocument(docname)?.viewer,
167
- documentName: docname,
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
- //after create, auto copy value into auto complete
170
- after:(eventType:string,data:any,result:any)=>{
171
- autocompleteitem.value = {
172
- _id: data._id,
173
- code: data[codefield],
174
- label: data[labelfield],
175
- }
176
- if(schema['x-simpleapp-config'].additionalAutoCompleteFields){
177
- const addfields = schema['x-simpleapp-config'].additionalAutoCompleteFields
178
- for(let i=0;i<addfields.length;i++){
179
- const fieldname = addfields[i] as string
180
- autocompleteitem.value[fieldname] = data[fieldname]
181
- }
182
- }
183
- modelValue.value = {...autocompleteitem.value}
184
- emitChanges()
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
- <div v-if="schema" :class="getLayoutClass()">
3
- <label v-if="hidelabel"></label>
4
- <label v-else :for="uuid" :class="getLabelClass()" @click="console.log(inputType)">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label>
5
- <!-- <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>
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
- <small v-if="error" class="text-danger-600">{{ error }}</small>
15
- <small v-else class="input-desc">{{ fielddesc }}</small>
16
- </div>
17
- <div v-else :class="defaultcssclass">
18
- <label class="etext-danger-600">wrong path in getField()</label>
19
- <div class="text-danger-600">{{ props.setting.path }}</div>
20
- </div>
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 './SimpleAppValue.vue'
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 'vue'
28
-
35
+ import { ref } from "vue";
29
36
 
30
- const uuid = randomUUID();
37
+ const uuid = randomUUID();
31
38
  // const fieldlabel = ref('')
32
39
  // const fielddesc = ref('')
33
- const defaultcssclass='simpleapp-input-container'
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
- label?: string,
38
- inputType: string,
39
- description?: string,
40
- instancepath?:string,
41
- hidelabel?:boolean,
42
- readonly?:boolean
43
- // error?:string,
44
- setting:any
45
- }>()
46
-
47
- const readonly = computed(()=>{
48
- return props.readonly ?? props.setting.readonly ?? false
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 = () => `simpleapp-input-container flex ${ props.inputType == 'checkbox' ? " flex-row gap-4 mt-1 ml-1 " : "flex flex-col "}`
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
- let class1= "simpleapp-input-label text-left text-gray-500 "
60
- if(!isMobile()) class1 += "whitespace-nowrap truncate"
61
- else if (props.inputType == 'checkbox' ) class1 += " ml-1 dark:text-grey-200"
62
- else if (props.inputType != 'autocomplete' && modelValue.value) class1 += "-mb-4 ml-1 z-50 text-xs dark:text-grey-100"
63
- else if (props.inputType == 'autocomplete' && modelValue.value?.label) class1 += "-mb-4 ml-1 z-50 text-xs dark:text-grey-100"
64
- else if (props.inputType == 'number' && modelValue.value !== undefined) class1 += "-mb-4 ml-1 z-50 text-xs dark:text-grey-100"
65
- else class1 += "-mb-4 ml-1 z-50 text-xs dark:text-grey-100 hidden"
66
- return class1
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
- const fielddesc = computed(()=>{
72
- return props.description ?? ''
73
- })
74
-
75
- if(props.setting.fieldsetting && props.setting.fieldsetting.type){
76
-
77
- schema = props.setting.fieldsetting
78
- // console.log("schema setting",props.setting,schema)
79
- if(props?.instancepath) instancepath.value =props.instancepath
80
- else if(props.setting?.instancepath) instancepath.value = props.setting.instancepath
81
- else instancepath.value='/unknown'
82
-
83
- const fieldnamearr = instancepath.value.split('/')
84
- const fieldname = camelCaseToWords(fieldnamearr[fieldnamearr.length-1])
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
- // console.log("validation result",props.setting.instancepath,)
127
- // error.value = newvalue[props.setting.instancepath].message
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>