@simitgroup/simpleapp-generator 1.2.7 → 1.3.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +3 -1
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +4 -9
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +14 -14
- package/dist/generate.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/organization.ts +3 -1
- package/src/framework.ts +5 -9
- package/src/generate.ts +17 -16
- package/templates/basic/nest/controller.ts.eta +17 -0
- package/templates/basic/nest/default.ts.eta +6 -2
- package/templates/basic/nuxt/default.ts.eta +10 -6
- package/templates/basic/nuxt/pages.[id].vue.eta +9 -7
- package/templates/basic/nuxt/pages.form.vue.eta +16 -36
- package/templates/basic/nuxt/pages.landing.vue.eta +42 -35
- package/templates/basic/nuxt/pages.viewer.vue.eta +4 -6
- package/templates/nest/.env._eta +0 -1
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +14 -2
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +32 -18
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +76 -13
- package/templates/nuxt/app.vue.eta +7 -3
- package/templates/nuxt/assets/css/calendar.css._eta +21 -8
- package/templates/nuxt/assets/css/style.css._eta +17 -10
- package/templates/nuxt/assets/primevue/passthrough.ts._eta +44 -22
- package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
- package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
- package/templates/nuxt/components/calendar/CalendarByResource.vue.eta +29 -8
- package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
- package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
- package/templates/nuxt/components/event/EventNotification.vue._eta +23 -2
- package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
- package/templates/nuxt/components/form/readme.md.eta +1 -0
- package/templates/nuxt/components/header/HeaderBar.vue._eta +9 -9
- package/templates/nuxt/components/header/HeaderBreadcrumb.vue.eta +2 -2
- package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +16 -22
- package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +29 -46
- package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
- package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
- package/templates/nuxt/components/list/ListView.vue.eta +129 -58
- package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
- package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
- package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
- package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
- package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
- package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
- package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
- package/templates/nuxt/components/renderer/RendererMoney.vue.eta +10 -2
- package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +202 -150
- package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +7 -1
- package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +112 -101
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -246
- package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +4 -3
- package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
- package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
- package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
- package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
- package/templates/nuxt/components/user/UserProfileListItem.vue.eta +2 -2
- package/templates/nuxt/composables/date.generate.ts.eta +21 -0
- package/templates/nuxt/composables/goTo.generate.ts.eta +1 -0
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +0 -5
- package/templates/nuxt/error.vue._eta +3 -3
- package/templates/nuxt/i18n.config.ts.eta +1 -1
- package/templates/nuxt/lang/en.ts.eta +16 -0
- package/templates/nuxt/layouts/default.vue._eta +34 -34
- package/templates/nuxt/layouts/loginlayout.vue._eta +3 -0
- package/templates/nuxt/layouts/mobile.vue._eta +52 -0
- package/templates/nuxt/nuxt.config.ts._eta +28 -22
- package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
- package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
- package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
- package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
- package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +40 -0
- package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +37 -0
- package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
- package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
- package/templates/nuxt/pages/[xorg]/{user.vue._eta → user.vue.eta} +88 -78
- package/templates/nuxt/pages/login.vue._eta +34 -0
- package/templates/nuxt/pages/profile.vue.eta +12 -3
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +36 -35
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
- package/templates/nuxt/server/api/[xorg]/[...].ts.eta +7 -40
- package/templates/nuxt/server/api/profile/[...].ts.eta +3 -32
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +42 -3
- package/templates/nuxt/types/calendar.ts.eta +8 -1
- package/templates/nuxt/types/documentlist.ts.eta +0 -9
- package/templates/nuxt/types/events.ts.eta +1 -0
- package/templates/nuxt/types/others.ts.eta +4 -1
- package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
- package/templates/nuxt/types/user.ts.eta +2 -0
- package/templates/project/lang/default._json +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
- package/templates/nuxt/lang/en.ts._eta +0 -6
- package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
- package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
- package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
- package/templates/nuxt/pages/[xorg]/user/[id].vue._eta +0 -6
- package/templates/nuxt/pages/[xorg]/user/index.vue._eta +0 -302
- package/templates/nuxt/pages/login.vue.eta +0 -30
- /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<span class="pi pi-check-circle text-green-500" v-if="modelValue">
|
|
3
|
+
</span>
|
|
4
|
+
<span class="pi pi-times-circle text-red-500" v-else>
|
|
5
|
+
</span>
|
|
6
|
+
|
|
3
7
|
</template>
|
|
4
8
|
<script lang="ts" setup>
|
|
5
9
|
/**
|
|
@@ -8,5 +12,5 @@
|
|
|
8
12
|
* last change 2024-02-04
|
|
9
13
|
* author: Ks Tan
|
|
10
14
|
*/
|
|
11
|
-
const modelValue = defineModel()
|
|
12
|
-
</script>
|
|
15
|
+
const modelValue = defineModel<boolean>();
|
|
16
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<template
|
|
2
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<span>{{ toLocalDate(value ?? "") }}</span>
|
|
3
3
|
</template>
|
|
4
4
|
<script lang="ts" setup>
|
|
5
5
|
/**
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* last change 2024-02-04
|
|
9
9
|
* author: Ks Tan
|
|
10
10
|
*/
|
|
11
|
-
const props = defineProps<{value?:string}>()
|
|
12
|
-
</script>
|
|
11
|
+
const props = defineProps<{ value?: string }>();
|
|
12
|
+
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<a @click="go" class="text-primary-700 dark:text-primary-300 dark:hover:text-primary-200 hover:text-primary-500 cursor-pointer">
|
|
3
|
+
<slot name="default">
|
|
4
|
+
<div>{{ value[fields[0]] }}</div>
|
|
5
|
+
</slot>
|
|
6
|
+
</a>
|
|
7
7
|
</template>
|
|
8
8
|
<script setup lang="ts">
|
|
9
9
|
/**
|
|
@@ -14,20 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const props = defineProps<{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}>()
|
|
17
|
+
fields: any;
|
|
18
|
+
setting: any;
|
|
19
|
+
value: any;
|
|
20
|
+
}>();
|
|
21
21
|
|
|
22
|
-
const go = ()=>{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// _id: props.value._id ,
|
|
26
|
-
// documentName: props.setting.documentName,
|
|
27
|
-
// viewer: getDocument(props.setting.documentName)?.viewer,
|
|
28
|
-
// label: props.setting.documentName,
|
|
29
|
-
// document:getDocument(props.setting.documentName)?.docClass,
|
|
30
|
-
// eventId: crypto.randomUUID()
|
|
31
|
-
// })
|
|
32
|
-
}
|
|
22
|
+
const go = () => {
|
|
23
|
+
goTo(props.setting.path, props.value._id);
|
|
24
|
+
};
|
|
33
25
|
</script>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
<template>
|
|
3
|
-
<span>
|
|
3
|
+
<span v-if="showCurrency"> {{ Intl.NumberFormat( useI18n().defaultLocale,{
|
|
4
4
|
style:'currency',
|
|
5
5
|
currency: getUserProfile()?.currency,
|
|
6
6
|
currencyDisplay: 'symbol',
|
|
7
7
|
}).format(modelValue) }}</span>
|
|
8
|
+
<span v-else> {{ modelValue.toLocaleString(useI18n().defaultLocale,options) }}</span>
|
|
8
9
|
</template>
|
|
9
10
|
<script lang="ts" setup>
|
|
10
11
|
/**
|
|
@@ -13,5 +14,12 @@
|
|
|
13
14
|
* last change 2024-02-04
|
|
14
15
|
* author: Ks Tan
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
const options = {
|
|
19
|
+
style: 'decimal', // Other options: 'currency', 'percent', etc.
|
|
20
|
+
minimumFractionDigits: 2,
|
|
21
|
+
maximumFractionDigits: 2,
|
|
22
|
+
};
|
|
23
|
+
const modelValue = defineModel<number>({required:true})
|
|
24
|
+
const props = defineProps<{showCurrency?:boolean}>()
|
|
17
25
|
</script>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<a
|
|
3
|
+
@click="openViewer"
|
|
4
|
+
class="text-primary-700 dark:text-primary-400 hover:text-primary-500 cursor-pointer"
|
|
5
|
+
>
|
|
6
|
+
<slot name="default">
|
|
7
|
+
<div v-if="fields">{{ value[fields[0]] }}</div>
|
|
8
|
+
</slot>
|
|
9
|
+
</a>
|
|
7
10
|
</template>
|
|
8
11
|
<script setup lang="ts">
|
|
9
12
|
/**
|
|
@@ -12,21 +15,24 @@
|
|
|
12
15
|
* last change 2024-02-04
|
|
13
16
|
* author: Ks Tan
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
import { RendererSetting } from "~/types";
|
|
16
19
|
const props = defineProps<{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}>()
|
|
20
|
+
fields?: string[];
|
|
21
|
+
setting: RendererSetting;
|
|
22
|
+
value: any;
|
|
23
|
+
}>();
|
|
21
24
|
|
|
22
|
-
const openViewer = ()=>{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const openViewer = () => {
|
|
26
|
+
useNuxtApp().$event("ViewRecord", {
|
|
27
|
+
_id: props.value._id,
|
|
28
|
+
documentName: props.setting.documentName,
|
|
29
|
+
viewer: getDocument(props.setting.documentName)?.viewer,
|
|
30
|
+
label: props.fields !== undefined ? props.value[props.fields[0]] : props.setting.documentName,
|
|
31
|
+
document: getDocument(props.setting.documentName)?.docClass,
|
|
32
|
+
eventId: randomUUID(),
|
|
33
|
+
after:()=>{
|
|
34
|
+
useNuxtApp().$event('CloseDialog',props.setting.documentName)
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
</script>
|
|
@@ -1,168 +1,220 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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>
|
|
25
69
|
</template>
|
|
26
70
|
<script setup lang="ts">
|
|
27
|
-
import { isNull } from
|
|
28
|
-
import * as jsonpath from
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
);
|
|
49
94
|
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
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 };
|
|
54
110
|
}
|
|
55
111
|
//clear auto complete auto set value = empty
|
|
56
|
-
const clear = ()=>{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
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
|
+
};
|
|
61
116
|
|
|
62
117
|
//if record picked, click button show record info instead
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
118
|
+
const openlink = () => {
|
|
119
|
+
if (modelValue.value?._id) {
|
|
120
|
+
openViewer(true);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
69
124
|
//recorrect data if lose focus
|
|
70
|
-
const onBlurAutocomplete = ()=>{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}
|
|
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
|
+
};
|
|
83
136
|
|
|
84
137
|
//obtain remote data
|
|
85
|
-
const getListFromAutocompleteApi =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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;
|
|
91
145
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
146
|
+
if (props.allowAddNew) {
|
|
147
|
+
list.value = list.value.concat({
|
|
148
|
+
_id: "new",
|
|
149
|
+
label: "<" + t("new") + ">",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
97
154
|
|
|
98
155
|
//on select
|
|
99
|
-
const pickAutoComplete = (event:any)=>{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}
|
|
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
|
+
};
|
|
114
169
|
|
|
115
|
-
const emits = defineEmits([
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
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
|
+
};
|
|
126
181
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if(remotedoc){
|
|
132
|
-
const schema:SchemaType = remotedoc.docClass.getSchema()
|
|
133
|
-
const labelfield = schema['x-simpleapp-config'].documentTitle as string
|
|
134
|
-
const codefield = schema['x-simpleapp-config'].uniqueKey as string
|
|
135
|
-
const docname = props.setting.fieldsetting['x-foreignkey']
|
|
136
|
-
$event('ViewRecord',{
|
|
137
|
-
_id: modelValue.value?._id as string,
|
|
138
|
-
eventId: randomUUID(),
|
|
139
|
-
label: (readonly ? modelValue.value?.label : `${t('new') + ' '+ t(docname) }`) as string,
|
|
140
|
-
readonly:readonly,
|
|
141
|
-
viewer : getDocument(docname)?.viewer,
|
|
142
|
-
documentName: docname,
|
|
182
|
+
const setFocus = (ev: any) => {
|
|
183
|
+
if (!isMobile()) ev.target.select();
|
|
184
|
+
};
|
|
143
185
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
modelValue.value = {...autocompleteitem.value}
|
|
159
|
-
emitChanges()
|
|
160
|
-
console.log("autocompleteitem.value",autocompleteitem.value ,modelValue.value)
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
})
|
|
186
|
+
//pop up records
|
|
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,
|
|
164
198
|
|
|
165
|
-
|
|
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
|
+
});
|
|
166
218
|
}
|
|
167
|
-
|
|
168
|
-
</script>
|
|
219
|
+
};
|
|
220
|
+
</script>
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="flex flex-row w-full">
|
|
5
5
|
<InputText
|
|
6
|
+
@focus="setFocus"
|
|
6
7
|
:readonly="readonly"
|
|
7
8
|
v-model="modelValue"
|
|
8
9
|
:placeholder="placeholder"
|
|
9
10
|
:pt="pt"
|
|
10
|
-
:class=" !pt ? 'flex-1 w-full rounded-lg '+ ( props.readonly?'':'
|
|
11
|
+
:class=" !pt ? 'flex-1 w-full rounded-lg '+ ( props.readonly?'':'rounded-tr-none rounded-br-none') : ''"
|
|
11
12
|
/>
|
|
12
13
|
<span class="" v-if="!readonly">
|
|
13
14
|
<button type="button" @click="toggle" tabindex="-1"
|
|
@@ -72,6 +73,11 @@ const loadDocFormats = async () =>{
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
|
|
77
|
+
const setFocus = (ev:any) => {
|
|
78
|
+
if(!isMobile()) ev.target.select()
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
onMounted(()=>{
|
|
76
82
|
loadDocFormats()
|
|
77
83
|
|