@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,294 +1,414 @@
1
1
  <template>
2
- <SimpleAppFieldContainer :hidelabel="hidelabel" v-model="modelValue"
3
- :label="label" :description="description" :pt="pt" :inputType="inputType"
4
- :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
5
- <Checkbox v-if="inputType ==SimpleAppInputType.checkbox" :readonly="isReadonly" :pt="pt"
6
- :inputId="slotprops.uuid" :path="setting.instancepath"
7
- v-model="modelValue" :binary="true"
8
- v-bind="(componentProps as CheckboxProps)"/>
9
- <InputSwitch v-else-if="inputType ==SimpleAppInputType.switch" :readonly="isReadonly" :pt="pt"
10
- :inputId="slotprops.uuid" :path="setting.instancepath"
11
- v-model="modelValue as boolean" :binary="true"
12
- v-bind="(componentProps as InputSwitchProps)"/>
2
+ <SimpleAppFieldContainer
3
+ :hidelabel="hidelabel"
4
+ v-model="modelValue"
5
+ :label="label"
6
+ :description="description"
7
+ :pt="pt"
8
+ :inputType="inputType"
9
+ :setting="setting"
10
+ :instancepath="instancepath"
11
+ :error="error"
12
+ #default="slotprops"
13
+ >
14
+ <Checkbox
15
+ v-if="inputType == SimpleAppInputType.checkbox"
16
+ :readonly="isReadonly"
17
+ :pt="pt"
18
+ :inputId="slotprops.uuid"
19
+ :path="setting.instancepath"
20
+ v-model="modelValue"
21
+ :binary="true"
22
+ v-bind="componentProps as CheckboxProps"
23
+ />
24
+ <InputSwitch
25
+ v-else-if="inputType == SimpleAppInputType.switch"
26
+ :readonly="isReadonly"
27
+ :pt="pt"
28
+ :inputId="slotprops.uuid"
29
+ :path="setting.instancepath"
30
+ v-model="modelValue as boolean"
31
+ :binary="true"
32
+ v-bind="componentProps as InputSwitchProps"
33
+ />
13
34
 
14
- <InputText type="date" :pt="pt"
15
- v-else-if="inputType == SimpleAppInputType.date"
16
- :inputId="slotprops.uuid" :path="setting.instancepath"
17
- v-model="datevalue" @update:modelValue="updateDate" :readonly="isReadonly"
18
- :placeholder="placeholder"
19
- v-bind="(componentProps as InputTextProps)"/>
20
- <!-- calendar component -->
21
- <Calendar type="date" :pt="pt" class="flex flex-col"
22
- v-else-if="SimpleAppInputType.calendar==inputType"
23
- :inputId="slotprops.uuid" :path="setting.instancepath"
24
- v-model="datevalue" @update:modelValue="updateDate" :readonly="isReadonly"
25
- :placeholder="placeholder"
26
- v-bind="(componentProps as CalendarProps)"/>
35
+ <InputText
36
+ type="date"
37
+ :pt="pt"
38
+ v-else-if="inputType == SimpleAppInputType.date"
39
+ :inputId="slotprops.uuid"
40
+ :path="setting.instancepath"
41
+ v-model="datevalue"
42
+ @update:modelValue="updateDate"
43
+ :readonly="isReadonly"
44
+ :placeholder="placeholder"
45
+ v-bind="componentProps as InputTextProps"
46
+ />
47
+ <!-- calendar component -->
48
+ <Calendar
49
+ type="date"
50
+ :pt="pt"
51
+ class="flex flex-col"
52
+ v-else-if="SimpleAppInputType.calendar == inputType"
53
+ :inputId="slotprops.uuid"
54
+ :path="setting.instancepath"
55
+ v-model="datevalue"
56
+ @update:modelValue="updateDate"
57
+ :readonly="isReadonly"
58
+ :placeholder="placeholder"
59
+ v-bind="componentProps as CalendarProps"
60
+ />
27
61
 
28
- <!-- time component -->
29
- <Calendar :pt="pt"
30
- v-else-if="inputType == SimpleAppInputType.time" timeOnly showTime
31
- hourFormat="12"
32
- @update:modelValue="updateTime"
33
- :inputId="slotprops.uuid" :path="setting.instancepath"
34
- v-model="(modelValue as string)" :readonly="isReadonly"
35
- :placeholder="placeholder"
36
- v-bind="(componentProps as CalendarProps)"/>
62
+ <!-- time component -->
63
+ <Calendar
64
+ :pt="pt"
65
+ v-else-if="inputType == SimpleAppInputType.time"
66
+ timeOnly
67
+ showTime
68
+ hourFormat="12"
69
+ @update:modelValue="updateTime"
70
+ :inputId="slotprops.uuid"
71
+ :path="setting.instancepath"
72
+ v-model="modelValue as string"
73
+ :readonly="isReadonly"
74
+ :placeholder="placeholder"
75
+ v-bind="componentProps as CalendarProps"
76
+ />
37
77
 
38
- <!-- select/list component -->
39
- <Listbox v-model="modelValue" :pt="pt"
40
- v-else-if="SimpleAppInputType.list==inputType"
41
- :inputId="slotprops.uuid" :path="setting.instancepath"
42
- :readonly="isReadonly"
43
- class="w w-full lg:w-full"
44
- :disabled="isReadonly"
45
- :options="getListOptions()" optionLabel="label" optionValue="value"
46
- :placeholder="placeholder"
47
- v-bind="(componentProps as ListboxProps)"/>
78
+ <!-- select/list component -->
79
+ <Listbox
80
+ v-model="modelValue"
81
+ :pt="pt"
82
+ v-else-if="SimpleAppInputType.list == inputType"
83
+ :inputId="slotprops.uuid"
84
+ :path="setting.instancepath"
85
+ :readonly="isReadonly"
86
+ class="w w-full lg:w-full"
87
+ :disabled="isReadonly"
88
+ :options="getListOptions()"
89
+ optionLabel="label"
90
+ optionValue="value"
91
+ :placeholder="placeholder"
92
+ v-bind="componentProps as ListboxProps"
93
+ />
48
94
 
49
- <Dropdown v-model="modelValue" :pt="pt"
50
- v-else-if="SimpleAppInputType.select == inputType"
51
- :inputId="slotprops.uuid" :path="setting.instancepath"
52
- :readonly="isReadonly"
53
- class="w w-full lg:w-full"
54
- :disabled="isReadonly"
55
- :options="getListOptions()" optionLabel="label" optionValue="value"
56
- :placeholder="placeholder"
57
- v-bind="componentProps"/>
58
-
59
- <!-- radio component -->
60
- <div v-else-if="inputType == SimpleAppInputType.radio" >
61
- <div v-for="(item,index) in getListOptions()">
62
- <RadioButton :pt="pt" v-model="modelValue"
63
- :inputId="setting.key+'-'+index" name="smaple" :value="item.value"
64
- :readonly="isReadonly"
65
- /> {{ ' ' }}
66
- <label :for="setting.key+'-'+index"> {{ item.label }} </label>
67
- </div>
68
- </div>
69
-
70
- <!-- autocomplete, need do more enterprise grade component-->
71
- <SimpleAppAutocomplete v-else-if="inputType==SimpleAppInputType.autocomplete"
72
- v-model="(modelValue as autocompletetype)"
73
- :pt="pt"
74
- :setting="setting"
75
- :disabled="isReadonly"
76
- :inputId="slotprops.uuid"
77
- :path="setting.instancepath"
78
- :readonly="isReadonly"
79
- :placeholder="placeholder"
80
- />
81
- <!-- v-bind:attributes="componentProps" -->
82
- <!-- document no input-->
83
- <SimpleAppDocumentNo v-else-if="inputType == SimpleAppInputType.documentno"
84
- :setting="setting" v-model="(modelValue as string)" :inputId="slotprops.uuid"
85
- :readonly="isReadonly" @update:docNoFormat="triggerDocNoFormatChange"
86
- :pt="pt"
87
- :path="setting.instancepath"
88
- v-bind="(componentProps as any)"/>
89
- <!-- use componentProps as any at the moment, no ideal yet, and for compatibility -->
90
-
91
-
92
- <!-- password -->
93
- <Password
94
- v-else-if="inputType == SimpleAppInputType.password"
95
- :type="type" v-model="(modelValue as string)" :pt="pt"
96
- @focus="setFocus"
97
- :readonly="isReadonly" class="flex flex-col"
98
- :inputId="slotprops.uuid" :path="setting.instancepath"
99
- :placeholder="placeholder"
100
- v-bind="(componentProps as PasswordProps)"/>
95
+ <Dropdown
96
+ v-model="modelValue"
97
+ :pt="pt"
98
+ v-else-if="SimpleAppInputType.select == inputType"
99
+ :inputId="slotprops.uuid"
100
+ :path="setting.instancepath"
101
+ :readonly="isReadonly"
102
+ class="w w-full lg:w-full"
103
+ :disabled="isReadonly"
104
+ :options="getListOptions()"
105
+ optionLabel="label"
106
+ optionValue="value"
107
+ :placeholder="placeholder"
108
+ v-bind="componentProps"
109
+ />
101
110
 
102
- <!-- rating -->
103
- <Rating v-else-if="inputType == SimpleAppInputType.rating"
104
- :type="type" v-model="(modelValue as number)" :pt="pt"
105
- :readonly="isReadonly"
106
- :inputId="slotprops.uuid" :path="setting.instancepath"
107
- v-bind="(componentProps as RatingProps)"/>
108
-
109
- <!-- chip -->
110
- <Chips v-else-if="inputType == SimpleAppInputType.chip"
111
- :type="type" v-model="(modelValue as string[])"
112
- :pt="pt"
113
- :disabled="isReadonly"
114
- :inputId="slotprops.uuid" :path="setting.instancepath"
115
- :placeholder="placeholder"
116
- v-bind="(componentProps as ChipsProps)"
117
- />
118
- <!-- simple component -->
119
- <InputNumber v-else-if="inputType == SimpleAppInputType.number"
120
- :type="type" v-model="(modelValue as number)"
121
- @focus="setFocus"
122
- :readonly="isReadonly"
123
- :pt="pt"
124
- :class="!pt ? 'w-full flex flex-col' :''"
125
- :inputId="slotprops.uuid" :path="setting.instancepath"
126
- v-bind="(componentProps as InputNumber)"
127
- :placeholder="placeholder"
128
- />
129
- <Textarea v-else-if="inputType == SimpleAppInputType.textarea"
130
- v-model="(modelValue as string)"
131
- :autofocus="autofocus"
132
- :readonly="isReadonly"
133
- :pt="pt"
134
- :type="type"
135
- class="w-full flex flex-col"
136
- :inputId="slotprops.uuid"
137
- :path="setting.instancepath"
138
- :placeholder="placeholder"
139
- v-bind="(componentProps as TextareaProps)"
140
- />
141
- <InputText v-else
142
- v-model="(modelValue as string)"
143
- @focus="setFocus"
144
- :autofocus="autofocus"
145
- :readonly="isReadonly"
146
- :pt="pt"
147
- :type="type"
148
- class="w-full flex flex-col"
149
- :inputId="slotprops.uuid"
150
- :path="setting.instancepath"
151
- :placeholder="placeholder"
152
- v-bind="(componentProps as InputTextProps)"
153
- />
154
- <!-- component require special treatment -->
155
- </SimpleAppFieldContainer>
111
+ <!-- radio component -->
112
+ <div v-else-if="inputType == SimpleAppInputType.radio">
113
+ <div v-for="(item, index) in getListOptions()">
114
+ <RadioButton
115
+ :pt="pt"
116
+ v-model="modelValue"
117
+ :inputId="setting.key + '-' + index"
118
+ name="smaple"
119
+ :value="item.value"
120
+ :readonly="isReadonly"
121
+ />
122
+ {{ " " }}
123
+ <label :for="setting.key + '-' + index"> {{ item.label }} </label>
124
+ </div>
125
+ </div>
126
+
127
+ <!-- autocomplete, need do more enterprise grade component-->
128
+ <SimpleAppAutocomplete
129
+ v-else-if="inputType == SimpleAppInputType.autocomplete"
130
+ v-model="modelValue as autocompletetype"
131
+ :hidelabel="hidelabel"
132
+ :pt="pt"
133
+ :setting="setting"
134
+ :disabled="isReadonly"
135
+ :inputId="slotprops.uuid"
136
+ :path="setting.instancepath"
137
+ :readonly="isReadonly"
138
+ :placeholder="placeholder"
139
+ />
140
+ <!-- v-bind:attributes="componentProps" -->
141
+ <!-- document no input-->
142
+ <SimpleAppDocumentNo
143
+ v-else-if="inputType == SimpleAppInputType.documentno"
144
+ :setting="setting"
145
+ v-model="modelValue as string"
146
+ :inputId="slotprops.uuid"
147
+ :readonly="isReadonly"
148
+ @update:docNoFormat="triggerDocNoFormatChange"
149
+ :pt="pt"
150
+ :path="setting.instancepath"
151
+ v-bind="componentProps as any"
152
+ />
153
+ <!-- use componentProps as any at the moment, no ideal yet, and for compatibility -->
154
+
155
+ <!-- password -->
156
+ <Password
157
+ v-else-if="inputType == SimpleAppInputType.password"
158
+ :type="type"
159
+ v-model="modelValue as string"
160
+ :pt="pt"
161
+ @focus="setFocus"
162
+ :readonly="isReadonly"
163
+ class="flex flex-col"
164
+ :inputId="slotprops.uuid"
165
+ :path="setting.instancepath"
166
+ :placeholder="placeholder"
167
+ v-bind="componentProps as PasswordProps"
168
+ />
169
+
170
+ <!-- rating -->
171
+ <Rating
172
+ v-else-if="inputType == SimpleAppInputType.rating"
173
+ :type="type"
174
+ v-model="modelValue as number"
175
+ :pt="pt"
176
+ :readonly="isReadonly"
177
+ :inputId="slotprops.uuid"
178
+ :path="setting.instancepath"
179
+ v-bind="componentProps as RatingProps"
180
+ />
181
+
182
+ <!-- chip -->
183
+ <Chips
184
+ v-else-if="inputType == SimpleAppInputType.chip"
185
+ :type="type"
186
+ v-model="modelValue as string[]"
187
+ :pt="pt"
188
+ :disabled="isReadonly"
189
+ :inputId="slotprops.uuid"
190
+ :path="setting.instancepath"
191
+ :placeholder="placeholder"
192
+ v-bind="componentProps as ChipsProps"
193
+ />
194
+ <!-- simple component -->
195
+
196
+ <InputNumber
197
+ v-else-if="inputType == SimpleAppInputType.number"
198
+ :type="type"
199
+ v-model="modelValue as number"
200
+ @focus="setFocus"
201
+ :readonly="isReadonly"
202
+ :pt="pt"
203
+ :class="!pt ? 'w-full flex flex-col' : ''"
204
+ :inputId="slotprops.uuid"
205
+ :path="setting.instancepath"
206
+ v-bind="componentProps as InputNumber"
207
+ :placeholder="placeholder"
208
+ />
209
+ <Textarea
210
+ v-else-if="inputType == SimpleAppInputType.textarea"
211
+ v-model="modelValue as string"
212
+ :autofocus="autofocus"
213
+ :readonly="isReadonly"
214
+ :pt="pt"
215
+ :type="type"
216
+ class="w-full flex flex-col"
217
+ :inputId="slotprops.uuid"
218
+ :path="setting.instancepath"
219
+ :placeholder="placeholder"
220
+ v-bind="componentProps as TextareaProps"
221
+ />
222
+ <InputText
223
+ v-else
224
+ v-model="modelValue as string"
225
+ @focus="setFocus"
226
+ :autofocus="autofocus"
227
+ :readonly="isReadonly"
228
+ :pt="pt"
229
+ :type="type"
230
+ class="w-full flex flex-col"
231
+ :inputId="slotprops.uuid"
232
+ :path="setting.instancepath"
233
+ :placeholder="placeholder"
234
+ v-bind="componentProps as InputTextProps"
235
+ />
236
+ <!-- component require special treatment -->
237
+ </SimpleAppFieldContainer>
156
238
  </template>
157
239
 
158
240
  <script lang="ts" setup>
159
- import {autocompletetype} from '~/types'
160
- import moment from 'moment'
161
- import AutoComplete,{ AutoCompleteProps } from 'primevue/autocomplete';
162
- import Calendar,{ CalendarProps } from 'primevue/calendar';
163
- import Checkbox,{ CheckboxProps } from 'primevue/checkbox';
164
- import Chips,{ ChipsProps } from 'primevue/chips';
165
- import SimpleAppDocumentNo from './SimpleAppDocumentNo.vue';
166
- import SimpleAppAutocomplete from './SimpleAppAutocomplete.vue'
167
- import Dropdown,{ DropdownProps } from 'primevue/dropdown';
168
- import InputNumber, { InputNumberProps } from 'primevue/inputnumber';
169
- import InputSwitch, { InputSwitchProps } from 'primevue/inputswitch';
170
- import InputText, { InputTextProps } from 'primevue/inputtext';
171
- import Listbox,{ ListboxProps } from 'primevue/listbox';
172
- import MultiSelect,{ MultiSelectProps } from 'primevue/multiselect';
173
- import Password,{ PasswordProps } from 'primevue/password';
174
- import RadioButton,{ RadioButtonProps } from 'primevue/radiobutton';
175
- import Rating,{ RatingProps } from 'primevue/rating';
176
- import Slider,{ SliderProps } from 'primevue/slider';
177
- import Textarea, { TextareaProps } from 'primevue/textarea';
178
- import {SimpleAppInputType} from '~/types'
179
-
180
- const modelValue = defineModel({required:true})
181
- const datevalue = ref('')
182
- const timevalue = ref<Date>()
241
+ import { autocompletetype } from "~/types";
242
+ import moment from "moment";
243
+ import AutoComplete, { AutoCompleteProps } from "primevue/autocomplete";
244
+ import Calendar, { CalendarProps } from "primevue/calendar";
245
+ import Checkbox, { CheckboxProps } from "primevue/checkbox";
246
+ import Chips, { ChipsProps } from "primevue/chips";
247
+ import SimpleAppDocumentNo from "./SimpleAppDocumentNo.vue";
248
+ import SimpleAppAutocomplete from "./SimpleAppAutocomplete.vue";
249
+ import Dropdown, { DropdownProps } from "primevue/dropdown";
250
+ import InputNumber, { InputNumberProps } from "primevue/inputnumber";
251
+ import InputSwitch, { InputSwitchProps } from "primevue/inputswitch";
252
+ import InputText, { InputTextProps } from "primevue/inputtext";
253
+ import Listbox, { ListboxProps } from "primevue/listbox";
254
+ import MultiSelect, { MultiSelectProps } from "primevue/multiselect";
255
+ import Password, { PasswordProps } from "primevue/password";
256
+ import RadioButton, { RadioButtonProps } from "primevue/radiobutton";
257
+ import Rating, { RatingProps } from "primevue/rating";
258
+ import Slider, { SliderProps } from "primevue/slider";
259
+ import Textarea, { TextareaProps } from "primevue/textarea";
260
+ import { SimpleAppInputType } from "~/types";
183
261
 
184
- const props = withDefaults( defineProps<{
185
- inputType:SimpleAppInputType,
186
- label?:string,
187
- description?:string,
188
- error?:string,
189
- setting:any,
190
- type?:string,
191
- instancepath?:string,
192
- hidelabel?: boolean
193
- readonly?: boolean
194
- autofocus?:boolean
195
- pt?:any,
196
- placeholder?:string
197
- componentProps?: InputNumberProps | InputSwitchProps | InputTextProps | TextareaProps | DropdownProps | CalendarProps | RatingProps
262
+ const instancepath = ref("");
263
+ const modelValue = defineModel({ required: true });
264
+ const datevalue = ref("");
265
+ const timevalue = ref<Date>();
198
266
 
199
- }>(),{type:'text'})
267
+ const props = withDefaults(
268
+ defineProps<{
269
+ inputType: SimpleAppInputType;
270
+ label?: string;
271
+ description?: string;
272
+ error?: string;
273
+ setting: any;
274
+ type?: string;
275
+ instancepath?: string;
276
+ hidelabel?: boolean;
277
+ readonly?: boolean;
278
+ autofocus?: boolean;
279
+ pt?: any;
280
+ placeholder?: string;
281
+ componentProps?:
282
+ | InputNumberProps
283
+ | InputSwitchProps
284
+ | InputTextProps
285
+ | TextareaProps
286
+ | DropdownProps
287
+ | CalendarProps
288
+ | RatingProps;
289
+ }>(),
290
+ { type: "text" },
291
+ );
200
292
 
293
+ const pt =ref(props.pt)
201
294
 
202
- if(props.inputType== SimpleAppInputType.date && modelValue.value){
203
- datevalue.value = moment(modelValue.value as string ).format('YYYY-MM-DD')
204
- }else{
205
- datevalue.value = ''
295
+ if (props.inputType == SimpleAppInputType.date && modelValue.value) {
296
+ datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
297
+ } else {
298
+ datevalue.value = "";
206
299
  }
207
300
 
208
- const isReadonly = computed(()=>{
209
- if(props.readonly){
210
- return props.readonly
211
- }else if(props.setting.readonly){
212
- return props.setting.readonly
213
- }else{
214
- return false
215
- }
216
- })
217
- const updateTime = () =>{
218
- modelValue.value = moment(timevalue.value).format("HH:mm:ss")
219
- }
220
- const updateDate = (value:any)=>{
221
-
222
- if(value){
223
- modelValue.value = moment(value).format('YYYY-MM-DD')
224
- }else{
225
- modelValue.value=''
226
- }
227
-
228
- }
301
+ if (props?.instancepath) instancepath.value = props.instancepath;
302
+ else if (props.setting?.instancepath)
303
+ instancepath.value = props.setting.instancepath;
304
+ else instancepath.value = "/unknown";
229
305
 
230
- const setFocus = (ev:any) => {
231
- if(!isMobile()) ev.target.select()
232
- }
306
+ watch(props.setting.errors, (newvalue, oldvalue) => {
307
+ let errmsg = ''
308
+ if (newvalue[instancepath.value]) {
309
+ const errlist: any[] = newvalue[instancepath.value];
310
+ for (let i = 0; i < errlist.length; i++) {
311
+ errmsg += errlist[i].message + ",";
312
+ }
313
+ } else {
314
+ errmsg = "";
315
+ }
316
+ if(errmsg!=''){
317
+ const errorstyle = { style:'border-color: lightcoral; color:white '}
318
+ if(!pt.value)pt.value = {}
233
319
 
234
- const getListOptions = () =>{
320
+ if(props.inputType == SimpleAppInputType.text) pt.value={ root: errorstyle}
321
+ else if(props.inputType == SimpleAppInputType.autocomplete) pt.value={ input:errorstyle}
322
+ else if(props.inputType == SimpleAppInputType.number) pt.value={ input: {root:errorstyle} }
323
+ else pt.value = {root: errorstyle, input:{root:errorstyle}}
324
+ //some component still not working
325
+
326
+ }else{
327
+ pt.value=props.pt
328
+ }
235
329
 
236
- const options = []
237
- if(props.setting.fieldsetting.enum){
238
- for(let i=0;i<props.setting.fieldsetting.enum.length;i++){
239
- const v = props.setting.fieldsetting.enum[i]
240
- if(typeof v == 'string'){
241
- options.push({value:v, label: t(v)})
242
- }else{
243
- options.push({value:v.value, label: t(v.label)})
244
- }
245
-
246
- }
330
+
331
+ })
332
+ const isReadonly = computed(() => {
333
+ if (props.readonly) {
334
+ return props.readonly;
335
+ } else if (props.setting.readonly) {
336
+ return props.setting.readonly;
337
+ } else {
338
+ return false;
339
+ }
340
+ });
341
+ const updateTime = () => {
342
+ modelValue.value = moment(timevalue.value).format("HH:mm:ss");
343
+ };
344
+ const updateDate = (value: any) => {
345
+ if (value) {
346
+ modelValue.value = moment(value).format("YYYY-MM-DD");
347
+ } else {
348
+ modelValue.value = "";
349
+ }
350
+ };
247
351
 
352
+ const setFocus = (ev: any) => {
353
+ if (!isMobile()) ev.target.select();
354
+ };
248
355
 
356
+ const getListOptions = () => {
357
+ const options = [];
358
+ if (props.setting.fieldsetting.enum) {
359
+ for (let i = 0; i < props.setting.fieldsetting.enum.length; i++) {
360
+ const v = props.setting.fieldsetting.enum[i];
361
+ if (typeof v == "string") {
362
+ options.push({ value: v, label: t(v) });
363
+ } else {
364
+ options.push({ value: v.value, label: t(v.label) });
365
+ }
249
366
  }
250
- return options
251
- }
252
-
367
+ }
368
+ return options;
369
+ };
253
370
 
254
- const emits = defineEmits(['change','update:modelValue','update:docNoFormat'])
371
+ const emits = defineEmits([
372
+ "change",
373
+ "update:modelValue",
374
+ "update:docNoFormat",
375
+ ]);
255
376
 
256
-
257
- watch(modelValue ,(newvalue:any)=>{
258
-
259
- if([SimpleAppInputType.date,SimpleAppInputType.calendar].includes(props.inputType)){
260
- if(modelValue.value){
261
- datevalue.value = moment(modelValue.value as string ).format('YYYY-MM-DD')
262
- }else{
263
- datevalue.value = ''
264
- }
265
-
377
+ watch(modelValue, (newvalue: any) => {
378
+ if (
379
+ [SimpleAppInputType.date, SimpleAppInputType.calendar].includes(
380
+ props.inputType,
381
+ )
382
+ ) {
383
+ if (modelValue.value) {
384
+ datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
385
+ } else {
386
+ datevalue.value = "";
266
387
  }
388
+ }
267
389
 
268
-
269
- emits('change',modelValue.value)
270
- emits('update:modelValue',modelValue.value)
271
- })
272
- onMounted(()=>{
273
- if([SimpleAppInputType.date,SimpleAppInputType.calendar].includes(props.inputType)){
274
- if(modelValue.value){
275
- datevalue.value = moment(modelValue.value as string ).format('YYYY-MM-DD')
276
- }else{
277
- datevalue.value = ''
278
- }
279
-
390
+ emits("change", modelValue.value);
391
+ emits("update:modelValue", modelValue.value);
392
+ });
393
+ onMounted(() => {
394
+ if (
395
+ [SimpleAppInputType.date, SimpleAppInputType.calendar].includes(
396
+ props.inputType,
397
+ )
398
+ ) {
399
+ if (modelValue.value) {
400
+ datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
401
+ } else {
402
+ datevalue.value = "";
280
403
  }
281
- })
404
+ }
405
+ });
282
406
 
283
407
  /************ start autocomplete only ***************/
284
408
 
285
409
  /************ end autocomplete only ***************/
286
410
 
287
-
288
-
289
-
290
-
291
- const triggerDocNoFormatChange=(formatdata:any)=>{
292
- emits('update:docNoFormat',formatdata)
293
- }
294
- </script>
411
+ const triggerDocNoFormatChange = (formatdata: any) => {
412
+ emits("update:docNoFormat", formatdata);
413
+ };
414
+ </script>