@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
@@ -22,14 +22,15 @@
22
22
  </slot>
23
23
  </ListView>
24
24
 
25
- <Dialog v-model:visible="showDialog" modal :header="t('editDetails')">
25
+ <Dialog v-model:visible="showDialog"
26
+ modal :header="t('editDetails')" :pt="{root:{class:'w-1/2'}}">
26
27
  <div class="flex flex-col p-2 gap-4">
27
28
  <slot name="popupbody" :index="rowIndex" :item="list[rowIndex]">
28
29
  row {{ rowIndex }} define SimpleAppInputs here
29
30
  </slot>
30
31
  </div>
31
32
  <template #footer>
32
- <div v-if="!readOnly" class="flex flex-row gap-2 w-full">
33
+ <div v-if="!readonly" class="flex flex-row gap-2 w-full">
33
34
  <ButtonDanger @click="deleteItem">{{ t("delete") }}</ButtonDanger>
34
35
  <ButtonPrimary @click="updateItem">{{ t("ok") }}</ButtonPrimary>
35
36
  </div>
@@ -38,6 +39,7 @@
38
39
  </div>
39
40
  </template>
40
41
  <script setup lang="ts" generic="T extends { [key: string]: any }">
42
+ import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
41
43
  /**
42
44
  * This file was automatically generated by simpleapp generator. Every
43
45
  * MODIFICATION OVERRIDE BY GENERATEOR
@@ -46,13 +48,20 @@
46
48
  */
47
49
  const showDialog = ref(false);
48
50
  const rowIndex = ref(0);
51
+
49
52
  const emits = defineEmits(["addrow", "deleteitem", "itemupdated"]);
50
- const props = defineProps<{
51
- list: T[];
52
- title?: string;
53
- addNew?: boolean
53
+ const props = defineProps<{
54
+ list: T[];
55
+ title?: string;
56
+ addNew?: boolean;
57
+ readonly?: boolean;
58
+ doc: SimpleAppClient<any, any>;
54
59
  }>();
55
-
60
+ const readonly = computed(() => {
61
+ if (props.readonly) return true;
62
+ else if (props.doc.isReadOnly()) return true;
63
+ else return false;
64
+ });
56
65
  const showRow = (index: number, item: T) => {
57
66
  showDialog.value = true;
58
67
  rowIndex.value = index;
@@ -70,6 +79,5 @@ const addRow = (event: MouseEvent) => {
70
79
  emits("addrow", MouseEvent);
71
80
  const lineno = props.list.length - 1;
72
81
  showRow(lineno, props.list[lineno]);
73
-
74
82
  };
75
83
  </script>
@@ -9,28 +9,28 @@
9
9
  :class="
10
10
  !pt
11
11
  ? 'flex-1 w-full rounded-lg ' +
12
- (props.readonly ? '' : 'rounded-tr-none rounded-br-none')
12
+ (props.readonly || !props.setting.document.isNew() ? '' : 'rounded-tr-none rounded-br-none')
13
13
  : ''
14
14
  "
15
15
  />
16
- <span class="" v-if="!readonly">
17
- <button v-ripple
16
+ <span class="" v-if="!readonly && props.setting.document.isNew()">
17
+ <button
18
+ v-ripple
18
19
  type="button"
19
20
  @click="toggle"
20
21
  tabindex="-1"
21
- class="'btn btn-primary p-3 dark:border-blue-900/40 rounded-lg rounded-tl-none rounded-bl-none"
22
+ class="'btn bg-primary-500 dark:text-black text-white p-3 dark:border-blue-900/40 rounded-lg rounded-tl-none rounded-bl-none"
22
23
  >
23
24
  <i class="pi pi-angle-down"></i>
24
25
  </button>
25
- <OverlayPanel ref="op" class="p-4">
26
+ <OverlayPanel ref="op">
26
27
  <div class="m-4">
27
28
  <ul>
28
29
  <li v-for="docno in docFormatlist" class="hover-list-primary p-2">
29
- <a class="" @click="chooseFormat(docno)">
30
- <span class="pi pi-hashtag mr-2"></span>
30
+ <div class="flex flex-row gap-2 cursor-pointer" @click="chooseFormat(docno)">
31
31
  <span class="">{{ docno.docNoFormatName }}</span>
32
32
  <span class="text text-green-600">{{ docno.sample }}</span>
33
- </a>
33
+ </div>
34
34
  </li>
35
35
  </ul>
36
36
  </div>
@@ -75,7 +75,7 @@ let schema: any;
75
75
  const getLayoutClass = () =>
76
76
  `simpleapp-input-container flex ${
77
77
  props.inputType == "checkbox"
78
- ? " flex-row gap-4 mt-1 ml-1 "
78
+ ? " flex flex-col "
79
79
  : "flex flex-col "
80
80
  }`;
81
81
 
@@ -35,18 +35,26 @@
35
35
  </MobileToolbar>
36
36
  </div>
37
37
  <div v-else class="simpleapp-tool-bar">
38
- <!-- <div class="flex flex-row justify-end p-2">
38
+ <!-- <div class="flex flex-row justify-end p-2">
39
39
  <TextTitle class="dark:text-white line-clamp-2 flex-1">{{
40
40
  title
41
41
  }}</TextTitle>
42
42
  <ButtonText @click="callClose"><i class="pi pi-times" /></ButtonText>
43
43
  </div> -->
44
- <div class="flex flex-row gap-2 p-0 justify-between">
44
+ <div class="flex flex-row gap-2 mb-2 p-0 justify-between">
45
45
  <!-- left -->
46
- <div class="flex flex-row">
46
+ <div class="flex flex-row gap-2">
47
47
  <div v-for="(menu, index) in menus" :key="index">
48
48
  <div v-if="menu.label && menu.type == 'crud'">
49
49
  <ButtonAction
50
+ v-if="menu.action == 'print'"
51
+ :disabled="!canPerform(doc.getDocName(true), 'access')"
52
+ @click="emitEvent(menu, $event)"
53
+ :action-name="menu.action"
54
+ >{{ menu.label }}</ButtonAction>
55
+ <ButtonAction
56
+ v-else
57
+ :disabled="!canPerform(doc.getDocName(true), menu.action)"
50
58
  @click="emitEvent(menu, $event)"
51
59
  :action-name="menu.action"
52
60
  >{{ menu.label }}</ButtonAction
@@ -56,12 +64,17 @@
56
64
  </div>
57
65
 
58
66
  <!-- center -->
59
- <div class="flex flex-row "></div>
67
+ <div class="flex flex-row"></div>
60
68
  <!-- right -->
61
- <div class="flex flex-row">
69
+ <div class="flex flex-row gap-2">
70
+ <DebugDocumentData v-model="data" :label="t(doc.getDocName())" />
71
+ <div v-if="data.documentStatus">
72
+ <RendererDocHistories :data="data" />
73
+ </div>
62
74
  <div v-for="(menu, index) in menus" :key="index">
63
75
  <div v-if="menu.label && menu.type == 'docstatus'">
64
76
  <ButtonAction
77
+ :disabled="!canPerform(doc.getDocName(true), menu.action)"
65
78
  @click="emitEvent(menu, $event)"
66
79
  :action-name="menu.action"
67
80
  >{{ menu.label }}</ButtonAction
@@ -70,22 +83,8 @@
70
83
  </div>
71
84
  </div>
72
85
  </div>
73
- <ConfirmPopup></ConfirmPopup>
74
86
  </div>
75
- <Dialog v-model:visible="visiblePrintFormats" :header="t('printFormats')">
76
- <div>
77
- <ListView
78
- :list="printformats"
79
- #default="{ item, index }"
80
- @click="printPdf"
81
- >
82
- <div class="flex flex-col">
83
- <TextBold>{{ t(item.formatName) }}</TextBold>
84
- <TextSubtitle>{{ item.description }}</TextSubtitle>
85
- </div>
86
- </ListView>
87
- </div>
88
- </Dialog>
87
+
89
88
  <OverlayPanelWithToolBar
90
89
  v-if="visiblePrintPreview"
91
90
  v-model="visiblePrintPreview"
@@ -96,11 +95,23 @@
96
95
  ><i class="pi pi-times"
97
96
  /></ButtonText>
98
97
  </template>
99
- <template #headerCenter>{{ t("printPreview") }}</template>
98
+ <template #headerCenter>
99
+ <div class="flex flex-row gap-2 justify-center">
100
+ <Dropdown
101
+ :options="printformats"
102
+ option-label="formatName"
103
+ option-value="formatId"
104
+ v-model="currentprintformat"
105
+ @change="printPdf"
106
+ ></Dropdown>
107
+ <ButtonPrimary @click="showPrintFormats"
108
+ ><i class="pi pi-refresh"
109
+ /></ButtonPrimary>
110
+ </div>
111
+ </template>
100
112
  <template #headerRight>
101
-
102
113
  <div v-if="isMobile()">
103
- <ButtonText class="text-xl" @click="sendToPrint" >
114
+ <ButtonText class="text-xl" @click="sendToPrint">
104
115
  <i class="pi pi-print"></i>
105
116
  </ButtonText>
106
117
  <ButtonText class="text-xl" v-if="sharable" @click="togglePdfMenu">
@@ -111,6 +122,14 @@
111
122
  </template>
112
123
  <!-- :header="t('printPreview')"
113
124
  position="bottom" -->
125
+ <!-- {{pdfReady}} -->
126
+
127
+ <!-- <div v-if="!pdfReady">
128
+ <div class="flex flex-col justify-center">
129
+ <div class="pi pi-spin pi-spinner" style="font-size: 8rem"></div>
130
+ <div>{{ t("loading") + "..." }}</div>
131
+ </div>
132
+ </div> -->
114
133
  <TextDanger v-if="printservererror || !printstr">
115
134
  {{ t("printServerError") }}
116
135
  </TextDanger>
@@ -142,9 +161,16 @@ import VuePdfEmbed from "vue-pdf-embed";
142
161
 
143
162
  import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
144
163
  import { useConfirm } from "primevue/useconfirm";
145
- import { FormActions, FormCrudEvent, FormMenu } from "~/types";
164
+ import {
165
+ FormActions,
166
+ FormCrudEvent,
167
+ FormMenu,
168
+ SchemaPrintFormat,
169
+ } from "~/types";
170
+ import { DropdownChangeEvent } from "primevue/dropdown";
146
171
  import { MenuItem } from "primevue/menuitem";
147
172
  import { MenuItemCommandEvent } from "primevue/menuitem";
173
+ const currentprintformat = ref();
148
174
  const pdfrenderer = ref();
149
175
  const confirm = useConfirm();
150
176
  const emits = defineEmits(["on", "close"]);
@@ -152,13 +178,22 @@ const visiblePrintFormats = ref(false);
152
178
  const visiblePrintPreview = ref(false);
153
179
  const printstr = ref();
154
180
  const printservererror = ref(false);
181
+ const pdfReady = ref(false);
155
182
  const props = defineProps<{
156
183
  document: SimpleAppClient<any, any>;
157
184
  disableaction?: string[];
158
185
  }>();
186
+ const doc = props.document;
187
+ const data = doc.getReactiveData();
159
188
 
160
189
  const createData = async () => {
161
190
  try {
191
+ setRecentDocument(data.value._id, {
192
+ docName: doc.getDocName(),
193
+ label: title.value,
194
+ branchId: data.value.branchId,
195
+ time: new Date().toISOString(),
196
+ });
162
197
  return await doc.create();
163
198
  } catch (e) {
164
199
  console.debug("validation error:", e);
@@ -166,6 +201,12 @@ const createData = async () => {
166
201
  };
167
202
  const updateData = async () => {
168
203
  try {
204
+ setRecentDocument(data.value._id, {
205
+ docName: doc.getDocName(),
206
+ label: title.value,
207
+ branchId: data.value.branchId,
208
+ time: new Date().toISOString(),
209
+ });
169
210
  return await doc.update();
170
211
  } catch (e) {
171
212
  console.debug("validation error:", e);
@@ -173,23 +214,36 @@ const updateData = async () => {
173
214
  };
174
215
  const deleteData = async () => {
175
216
  try {
217
+ getRecently().delete(data.value._id);
176
218
  return await doc.delete();
177
219
  } catch (e) {
178
220
  console.debug("validation error:", e);
179
221
  }
180
222
  };
181
223
 
182
- const doc = props.document;
183
- const data = doc.getReactiveData();
184
224
  type Datatype = keyof typeof data.value;
185
225
  const config = doc.getSchema()["x-simpleapp-config"];
186
- const titlefield = (config.documentTitle ?? config.uniqueKey) as Datatype;
226
+ const titlefield = (
227
+ config.allStatus && config.allStatus.length > 0
228
+ ? config.uniqueKey
229
+ : config.documentTitle
230
+ ) as Datatype;
187
231
  const title = computed(() =>
188
232
  data.value[titlefield as Datatype]
189
233
  ? data.value[titlefield as Datatype]
190
234
  : t(doc.getDocName()),
191
235
  );
192
- const printformats = doc.getSchema()["x-simpleapp-config"]?.printFormats;
236
+ const printformats = computed(() => {
237
+ const formats = doc.getSchema()["x-simpleapp-config"]?.printFormats;
238
+ if (Array.isArray(formats)) {
239
+ return formats.map((item) => {
240
+ item.formatName = t(item.formatName);
241
+ return item;
242
+ });
243
+ } else {
244
+ return [];
245
+ }
246
+ });
193
247
  const menu = ref();
194
248
  const menus = computed(() =>
195
249
  [...getActions(), ...getDocActions()].filter((item) => showMenuButton(item)),
@@ -214,26 +268,43 @@ const emitMobileEvent = (itemevent: MenuItemCommandEvent) => {
214
268
  emitEvent(itemevent.item, event);
215
269
  };
216
270
 
217
- const printPdf = async (index: number, format: any) => {
218
- console.log("printPdf");
271
+ const printPdf = async (dropdown?: DropdownChangeEvent) => {
272
+ let index = 0;
273
+ setRecentDocument(data.value._id, {
274
+ docName: doc.getDocName(),
275
+ label: title.value,
276
+ branchId: data.value.branchId,
277
+ time: new Date().toISOString(),
278
+ });
279
+ if (printformats && printformats.value.length > 0 && dropdown !== undefined) {
280
+ index = printformats.value.findIndex(
281
+ (item) => item.formatId == dropdown.value,
282
+ );
283
+ }
284
+ let format: SchemaPrintFormat = printformats.value[index];
219
285
  printservererror.value = false;
220
286
  const formatid: string = format.formatId;
287
+ currentprintformat.value = formatid;
221
288
  visiblePrintPreview.value = true;
222
289
  // console.log("formatidformatid", format);
290
+ // pdfReady.value=false
223
291
  try {
224
292
  const tmp: any = await doc
225
293
  .getApi()
226
294
  .runPrint(data.value._id ?? "", formatid);
295
+ // pdfReady.value=true
227
296
  printstr.value = "data:application/pdf;base64," + tmp.data;
228
297
  } catch (e) {
298
+ pdfReady.value = true;
229
299
  printservererror.value = true;
230
- printstr.value = "";
300
+ // printstr.value = "";
231
301
  console.error("error from print server", e);
232
302
  }
233
303
  };
234
304
  const getActions = () => {
235
305
  const actions = doc.getActions();
236
- const printformats = doc.getSchema()["x-simpleapp-config"]?.printFormats;
306
+ // const printformats = doc.getSchema()["x-simpleapp-config"]?.printFormats;
307
+
237
308
  const crudmenus: any[] = [];
238
309
 
239
310
  // Object.keys(actions).forEach((key)=>{ //crud, api, docstatus
@@ -250,7 +321,7 @@ const getActions = () => {
250
321
  });
251
322
  }
252
323
  });
253
- if (printformats && printformats.length > 0) {
324
+ if (printformats && printformats.value.length > 0) {
254
325
  crudmenus.push({
255
326
  action: "print",
256
327
  label: t("preview"),
@@ -259,15 +330,14 @@ const getActions = () => {
259
330
  command: showPrintFormats,
260
331
  });
261
332
  }
262
- console.log("crudmenus", crudmenus);
333
+ // console.log("crudmenus", crudmenus);
263
334
 
264
335
  // })
265
336
  return crudmenus;
266
337
  };
267
338
 
268
- const showPrintFormats = () => {
269
- visiblePrintFormats.value = true;
270
- // console.log("showPrintFormatContext",itemEvent)
339
+ const showPrintFormats = async () => {
340
+ await printPdf();
271
341
  };
272
342
  const emitEvent = async (menu: FormMenu, clickEvent: Event | MouseEvent) => {
273
343
  if (menu.action == "delete") {
@@ -290,6 +360,12 @@ const emitEvent = async (menu: FormMenu, clickEvent: Event | MouseEvent) => {
290
360
  } else if (menu.action == "update") {
291
361
  if (await updateData()) emits("on", FormCrudEvent.update);
292
362
  } else if (menu.type == "docstatus") {
363
+ setRecentDocument(data.value._id, {
364
+ docName: doc.getDocName(),
365
+ label: title.value,
366
+ branchId: data.value.branchId,
367
+ time: new Date().toISOString(),
368
+ });
293
369
  emits("on", FormCrudEvent.setDocStatus, menu.action);
294
370
  } else if (menu.action == FormCrudEvent.exit)
295
371
  emits("on", FormCrudEvent.exit);
@@ -321,7 +397,7 @@ const getDocActions = () => {
321
397
  const showMenuButton = (menu: FormMenu) => {
322
398
  if (menu.separator) return true;
323
399
 
324
- if (menu.action == "print") return true;
400
+ if (menu.action == "print" && !doc.isNew()) return true;
325
401
  //all document status cannot direct apply regardless new or draft
326
402
  if (menu.type == "docstatus") return true;
327
403