@simitgroup/simpleapp-generator 1.6.3-alpha → 1.6.4-b-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 (152) hide show
  1. package/dist/buildinschemas/branch.d.ts.map +1 -1
  2. package/dist/buildinschemas/branch.js +1 -0
  3. package/dist/buildinschemas/branch.js.map +1 -1
  4. package/dist/buildinschemas/changehistories.d.ts +3 -0
  5. package/dist/buildinschemas/changehistories.d.ts.map +1 -0
  6. package/dist/buildinschemas/changehistories.js +36 -0
  7. package/dist/buildinschemas/changehistories.js.map +1 -0
  8. package/dist/buildinschemas/index.d.ts +1 -0
  9. package/dist/buildinschemas/index.d.ts.map +1 -1
  10. package/dist/buildinschemas/index.js +3 -1
  11. package/dist/buildinschemas/index.js.map +1 -1
  12. package/dist/buildinschemas/organization.js +2 -2
  13. package/dist/buildinschemas/organization.js.map +1 -1
  14. package/dist/buildinschemas/user.d.ts.map +1 -1
  15. package/dist/buildinschemas/user.js +5 -1
  16. package/dist/buildinschemas/user.js.map +1 -1
  17. package/dist/buildinschemas/webhook.d.ts +3 -0
  18. package/dist/buildinschemas/webhook.d.ts.map +1 -0
  19. package/dist/buildinschemas/webhook.js +33 -0
  20. package/dist/buildinschemas/webhook.js.map +1 -0
  21. package/dist/framework.d.ts.map +1 -1
  22. package/dist/framework.js +3 -2
  23. package/dist/framework.js.map +1 -1
  24. package/dist/generate.js +30 -11
  25. package/dist/generate.js.map +1 -1
  26. package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
  27. package/dist/processors/jsonschemabuilder.js +10 -2
  28. package/dist/processors/jsonschemabuilder.js.map +1 -1
  29. package/dist/type.d.ts +2 -0
  30. package/dist/type.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/buildinschemas/branch.ts +1 -0
  33. package/src/buildinschemas/changehistories.ts +33 -0
  34. package/src/buildinschemas/index.ts +2 -1
  35. package/src/buildinschemas/organization.ts +2 -2
  36. package/src/buildinschemas/user.ts +5 -1
  37. package/src/buildinschemas/webhook.ts +31 -0
  38. package/src/framework.ts +3 -2
  39. package/src/generate.ts +35 -15
  40. package/src/processors/jsonschemabuilder.ts +10 -2
  41. package/src/type.ts +2 -0
  42. package/templates/basic/nest/controller.ts.eta +24 -3
  43. package/templates/basic/nest/model.ts.eta +9 -1
  44. package/templates/basic/nest/resolver.ts.eta +2 -2
  45. package/templates/basic/nuxt/pages.[id].vue.eta +7 -7
  46. package/templates/basic/nuxt/pages.form.vue.eta +1 -4
  47. package/templates/basic/nuxt/pages.landing.vue.eta +1 -20
  48. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +8 -1
  49. package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +2 -0
  50. package/templates/nest/src/simpleapp/generate/commons/dicts/documents.ts.eta +9 -2
  51. package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +21 -8
  52. package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +5 -10
  53. package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +1 -0
  54. package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +50 -0
  55. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +22 -8
  56. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +9 -1
  57. package/templates/nest/src/simpleapp/generate/processors/branch.processor.ts.eta +12 -6
  58. package/templates/nest/src/simpleapp/generate/processors/org.processor.ts.eta +7 -12
  59. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +133 -28
  60. package/templates/nest/src/simpleapp/generate/types/schema.type.ts.eta +3 -1
  61. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +1 -0
  62. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +19 -0
  63. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +33 -8
  64. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +15 -9
  65. package/templates/nuxt/assets/css/calendar.css._eta +3 -0
  66. package/templates/nuxt/assets/css/style.css._eta +1 -1
  67. package/templates/nuxt/assets/images/unknown.png.eta +0 -0
  68. package/templates/nuxt/assets/primevue/passthrough.ts._eta +6 -1
  69. package/templates/nuxt/components/button/ButtonAction.vue._eta +40 -39
  70. package/templates/nuxt/components/button/ButtonDanger.vue._eta +11 -3
  71. package/templates/nuxt/components/button/ButtonDefault.vue._eta +11 -3
  72. package/templates/nuxt/components/button/ButtonPrimary.vue._eta +9 -3
  73. package/templates/nuxt/components/button/ButtonSecondary.vue._eta +33 -0
  74. package/templates/nuxt/components/button/ButtonText.vue._eta +9 -5
  75. package/templates/nuxt/components/button/ButtonWarning.vue._eta +11 -3
  76. package/templates/nuxt/components/calendar/CalendarInput.vue.eta +4 -3
  77. package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +76 -52
  78. package/templates/nuxt/components/chart/card.vue._eta +1 -1
  79. package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +36 -26
  80. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +35 -13
  81. package/templates/nuxt/components/form/FormBranch.vue._eta +52 -5
  82. package/templates/nuxt/components/form/FormDocnoformat.vue.eta +14 -10
  83. package/templates/nuxt/components/form/FormUser.vue._eta +2 -4
  84. package/templates/nuxt/components/form/user/FormUserPermission.vue.eta +77 -59
  85. package/templates/nuxt/components/header/HeaderSelectBranch.vue.eta +42 -35
  86. package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +30 -0
  87. package/templates/nuxt/components/image/ImageOrganization.vue.eta.vue +34 -14
  88. package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta.vue +67 -50
  89. package/templates/nuxt/components/list/ListDocumentTable.vue.eta +20 -12
  90. package/templates/nuxt/components/list/ListView.vue.eta +64 -35
  91. package/templates/nuxt/components/overlay/OverlayPanelWithToolBar.vue.eta +5 -4
  92. package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +8 -8
  93. package/templates/nuxt/components/page/PageDocList.vue.eta +36 -13
  94. package/templates/nuxt/components/renderer/RendererDate.vue.eta +8 -2
  95. package/templates/nuxt/components/renderer/RendererDateTime.vue.eta +7 -1
  96. package/templates/nuxt/components/renderer/RendererDocHistories.vue.eta +56 -0
  97. package/templates/nuxt/components/renderer/RendererForeignKey.vue.eta +14 -8
  98. package/templates/nuxt/components/renderer/RendererLink.vue.eta +7 -4
  99. package/templates/nuxt/components/renderer/RendererMoney.vue.eta +25 -17
  100. package/templates/nuxt/components/renderer/RendererTime.vue.eta +7 -1
  101. package/templates/nuxt/components/renderer/RendererViewer.vue.eta +19 -9
  102. package/templates/nuxt/components/select/SelectTemplate.vue.eta +53 -22
  103. package/templates/nuxt/components/session/SessionBlock.vue.eta +44 -46
  104. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +25 -16
  105. package/templates/nuxt/components/simpleApp/SimpleAppCalendarInput.vue.eta +60 -0
  106. package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +16 -8
  107. package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +8 -8
  108. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +1 -1
  109. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +114 -38
  110. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +89 -168
  111. package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +44 -40
  112. package/templates/nuxt/components/simpleApp/SimpleAppUserPicker.vue.eta +387 -0
  113. package/templates/nuxt/components/text/TextDocStatus.vue._eta +22 -0
  114. package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +13 -15
  115. package/templates/nuxt/components/user/UserButtonPermissionInfo.vue.eta +138 -95
  116. package/templates/nuxt/components/user/UserInvitation.vue.eta +53 -45
  117. package/templates/nuxt/components/user/UserTenantPicker.vue.eta +32 -71
  118. package/templates/nuxt/composables/date.generate.ts.eta +105 -8
  119. package/templates/nuxt/composables/getDocument.generate.ts.eta +8 -6
  120. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +58 -10
  121. package/templates/nuxt/composables/getUserStore.generate.ts.eta +39 -6
  122. package/templates/nuxt/composables/goTo.generate.ts.eta +14 -1
  123. package/templates/nuxt/composables/graphquery.generate.ts.eta +20 -2
  124. package/templates/nuxt/composables/recently.generate.ts.eta +16 -0
  125. package/templates/nuxt/composables/roles.generate.ts.eta +9 -13
  126. package/templates/nuxt/composables/stringHelper.generate.ts.eta +52 -0
  127. package/templates/nuxt/composables/sysmessage.generate.ts.eta +1 -1
  128. package/templates/nuxt/error.vue._eta +4 -2
  129. package/templates/nuxt/pages/[xorg]/{organization.vue.eta → organization.vue._eta} +38 -9
  130. package/templates/nuxt/pages/[xorg]/user.vue.eta +12 -9
  131. package/templates/nuxt/pages/login.vue._eta +4 -1
  132. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +54 -26
  133. package/templates/nuxt/plugins/70.recently.ts.eta +55 -0
  134. package/templates/nuxt/providers/my-provider.ts.eta +22 -0
  135. package/templates/nuxt/server/api/[xorg]/{[...].ts.eta → [...].ts._eta} +47 -21
  136. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +44 -3
  137. package/templates/nuxt/types/events.ts.eta +3 -2
  138. package/templates/nuxt/types/others.ts.eta +11 -1
  139. package/templates/nuxt/types/schema.ts.eta +3 -1
  140. package/templates/nuxt/types/simpleappinput.ts.eta +1 -1
  141. package/templates/nuxt/types/user.ts.eta +8 -7
  142. package/templates/project/jsonschemas/branch.json._eta +1 -0
  143. package/templates/project/jsonschemas/invoice.json._eta +4 -3
  144. package/templates/project/jsonschemas/organization.json._eta +2 -2
  145. package/templates/project/lang/default._json +6 -2
  146. package/tsconfig.tsbuildinfo +1 -1
  147. package/templates/nuxt/components/image/ImageAvatar.vue.eta.vue +0 -38
  148. /package/templates/nuxt/pages/[xorg]/mobile/docnoformat/{index.vue.eta → index.vue.etaxxx} +0 -0
  149. /package/templates/nuxt/pages/[xorg]/mobile/{index.vue._eta → index.vue._etaxxx} +0 -0
  150. /package/templates/nuxt/pages/[xorg]/mobile/organization/{[id].vue._eta → [id].vue._etaxxx} +0 -0
  151. /package/templates/nuxt/pages/[xorg]/mobile/{pickgroup.vue._eta → pickgroup.vue._etaxxx} +0 -0
  152. /package/templates/nuxt/pages/[xorg]/mobile/user/{index.vue.eta → index.vue.etaxxx} +0 -0
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div class="flex flex-row text-xs cursor-pointer"
3
+ v-if="data?.updated && data?.updated !=''" @click="viewHistories">
4
+ <ImageAvatar v-if="data?.updatedBy" :id="data.updatedBy" :size="12"></ImageAvatar>
5
+ <div class="flex flex-col p-2">
6
+ <TextDocStatus v-if="data?.docStatus" :docStatus="data?.docStatus" />
7
+ <TextSubsubtitle class=" text-gray-400 italic">{{ t('updated') }}:</TextSubsubtitle>
8
+ <RendererDateTime :value="data?.updated" class="text-gray-400 italic"/>
9
+ </div>
10
+
11
+
12
+ <Dialog v-model:visible="visibleHistories" modal
13
+ :header="t('histories')" :pt="{root:{class:'w-1/4'}}">
14
+ <Timeline :value="events" class="w-full md:w-20rem">
15
+ <template #opposite="slotProps">
16
+ <RendererDateTime class="italic text-gray-400 text-xs" :value="slotProps.item.date"/>
17
+ </template>
18
+ <template #content="slotProps">
19
+ <div>
20
+ <div>{{ slotProps.item.status }}</div>
21
+ </div>
22
+
23
+ </template>
24
+ </Timeline>
25
+ </Dialog>
26
+ </div>
27
+
28
+ </template>
29
+ <script lang="ts" setup>
30
+ import TextSubsubtitle from '../text/TextSubsubtitle.vue';
31
+ import RendererDateTime from './RendererDateTime.vue';
32
+ const visibleHistories = ref(false)
33
+ const props=defineProps<{data:any}>()
34
+ const events = computed(()=>{
35
+ const list = [{ status: t('created'), date: props.data.created },]
36
+
37
+ if(props.data.updated != props.data.created){
38
+ list.push({ status: t('paidFeature'), date:''})
39
+ list.push( { status: t('lastUpdate'), date: props.data.updated })
40
+ }
41
+ return list
42
+ })
43
+ const severity = computed(()=>{
44
+ const stat = props.data.docStatus
45
+ if(props.data.docStatus=='confirm') return "success"
46
+ else if(props.data.docStatus=='void') return "danger"
47
+ else if(props.data.docStatus=='draft') return "secondary"
48
+ else return "warning"
49
+ })
50
+
51
+
52
+ const viewHistories = () =>{
53
+ visibleHistories.value=true
54
+ console.log("histories")
55
+ }
56
+ </script>
@@ -21,25 +21,31 @@ import { ForeignKey, FormCrudEvent, SimpleAppDocumentType } from "~/types";
21
21
 
22
22
  type SettingProp = { collection: SimpleAppDocumentType; displayField?: string };
23
23
  const modelValue = defineModel<ForeignKey>();
24
+
24
25
  const emits = defineEmits(["after"]);
25
- const props = defineProps<{ setting: SettingProp }>();
26
+ const props = defineProps<{ value?: ForeignKey; setting: SettingProp }>();
26
27
  const displayText = computed(() => {
27
28
  const s = props.setting;
28
- if (!modelValue.value) return undefined;
29
- else if (!s.collection) return modelValue.value;
30
- else if (s.displayField) return modelValue.value[s.displayField];
31
- else return modelValue.value.label;
29
+ if (!modelValue.value && !props.value) return undefined;
30
+ else if (!s.collection) return modelValue.value ?? props.value;
31
+ else if (s.displayField) {
32
+ if(modelValue.value) return modelValue.value[s.displayField]
33
+ else if (props.value) props.value[s.displayField];
34
+ else return ''
35
+ }
36
+
37
+ else return modelValue.value?.label ?? props.value?.label;
32
38
  });
33
39
  const { $event } = useNuxtApp();
34
40
  const viewer = ref();
35
41
  const viewRecord = () => {
36
42
  viewer.value = getDocument(props.setting.collection)?.viewer;
37
-
43
+ const value = modelValue.value ?? props.value;
38
44
  // getDocumentUrl(setting.collection,modelValue ? modelValue['_id']:'')
39
45
  //getDocumentUrl(setting.collection,modelValue ? modelValue['_id']:'')
40
46
  $event("ViewRecord", {
41
- _id: modelValue.value?._id as string,
42
- label: modelValue.value?.label as string,
47
+ _id: value?._id as string,
48
+ label: value?.label as string,
43
49
  eventId: randomUUID(),
44
50
  documentName: props.setting.collection,
45
51
  viewer: viewer.value,
@@ -1,7 +1,10 @@
1
1
  <template>
2
- <a @click="go" class="text-primary-700 dark:text-primary-300 dark:hover:text-primary-200 hover:text-primary-500 cursor-pointer">
2
+ <a
3
+ @click="go"
4
+ class="text-primary-700 dark:text-primary-300 dark:hover:text-primary-200 hover:text-primary-500 cursor-pointer"
5
+ >
3
6
  <slot name="default">
4
- <div>{{ value[fields[0]] }}</div>
7
+ <div>{{ value[fields[0]] ?? t('undefined') }}</div>
5
8
  </slot>
6
9
  </a>
7
10
  </template>
@@ -20,6 +23,6 @@ const props = defineProps<{
20
23
  }>();
21
24
 
22
25
  const go = () => {
23
- goTo(props.setting.path, props.value._id);
26
+ goTo(props.setting.path, props.value._id);
24
27
  };
25
- </script>
28
+ </script>
@@ -1,11 +1,15 @@
1
1
  <template>
2
- <span v-if="typeof modelValue == 'undefined' || typeof modelValue == 'string'"
3
- >-</span
4
- >
5
- <span v-else-if="showCurrency"> {{ currenyValue }}</span>
6
- <span v-else>
7
- {{ modelValue.toLocaleString(useI18n().defaultLocale, options) }}</span
8
- >
2
+
3
+ <span>
4
+ <span class="mr-1" v-if="showCurrency">{{ getCurrency() }}</span>
5
+ <span v-if="typeof modelValue != 'undefined'">{{
6
+ modelValue.toLocaleString(useI18n().defaultLocale, options)
7
+ }}</span>
8
+ <span v-else-if="typeof props.value != 'undefined'">{{
9
+ props.value.toLocaleString(useI18n().defaultLocale, options)
10
+ }}</span>
11
+ <span v-else>-</span>
12
+ </span>
9
13
  </template>
10
14
  <script lang="ts" setup>
11
15
  /**
@@ -14,20 +18,24 @@
14
18
  * last change 2024-02-04
15
19
  * author: Ks Tan
16
20
  */
17
- const currenyValue = computed(() => {
18
- if (modelValue.value === undefined) return "-";
19
- return Intl.NumberFormat(useI18n().defaultLocale, {
20
- // style: "currency",
21
- // currency: getUserProfile()?.currency ?? '',
22
- // currencyDisplay: "symbol",
23
- }).format(modelValue.value);
24
- });
25
21
  const options = {
26
22
  style: "decimal", // Other options: 'currency', 'percent', etc.
27
23
  minimumFractionDigits: 2,
28
24
  maximumFractionDigits: 2,
29
25
  };
30
- const modelValue = defineModel<number>({ required: true });
31
- const props = defineProps<{ showCurrency?: boolean }>();
26
+ const modelValue = defineModel<number>();
27
+ const props = defineProps<{ showCurrency?: boolean ; value?:number }>();
28
+
29
+ const currenyValue = computed(() => {
30
+ if (typeof modelValue.value == 'number'){
31
+ return Intl.NumberFormat(useI18n().defaultLocale,
32
+ {}).format(modelValue.value);
33
+ }else if(typeof props.value == 'number'){
34
+ return Intl.NumberFormat(useI18n().defaultLocale,{}).format(props.value);
35
+ }else return '-'
36
+
37
+
38
+ });
39
+
32
40
 
33
41
  </script>
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <span v-if="modelValue">{{ toUTCTime(modelValue) }}</span>
2
+ <span v-if="modelValue">
3
+ {{ dateRenderToTimeStr(modelValue) }}
4
+ </span>
5
+ <span v-else-if="value">
6
+ {{ dateRenderToTimeStr(value) }}
7
+ </span>
3
8
  <span v-else>-</span>
4
9
  </template>
5
10
  <script lang="ts" setup>
@@ -10,4 +15,5 @@
10
15
  * author: Ks Tan
11
16
  */
12
17
  const modelValue = defineModel<Date | string>();
18
+ const props = defineProps<{ value: Date | string }>();
13
19
  </script>
@@ -1,12 +1,17 @@
1
1
  <template>
2
- <a
2
+ <div v-if="!value"></div>
3
+ <a v-else
3
4
  @click="openViewer"
4
5
  class="text-primary-700 dark:text-primary-400 hover:text-primary-500 cursor-pointer"
5
6
  >
6
7
  <slot name="default">
7
- <div v-if="fields">{{ value[fields[0]] }}</div>
8
+
9
+ <TextDanger v-if="!value">{{t('undefined')}}</TextDanger>
10
+ <TextDanger v-else-if="!Array.isArray(fields) || !fields[0]">{{t('undefinedFields')}}</TextDanger>
11
+ <div v-else-if="value[fields[0]]">{{ value[fields[0]] }}</div>
12
+ <div v-else></div>
8
13
  </slot>
9
- </a>
14
+ </a>
10
15
  </template>
11
16
  <script setup lang="ts">
12
17
  /**
@@ -21,18 +26,23 @@ const props = defineProps<{
21
26
  setting: RendererSetting;
22
27
  value: any;
23
28
  }>();
24
-
29
+ const viewervalue = computed(()=>{
30
+ return props.value ?? {}
31
+ })
25
32
  const openViewer = () => {
26
33
  useNuxtApp().$event("ViewRecord", {
27
34
  _id: props.value._id,
28
35
  documentName: props.setting.documentName,
29
36
  viewer: getDocument(props.setting.documentName)?.viewer,
30
- label: props.fields !== undefined ? props.value[props.fields[0]] : props.setting.documentName,
37
+ label:
38
+ props.fields !== undefined
39
+ ? props.value[props.fields[0]]
40
+ : props.setting.documentName,
31
41
  document: getDocument(props.setting.documentName)?.docClass,
32
- eventId: randomUUID(),
33
- after:()=>{
34
- useNuxtApp().$event('CloseDialog',props.setting.documentName)
35
- }
42
+ eventId: randomUUID(),
43
+ after: () => {
44
+ useNuxtApp().$event("CloseDialog", props.setting.documentName);
45
+ },
36
46
  });
37
47
  };
38
48
  </script>
@@ -1,18 +1,19 @@
1
1
  <template>
2
- <div>
2
+ <div class="w-full">
3
3
  <div class="flex flex-row">
4
- <label v-if="!hideLabel" :for="fieldid" class="pt-2">
4
+ <label v-if="!hideLabel" :for="fieldid">
5
5
  {{ t(documentName) }}
6
6
  </label>
7
- <ButtonText
7
+ <div
8
8
  v-if="allowAddNew"
9
9
  @click="addnew"
10
- class="text-xs text-blue-600"
10
+ class="cursor-pointer ml-2 pt-1 text-xs text-blue-600"
11
11
  >
12
12
  <span>{{ t("new") }}</span>
13
- </ButtonText>
13
+ </div>
14
14
  </div>
15
15
  <MultiSelect
16
+ class="w-full md:w-full"
16
17
  :input-id="fieldid"
17
18
  v-if="multiple"
18
19
  display="chip"
@@ -21,18 +22,44 @@
21
22
  :options="options"
22
23
  optionLabel="label"
23
24
  optionValue="value"
25
+ filter
24
26
  :placeholder="placeholder"
25
- />
27
+ >
28
+ <template #value="slotProps">
29
+ <slot name="value" :slotProps="slotProps"> </slot>
30
+ </template>
31
+ <template #option="slotProps">
32
+ <slot
33
+ name="default"
34
+ :option="slotProps.option"
35
+ :index="slotProps.index"
36
+ >
37
+ </slot>
38
+ </template>
39
+ </MultiSelect>
26
40
  <Dropdown
41
+ class="w-full md:w-full"
27
42
  :input-id="fieldid"
28
43
  v-else
29
44
  @update:modelValue="change"
45
+ filter
30
46
  v-model="modelValue"
31
47
  :options="options"
32
48
  optionLabel="label"
33
49
  optionValue="value"
34
50
  :placeholder="placeholder"
35
- />
51
+ >
52
+ <template #value="slotProps">
53
+ <slot name="value" :item="getItem(modelValue)"></slot>
54
+ </template>
55
+ <template #option="slotProps">
56
+ <slot
57
+ name="default"
58
+ :option="slotProps.option"
59
+ :index="slotProps.index"
60
+ ></slot>
61
+ </template>
62
+ </Dropdown>
36
63
  </div>
37
64
  </template>
38
65
  <script setup lang="ts">
@@ -44,11 +71,11 @@
44
71
  */
45
72
  import Dropdown from "primevue/dropdown";
46
73
 
47
- import { ForeignKey,SimpleAppDocuments, FormCrudEvent } from "~/types";
74
+ import { ForeignKey, SimpleAppDocuments, FormCrudEvent } from "~/types";
48
75
  const emits = defineEmits(["change"]);
49
76
 
50
77
  const props = defineProps<{
51
- documentName: SimpleAppDocuments;
78
+ documentName: keyof SimpleAppDocuments;
52
79
  placeholder?: string;
53
80
  showNull?: boolean;
54
81
  allowAddNew?: boolean;
@@ -58,7 +85,7 @@ const props = defineProps<{
58
85
  }>();
59
86
  // const initvalue = props.multiple==true ? [] : ''
60
87
  const modelValue = defineModel<string | string[]>();
61
-
88
+ const allowAddNew = computed(()=> props.allowAddNew && canPerform(props.documentName,'create'))
62
89
  const list = ref<ForeignKey[]>([]);
63
90
  const fieldid = randomUUID();
64
91
 
@@ -66,6 +93,7 @@ const options = ref<
66
93
  {
67
94
  value: string;
68
95
  label: string;
96
+ more: any;
69
97
  }[]
70
98
  >([]);
71
99
  const getListOptions = async () => {
@@ -79,38 +107,41 @@ const getListOptions = async () => {
79
107
  options.value = list.value.map((item) => ({
80
108
  value: item._id,
81
109
  label: item.label,
110
+ more: item,
82
111
  }));
83
112
  };
84
113
  onMounted(async () => {
85
114
  await getListOptions();
86
115
  if (modelValue.value) change(modelValue.value);
87
116
  });
88
- const getItem = (id: string) => list.value?.find((item) => item._id == id);
117
+ const getItem = (id: string) =>
118
+ list.value?.find((item) => {
119
+ return item._id == id;
120
+ });
89
121
 
90
- const change = (id: string|string[]) => {
122
+ const change = (id: string | string[]) => {
91
123
  const selectedItem = getItem(id);
92
124
  emits("change", id, selectedItem);
125
+ // console.log("changed",selectedItem)
93
126
  };
94
127
 
95
128
  const addnew = () => {
96
- const doc = getDocument(props.documentName )?.docClass;
129
+ const doc = getDocument(props.documentName)?.docClass;
97
130
  if (doc) {
98
131
  const tmpdata = doc?.getReactiveData();
99
132
  type DataType = typeof tmpdata.value;
100
133
  onScreenAddDocument<DataType>(
101
- props.documentName ,
134
+ props.documentName,
102
135
  undefined,
103
136
  async (eventType: FormCrudEvent, data: DataType) => {
104
137
  if (eventType == FormCrudEvent.create) {
105
138
  await getListOptions();
106
- if(props.multiple) {
107
- if(modelValue.value===undefined) modelValue.value=[data._id]
108
- else if(Array.isArray(modelValue.value))
109
- modelValue.value.push(data._id);
110
-
111
-
112
- }
113
- else modelValue.value = data._id;
139
+ if (props.multiple) {
140
+ if (modelValue.value === undefined) modelValue.value = [data._id];
141
+ else if (Array.isArray(modelValue.value))
142
+ modelValue.value.push(data._id);
143
+ } else modelValue.value = data._id;
144
+ refreshDocumentList(props.documentName);
114
145
  emits("change", data._id, getItem(data._id));
115
146
  }
116
147
  },
@@ -1,55 +1,53 @@
1
1
  <template>
2
-
3
- <Dialog v-model:visible="showDialog" modal :pt="{root:{class:'w-1/3'}}"
4
- :header="t('sessionExpire')">
5
- <div>
6
- {{ t('reloginMessage') }}
7
- </div>
8
- <div class="text-right">
9
- <Button @click="relogin" class="btn-primary">
10
- {{ t('login') }}
11
- </Button>
12
- </div>
13
-
14
-
15
- </Dialog>
16
-
17
-
18
-
19
-
20
- </template>
21
- <script lang="ts" setup>
22
- /**
2
+ <Dialog
3
+ v-model:visible="showDialog"
4
+ modal
5
+ :pt="{ root: { class: 'w-1/3' } }"
6
+ :header="t('sessionExpire')"
7
+ >
8
+ <div>
9
+ {{ t("reloginMessage") }}
10
+ </div>
11
+ <div class="text-right">
12
+ <Button @click="relogin" class="btn-primary">
13
+ {{ t("login") }}
14
+ </Button>
15
+ </div>
16
+ </Dialog>
17
+ </template>
18
+ <script lang="ts" setup>
19
+ /**
23
20
  * This file was automatically generated by simpleapp generator. Every
24
21
  * MODIFICATION OVERRIDE BY GENERATEOR
25
22
  * last change 2023-10-28
26
23
  * Author: Ks Tan
27
24
  */
28
- import {PROFILEApi} from '~/simpleapp/generate/openapi'
29
- const showDialog = ref(false)
30
- const tabvisible = ref('')
31
-
32
-
33
- addEventListener("visibilitychange", async (event) => {
34
- tabvisible.value = document.visibilityState
35
-
36
- if(document.visibilityState ==='visible'){
37
- //focus tab, try session still active?
38
- const result = await getApiSession()
39
- if(result){
40
- showDialog.value=false
41
- }else{
42
- showDialog.value=true
25
+ import { PROFILEApi } from "~/simpleapp/generate/openapi";
26
+ const showDialog = ref(false);
27
+ const tabvisible = ref("");
28
+
29
+ addEventListener("visibilitychange", async (event) => {
30
+ tabvisible.value = document.visibilityState;
31
+
32
+ if (document.visibilityState === "visible") {
33
+ //focus tab, try session still active?
34
+ try{
35
+ const result = await getApiSession();
36
+ console.log("get sessionresult ",result)
37
+ if (result) {
38
+
39
+ showDialog.value = false;
40
+ } else {
41
+ showDialog.value = true;
43
42
  }
43
+ }catch(e){
44
+ showDialog.value = true;
44
45
  }
45
- });
46
-
47
-
48
- const relogin= ()=>{
49
- window.open(useRuntimeConfig().public.APP_URL+'/relogin')
46
+
50
47
  }
51
-
52
-
53
-
54
-
55
- </script>
48
+ });
49
+
50
+ const relogin = () => {
51
+ window.open(useRuntimeConfig().public.APP_URL + "/relogin");
52
+ };
53
+ </script>
@@ -1,35 +1,37 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="readonly"
4
- class="p-3 border rounded-lg border-gray-300 dark:border-blue-900/40"
4
+ class="p-2 border rounded-lg border-gray-300 dark:border-blue-900/40"
5
5
  >
6
6
  <button
7
7
  :readonly="readonly"
8
8
  class="cursor-pointer text-primary-600 dark:text-primary-400"
9
9
  tabindex="0"
10
10
  @click="openViewer(true)"
11
- >{{ modelValue && modelValue.label ? modelValue.label : "-" }}</button
12
11
  >
12
+ {{ modelValue && modelValue.label ? modelValue.label : "-" }}
13
+ </button>
13
14
  </div>
14
15
  <div
15
16
  v-else-if="modelValue !== undefined"
16
- class="p-3 border rounded-lg border-gray-300 dark:border-blue-900/40 relative"
17
+ class="p-2 border rounded-lg border-gray-300 dark:border-blue-900/40 relative"
17
18
  >
18
19
  <button
19
20
  ref="autocompleteinput"
20
21
  readonly
21
22
  class="cursor-pointer text-primary-600 dark:text-primary-400"
22
-
23
23
  @click="openViewer(true)"
24
- >{{ modelValue && modelValue.label ? modelValue.label : "-" }}</button>
24
+ >
25
+ {{ modelValue && modelValue.label ? modelValue.label : "-" }}
26
+ </button>
25
27
 
26
28
  <div
27
29
  class="absolute h-full top-0 right-0 text-right text-white z-10 align-middle p-3"
28
30
  >
29
31
  <button
30
32
  class="pi pi-times rounded-full bg-slate-500 p-1 cursor-pointer text-xs"
31
- @click="clear" tabindex="0"
32
-
33
+ @click="clear"
34
+ tabindex="0"
33
35
  ></button>
34
36
  </div>
35
37
  </div>
@@ -47,7 +49,7 @@
47
49
  <AutoComplete
48
50
  v-if="!isMobile()"
49
51
  class="w-full"
50
- v-model="modelValue"
52
+ v-model="autocompleteitem"
51
53
  ref="autocompleteinput"
52
54
  forceSelection
53
55
  optionLabel="label"
@@ -70,9 +72,15 @@
70
72
  >
71
73
  <template #header>
72
74
  <slot name="header">
73
- <div class="flex flex-row font font-bold dark:text-white">
74
- <div class="w w-1/3">{{ t(codefield) ?? t("code") }}</div>
75
- <div class="w w-2/3">{{ t(labelfield) ?? t("label") }}</div>
75
+ <div
76
+ class="flex flex-row font font-semibold text-sm dark:text-white gap-2 p-2"
77
+ >
78
+ <div class="w w-1/3 line-clamp-1">
79
+ {{ t(codefield) ?? t("code") }}
80
+ </div>
81
+ <div class="w w-2/3 line-clamp-1">
82
+ {{ t(labelfield) ?? t("label") }}
83
+ </div>
76
84
  </div>
77
85
  </slot>
78
86
  </template>
@@ -81,9 +89,9 @@
81
89
  </template>
82
90
  <template #option="{ index, option }">
83
91
  <slot name="option" :index="index" :option="option">
84
- <div class="flex flex-row dark:text-white">
85
- <div class="w w-1/3">{{ option.code }}</div>
86
- <div class="w w-2/3">{{ option.label }}</div>
92
+ <div class="flex flex-row dark:text-white text-sm gap-2">
93
+ <div class="w w-1/3 line-clamp-1">{{ option.code }}</div>
94
+ <div class="w w-2/3 line-clamp-1">{{ option.label }}</div>
87
95
  </div>
88
96
  </slot>
89
97
  </template>
@@ -202,6 +210,7 @@ const props = withDefaults(
202
210
  showNull: true,
203
211
  },
204
212
  );
213
+
205
214
  const mobileListMode = ref("list");
206
215
  const defaultFilterValue = ref("");
207
216
  const path = "$" + props.setting.instancepath;
@@ -276,7 +285,7 @@ const getListFromAutocompleteApi = (event: any) => {
276
285
  console.log("Run autocomplete?");
277
286
  list.value = res.data;
278
287
 
279
- if (props.allowAddNew) {
288
+ if (props.allowAddNew && canPerform(upperFirst(targetDocument),'create')) {
280
289
  list.value = list.value.concat({
281
290
  _id: "new",
282
291
  label: "<" + t("new") + ">",
@@ -324,7 +333,7 @@ const setFocus = (ev: any) => {
324
333
  const openViewer = (readonly: boolean) => {
325
334
  if (remotedoc) {
326
335
  $event("ViewRecord", {
327
- _id: modelValue.value?._id as string,
336
+ _id: (modelValue.value?._id ?? "") as string,
328
337
  eventId: randomUUID(),
329
338
  label: (readonly
330
339
  ? modelValue.value?.label
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <Calendar
3
+ :pt="pt"
4
+ :inputId="uuid"
5
+ :path="setting.instancepath"
6
+ v-model="datetimevalue"
7
+ @update:modelValue="updateDateTime"
8
+ showButtonBar
9
+ :readonly="readonly"
10
+ :placeholder="placeholder"
11
+ :showTime="showtime"
12
+ :timeOnly="timeOnly"
13
+ hourFormat="12"
14
+ v-bind="componentProps as CalendarProps"
15
+ />
16
+ </template>
17
+ <script setup lang="ts">
18
+ // :date-format="getDateFormat()"
19
+ import { CalendarProps } from "primevue/calendar";
20
+ const props = defineProps<{
21
+ pt: any;
22
+ uuid: string;
23
+ placeholder?: string;
24
+ setting: any;
25
+ readonly?: boolean;
26
+ componentProps?: CalendarProps;
27
+ type: "date" | "time" | "datetime";
28
+ }>();
29
+
30
+ const emits = defineEmits(["change"]);
31
+ const showtime = props.type == "date" ? false : true;
32
+ const timeOnly = props.type == "time" ? true : false;
33
+ const modelValue = defineModel<string>({ required: true });
34
+ const datetimevalue = ref<Date>();
35
+
36
+ const refreshFromParent = () => {
37
+ if (modelValue.value === undefined || modelValue.value == "")
38
+ datetimevalue.value = undefined;
39
+ else if (props.type == "time")
40
+ datetimevalue.value = stringToDate(
41
+ "2000-01-01 " + (modelValue.value ?? "00:00:00"),
42
+ );
43
+ else if (props.type == "date")
44
+ datetimevalue.value = stringToDate(modelValue.value + "T00:00:00");
45
+ else datetimevalue.value = stringToDate(modelValue.value);
46
+ };
47
+
48
+ watch(modelValue, () => refreshFromParent());
49
+
50
+ const updateDateTime = (value: any) => {
51
+ if (!value) modelValue.value = "";
52
+ else if (props.type == "datetime") modelValue.value = dateToISOString(value);
53
+ else if (props.type == "date") modelValue.value = dateToString(value);
54
+ else if (props.type == "time") modelValue.value = dateToTimeString(value);
55
+
56
+ emits("change");
57
+ };
58
+
59
+ refreshFromParent();
60
+ </script>