@simitgroup/simpleapp-generator 1.3.3-alpha → 1.3.5-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 (71) hide show
  1. package/dist/framework.js +2 -2
  2. package/dist/framework.js.map +1 -1
  3. package/dist/generate.d.ts.map +1 -1
  4. package/dist/generate.js +7 -11
  5. package/dist/generate.js.map +1 -1
  6. package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
  7. package/dist/processors/jsonschemabuilder.js +8 -0
  8. package/dist/processors/jsonschemabuilder.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/framework.ts +2 -2
  11. package/src/generate.ts +15 -12
  12. package/src/processors/jsonschemabuilder.ts +12 -1
  13. package/templates/basic/nest/controller.ts.eta +17 -6
  14. package/templates/basic/nuxt/component.select.vue.eta +35 -0
  15. package/templates/basic/nuxt/pages.form.vue.eta +5 -8
  16. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +3 -1
  17. package/templates/nest/.gitignore.eta +6 -1
  18. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +10 -9
  19. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +2 -2
  20. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +38 -38
  21. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +14 -9
  22. package/templates/nuxt/assets/css/style.css._eta +43 -7
  23. package/templates/nuxt/assets/primevue/passthrough.ts._eta +26 -15
  24. package/templates/nuxt/components/button/ButtonAction.vue._eta +19 -0
  25. package/templates/nuxt/components/button/ButtonDanger.vue._eta +13 -6
  26. package/templates/nuxt/components/button/ButtonDefault.vue._eta +13 -6
  27. package/templates/nuxt/components/button/ButtonMultiple.vue._eta +9 -7
  28. package/templates/nuxt/components/button/ButtonPrimary.vue._eta +13 -6
  29. package/templates/nuxt/components/button/ButtonText.vue._eta +16 -7
  30. package/templates/nuxt/components/button/ButtonWarning.vue._eta +13 -6
  31. package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +83 -69
  32. package/templates/nuxt/components/chart/card.vue._eta +32 -0
  33. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +44 -21
  34. package/templates/nuxt/components/event/EventNotification.vue._eta +119 -107
  35. package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +46 -38
  36. package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +131 -75
  37. package/templates/nuxt/components/list/ListView.vue.eta +44 -13
  38. package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +13 -8
  39. package/templates/nuxt/components/overlay/OverlayPanelWithToolBar.vue.eta +35 -37
  40. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +3 -4
  41. package/templates/nuxt/components/renderer/RendererDate.vue.eta +3 -2
  42. package/templates/nuxt/components/renderer/RendererForeignKey.vue.eta +38 -34
  43. package/templates/nuxt/components/select/SelectTemplate.vue.eta +79 -0
  44. package/templates/nuxt/components/select/readme.md +1 -0
  45. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +181 -35
  46. package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +70 -0
  47. package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +77 -73
  48. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +20 -7
  49. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +113 -111
  50. package/templates/nuxt/components/simpleApp/{SimpleAppFormToolBar.vue.eta → SimpleAppFormToolBar.vue._eta} +126 -65
  51. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +117 -43
  52. package/templates/nuxt/components/text/TextPrimary.vue._eta +13 -0
  53. package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +64 -0
  54. package/templates/nuxt/components/user/UserTenantPicker.vue.eta +81 -70
  55. package/templates/nuxt/composables/date.generate.ts.eta +2 -0
  56. package/templates/nuxt/composables/getDocument.generate.ts.eta +35 -2
  57. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +5 -1
  58. package/templates/nuxt/composables/refreshDocumentList.generate.ts.eta +14 -2
  59. package/templates/nuxt/lang/en.ts.eta +3 -1
  60. package/templates/nuxt/nuxt.config.ts._eta +3 -0
  61. package/templates/nuxt/pages/[xorg]/organization.vue.eta +80 -61
  62. package/templates/nuxt/pages/index.vue._eta +10 -56
  63. package/templates/nuxt/pages/picktenant.vue._eta +19 -0
  64. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +10 -2
  65. package/templates/nuxt/server/api/[xorg]/[...].ts.eta +9 -10
  66. package/templates/nuxt/types/calendar.ts.eta +2 -0
  67. package/templates/nuxt/types/events.ts.eta +3 -1
  68. package/templates/nuxt/types/simpleappinput.ts.eta +1 -0
  69. package/templates/project/lang/default._json +150 -63
  70. package/tsconfig.tsbuildinfo +1 -1
  71. package/templates/nuxt/components/user/UserButtonCreateTenant.vue.eta +0 -103
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <div>
3
+ <div class="mt-8 md:flex justify-start md:gap-4">
4
+ <form @submit.prevent="true" class="w-full">
5
+ <div>{{ t("createNewCompany") }}</div>
6
+ <div class="p-inputgroup flex flex-row">
7
+ <InputText
8
+ class="flex-1"
9
+ :placeholder="t('enterYourCompanyName')"
10
+ v-model:model-value="data.tenantName"
11
+ />
12
+ <div class="p-inputgroup-addon p p-0">
13
+ <button
14
+ :label="t('create')"
15
+ class="border rounded-tl-none rounded-bl-none btn btn-primary -ml-1 h-full p-3 rounded-r-md"
16
+ @click="createTenant"
17
+ :loading="onhold"
18
+ >
19
+ {{ t("create") }}
20
+ </button>
21
+ </div>
22
+ </div>
23
+ </form>
24
+ </div>
25
+ </div>
26
+ </template>
27
+ <script setup lang="ts">
28
+ /**
29
+ * This file was automatically generated by simpleapp generator during initialization. It is changable.
30
+ * --remove-this-line-to-prevent-override--
31
+ * last change 2024-03-05
32
+ * author: Ks Tan
33
+ */
34
+ import { ref } from "vue";
35
+ import { AxiosResponse } from "axios";
36
+ const visible = ref(false);
37
+ const data = ref({ tenantName: "" });
38
+
39
+ const createtitle = ref("Create My Company");
40
+ const errCreateTenant = ref();
41
+ const onhold = ref(false);
42
+
43
+ const createTenant = async () => {
44
+ onhold.value = true;
45
+
46
+ getPorfileApi()
47
+ .createTenant(data.value)
48
+ .then((res: AxiosResponse) => {
49
+ if (res && res.status && res.status == 201) {
50
+ if (res.data && res.data["xOrg"]) {
51
+ const xorg = res.data["xOrg"];
52
+ navigateTo("/" + xorg, { external: true });
53
+ }
54
+ }
55
+ })
56
+ .catch((err) => {
57
+ errCreateTenant.value = err["message"];
58
+ console.error("errCreateTenant", err);
59
+ })
60
+ .finally(() => {
61
+ onhold.value = false;
62
+ });
63
+ };
64
+ </script>
@@ -1,61 +1,72 @@
1
1
  <template>
2
- <div v-if="alltenants" v-for="tenant in alltenants">
3
- <card :pt="{ header:{class:'text-xl text-gray-600'}}">
4
-
2
+ <div class="w-full">
3
+ <div v-if="waiting" class="p-4 w-full">
4
+ waiting..
5
+ </div>
6
+ <div v-else class="w-full p-4">
7
+
8
+ <div v-for="tenant in alltenants" class="border rounded-lg p-2 m-2">
9
+ <TextTitle>{{ tenant.tenantName }}</TextTitle>
10
+ <ListView :list="tenant.permissions" url="/" idField="xOrg">
11
+ <template #default="{item,index}">
12
+ <div class="flex flex-row w-full justify-end">
13
+ <TextPrimary class="flex-1">{{ item.orgName }}</TextPrimary>
14
+ <TextPrimary>{{ item.branchCode }}</TextPrimary>
15
+
16
+ </div>
17
+ </template>
18
+ </ListView>
19
+ </div>
20
+
21
+ <!-- <card :pt="{ header: { class: 'text-xl text-gray-600' } }">
5
22
  <template #header>
6
- {{tenant.tenantName }}
23
+ {{ tenant.tenantName }}
7
24
  </template>
8
- <template #content>
9
-
10
- <ul >
11
- <li v-for="o in getOrglist(tenant)">
12
- <h1 class="subtitle-text">{{ o.orgName }}</h1>
13
- <ul role="list" class="divide-y divide-gray-100 rounded-md border border-gray-200">
14
- <li v-for="b in getBranchlist(tenant)" class="w-full items-center justify-between py-4 pl-4 pr-4 text-sm route-link-list">
15
- <NuxtLink :href="`/${b.xOrg }`" v-if="o.orgId==b.orgId" :external="true" >
16
- <div class="flex w-full flex-1 items-center ">
17
- <!-- <i class="pi pi-sitemap"></i> -->
18
- <p class="flex-1 flex-shrink-0 font-bold text-primary-600 ">
19
- {{ b.branchCode }}
20
- </p>
21
- <p class=" text-right min-w-0 flex-1 gap-2">
22
- <span href="#" class="font-medium text-gray-600 ">{{ b.group }}</span>
23
- </p>
24
- </div>
25
- <div class=" flex-shrink-0">
26
-
27
- <span class=" font-medium text-gray-400">{{useRuntimeConfig().public.APP_URL}}/{{b.xOrg }}</span>
28
-
29
- </div>
30
-
31
- </NuxtLink>
32
- </li>
33
- </ul>
34
-
35
- </li>
36
- </ul>
37
-
38
- <!-- <ul>
39
- <li v-for="b in branches" class="border border-b-1">
40
- <NuxtLink :href="`/${b.xOrg }`" :external="true">
41
-
42
- <div class="flex flex-col">
43
- <div class="flex">
44
- <p class="flex-1">{{b.branch.branchCode}}</p>
45
- <p class="flex-1 text-right">{{b.group }}</p>
46
- </div>
47
-
48
-
49
- <p class="text-gray-500">{{useRuntimeConfig().public.APP_URL}}/{{b.xOrg }}</p>
50
-
25
+ <template #content>
26
+ <ul>
27
+ <li v-for="o in getOrglist(tenant)">
28
+ <h1 class="subtitle-text">{{ o.orgName }}</h1>
29
+ <ul
30
+ role="list"
31
+ class="divide-y divide-gray-100 rounded-md border border-gray-200"
32
+ >
33
+ <li
34
+ v-for="b in getBranchlist(tenant)"
35
+ class="w-full items-center justify-between py-4 pl-4 pr-4 text-sm route-link-list"
36
+ >
37
+ <NuxtLink
38
+ :href="`/${b.xOrg}`"
39
+ v-if="o.orgId == b.orgId"
40
+ :external="true"
41
+ >
42
+ <div class="flex w-full flex-1 items-center">
43
+ <p class="flex-1 flex-shrink-0 font-bold text-primary-600">
44
+ {{ b.branchCode }}
45
+ </p>
46
+ <p class="text-right min-w-0 flex-1 gap-2">
47
+ <span href="#" class="font-medium text-gray-600">{{
48
+ b.group
49
+ }}</span>
50
+ </p>
51
+ </div>
52
+ <div class="flex-shrink-0">
53
+ <span class="font-medium text-gray-400"
54
+ >{{ useRuntimeConfig().public.APP_URL }}/{{
55
+ b.xOrg
56
+ }}</span
57
+ >
51
58
  </div>
52
-
53
- </NuxtLink>
59
+ </NuxtLink>
60
+ </li>
61
+ </ul>
54
62
  </li>
55
- </ul> -->
63
+ </ul>
64
+
56
65
  </template>
57
- </card>
66
+ </card> -->
58
67
  </div>
68
+
69
+ </div>
59
70
  </template>
60
71
  <script setup lang="ts">
61
72
  /**
@@ -64,29 +75,29 @@
64
75
  * last change 2023-10-28
65
76
  * Author: Ks Tan
66
77
  */
67
- import _ from 'lodash'
68
- const profileapi = getAllApi().PROFILEApi;
69
- const alltenants = ref()
70
-
71
-
78
+ import _ from "lodash";
79
+ import TextPrimary from "../text/TextPrimary.vue";
80
+ const waiting = ref(true)
81
+ const alltenants = ref();
72
82
 
73
-
74
- const loadAllTenants = async () =>{
75
- const api = new profileapi(undefined,useRuntimeConfig().public.API_URL,)
76
- alltenants.value = (await api.getAllTenants()).data
77
- }
83
+ const loadAllTenants = async () => {
84
+ waiting.value=false
85
+ alltenants.value = (await getPorfileApi().getAllTenants()).data;
86
+ };
78
87
 
79
88
  // const props = defineProps<{
80
89
  // tenant:any
81
90
  // }>()
82
- const getBranchlist = (tenant:any)=>tenant.permissions
83
-
84
-
85
- const getOrglist = (tenant:any) => _.uniqBy(getBranchlist(tenant),'orgId')
86
- .map((item:any)=>({ orgId:item.orgId,orgCode:item.orgCode,orgName:item.orgName}) )
91
+ const getBranchlist = (tenant: any) => tenant.permissions;
87
92
 
93
+ const getOrglist = (tenant: any) =>
94
+ _.uniqBy(getBranchlist(tenant), "orgId").map((item: any) => ({
95
+ orgId: item.orgId,
96
+ orgCode: item.orgCode,
97
+ orgName: item.orgName,
98
+ }));
88
99
 
89
- onNuxtReady(()=>{
90
- loadAllTenants()
91
- })
92
- </script>
100
+ onNuxtReady(() => {
101
+ loadAllTenants();
102
+ });
103
+ </script>
@@ -15,6 +15,8 @@ export const getDayJs = ()=>useDayjs()
15
15
  export const lastDateOfMonth = (datestr:string) => useDayjs()(datestr).endOf('month').format('YYYY-MM-DD');
16
16
  export const today = () => useDayjs()().format('YYYY-MM-DD')
17
17
  export const dateToString = (date:Date) => useDayjs()(date).format('YYYY-MM-DD')
18
+ export const dateToTimeString = (date:Date) => useDayjs()(date).format('HH:mm:ss')
19
+ export const stringToDate = (datestr:string) => new Date(datestr)
18
20
  export const dateToDateTimeString = (date:Date)=> useDayjs()(date).format('YYYY-MM-DD HH:mm:ss')
19
21
  export const toLocalDate = (date:string | Date)=> useDayjs()(date).format(getDateFormat())
20
22
  export const getDateFormat = ():string=> 'DD-MM-YYYY'
@@ -1,10 +1,43 @@
1
1
  /**
2
2
  * This file was automatically generated by simpleapp generator. Every
3
3
  * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2023-10-28
4
+ * last change 2024-02-24
5
5
  * Author: Ks Tan
6
6
  */
7
7
  import {getAllDocuments} from '~/simpleapp/generate/commons/documents'
8
+ import { FormCrudEvent } from '~/types'
8
9
  export const getDocument = (docname:string) =>{
9
10
  return getAllDocuments().find((item)=>item.docName==docname) //?.docClass
10
- }
11
+ }
12
+
13
+ // (appuser: UserContext, filter: any) => Promise<void>;
14
+ export const onScreenAddDocument = <T>(docname:string,paras?:T,after?:(eventType:FormCrudEvent, data:T)=>Promise<void>)=>{
15
+ useNuxtApp().$event('ViewRecord',{
16
+ documentName: docname,
17
+ eventId:randomUUID(),
18
+ _id:'new',
19
+ paras:paras,
20
+ document: getDocument(docname)?.docClass,
21
+ viewer: getDocument(docname)?.viewer,
22
+ after: (eventType:FormCrudEvent, data: any) => {
23
+ //do nothing
24
+ if(after)after(eventType,data as T)
25
+ },
26
+ label:t(docname)
27
+
28
+ })
29
+ }
30
+ export const onScreenEditDocument = <T>(docname:string,_id:string,after?:(eventType:FormCrudEvent, data:T)=>Promise<void>)=>{
31
+ useNuxtApp().$event('ViewRecord',{
32
+ documentName: docname,
33
+ eventId:randomUUID(),
34
+ _id:_id,
35
+ document: getDocument(docname)?.docClass,
36
+ viewer: getDocument(docname)?.viewer,
37
+ after: async (eventType:FormCrudEvent, data: any) => {
38
+ //do nothing
39
+ if(after)after(eventType,data as T)
40
+ },
41
+ label:t(docname)
42
+ })
43
+ }
@@ -55,4 +55,8 @@ export const getAllApi=()=>{
55
55
  export const getWorkflowApi = () => {
56
56
  return new o.WorkflowApi(getAxiosConfig())
57
57
 
58
- }
58
+ }
59
+
60
+ export const getPorfileApi = () => {
61
+ return new o.PROFILEApi(getAxiosConfig())
62
+ }
@@ -1,7 +1,19 @@
1
1
  /**
2
2
  * This file was automatically generated by simpleapp generator. Every
3
3
  * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2023-10-28
4
+ * last change 2024-03-07
5
5
  * Author: Ks Tan
6
6
  */
7
- export const refreshDocumentList = (docName:string)=>useNuxtApp().$event('RefreshDocumentList',{documentName:docName})
7
+ export const refreshDocumentList = (docName:string)=>useNuxtApp().$event('RefreshDocumentList',{documentName:docName})
8
+ export const refreshDocument = (docName:string)=>useNuxtApp().$event('RefreshDocument',docName)
9
+
10
+ export const listenDocument = (docName:string,callback:Function) =>{
11
+ useNuxtApp().$listen('RefreshDocument',async (eventdocname:string)=>{
12
+ if(eventdocname==docName) await callback()
13
+ })
14
+ }
15
+ export const listenDocumentList = (docName:string,callback:Function) =>{
16
+ useNuxtApp().$listen('RefreshDocumentList',async (eventdata)=>{
17
+ if(eventdata.documentName == docName) await callback()
18
+ })
19
+ }
@@ -11,7 +11,9 @@ export default {
11
11
  //auto generate from schema
12
12
  <% for(let i=0; i< it.allfields.length; i++){ %>
13
13
  <% let f = it.allfields[i] %>
14
- '<%= f %>' : '<%= camelCaseToWords(f) %>',
14
+ <% if(!it.lang[f]){%>
15
+ '<%= f %>' : '<%= camelCaseToWords(f) %>',
16
+ <%}%>
15
17
  <%}%>
16
18
 
17
19
  }
@@ -105,6 +105,9 @@ devServer: {
105
105
  auth: {
106
106
  globalAppMiddleware: false
107
107
  },
108
+ dayjs:{
109
+ plugins: [ 'utc', 'duration']
110
+ },
108
111
  // security: {
109
112
  // corsHandler:{
110
113
  // origin: '*' //| 'null' | (string | RegExp)[] | ((origin: string) => boolean);
@@ -1,47 +1,69 @@
1
1
  <template>
2
- <title>{{ t("organization") }}</title>
3
- <div class="w-full flex-col flex">
4
- <MobileToolbar>
5
- <template #center>{{ t('organization') }}</template>
6
- <template #end>
7
- <ButtonText @click="showEditOrg=true"><i class="pi pi-pencil"></i></ButtonText>
8
- </template>
9
- </MobileToolbar>
10
- <div class="w-full flex flex-row p-2">
11
- <div class="p-4">
12
- <div class="border w-12 h-12 md:w-24 md:h24"></div>
13
- </div>
14
- <div class="flex flex-col flex-1 ">
15
- <TextTitle>{{ data.orgName }} / {{ data.orgCode }}</TextTitle>
16
- <div class="text-gray-600 dark:text-gray-400 text-sm">{{ data.description }}</div>
17
- <div class="text-gray-600 dark:text-gray-400 text-sm">
18
- {{ data.country }}/{{ data.currency }}/{{ data.timeZone }}//{{ data.offsetMinute }}
19
- </div>
20
-
21
- </div>
2
+
3
+ <div class="w-full flex-col flex">
4
+ <title>{{ t("organization") }}</title>
5
+ <MobileToolbar class="bg-gray-600">
6
+ <template #center><TextTitle class="text-white">{{ t("organization") }}</TextTitle></template>
7
+ <template #end>
8
+ <ButtonText @click="showEditOrg = true" class="text-white"
9
+ ><i class="pi pi-pencil"></i
10
+ ></ButtonText>
11
+ </template>
12
+ </MobileToolbar>
13
+
14
+ <div class="w-full flex flex-row p-2 border-b border-gray-300 ">
15
+ <div class="p-4">
16
+ <div class="border w-12 h-12 md:w-24 md:h24"></div>
22
17
  </div>
18
+ <div class="flex flex-col flex-1 ">
19
+ <TextTitle>{{ data.orgName }} / {{ data.orgCode }}</TextTitle>
20
+ <TextSubtitle>
21
+ {{ data.description }}
22
+ </TextSubtitle>
23
+ </div>
24
+ </div>
23
25
 
24
-
25
- <div class="w-full p-2">
26
- <h1>Branches</h1>
27
- <ButtonText @click="goBranch('new')">{{ t('addBranch') }}</ButtonText>
28
- <ListView
29
- :list="branchlist"
30
- title-field="branchName"
31
- sub-title-field="branchCode"
32
- :url="getDocumentUrl('organization', id)"
33
- >
34
- </ListView>
26
+ <div class="w-full p-2 flex flex-col ">
27
+
28
+ <div class="flex flex-row justify-end">
29
+ <TextTitle class="flex-1 p-2">{{ t('branches') }}</TextTitle>
30
+ <div>
31
+ <ButtonPrimary @click="goBranch('new')">
32
+ <i class="pi pi-plus"></i> <span>{{ t("addBranches") }}</span>
33
+ </ButtonPrimary>
34
+ </div>
35
35
  </div>
36
-
36
+ <ListView class="border rounded-lg border-gray-400 dark:border-gray-600"
37
+ :list="branchlist"
38
+ title-field="branchName"
39
+ sub-title-field="branchCode"
40
+ :url="getDocumentUrl('organization', id)"
41
+ #default="{item}"
42
+ >
43
+ <div class="flex flex-row">
44
+ <div class="flex-col flex flex-1">
45
+ <TextPrimary>{{ item.branchName }}</TextPrimary>
46
+ <TextSubtitle>{{ item.description }}</TextSubtitle>
47
+ </div>
48
+ <div class="flex-col flex text-right">
49
+ <div>{{ item.branchCode }}</div>
50
+ <renderer-boolean v-model="item.active"></renderer-boolean>
51
+ </div>
52
+ </div>
37
53
 
38
- <OverlaySideBarCrud v-model="showEditOrg" close-event-name="organization">
39
- <FormOrganization :_id="getUserProfile()?.orgRecordId" @after="afterOrganization"></FormOrganization>
40
- </OverlaySideBarCrud>
41
-
42
- <OverlaySideBarCrud v-model="showEditBranch" close-event-name="branch">
43
- <NuxtPage :_id="id"></NuxtPage>
44
- </OverlaySideBarCrud>
54
+ </ListView>
55
+ </div>
56
+
57
+ <OverlaySideBarCrud v-model="showEditOrg" close-event-name="organization">
58
+ <FormOrganization
59
+ :_id="getUserProfile()?.orgRecordId"
60
+ @after="afterOrganization"
61
+ ></FormOrganization>
62
+ </OverlaySideBarCrud>
63
+
64
+ <OverlaySideBarCrud v-model="showEditBranch" close-event-name="branch">
65
+ <NuxtPage :_id="id"></NuxtPage>
66
+ </OverlaySideBarCrud>
45
67
  </div>
46
68
  </template>
47
69
 
@@ -56,12 +78,12 @@ import { FormCrudEvent, SimpleAppInputType } from "~/types";
56
78
  import ConfirmPopup from "primevue/confirmpopup";
57
79
  import { useConfirm } from "primevue/useconfirm";
58
80
  const confirm = useConfirm();
59
- const showEditOrg = ref<boolean>(false)
60
- const showEditBranch = ref<boolean>(false)
81
+ const showEditOrg = ref<boolean>(false);
82
+ const showEditBranch = ref<boolean>(false);
61
83
 
62
84
  const { $OrganizationDoc, $BranchDoc, $event, $listen } = useNuxtApp();
63
85
 
64
- const orgId = computed(()=><string>getUserProfile()?.orgRecordId)
86
+ const orgId = computed(() => <string>getUserProfile()?.orgRecordId);
65
87
  const doc = $OrganizationDoc();
66
88
  const brancdoc = $BranchDoc();
67
89
  const data = doc.getReactiveData();
@@ -69,7 +91,7 @@ const branchlist = ref([]);
69
91
  const isReadOnly = ref(true);
70
92
  const getCurrentOrg = async () => {
71
93
  await doc.getById(orgId.value);
72
- await fetchRecord()
94
+ await fetchRecord();
73
95
  };
74
96
  const fetchRecord = async () => {
75
97
  //fetch org
@@ -79,41 +101,38 @@ const fetchRecord = async () => {
79
101
  filter: { orgId: data.value.orgId },
80
102
  });
81
103
 
82
- console.log("reload data",branchlist)
104
+ console.log("reload data", branchlist);
83
105
  };
84
106
 
85
107
  const id = computed((): string => String(useRoute().params.id ?? ""));
86
108
 
87
-
88
109
  definePageMeta({
89
110
  menuPath: "setting/organization",
90
111
  });
91
112
 
92
113
  //branch record update then reload
93
114
  $listen("RefreshDocumentList", async (data) => {
94
- console.log("trigger RefreshDocumentList",data)
115
+ console.log("trigger RefreshDocumentList", data);
95
116
  if (data.documentName == "branch" || data.documentName == "organization") {
96
117
  await fetchRecord();
97
118
  }
98
119
  });
99
120
 
121
+ const showBranchDialogIfRequired = () => {
122
+ if (useRoute().path.includes("/new") || id.value) showEditBranch.value = true;
123
+ };
100
124
 
101
-
102
- const showBranchDialogIfRequired = () =>{
103
- if(useRoute().path.includes('/new') || id.value) showEditBranch.value=true
104
- }
105
-
106
- const afterOrganization = (actionName:FormCrudEvent)=>{
107
- if(actionName==FormCrudEvent.update){
108
- showEditOrg.value=false
109
- getCurrentOrg()
125
+ const afterOrganization = (actionName: FormCrudEvent) => {
126
+ if (actionName == FormCrudEvent.update) {
127
+ showEditOrg.value = false;
128
+ getCurrentOrg();
110
129
  }
111
- }
130
+ };
112
131
 
113
- watch(()=>useRoute().path,()=>showBranchDialogIfRequired())
114
- onMounted(()=>showBranchDialogIfRequired())
132
+ watch(
133
+ () => useRoute().path,
134
+ () => showBranchDialogIfRequired(),
135
+ );
136
+ onMounted(() => showBranchDialogIfRequired());
115
137
  getCurrentOrg();
116
-
117
-
118
-
119
138
  </script>
@@ -1,65 +1,19 @@
1
1
  <script lang="ts" setup>
2
2
  /**
3
- * This file was automatically generated by simpleapp generator during initialization. It is changable.
3
+ * This file was automatically generated by simpleapp generator.
4
4
  * --remove-this-line-to-prevent-override--
5
- * last change 2024-02-22
5
+ * last change 2024-03-05
6
6
  * author: Ks Tan
7
7
  */
8
+ const alltenants = ref<any[]>([])
9
+ const totaltenant = ref(0)
10
+ const list = (await getPorfileApi().getAllTenants()).data as any[];
11
+ if(list.length==0 || list.length>1) navigateTo('/picktenant')
12
+ else navigateTo (`/${list[0].permissions[0].xOrg}`)
13
+
8
14
  </script>
9
15
  <template>
10
- <div class="grid place-content-center">
11
- <title>{{ t('home')}} </title>
12
- <ClientOnly><div class="flex flex-row">
13
- <div class="block">
14
- <h1
15
- class="font-bold text-3xl md:text-5xl text-gray-800 dark:text-white"
16
- >
17
- {{ t("welcomeSimpleApp") }}
18
- </h1>
19
- <p class="text-gray-600 dark:text-gray-200">
20
- {{ t("changeHomePageMsg",{fullName:getProfileFullName()}) }}
21
- </p>
22
- <div class="">
23
- <UserButtonCreateTenant></UserButtonCreateTenant>
24
- </div>
25
- </div>
26
- <div class="hidden lg:block">
27
- <svg
28
- :fill="getAvatarColor"
29
- viewBox="0 0 512 512"
30
- xmlns="http://www.w3.org/2000/svg"
31
- >
32
- <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
33
- <g
34
- id="SVGRepo_tracerCarrier"
35
- stroke-linecap="round"
36
- stroke-linejoin="round"
37
- ></g>
38
- <g id="SVGRepo_iconCarrier">
39
- <g id="Anonymous">
40
- <path
41
- d="M475.3571,413.24a69.9,69.9,0,0,0-39.8845-57.4407l-39.9287-18.7987,21.5791-44.5621a89.4527,89.4527,0,0,0,.0025-77.9684L359.7988,96.0682C317.7933,9.3105,194.2088,9.31,152.2019,96.0666L94.87,214.4745a89.445,89.445,0,0,0,.0049,77.9692l21.581,44.5569L76.5256,355.8a69.898,69.898,0,0,0-39.8831,57.439l-3.612,43.3773a22.5157,22.5157,0,0,0,22.4381,24.3842H456.5337A22.5134,22.5134,0,0,0,478.97,456.6187ZM364,260.1205a107.9746,107.9746,0,0,1-98.1035,107.5V341.1249a9.8965,9.8965,0,0,0-19.793,0v26.4957A107.9746,107.9746,0,0,1,148,260.1205V203.44a28.8192,28.8192,0,0,1,28.8193-28.8193H335.1806A28.8193,28.8193,0,0,1,364,203.44Z"
42
- ></path>
43
- <path
44
- d="M321.8213,275.9979a9.91,9.91,0,0,0-12.3135,6.6709,13.5776,13.5776,0,0,1-26.0156,0,9.9026,9.9026,0,1,0-18.9844,5.6426,33.3877,33.3877,0,0,0,63.9844,0A9.9125,9.9125,0,0,0,321.8213,275.9979Z"
45
- ></path>
46
- <path
47
- d="M240.8213,275.9979a9.8908,9.8908,0,0,0-12.3135,6.6709,13.5776,13.5776,0,0,1-26.0156,0,9.9026,9.9026,0,1,0-18.9844,5.6426,33.3877,33.3877,0,0,0,63.9844,0A9.9125,9.9125,0,0,0,240.8213,275.9979Z"
48
- ></path>
49
- <path
50
- d="M319,227.4384H283a9.8965,9.8965,0,1,0,0,19.7929h36a9.8965,9.8965,0,1,0,0-19.7929Z"
51
- ></path>
52
- <path
53
- d="M193,247.2313h36a9.8965,9.8965,0,1,0,0-19.7929H193a9.8965,9.8965,0,1,0,0,19.7929Z"
54
- ></path>
55
- </g>
56
- </g>
57
- </svg>
58
- <p class="text-gray-500 dark:text-gray-200">{{ t('realman') }}</p>
59
- </div>
60
- </div></ClientOnly>
61
- <div class="grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3">
62
- <UserTenantPicker></UserTenantPicker>
63
- </div>
16
+ <div>
17
+ redirecting...
64
18
  </div>
65
19
  </template>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div class="flex flex-col w-full">
3
+ <TextTitle class="text-center p-2">{{ t("pickYourDatabase") }}</TextTitle>
4
+ <div class="flex flex-col">
5
+ <div class="p-4">
6
+ <UserButtonCreateTenant></UserButtonCreateTenant>
7
+ </div>
8
+ <UserTenantPicker></UserTenantPicker>
9
+ </div>
10
+ </div>
11
+ </template>
12
+ <script lang="ts" setup>
13
+ /**
14
+ * This file was automatically generated by simpleapp generator.
15
+ * --remove-this-line-to-prevent-override--
16
+ * last change 2023-09-09
17
+ * author: Ks Tan
18
+ */
19
+ </script>
@@ -29,8 +29,16 @@ export default defineNuxtPlugin( async(nuxtApp) => {
29
29
  return response
30
30
  },
31
31
  (error) => {
32
- if(error.code && error.code == 'ERR_BAD_REQUEST'){
33
- console.error("axios ERR_BAD_REQUEST, redirect to relogin")
32
+ // console.log("error catch",error)
33
+
34
+ if(error?.code && error.code == 'ERR_BAD_REQUEST'){
35
+ // console.log("error.code",error.response.status, error)
36
+ if(error.response && error.response.status==403){
37
+ console.warn("error status 403, redirect to external link /" )
38
+ navigateTo('/',{external:true})
39
+ }else{
40
+ console.error("axios ERR_BAD_REQUEST",error)
41
+ }
34
42
  }
35
43
  else if(error.code){
36
44
  throw createError({