@simitgroup/simpleapp-generator 1.0.32 → 1.0.35
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/.vscode/settings.json +3 -0
- package/README.md +185 -16
- package/buildinschemas copy/autoincreament.autoinc.jsonschema.json +39 -0
- package/buildinschemas copy/branch.branch.jsonschema.json +41 -0
- package/buildinschemas copy/docnoformat.docno.jsonschema.json +41 -0
- package/buildinschemas copy/organization.org.jsonschema.json +50 -0
- package/buildinschemas copy/permission.perm.jsonschema.json +23 -0
- package/buildinschemas copy/permission.perm.jsonschema.try.json +25 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.json +21 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.try.json +27 -0
- package/buildinschemas copy/user.user.jsonschema.json +31 -0
- package/dist/buildinschemas/autoincreament.d.ts +3 -0
- package/dist/buildinschemas/autoincreament.d.ts.map +1 -0
- package/dist/buildinschemas/autoincreament.js +36 -0
- package/dist/buildinschemas/autoincreament.js.map +1 -0
- package/dist/buildinschemas/branch.d.ts +3 -0
- package/dist/buildinschemas/branch.d.ts.map +1 -0
- package/dist/buildinschemas/branch.js +41 -0
- package/dist/buildinschemas/branch.js.map +1 -0
- package/dist/buildinschemas/docnoformat.d.ts +3 -0
- package/dist/buildinschemas/docnoformat.d.ts.map +1 -0
- package/dist/buildinschemas/docnoformat.js +60 -0
- package/dist/buildinschemas/docnoformat.js.map +1 -0
- package/dist/buildinschemas/index.d.ts +8 -0
- package/dist/buildinschemas/index.d.ts.map +1 -0
- package/dist/buildinschemas/index.js +18 -0
- package/dist/buildinschemas/index.js.map +1 -0
- package/dist/buildinschemas/organization.d.ts +3 -0
- package/dist/buildinschemas/organization.d.ts.map +1 -0
- package/dist/buildinschemas/organization.js +34 -0
- package/dist/buildinschemas/organization.js.map +1 -0
- package/dist/buildinschemas/permission.d.ts +3 -0
- package/dist/buildinschemas/permission.d.ts.map +1 -0
- package/dist/buildinschemas/permission.js +34 -0
- package/dist/buildinschemas/permission.js.map +1 -0
- package/dist/buildinschemas/tenant.d.ts +3 -0
- package/dist/buildinschemas/tenant.d.ts.map +1 -0
- package/dist/buildinschemas/tenant.js +41 -0
- package/dist/buildinschemas/tenant.js.map +1 -0
- package/dist/buildinschemas/user.d.ts +3 -0
- package/dist/buildinschemas/user.d.ts.map +1 -0
- package/dist/buildinschemas/user.js +31 -0
- package/dist/buildinschemas/user.js.map +1 -0
- package/dist/constant.d.ts +4 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +2 -1
- package/dist/constant.js.map +1 -1
- package/dist/framework.d.ts +10 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/framework.js +120 -68
- package/dist/framework.js.map +1 -1
- package/dist/generate-allow-changebackend.js +305 -0
- package/dist/generate-allow-changebackend.js.map +1 -0
- package/dist/generate.d.ts +2 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +310 -230
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -20
- package/dist/index.js.map +1 -1
- package/dist/libs.d.ts +2 -0
- package/dist/libs.d.ts.map +1 -0
- package/dist/processors/groupsbuilder.js +2 -0
- package/dist/processors/groupsbuilder.js.map +1 -0
- package/dist/processors/jsonschemabuilder.d.ts +4 -0
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -0
- package/dist/processors/jsonschemabuilder.js +146 -172
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/schematype/baseschema.js +25 -0
- package/dist/schematype/baseschema.js.map +1 -0
- package/dist/schematype/default.js +2 -0
- package/dist/schematype/default.js.map +1 -0
- package/dist/schematype/index.js +12 -0
- package/dist/schematype/index.js.map +1 -0
- package/dist/schematype/primarymasterdata.js +38 -0
- package/dist/schematype/primarymasterdata.js.map +1 -0
- package/dist/schematype/simple.js +24 -0
- package/dist/schematype/simple.js.map +1 -0
- package/dist/schematype/simplemasterdata.js +31 -0
- package/dist/schematype/simplemasterdata.js.map +1 -0
- package/dist/schematype/transaction.js +74 -0
- package/dist/schematype/transaction.js.map +1 -0
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +2 -2
- package/dist/storage.js.map +1 -1
- package/dist/type.d.ts +164 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +16 -1
- package/dist/type.js.map +1 -1
- package/dist/validation.d.ts +1 -0
- package/dist/validation.d.ts.map +1 -0
- package/documentation/designconcept.bpmn +349 -0
- package/documentation/documentation.png +0 -0
- package/documentation/infra.drawio +141 -0
- package/documentation/infra.png +0 -0
- package/documentation/management.drawio +57 -0
- package/documentation/stack.drawio +106 -0
- package/package.json +3 -1
- package/src/buildinschemas/autoincreament.ts +34 -0
- package/src/buildinschemas/branch.ts +39 -0
- package/src/buildinschemas/docnoformat.ts +58 -0
- package/src/buildinschemas/index.ts +7 -0
- package/src/buildinschemas/organization.ts +31 -0
- package/src/buildinschemas/permission.ts +31 -0
- package/src/buildinschemas/tenant.ts +38 -0
- package/src/buildinschemas/user.ts +28 -0
- package/src/constant.ts +2 -1
- package/src/framework.ts +126 -67
- package/src/generate.ts +327 -266
- package/src/generate.ts.backup +339 -0
- package/src/index.ts +93 -18
- package/src/processors/jsonschemabuilder.ts +199 -226
- package/src/processors/jsonschemabuilder.ts-old +383 -0
- package/src/storage.ts +1 -1
- package/src/type.ts +94 -27
- package/templates/basic/nest/controller.ts.eta +255 -0
- package/templates/basic/nest/default.ts.eta +42 -0
- package/templates/basic/{model.eta → nest/model.ts.eta} +18 -5
- package/templates/basic/nest/processor.ts.eta +129 -0
- package/templates/basic/nest/service.ts.eta +64 -0
- package/templates/basic/{type.eta → nest/type.ts.eta} +3 -3
- package/templates/basic/nuxt/default.ts.eta +42 -0
- package/templates/basic/{pageindex.vue.eta → nuxt/pages.crud.vue.eta} +85 -22
- package/templates/basic/nuxt/simpleapp.doc.ts.eta +11 -0
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +212 -0
- package/templates/nest/.env.eta +31 -0
- package/templates/nest/.gitignore.eta +40 -0
- package/templates/nest/src/app.controller.ts.eta +19 -0
- package/templates/nest/src/app.module.ts.eta +77 -0
- package/templates/nest/src/app.service.ts.eta +9 -0
- package/templates/nest/src/main.ts.eta +58 -0
- package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +16 -0
- package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +8 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +1 -0
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +101 -0
- package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +39 -0
- package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +38 -0
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +88 -0
- package/templates/nest/{Workflow.eta → src/simpleapp/generate/commons/providers/workflow.provider.ts.etax} +20 -14
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +28 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +10 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +34 -0
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +391 -0
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +71 -0
- package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +53 -0
- package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +45 -0
- package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +57 -0
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +624 -0
- package/templates/nest/src/simpleapp/generate/types/index.ts.eta +19 -0
- package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +74 -0
- package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +110 -0
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +195 -0
- package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +18 -0
- package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +89 -0
- package/templates/nest/src/simpleapp/services/branch.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/services/docno.service.ts.eta +93 -0
- package/templates/nest/src/simpleapp/services/org.service.ts.eta +67 -0
- package/templates/nest/src/simpleapp/services/perm.service.ts.eta +102 -0
- package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +69 -0
- package/templates/nest/src/simpleapp/services/user.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +43 -0
- package/templates/nuxt/.env.eta +21 -0
- package/templates/nuxt/.gitignore.eta +28 -0
- package/templates/nuxt/app.vue.eta +5 -2
- package/templates/nuxt/assets/css/tailwind.css.eta +35 -0
- package/templates/nuxt/components/CrudNestedDoc.vue.eta +164 -0
- package/templates/nuxt/components/CrudSimple.vue.eta +179 -0
- package/templates/nuxt/{components.debugdocdata.vue.eta → components/DebugDocumentData.vue.eta} +4 -1
- package/templates/nuxt/{components.eventmonitor.vue.eta → components/EventMonitor.vue.eta} +27 -27
- package/templates/nuxt/components/Invitation.vue.eta +50 -0
- package/templates/nuxt/components/Menus.vue.eta +58 -0
- package/templates/nuxt/components/PermissionInfo.vue.eta +92 -0
- package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppAutocompletemulti.vue.eta +73 -0
- package/templates/nuxt/components/SimpleAppCalendar.vue.eta +55 -0
- package/templates/nuxt/components/SimpleAppCheckbox.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppChip.vue.eta +28 -0
- package/templates/nuxt/components/SimpleAppColor.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppDatatable.vue.eta +20 -0
- package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +90 -0
- package/templates/nuxt/components/SimpleAppDynamicInput.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppEditor.vue.eta +31 -0
- package/templates/nuxt/components/SimpleAppForm.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppInputTable.vue.eta +104 -0
- package/templates/nuxt/components/SimpleAppList.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppListmulti.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppNumber.vue.eta +32 -0
- package/templates/nuxt/components/SimpleAppPassword.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppRadio.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppRating.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppSelect.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppSelectmulti.vue.eta +39 -0
- package/templates/nuxt/components/SimpleAppSlider.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppSwitch.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppText.vue.eta +50 -0
- package/templates/nuxt/components/SimpleAppTextarea.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppValue.vue.eta +86 -0
- package/templates/nuxt/components/SimpleFieldContainer.vue.eta +102 -0
- package/templates/nuxt/components/XorgPicker.vue.eta +66 -0
- package/templates/nuxt/components/helper.ts.eta +90 -0
- package/templates/nuxt/components/type.ts.eta +32 -0
- package/templates/nuxt/composables/docformat.generate.ts.eta +5 -0
- package/templates/nuxt/{composables.getautocomplete.ts.eta → composables/getAutocomplete.generate.ts.eta} +4 -5
- package/templates/nuxt/{composables.getmenus.ts.eta → composables/getMenus.generate.ts.eta} +22 -7
- package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -0
- package/templates/nuxt/composables/getTenant.generate.ts.eta +4 -0
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +22 -0
- package/templates/nuxt/composables/logout.generate.ts.eta +22 -0
- package/templates/nuxt/composables/roles.generate.ts.eta +48 -0
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -0
- package/templates/nuxt/{layouts.default.vue.eta → layouts/default.vue.eta} +2 -0
- package/templates/nuxt/middleware/10.acl.global.ts.eta +38 -0
- package/templates/nuxt/nuxt.config.ts.eta +12 -2
- package/templates/nuxt/pages/[xorg]/branch/index.vue.eta +102 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +17 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +269 -0
- package/templates/nuxt/pages/[xorg]/index.vue.eta +36 -0
- package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +148 -0
- package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +280 -0
- package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +93 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +468 -0
- package/templates/nuxt/pages/index.vue.eta +191 -0
- package/templates/nuxt/pages/login.vue.eta +21 -0
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +53 -0
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +155 -0
- package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +23 -0
- package/templates/nuxt/{server.api.ts.eta → server/api/[xorg]/[...].ts.eta} +5 -2
- package/templates/nuxt/server/api/auth/[...].ts.eta +68 -0
- package/templates/nuxt/{server.api.auth.logout.ts.eta → server/api/auth/logout.ts.eta} +1 -3
- package/templates/nuxt/server/api/profile/[...].ts.eta +150 -0
- package/templates/nuxt/server/api/profile/index.ts.eta +103 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +187 -0
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +5 -0
- package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +11 -0
- package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +21 -0
- package/templates/nuxt/types/index.ts.eta +65 -0
- package/templates/project/README.md +11 -0
- package/templates/project/build.sh.eta +17 -0
- package/templates/project/config.json.eta +2 -0
- package/templates/project/generate.ts.eta +10 -0
- package/templates/project/schemas/category.ts.eta +26 -0
- package/templates/project/schemas/index.ts.eta +5 -0
- package/templates/project/schemas/product.ts.eta +59 -0
- package/templates/project/shares/hello.ts.eta +1 -0
- package/templates/project/shares/index.ts.eta +2 -0
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -0
- package/definations/category.cat.jsonschema.json +0 -55
- package/definations/level.lvl.jsonschema.json +0 -48
- package/definations/product.prd.jsonschema.json +0 -46
- package/templates/basic/controller.eta +0 -152
- package/templates/basic/module.eta +0 -22
- package/templates/basic/service.eta +0 -62
- package/templates/basic/simpleappclient.eta +0 -120
- package/templates/nest/SimpleAppController.eta +0 -69
- package/templates/nest/SimpleAppService.eta +0 -366
- package/templates/nest/TenantMiddleware.eta +0 -34
- package/templates/nest/UserProvider.eta +0 -127
- package/templates/nest/app.controller.eta +0 -12
- package/templates/nest/app.module.eta +0 -64
- package/templates/nest/app.service.eta +0 -8
- package/templates/nest/inputvalidation-exception.eta +0 -6
- package/templates/nest/nest.env.eta +0 -28
- package/templates/nest/nest.main.eta +0 -31
- package/templates/nuxt/components.crudsimple.vue.eta +0 -124
- package/templates/nuxt/components.menus.vue.eta +0 -35
- package/templates/nuxt/env.eta +0 -17
- package/templates/nuxt/pages.[xorg].index.vue.eta +0 -20
- package/templates/nuxt/pages.index.vue.eta +0 -72
- package/templates/nuxt/pages.login.vue.eta +0 -20
- package/templates/nuxt/plugins.simpleapp.ts.eta +0 -88
- package/templates/nuxt/server.api.auth[...].ts.eta +0 -233
- package/templates/nuxt/tailwind.css.eta +0 -49
- /package/templates/basic/{apischema.eta → nest/apischema.ts.eta} +0 -0
- /package/templates/basic/{jsonschema.eta → nest/jsonschema.ts.eta} +0 -0
- /package/templates/basic/{pageindexwithid.vue.eta → nuxt/pages.[id].vue.eta} +0 -0
- /package/templates/nest/{oauth2-redirect.eta → public_html/oauth2-redirect.html.eta} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
3
|
+
<AutoComplete
|
|
4
|
+
class="simpleapp-inputfield"
|
|
5
|
+
:inputId="slotprops.uuid"
|
|
6
|
+
v-model="selecteditem"
|
|
7
|
+
v-bind="$attrs"
|
|
8
|
+
@item-unselect="deleteValue"
|
|
9
|
+
:path="setting.instancepath"
|
|
10
|
+
@blur="onblur"
|
|
11
|
+
@item-select="pickValue"
|
|
12
|
+
forceSelection
|
|
13
|
+
multiple
|
|
14
|
+
|
|
15
|
+
/>
|
|
16
|
+
</FieldContainer>
|
|
17
|
+
</template>
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
|
|
20
|
+
import {computed,watch,ref} from 'vue'
|
|
21
|
+
import AutoComplete from 'primevue/autocomplete';
|
|
22
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
23
|
+
import {prepareList} from './helper'
|
|
24
|
+
import type {SimpleAppFieldSetting,ListOptionType} from './type'
|
|
25
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
26
|
+
|
|
27
|
+
const props = defineProps<{
|
|
28
|
+
label?:string,
|
|
29
|
+
description?:string,
|
|
30
|
+
error?:string,
|
|
31
|
+
setting:SimpleAppFieldSetting,
|
|
32
|
+
instancepath?:string,
|
|
33
|
+
displayText?:string
|
|
34
|
+
}>()
|
|
35
|
+
const modelValue = defineModel<any[]>()
|
|
36
|
+
const selecteditem=ref(modelValue.value)
|
|
37
|
+
|
|
38
|
+
if(props.setting.fieldsetting && props.setting.fieldsetting.format){
|
|
39
|
+
const formatarr=props.setting.fieldsetting.format.split(':')
|
|
40
|
+
}
|
|
41
|
+
watch(modelValue,(newvalue)=>selecteditem.value=newvalue)
|
|
42
|
+
const deleteValue = (event:any)=>{
|
|
43
|
+
modelValue.value = selecteditem.value
|
|
44
|
+
console.log(selecteditem.value)
|
|
45
|
+
// if(typeof event.value.query == 'undefined' && typeof modelValue.value != 'undefined'){
|
|
46
|
+
|
|
47
|
+
// for(let i=0;i< modelValue.value.length;i++){
|
|
48
|
+
// if(event.value.ic == modelValue.value[i].ic){
|
|
49
|
+
|
|
50
|
+
// // modelValue.value =
|
|
51
|
+
// modelValue.value.slice(i,0)
|
|
52
|
+
// // delete modelValue.value[i]
|
|
53
|
+
// // console.log("sliced ",slicedvalue)
|
|
54
|
+
// console.log("Delete item ",i, event.value,modelValue.value)
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const pickValue = (event:any)=>{
|
|
61
|
+
if(typeof modelValue.value == 'undefined'){
|
|
62
|
+
modelValue.value=[]
|
|
63
|
+
}
|
|
64
|
+
if(typeof event.value.query == 'undefined'){
|
|
65
|
+
modelValue.value.push(event.value)
|
|
66
|
+
console.log("pick value",modelValue.value)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const onblur = ()=>{
|
|
71
|
+
selecteditem.value=modelValue.value
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :error="error" #default="slotprops">
|
|
3
|
+
<Calendar
|
|
4
|
+
v-model="datedata"
|
|
5
|
+
:inputId="slotprops.uuid"
|
|
6
|
+
@update:modelValue="change"
|
|
7
|
+
:numberOfMonths="2"
|
|
8
|
+
v-bind="$attrs"
|
|
9
|
+
:dateFormat="dateformat"/>
|
|
10
|
+
</FieldContainer>
|
|
11
|
+
</template>
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
14
|
+
import { ref, watch,computed } from "vue"
|
|
15
|
+
import moment from 'moment'
|
|
16
|
+
import Calendar from 'primevue/calendar';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const x = new Date()
|
|
20
|
+
const date = ref<Date>()
|
|
21
|
+
// const emit = defineEmits(['update:modelValue'])
|
|
22
|
+
const props = defineProps<{
|
|
23
|
+
label?:string,
|
|
24
|
+
id?:string,
|
|
25
|
+
description?:string,
|
|
26
|
+
setting?:any,
|
|
27
|
+
error?:string,
|
|
28
|
+
}>()
|
|
29
|
+
const modelValue = defineModel<string>()
|
|
30
|
+
const emit = defineEmits(['update:modelValue'])
|
|
31
|
+
const getDateFormat=():string=>{
|
|
32
|
+
// const date = new Date();
|
|
33
|
+
const date = new Date();
|
|
34
|
+
const datestr = date.toISOString()
|
|
35
|
+
let day =date.getDate().toString()
|
|
36
|
+
day = day.length == 1 ? '0'+day : day
|
|
37
|
+
let month = (date.getMonth() + 1).toString()
|
|
38
|
+
month = month.length == 1 ? '0'+month : month
|
|
39
|
+
const year = date.getFullYear().toString()
|
|
40
|
+
const dateformat = datestr.replace(year,'yy').replace(month,'mm').replace(day,'dd');
|
|
41
|
+
return dateformat
|
|
42
|
+
}
|
|
43
|
+
const datestr:string = modelValue.value??''
|
|
44
|
+
const datedefaultdata = new Date(datestr)
|
|
45
|
+
const dateformat = computed(()=> getDateFormat())
|
|
46
|
+
const datedata = ref(datedefaultdata)
|
|
47
|
+
watch(props,(newvalue)=>{
|
|
48
|
+
datedata.value = new Date(datedefaultdata)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const change = (e:Date)=>{
|
|
52
|
+
const newdate:string = moment(e).format("yyyy-MM-DD")
|
|
53
|
+
emit('update:modelValue',newdate)
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<template>
|
|
4
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
5
|
+
<Checkbox
|
|
6
|
+
class="simpleapp-inputfield"
|
|
7
|
+
:inputId="slotprops.uuid"
|
|
8
|
+
v-model="modelValue"
|
|
9
|
+
:binary="true"
|
|
10
|
+
v-bind="$attrs"
|
|
11
|
+
:path="setting.instancepath"
|
|
12
|
+
></Checkbox>
|
|
13
|
+
</FieldContainer>
|
|
14
|
+
</template>
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
// import {Ref} from 'vue'
|
|
17
|
+
import Checkbox from 'primevue/checkbox';
|
|
18
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
19
|
+
|
|
20
|
+
const modelValue = defineModel<boolean>()
|
|
21
|
+
const props = defineProps<{
|
|
22
|
+
label?:string,
|
|
23
|
+
description?:string,
|
|
24
|
+
error?:string,
|
|
25
|
+
setting:any,
|
|
26
|
+
instancepath?:string,
|
|
27
|
+
}>()
|
|
28
|
+
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :error="error" #default="slotprops">
|
|
4
|
+
<Chips class="simpleapp-inputfield simpleapp-inputchip"
|
|
5
|
+
v-model="modelValue"
|
|
6
|
+
:inputId="slotprops.uuid"
|
|
7
|
+
v-bind="$attrs"
|
|
8
|
+
></Chips>
|
|
9
|
+
</FieldContainer>
|
|
10
|
+
</template>
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import {computed,watch,ref} from 'vue'
|
|
13
|
+
import Chips from 'primevue/chips';
|
|
14
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
15
|
+
// const modelValue = defineModel()
|
|
16
|
+
|
|
17
|
+
const modelValue=defineModel()
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
label?:string,
|
|
20
|
+
description?:string,
|
|
21
|
+
setting?:any,
|
|
22
|
+
error?:string
|
|
23
|
+
}>()
|
|
24
|
+
</script>
|
|
25
|
+
<style >
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
4
|
+
<ColorPicker
|
|
5
|
+
class="simpleapp-inputcolor"
|
|
6
|
+
:inputId="slotprops.uuid"
|
|
7
|
+
v-model="modelValue"
|
|
8
|
+
v-bind="$attrs"
|
|
9
|
+
:path="setting.instancepath"
|
|
10
|
+
></ColorPicker>
|
|
11
|
+
</FieldContainer>
|
|
12
|
+
</template>
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
import {computed,watch,ref} from 'vue'
|
|
15
|
+
import ColorPicker from 'primevue/colorpicker';
|
|
16
|
+
|
|
17
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
18
|
+
const modelValue = defineModel()
|
|
19
|
+
const props = defineProps<{
|
|
20
|
+
label?:string,
|
|
21
|
+
description?:string,
|
|
22
|
+
error?:string,
|
|
23
|
+
setting:any,
|
|
24
|
+
instancepath?:string,
|
|
25
|
+
}>()
|
|
26
|
+
|
|
27
|
+
// const modelValue = defineModel<{modelValue?:string}>()
|
|
28
|
+
// console.log(modelValue.value)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// const emits = defineEmits(['update:modelValue'])
|
|
32
|
+
// const onchange=(e:any)=>{
|
|
33
|
+
// emits('update:modelValue',e.target.value)
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// watch(props ,(after,before)=>{
|
|
38
|
+
// // console.log("B4",before,"after",after)
|
|
39
|
+
// inputvalue.value=after.modelValue
|
|
40
|
+
// })
|
|
41
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DataTable v-bind="$attrs" class="simpleapp-datatable" stripedRows :value="valueModel">
|
|
3
|
+
<template #empty> <div class="text-center">No record found.</div> </template>
|
|
4
|
+
<template #header><slot name="header"></slot></template>
|
|
5
|
+
<Column v-for="(col,index) in columns" :field="col" :header="camelCaseToWords(col)"></Column>
|
|
6
|
+
<slot >
|
|
7
|
+
|
|
8
|
+
</slot>
|
|
9
|
+
</DataTable>
|
|
10
|
+
</template>
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import DataTable from 'primevue/datatable';
|
|
13
|
+
import Column from 'primevue/column';
|
|
14
|
+
import Button from 'primevue/button';
|
|
15
|
+
import {camelCaseToWords} from './helper'
|
|
16
|
+
const props = defineProps<{columns:string[]}>()
|
|
17
|
+
const valueModel = defineModel<Object[]>()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<FieldContainer :hidelabel="hidelabel" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
4
|
+
<div class="p-inputgroup flex-1 ">
|
|
5
|
+
<InputText class="simpleapp-inputfield"
|
|
6
|
+
:inputId="slotprops.uuid"
|
|
7
|
+
v-model="modelValue"
|
|
8
|
+
:placeholder="placeholder"
|
|
9
|
+
:path="setting.instancepath"
|
|
10
|
+
:pt="{input:{class:'text-right w-full'}}"
|
|
11
|
+
/>
|
|
12
|
+
<span class="p-inputgroup-addon p p-0">
|
|
13
|
+
<button class="pi pi-angle-down" type="button" @click="toggle"></button>
|
|
14
|
+
|
|
15
|
+
<OverlayPanel ref="op">
|
|
16
|
+
<ul>
|
|
17
|
+
<li v-for="docno in docFormatlist" class="hover-list-primary " >
|
|
18
|
+
<a class="flex-row p-2 mt-4" @click="chooseFormat(docno)">
|
|
19
|
+
<span class="pi pi-hashtag mr-2"></span>
|
|
20
|
+
<span class="">{{docno.docNoFormatName}}</span>
|
|
21
|
+
<span class="ml-2 text text-green-600">{{docno.sample}}</span>
|
|
22
|
+
</a>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
</OverlayPanel>
|
|
26
|
+
</span>
|
|
27
|
+
<!-- {{ Object.getOwnPropertyNames(setting) }} -->
|
|
28
|
+
</div>
|
|
29
|
+
</FieldContainer>
|
|
30
|
+
</template>
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import {ForeignKey} from '~/types'
|
|
33
|
+
import OverlayPanel from 'primevue/overlaypanel';
|
|
34
|
+
import {computed,watch,ref} from 'vue'
|
|
35
|
+
import InputText from 'primevue/inputtext';
|
|
36
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
37
|
+
import {DocNoFormat} from "~/types"
|
|
38
|
+
const selectedformat = ref()
|
|
39
|
+
const op = ref();
|
|
40
|
+
const placeholder = ref('')
|
|
41
|
+
const docFormatlist = ref()
|
|
42
|
+
const modelValue = defineModel<string>()
|
|
43
|
+
const docNoFormat = defineModel<ForeignKey>('docNoFormat')
|
|
44
|
+
// const emit = defineEmits(['update:docNoFormat'])
|
|
45
|
+
|
|
46
|
+
const props = withDefaults(defineProps<{
|
|
47
|
+
// docNoFormat:object,
|
|
48
|
+
// docFormatlist?:DocNoFormat[]
|
|
49
|
+
label?:string,
|
|
50
|
+
description?:string,
|
|
51
|
+
setting:any
|
|
52
|
+
error?:string,
|
|
53
|
+
instancepath?:string,
|
|
54
|
+
hidelabel?:boolean,
|
|
55
|
+
|
|
56
|
+
}>(),{
|
|
57
|
+
hidelabel:false
|
|
58
|
+
})
|
|
59
|
+
const documenttype = props.setting.document.doctype
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const toggle = async (event:any) => {
|
|
63
|
+
op.value.toggle(event);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const chooseFormat = (item:any) =>{
|
|
69
|
+
placeholder.value = item.sample
|
|
70
|
+
const f = item
|
|
71
|
+
docNoFormat.value = { _id : f._id, label : f.docNoFormatName}
|
|
72
|
+
op.value.toggle();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const loadDocFormats = async () =>{
|
|
76
|
+
docFormatlist.value= await getDocFormats(documenttype)
|
|
77
|
+
if(docFormatlist.value.length>0){
|
|
78
|
+
const f = docFormatlist.value[0]
|
|
79
|
+
docNoFormat.value = { _id : f._id, label : f.docNoFormatName}
|
|
80
|
+
placeholder.value = docFormatlist.value[0].sample
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
onMounted(()=>{
|
|
87
|
+
loadDocFormats()
|
|
88
|
+
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type {SimpleAppFieldSetting} from './type';
|
|
3
|
+
import SimpleAppAutocomplete from './SimpleAppAutocomplete.vue';
|
|
4
|
+
import SimpleAppText from './SimpleAppText.vue';
|
|
5
|
+
import SimpleAppSelect from './SimpleAppSelect.vue';
|
|
6
|
+
import type {JSONSchema7} from 'json-schema'
|
|
7
|
+
import {watch} from 'vue'
|
|
8
|
+
import SimpleAppTextarea from './SimpleAppTextarea.vue';
|
|
9
|
+
import SimpleAppCheckbox from './SimpleAppCheckbox.vue';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{setting:SimpleAppFieldSetting, getAutocomplete:Function, hidelabel?:boolean}>()
|
|
12
|
+
interface customSchema extends JSONSchema7 {
|
|
13
|
+
'x-foreignkey'?:string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// by right use 'customSchema', but been force to use any for avoid some error
|
|
17
|
+
const f:any = props.setting.fieldsetting
|
|
18
|
+
const modelValue = defineModel()
|
|
19
|
+
</script>
|
|
20
|
+
<template>
|
|
21
|
+
<SimpleAppAutocomplete v-if="f['x-foreignkey']" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel" :remote-src="getAutocomplete(typeof f['x-foreignkey']=='string' ? f['x-foreignkey'] : f['x-foreignkey']['target'])" optionLabel="label"/>
|
|
22
|
+
<SimpleAppCheckbox v-else-if="f.type=='boolean'" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"/>
|
|
23
|
+
<SimpleAppNumber v-else-if="f.type=='number' || f.type=='integer'" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppNumber>
|
|
24
|
+
<SimpleAppSelect v-else-if="f.enum" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppSelect>
|
|
25
|
+
<SimpleAppChip v-else-if="f.type=='array' && f.items && f.items.type=='string'" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppChip>
|
|
26
|
+
<SimpleAppTextarea v-else-if="f.type=='string' && f.format=='text'" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppTextarea>
|
|
27
|
+
<SimpleAppText v-else-if="f.type=='string' && f.format" :type="f.format" v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppText>
|
|
28
|
+
<SimpleAppText v-else v-model="modelValue" :setting="props.setting" :hidelabel="hidelabel"></SimpleAppText>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
4
|
+
<Editor
|
|
5
|
+
class="simpleapp-inputfield"
|
|
6
|
+
:inputId="slotprops.uuid"
|
|
7
|
+
v-model="modelValue"
|
|
8
|
+
v-bind="$attrs"
|
|
9
|
+
:autoResize="autoResize"
|
|
10
|
+
:path="setting.instancepath"
|
|
11
|
+
></Editor>
|
|
12
|
+
</FieldContainer>
|
|
13
|
+
</template>
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import {computed,watch,ref} from 'vue'
|
|
16
|
+
import Editor from 'primevue/editor';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
20
|
+
const modelValue = defineModel()
|
|
21
|
+
const props = defineProps<{
|
|
22
|
+
label?:string,
|
|
23
|
+
id?:string,
|
|
24
|
+
description?:string,
|
|
25
|
+
error?:string,
|
|
26
|
+
setting:any,
|
|
27
|
+
autoResize?:boolean,
|
|
28
|
+
instancepath?:string,
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form class="simpleapp-form" @submit.prevent="true">
|
|
3
|
+
<slot name="header"><h3 class="flex flex-col">{{ title }}</h3></slot>
|
|
4
|
+
<slot name="default" :data="document.getData()" :getField="getField"></slot>
|
|
5
|
+
</form>
|
|
6
|
+
</template>
|
|
7
|
+
<script setup lang="ts" >
|
|
8
|
+
import type {SimpleAppFieldSetting} from './type'
|
|
9
|
+
import { SimpleAppClient } from '../generate/docs/SimpleAppClient' //'../SimpleAppClient';
|
|
10
|
+
import type { JSONSchema7,JSONSchema7Definition } from 'json-schema';
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
title?:string,
|
|
14
|
+
document: SimpleAppClient<any,any>
|
|
15
|
+
readonly?:boolean
|
|
16
|
+
}>()
|
|
17
|
+
if(!props.document){
|
|
18
|
+
throw "undefine SimpleAppForm property 'document'"
|
|
19
|
+
}
|
|
20
|
+
// const obj = {schema:props.schema,data: props.schema}
|
|
21
|
+
const getField = (path:string)=>{
|
|
22
|
+
// console.log("simpleform topath",path)
|
|
23
|
+
const data = props.document.getData()
|
|
24
|
+
const schema = props.document.getSchema()
|
|
25
|
+
const fieldsetting = getPathObject(schema,path)
|
|
26
|
+
// console.log("setting",fieldsetting)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
path: path,
|
|
31
|
+
instancepath: getInstancePath(schema,path),
|
|
32
|
+
fieldsetting: fieldsetting,
|
|
33
|
+
modelObject: data,
|
|
34
|
+
document: props.document,
|
|
35
|
+
apiObj:props.document.getApi(),
|
|
36
|
+
modelField: 'email',
|
|
37
|
+
isrequired: getIsRequired(schema,path),
|
|
38
|
+
errors: props.document.getErrors(),
|
|
39
|
+
readonly: props.readonly
|
|
40
|
+
} as SimpleAppFieldSetting
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// "schemaPath": "#/properties/email/format",
|
|
44
|
+
|
|
45
|
+
const getModelValue=(data:any,path:string)=>{
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
const getIsRequired=(schema:any,path:string)=>{
|
|
49
|
+
if(!path){
|
|
50
|
+
console.error('unknown path')
|
|
51
|
+
return 'xx'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try{
|
|
55
|
+
let paths = path.replace('#/','').split('/')
|
|
56
|
+
const fieldname = paths[paths.length-1]
|
|
57
|
+
paths = paths.slice(0, -2);
|
|
58
|
+
let tmp = schema
|
|
59
|
+
for(let i=0;i<paths.length;i++){
|
|
60
|
+
tmp = tmp[paths[i]]
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
if(Array.isArray(tmp['required']) ) {
|
|
64
|
+
const arr:string[] = tmp['required']
|
|
65
|
+
return arr.includes (fieldname)
|
|
66
|
+
}else{
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// console.log("get instance path",instancepath)
|
|
71
|
+
|
|
72
|
+
// return tmp
|
|
73
|
+
}catch(err:any){
|
|
74
|
+
console.error(err.message)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const getInstancePath=(schema:any,path:string)=>{
|
|
78
|
+
if(!path){
|
|
79
|
+
console.error('unknown path')
|
|
80
|
+
return 'yy'
|
|
81
|
+
}
|
|
82
|
+
try{
|
|
83
|
+
let paths = path.replace('#/','').split('/')
|
|
84
|
+
let tmp = schema
|
|
85
|
+
let instancepath=''
|
|
86
|
+
for(let i=0;i<paths.length;i++){
|
|
87
|
+
tmp = tmp[paths[i]]
|
|
88
|
+
if(tmp['type'] && paths[i] !='items'){
|
|
89
|
+
instancepath=instancepath+'/'+paths[i]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// console.log("get instance path",instancepath)
|
|
94
|
+
return instancepath
|
|
95
|
+
// return tmp
|
|
96
|
+
}catch(err:any){
|
|
97
|
+
console.error(err.message)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// let paths = path.replace('#/','').split('/')
|
|
102
|
+
// return '/'+paths[1]
|
|
103
|
+
}
|
|
104
|
+
const getPathObject=(schema:JSONSchema7,path:string):JSONSchema7|undefined=>{
|
|
105
|
+
// console.log("path",path)
|
|
106
|
+
if(!path){
|
|
107
|
+
console.error('unknown path')
|
|
108
|
+
return undefined
|
|
109
|
+
}
|
|
110
|
+
try{
|
|
111
|
+
let paths:string[] = path.replace('#/','').split('/')
|
|
112
|
+
let tmp :JSONSchema7Definition= schema
|
|
113
|
+
// console.log(path)
|
|
114
|
+
for(let i=0;i<paths.length;i++){
|
|
115
|
+
|
|
116
|
+
//silly code, but it seems require to avoid typescript complaint.
|
|
117
|
+
//ultimately it is to obtain result as "tmp=tmp[path[i]]"
|
|
118
|
+
const key1 = paths[i] as keyof JSONSchema7
|
|
119
|
+
let jsonkey: keyof JSONSchema7 = key1
|
|
120
|
+
let obj:JSONSchema7 = {} as JSONSchema7
|
|
121
|
+
Object.assign(obj,tmp[jsonkey])
|
|
122
|
+
tmp = {...obj}
|
|
123
|
+
}
|
|
124
|
+
// console.log('final ',path,tmp)
|
|
125
|
+
return tmp
|
|
126
|
+
}catch(err:any){
|
|
127
|
+
console.error(err.message)
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
</script>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DataTable v-bind="$attrs" stripedRows resizableColumns
|
|
3
|
+
class="simpleapp-datatable p-datatable-sm" :value="modelValue">
|
|
4
|
+
<template #empty> <div class="text-center">No record found.</div> </template>
|
|
5
|
+
<template #header >
|
|
6
|
+
<div>
|
|
7
|
+
<button icon="pi pi-plus" @click="addNew()" class="simpleapp-datatable-add btn-primary" type="button">Add</button>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
<slot>
|
|
11
|
+
<!-- <template> -->
|
|
12
|
+
|
|
13
|
+
<Column class="text-center" header="undefine columns">
|
|
14
|
+
<template #body>
|
|
15
|
+
<div class="text-center">Missing {{ '<Column></Column>' }}</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
</Column>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<!-- </template> -->
|
|
22
|
+
|
|
23
|
+
</slot>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<!-- <Column v-for="(col,index) in columns" :field="col.field" :style="col.style" :header="camelCaseToWords(col.title??'')">
|
|
36
|
+
<template #body="{ data, field,index }">
|
|
37
|
+
<SimpleAppDynamicInput v-if="modelValue" :instancepath="getInstancePath(index,field)" :setting="getChildFieldSetting(field)" v-model="modelValue[index][field]" :getAutocomplete="getAutocomplete" :hidelabel="true" />
|
|
38
|
+
</template>
|
|
39
|
+
</Column>
|
|
40
|
+
<Column v-if="!readonly">
|
|
41
|
+
<template #body="{data,field,index}">
|
|
42
|
+
<button class="simpleapp-inputtable-delrow button-danger" @click="deleteRow(index)" type="button">X</button>
|
|
43
|
+
</template>
|
|
44
|
+
</Column> -->
|
|
45
|
+
</DataTable>
|
|
46
|
+
</template>
|
|
47
|
+
<script setup lang="ts">
|
|
48
|
+
|
|
49
|
+
import {ref} from 'vue'
|
|
50
|
+
import DataTable from 'primevue/datatable';
|
|
51
|
+
import Column from 'primevue/column';
|
|
52
|
+
import {camelCaseToWords} from './helper'
|
|
53
|
+
import type {InputTableColumn} from './type'
|
|
54
|
+
const props = defineProps<{
|
|
55
|
+
// columns:InputTableColumn[],
|
|
56
|
+
setting:any,
|
|
57
|
+
getField:Function,
|
|
58
|
+
getAutocomplete:Function, readonly?:boolean
|
|
59
|
+
}>()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
//{path: '#/properties/details', instancepath: '/details', fieldsetting: {…}, modelObject: Proxy(Object), apiObj: INVApi, …}
|
|
63
|
+
const modelValue = defineModel<any[]>()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const fieldsetting = props.setting.fieldsetting
|
|
67
|
+
|
|
68
|
+
const readonly = ref(false)
|
|
69
|
+
if(props.setting.readonly!==undefined ){
|
|
70
|
+
readonly.value = props.setting.readonly
|
|
71
|
+
}
|
|
72
|
+
if(props.readonly!==undefined ){
|
|
73
|
+
readonly.value = props.readonly
|
|
74
|
+
}
|
|
75
|
+
// const columns = ref(props.columns)
|
|
76
|
+
// for(let i=0;i<props.columns.length;i++){
|
|
77
|
+
// if(columns.value[i].title ===undefined){
|
|
78
|
+
// columns.value[i].title=columns.value[i].field
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
const getChildFieldSetting=(field:string)=>{
|
|
82
|
+
return props.getField(`${props.setting.path}/items/properties/${field}`)
|
|
83
|
+
}
|
|
84
|
+
const getInstancePath=(index:number,field:string)=>{
|
|
85
|
+
return `${props.setting.instancepath}/${index}/${field}`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const deleteRow=(index: number)=>{
|
|
89
|
+
if(modelValue.value){
|
|
90
|
+
modelValue.value.splice(index,1)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const addNew = () => {
|
|
94
|
+
const field = props.setting.path.split('/').at(-1)
|
|
95
|
+
props.setting.document[`add${field}`]()
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 1. support array with field to label
|
|
99
|
+
* 2. auto add edit button
|
|
100
|
+
* 3. option readonly or not readonly
|
|
101
|
+
* 4.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<FieldContainer v-bind="$attrs" v-model="modelValue" :label="label" :description="description" :setting="setting" :instancepath="instancepath" :error="error" #default="slotprops">
|
|
4
|
+
<Listbox v-model="modelValue"
|
|
5
|
+
class="simpleapp-inputfield"
|
|
6
|
+
:inputId="slotprops.uuid"
|
|
7
|
+
v-bind="$attrs"
|
|
8
|
+
:optionValue="optionValue"
|
|
9
|
+
:optionLabel="optionLabel"
|
|
10
|
+
:path="setting.instancepath"
|
|
11
|
+
:options="options"
|
|
12
|
+
/>
|
|
13
|
+
</FieldContainer>
|
|
14
|
+
</template>
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import {computed,watch,ref} from 'vue'
|
|
17
|
+
import Listbox from 'primevue/listbox';
|
|
18
|
+
import FieldContainer from './SimpleFieldContainer.vue'
|
|
19
|
+
import {prepareList,simpleArrayToObject} from './helper'
|
|
20
|
+
import type {SimpleAppFieldSetting} from './type'
|
|
21
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
22
|
+
const modelValue = defineModel()
|
|
23
|
+
const props = defineProps<{
|
|
24
|
+
label?:string,
|
|
25
|
+
description?:string,
|
|
26
|
+
error?:string,
|
|
27
|
+
setting:SimpleAppFieldSetting,
|
|
28
|
+
optionLabel?:string,
|
|
29
|
+
optionValue?:string,
|
|
30
|
+
instancepath?:string,
|
|
31
|
+
options?:any[],
|
|
32
|
+
}>()
|
|
33
|
+
const optionValue = props.optionValue ?? 'label'
|
|
34
|
+
const optionLabel = props.optionLabel ?? 'value'
|
|
35
|
+
const options = prepareList('oneOf',props.setting.fieldsetting,optionLabel,optionValue,props.options,)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</script>
|