@simitgroup/simpleapp-generator 1.6.2-alpha → 1.6.4-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 (161) hide show
  1. package/README.md +6 -5
  2. package/dist/buildinschemas/branch.d.ts.map +1 -1
  3. package/dist/buildinschemas/branch.js +1 -2
  4. package/dist/buildinschemas/branch.js.map +1 -1
  5. package/dist/buildinschemas/changehistories.d.ts +3 -0
  6. package/dist/buildinschemas/changehistories.d.ts.map +1 -0
  7. package/dist/buildinschemas/changehistories.js +36 -0
  8. package/dist/buildinschemas/changehistories.js.map +1 -0
  9. package/dist/buildinschemas/index.d.ts +1 -0
  10. package/dist/buildinschemas/index.d.ts.map +1 -1
  11. package/dist/buildinschemas/index.js +3 -1
  12. package/dist/buildinschemas/index.js.map +1 -1
  13. package/dist/buildinschemas/organization.js +2 -2
  14. package/dist/buildinschemas/organization.js.map +1 -1
  15. package/dist/buildinschemas/user.d.ts.map +1 -1
  16. package/dist/buildinschemas/user.js +5 -1
  17. package/dist/buildinschemas/user.js.map +1 -1
  18. package/dist/buildinschemas/webhook.d.ts +3 -0
  19. package/dist/buildinschemas/webhook.d.ts.map +1 -0
  20. package/dist/buildinschemas/webhook.js +33 -0
  21. package/dist/buildinschemas/webhook.js.map +1 -0
  22. package/dist/framework.d.ts.map +1 -1
  23. package/dist/framework.js +3 -2
  24. package/dist/framework.js.map +1 -1
  25. package/dist/generate.js +30 -11
  26. package/dist/generate.js.map +1 -1
  27. package/dist/index.js +4 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
  30. package/dist/processors/jsonschemabuilder.js +10 -2
  31. package/dist/processors/jsonschemabuilder.js.map +1 -1
  32. package/dist/type.d.ts +2 -0
  33. package/dist/type.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/buildinschemas/branch.ts +1 -2
  36. package/src/buildinschemas/changehistories.ts +33 -0
  37. package/src/buildinschemas/index.ts +2 -1
  38. package/src/buildinschemas/organization.ts +2 -2
  39. package/src/buildinschemas/user.ts +5 -1
  40. package/src/buildinschemas/webhook.ts +31 -0
  41. package/src/framework.ts +3 -2
  42. package/src/generate.ts +35 -15
  43. package/src/index.ts +8 -3
  44. package/src/processors/jsonschemabuilder.ts +10 -2
  45. package/src/type.ts +2 -0
  46. package/templates/basic/nest/controller.ts.eta +23 -2
  47. package/templates/basic/nest/model.ts.eta +9 -1
  48. package/templates/basic/nest/resolver.ts.eta +2 -2
  49. package/templates/basic/nuxt/pages.[id].vue.eta +7 -7
  50. package/templates/basic/nuxt/pages.form.vue.eta +3 -6
  51. package/templates/basic/nuxt/pages.landing.vue.eta +2 -21
  52. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +8 -1
  53. package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +2 -0
  54. package/templates/nest/src/simpleapp/generate/commons/dicts/documents.ts.eta +9 -2
  55. package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +36 -30
  56. package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +5 -10
  57. package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +1 -0
  58. package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +50 -0
  59. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +13 -3
  60. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +9 -1
  61. package/templates/nest/src/simpleapp/generate/processors/branch.processor.ts.eta +12 -6
  62. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +128 -14
  63. package/templates/nest/src/simpleapp/generate/types/schema.type.ts.eta +3 -1
  64. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +1 -0
  65. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +19 -0
  66. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +30 -8
  67. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +2 -1
  68. package/templates/nuxt/{app.vue._eta → app.vue.eta} +3 -1
  69. package/templates/nuxt/assets/css/calendar.css._eta +3 -0
  70. package/templates/nuxt/assets/css/style.css._eta +1 -1
  71. package/templates/nuxt/assets/images/unknown.png.eta +0 -0
  72. package/templates/nuxt/assets/primevue/passthrough.ts._eta +6 -1
  73. package/templates/nuxt/components/button/ButtonAction.vue._eta +49 -7
  74. package/templates/nuxt/components/button/ButtonDanger.vue._eta +11 -3
  75. package/templates/nuxt/components/button/ButtonDefault.vue._eta +11 -3
  76. package/templates/nuxt/components/button/ButtonPrimary.vue._eta +9 -3
  77. package/templates/nuxt/components/button/ButtonSecondary.vue._eta +33 -0
  78. package/templates/nuxt/components/button/ButtonText.vue._eta +9 -5
  79. package/templates/nuxt/components/button/ButtonWarning.vue._eta +11 -3
  80. package/templates/nuxt/components/calendar/CalendarInput.vue.eta +17 -14
  81. package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +33 -16
  82. package/templates/nuxt/components/chart/card.vue._eta +1 -1
  83. package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +36 -26
  84. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +62 -22
  85. package/templates/nuxt/components/form/FormBranch.vue._eta +52 -5
  86. package/templates/nuxt/components/form/FormDocnoformat.vue.eta +14 -10
  87. package/templates/nuxt/components/form/FormUser.vue._eta +1 -1
  88. package/templates/nuxt/components/form/user/FormUserPermission.vue.eta +77 -59
  89. package/templates/nuxt/components/header/HeaderSelectBranch.vue.eta +42 -35
  90. package/templates/nuxt/components/image/ImageAvatar.vue.eta._vue +30 -0
  91. package/templates/nuxt/components/image/ImageOrganization.vue.eta.vue +7 -5
  92. package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta.vue +67 -50
  93. package/templates/nuxt/components/list/ListDocument.vue.eta +10 -5
  94. package/templates/nuxt/components/list/ListDocumentTable.vue.eta +21 -13
  95. package/templates/nuxt/components/list/ListMessages.vue.eta +1 -1
  96. package/templates/nuxt/components/list/ListView.vue.eta +94 -56
  97. package/templates/nuxt/components/overlay/OverlayPanelWithToolBar.vue.eta +11 -4
  98. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +17 -6
  99. package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +16 -6
  100. package/templates/nuxt/components/page/PageDocList.vue.eta +108 -31
  101. package/templates/nuxt/components/renderer/RendererDate.vue.eta +8 -2
  102. package/templates/nuxt/components/renderer/RendererDateTime.vue.eta +7 -1
  103. package/templates/nuxt/components/renderer/RendererDocHistories.vue.eta +56 -0
  104. package/templates/nuxt/components/renderer/RendererForeignKey.vue.eta +9 -8
  105. package/templates/nuxt/components/renderer/RendererLink.vue.eta +7 -4
  106. package/templates/nuxt/components/renderer/RendererMoney.vue.eta +25 -17
  107. package/templates/nuxt/components/renderer/RendererTime.vue.eta +7 -1
  108. package/templates/nuxt/components/renderer/RendererViewer.vue.eta +19 -9
  109. package/templates/nuxt/components/select/SelectTemplate.vue.eta +76 -38
  110. package/templates/nuxt/components/session/SessionBlock.vue.eta +44 -46
  111. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +61 -24
  112. package/templates/nuxt/components/simpleApp/SimpleAppCalendarInput.vue.eta +64 -0
  113. package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +26 -14
  114. package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +8 -8
  115. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +1 -1
  116. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +128 -33
  117. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +89 -168
  118. package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +43 -40
  119. package/templates/nuxt/components/simpleApp/SimpleAppUserPicker.vue.eta +387 -0
  120. package/templates/nuxt/components/text/TextDocStatus.vue._eta +22 -0
  121. package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +13 -15
  122. package/templates/nuxt/components/user/UserButtonPermissionInfo.vue.eta +127 -93
  123. package/templates/nuxt/components/user/UserTenantPicker.vue.eta +1 -1
  124. package/templates/nuxt/composables/confirm.generate.ts.eta +19 -0
  125. package/templates/nuxt/composables/date.generate.ts.eta +106 -8
  126. package/templates/nuxt/composables/getDocument.generate.ts.eta +8 -6
  127. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +58 -10
  128. package/templates/nuxt/composables/getUserStore.generate.ts.eta +37 -5
  129. package/templates/nuxt/composables/goTo.generate.ts.eta +14 -1
  130. package/templates/nuxt/composables/graphquery.generate.ts.eta +20 -2
  131. package/templates/nuxt/composables/recently.generate.ts.eta +16 -0
  132. package/templates/nuxt/composables/roles.generate.ts.eta +8 -13
  133. package/templates/nuxt/composables/stringHelper.generate.ts.eta +54 -1
  134. package/templates/nuxt/composables/sysmessage.generate.ts.eta +1 -1
  135. package/templates/nuxt/pages/[xorg]/docnoformat.vue.eta +1 -1
  136. package/templates/nuxt/pages/[xorg]/mobile/docnoformat/{index.vue.eta → index.vue.etaxxx} +1 -1
  137. package/templates/nuxt/pages/[xorg]/mobile/user/{index.vue.eta → index.vue.etaxxx} +1 -1
  138. package/templates/nuxt/pages/[xorg]/{organization.vue.eta → organization.vue._eta} +39 -10
  139. package/templates/nuxt/pages/[xorg]/profile.vue.eta +1 -1
  140. package/templates/nuxt/pages/[xorg]/user.vue.eta +13 -10
  141. package/templates/nuxt/pages/login.vue._eta +4 -1
  142. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +4 -0
  143. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +45 -26
  144. package/templates/nuxt/plugins/70.recently.ts.eta +55 -0
  145. package/templates/nuxt/providers/my-provider.ts.eta +22 -0
  146. package/templates/nuxt/server/api/[xorg]/{[...].ts.eta → [...].ts._eta} +47 -21
  147. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +44 -3
  148. package/templates/nuxt/types/events.ts.eta +3 -2
  149. package/templates/nuxt/types/others.ts.eta +11 -1
  150. package/templates/nuxt/types/schema.ts.eta +3 -1
  151. package/templates/nuxt/types/simpleappinput.ts.eta +1 -1
  152. package/templates/nuxt/types/user.ts.eta +8 -7
  153. package/templates/project/jsonschemas/branch.json._eta +1 -0
  154. package/templates/project/jsonschemas/invoice.json._eta +4 -3
  155. package/templates/project/jsonschemas/organization.json._eta +2 -2
  156. package/templates/project/lang/default._json +5 -1
  157. package/tsconfig.tsbuildinfo +1 -1
  158. package/templates/nuxt/components/image/ImageAvatar.vue.eta.vue +0 -38
  159. /package/templates/nuxt/pages/[xorg]/mobile/{index.vue._eta → index.vue._etaxxx} +0 -0
  160. /package/templates/nuxt/pages/[xorg]/mobile/organization/{[id].vue._eta → [id].vue._etaxxx} +0 -0
  161. /package/templates/nuxt/pages/[xorg]/mobile/{pickgroup.vue._eta → pickgroup.vue._etaxxx} +0 -0
@@ -1,12 +1,14 @@
1
1
  <template>
2
2
  <title v-if="!id">{{ t(doc.getDocName()) }}</title>
3
+
3
4
  <div v-if="isMobile()" class="w-full">
4
5
  <div class="p-2 flex flex-row justify-end place-items-center h-14">
5
6
  <div class="flex-1">
6
- <TextTitle>{{ t(doc.getDocName()) }}</TextTitle>
7
+ <TextMain>{{ t(doc.getDocName()) }}</TextMain>
7
8
  </div>
8
9
  <div>
9
10
  <ButtonText
11
+ v-if="allowAction('create')"
10
12
  @click="goTo(doc.getDocName(), 'new')"
11
13
  class="pi pi-plus"
12
14
  ></ButtonText>
@@ -35,47 +37,107 @@
35
37
  >
36
38
  <template #toolbar>
37
39
  <div class="w-full text-left">
38
- <ButtonPrimary
39
- class="pi pi-plus"
40
+ <ButtonPrimary
40
41
  @click="newData"
41
42
  v-tooltip="t('new')"
42
- v-if="canPerform(resourcename, 'create')"
43
- ></ButtonPrimary>
43
+ v-if="allowAction('create') && canPerform(resourcename, 'create')"
44
+ >
45
+ <i class="pi pi-plus"></i>
46
+ </ButtonPrimary>
44
47
  </div>
45
48
  </template>
46
49
  <template #default>
47
50
  <slot name="dataTableColumns">
48
- <Column
49
- v-for="col in columns.filter((item, index) => index < 6)"
50
- :header="t(col)"
51
- class="min-w-[5rem]"
52
- #body="{ index, data }"
51
+ <!-- :sortable="schemacols[col] && schemacols[col].type!='object'" -->
52
+ <template
53
+ v-for="col in columns.filter((item, index) => index < maxcolumns)"
53
54
  >
54
- <RendererLink
55
- v-if="uniqueKey === col || documentTitle === col"
56
- :value="data"
57
- :setting="{ path: resourcename.toLocaleLowerCase() }"
58
- :fields="[col]"
55
+ <Column
56
+ v-if="schemacols[col]"
57
+ :header="t(col)"
58
+ sortable
59
+ :field="schemacols[col]['x-foreignkey'] ? col + '.label' : col"
60
+ :class="`min-w-[5rem] ${getCssClass(col)}`"
61
+ #body="{ index, data }"
59
62
  >
60
- {{ data[col] }}
61
- </RendererLink>
62
- <span v-else-if="data[col]?.label !== undefined">{{
63
- data[col].label
64
- }}</span>
65
- <span v-else>{{ data[col] }}</span>
66
- </Column>
63
+ <RendererLink
64
+ v-if="uniqueKey === col || documentTitle === col"
65
+ :value="data"
66
+ :setting="{ path: resourcename.toLocaleLowerCase() }"
67
+ :fields="[col]"
68
+ >
69
+ </RendererLink>
70
+ <TextMain v-else-if="col == 'documentStatus'">{{
71
+ t(data[col])
72
+ }}</TextMain>
73
+ <RendererMoney
74
+ v-else-if="schemacols[col]['format'] == 'money'"
75
+ v-model="data[col]"
76
+ >
77
+ </RendererMoney>
78
+ <span v-else-if="typeof schemacols[col].enum != 'undefined'">
79
+ {{ t(data[col]) }}
80
+ </span>
81
+ <span v-else-if="schemacols[col].type == 'boolean'">
82
+ <RendererBoolean v-model="data[col]" />
83
+ </span>
84
+ <RendererForeignKey
85
+ v-else-if="schemacols[col]['x-foreignkey']"
86
+ v-model="data[col]"
87
+ :setting="{ collection: schemacols[col]['x-foreignkey'] }"
88
+ >
89
+ {{ data[col]?.label ?? data[col]?.code ?? data[col] }}
90
+ </RendererForeignKey>
91
+ <span v-else-if="schemacols[col].format == 'date'">
92
+ <RendererDate v-model="data[col]" />
93
+ </span>
94
+ <span v-else-if="schemacols[col].format == 'datetime'">
95
+ <RendererDateTime v-model="data[col]" />
96
+ </span>
97
+ <span v-else-if="data[col]?.label !== undefined">{{
98
+ data[col].label
99
+ }}</span>
100
+ <span v-else>{{ data[col] }}</span>
101
+ </Column>
102
+ </template>
67
103
  </slot>
68
104
  </template>
69
105
  </ListDocumentTable>
70
106
  </div>
71
- <OverlaySideBarCrud
107
+ <OverlayPanelWithToolBar
72
108
  v-model="showDialog"
73
109
  :closeEventName="doc.getDocName()"
74
- #default
75
- ><slot name="default">
76
- <NuxtPage :_id="id"></NuxtPage>
77
- </slot>
78
- </OverlaySideBarCrud>
110
+ :dismissable="false"
111
+ :position="sidebarposition"
112
+ >
113
+ <template #headerLeft>
114
+ <ButtonText @click="showDialog = false">
115
+ <i class="pi pi-times"></i>
116
+ </ButtonText>
117
+ </template>
118
+ <template #headerCenter>
119
+ <TextTitle class="text-center text-white">{{
120
+ t(doc.getDocName())
121
+ }}</TextTitle>
122
+ </template>
123
+ <template #headerRight>
124
+ <ButtonText
125
+ @click="
126
+ sidebarposition =
127
+ sidebarposition == 'right' ? (sidebarposition = 'full') : 'right'
128
+ "
129
+ >
130
+ <i v-if="sidebarposition == 'right'" class="pi pi-window-maximize" />
131
+ <i v-if="sidebarposition == 'full'" class="pi pi-window-minimize" />
132
+ </ButtonText>
133
+ </template>
134
+
135
+ <div class="p-2">
136
+ <slot name="default">
137
+ <NuxtPage :_id="id"></NuxtPage>
138
+ </slot>
139
+ </div>
140
+ </OverlayPanelWithToolBar>
79
141
  </template>
80
142
 
81
143
  <script setup lang="ts" generic="T extends { [key: string]: any }">
@@ -89,14 +151,17 @@ import { ref } from "vue";
89
151
  import _ from "lodash";
90
152
  import { SearchBody } from "~/types";
91
153
  import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
154
+ const sidebarposition = ref("right");
92
155
  const props = defineProps<{
93
156
  document: SimpleAppClient<any, any>;
94
157
  data: T;
158
+ dismissable?: boolean;
95
159
  columns: string[];
96
160
  mobileColumns?: string[];
97
161
  sorts?: string[][];
162
+ availableActions?:string[]
98
163
  }>();
99
-
164
+ const maxcolumns = 16;
100
165
  const emits = defineEmits(["selectRow"]);
101
166
  const id = computed(() => getPathPara("id"));
102
167
  const resourcename = ref(_.upperFirst(props.document.getDocName()));
@@ -115,7 +180,19 @@ const { $event, $listen } = useNuxtApp();
115
180
  const recordlist = ref<T[]>();
116
181
  const uniqueKey = doc.getSchema()["x-simpleapp-config"].uniqueKey;
117
182
  const documentTitle = doc.getSchema()["x-simpleapp-config"].documentTitle;
118
-
183
+ const schemacols = doc.getSchema().properties;
184
+ const allowAction = (actname:string)=>{
185
+ if(props.availableActions === undefined) return true
186
+ else if(Array.isArray(props.availableActions) && props.availableActions.length>0 && !props.availableActions.includes(actname))
187
+ return false
188
+ else return true
189
+ }
190
+ const getCssClass = (col: string) => {
191
+ if (schemacols[col]?.type == "number") return "text-right";
192
+ else if (schemacols[col]?.type == "boolean")
193
+ return "text-center place-items-center";
194
+ else return "text-left";
195
+ };
119
196
  const refresh = () => {
120
197
  const searchbody: SearchBody = {
121
198
  fields: props.columns,
@@ -154,7 +231,7 @@ watch(showDialog, () => {
154
231
  watch(
155
232
  () => useRoute().path,
156
233
  async () => {
157
- if(!isMobile()){
234
+ if (!isMobile()) {
158
235
  if (getPathPara("id")) {
159
236
  showDialog.value = true;
160
237
  } else {
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <span v-if="modelValue">{{ toUTCDate(modelValue) }}</span>
2
+ <span v-if="modelValue">
3
+ {{ dateRenderToDateStr(modelValue) }}
4
+ </span>
5
+ <span v-else-if="value">
6
+ {{ dateRenderToDateStr(value) }}
7
+ </span>
3
8
  <span v-else>-</span>
4
9
  </template>
5
10
  <script lang="ts" setup>
@@ -9,5 +14,6 @@
9
14
  * last change 2024-02-04
10
15
  * author: Ks Tan
11
16
  */
12
- const modelValue = defineModel<Date|string>()
17
+ const modelValue = defineModel<Date | string>();
18
+ const props = defineProps<{value:Date|string}>()
13
19
  </script>
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <span v-if="modelValue">{{ toUTCDateTime(modelValue) }}</span>
2
+ <span v-if="modelValue">
3
+ {{ dateRenderToDateTimeStr(modelValue) }}
4
+ </span>
5
+ <span v-else-if="value">
6
+ {{ dateRenderToDateTimeStr(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>
@@ -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,26 @@ 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) return modelValue.value[s.displayField] ??props.value[s.displayField];
32
+ else return modelValue.value?.label ??props.value?.label;
32
33
  });
33
34
  const { $event } = useNuxtApp();
34
35
  const viewer = ref();
35
36
  const viewRecord = () => {
36
37
  viewer.value = getDocument(props.setting.collection)?.viewer;
37
-
38
+ const value = modelValue.value?? props.value
38
39
  // getDocumentUrl(setting.collection,modelValue ? modelValue['_id']:'')
39
40
  //getDocumentUrl(setting.collection,modelValue ? modelValue['_id']:'')
40
41
  $event("ViewRecord", {
41
- _id: modelValue.value?._id as string,
42
- label: modelValue.value?.label as string,
42
+ _id: value?._id as string,
43
+ label: value?.label as string,
43
44
  eventId: randomUUID(),
44
45
  documentName: props.setting.collection,
45
46
  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,14 +1,19 @@
1
1
  <template>
2
- <div>
3
- <div class="flex flex-row ">
4
- <label v-if="!hideLabel" :for="fieldid" class="pt-2">
5
- {{t(documentName)}}
2
+ <div class="w-full">
3
+ <div class="flex flex-row">
4
+ <label v-if="!hideLabel" :for="fieldid">
5
+ {{ t(documentName) }}
6
6
  </label>
7
- <ButtonText v-if="allowAddNew" @click="addnew" class="text-xs text-blue-600">
8
- <span>{{t('new')}}</span>
9
- </ButtonText>
7
+ <div
8
+ v-if="allowAddNew"
9
+ @click="addnew"
10
+ class="cursor-pointer ml-2 pt-1 text-xs text-blue-600"
11
+ >
12
+ <span>{{ t("new") }}</span>
13
+ </div>
10
14
  </div>
11
15
  <MultiSelect
16
+ class="w-full md:w-full"
12
17
  :input-id="fieldid"
13
18
  v-if="multiple"
14
19
  display="chip"
@@ -17,19 +22,39 @@
17
22
  :options="options"
18
23
  optionLabel="label"
19
24
  optionValue="value"
25
+ filter
20
26
  :placeholder="placeholder"
21
- />
27
+ >
28
+ <template #value="slotProps">
29
+ <slot name="value" :slotProps="slotProps">
30
+ </slot>
31
+ </template>
32
+ <template #option="slotProps">
33
+ <slot name="default" :option="slotProps.option" :index="slotProps.index">
34
+ </slot>
35
+ </template>
36
+
37
+ </MultiSelect>
22
38
  <Dropdown
23
-
39
+ class="w-full md:w-full"
24
40
  :input-id="fieldid"
25
41
  v-else
26
42
  @update:modelValue="change"
43
+ filter
27
44
  v-model="modelValue"
28
45
  :options="options"
29
46
  optionLabel="label"
30
47
  optionValue="value"
31
48
  :placeholder="placeholder"
32
- />
49
+ >
50
+ <template #value="slotProps">
51
+ <slot name="value" :item="getItem(modelValue)"></slot>
52
+ </template>
53
+ <template #option="slotProps" >
54
+ <slot name="default" :option="slotProps.option" :index="slotProps.index"></slot>
55
+ </template>
56
+
57
+ </Dropdown>
33
58
  </div>
34
59
  </template>
35
60
  <script setup lang="ts">
@@ -40,24 +65,30 @@
40
65
  * Author: Ks Tan
41
66
  */
42
67
  import Dropdown from "primevue/dropdown";
43
- import { ForeignKey, FormCrudEvent } from "~/types";
68
+
69
+ import { ForeignKey, SimpleAppDocuments, FormCrudEvent } from "~/types";
44
70
  const emits = defineEmits(["change"]);
45
- const modelValue = defineModel<string | string[]>();
46
- const list = ref<ForeignKey[]>([]);
47
- const fieldid = randomUUID()
71
+
48
72
  const props = defineProps<{
49
- documentName: string;
73
+ documentName: keyof SimpleAppDocuments;
50
74
  placeholder?: string;
51
75
  showNull?: boolean;
52
76
  allowAddNew?: boolean;
53
77
  filter?: any;
54
78
  multiple?: boolean;
55
- hideLabel?:boolean
79
+ hideLabel?: boolean;
56
80
  }>();
81
+ // const initvalue = props.multiple==true ? [] : ''
82
+ const modelValue = defineModel<string | string[]>();
83
+
84
+ const list = ref<ForeignKey[]>([]);
85
+ const fieldid = randomUUID();
86
+
57
87
  const options = ref<
58
88
  {
59
89
  value: string;
60
90
  label: string;
91
+ more:any;
61
92
  }[]
62
93
  >([]);
63
94
  const getListOptions = async () => {
@@ -71,38 +102,45 @@ const getListOptions = async () => {
71
102
  options.value = list.value.map((item) => ({
72
103
  value: item._id,
73
104
  label: item.label,
105
+ more: item
74
106
  }));
75
107
  };
76
108
  onMounted(async () => {
109
+
77
110
  await getListOptions();
78
111
  if (modelValue.value) change(modelValue.value);
79
112
  });
80
- const getItem = (id: string) => list.value?.find((item) => item._id == id);
113
+ const getItem = (id: string) => list.value?.find((item) => {
114
+ return item._id == id
115
+ });
81
116
 
82
- const change = (id: string) => {
117
+ const change = (id: string | string[]) => {
83
118
  const selectedItem = getItem(id);
84
119
  emits("change", id, selectedItem);
85
-
120
+ // console.log("changed",selectedItem)
86
121
  };
87
122
 
88
- const addnew=()=>{
89
-
90
- const doc = getDocument(props.documentName)?.docClass;
91
- if (doc) {
92
- const tmpdata = doc?.getReactiveData();
93
- type DataType = typeof tmpdata.value;
94
- onScreenAddDocument<DataType>(
95
- props.documentName,
96
- undefined,
97
- async (eventType: FormCrudEvent, data: DataType) => {
98
- if (eventType == FormCrudEvent.create) {
99
- await getListOptions();
100
- modelValue.value = data._id;
101
- emits("change", data._id, getItem(data._id));
102
- }
103
- },
104
- );
105
-
123
+ const addnew = () => {
124
+ const doc = getDocument(props.documentName)?.docClass;
125
+ if (doc) {
126
+ const tmpdata = doc?.getReactiveData();
127
+ type DataType = typeof tmpdata.value;
128
+ onScreenAddDocument<DataType>(
129
+ props.documentName,
130
+ undefined,
131
+ async (eventType: FormCrudEvent, data: DataType) => {
132
+ if (eventType == FormCrudEvent.create) {
133
+ await getListOptions();
134
+ if (props.multiple) {
135
+ if (modelValue.value === undefined) modelValue.value = [data._id];
136
+ else if (Array.isArray(modelValue.value))
137
+ modelValue.value.push(data._id);
138
+ } else modelValue.value = data._id;
139
+ refreshDocumentList(props.documentName);
140
+ emits("change", data._id, getItem(data._id));
141
+ }
142
+ },
143
+ );
106
144
  }
107
- }
145
+ };
108
146
  </script>