@simitgroup/simpleapp-generator 1.2.8 → 1.3.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/buildinschemas/organization.d.ts.map +1 -1
  2. package/dist/buildinschemas/organization.js +3 -1
  3. package/dist/buildinschemas/organization.js.map +1 -1
  4. package/dist/framework.d.ts.map +1 -1
  5. package/dist/framework.js +3 -8
  6. package/dist/framework.js.map +1 -1
  7. package/dist/generate.js +14 -14
  8. package/dist/generate.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/buildinschemas/organization.ts +3 -1
  11. package/src/framework.ts +4 -8
  12. package/src/generate.ts +17 -16
  13. package/templates/basic/nest/controller.ts.eta +17 -0
  14. package/templates/basic/nest/default.ts.eta +6 -2
  15. package/templates/basic/nuxt/default.ts.eta +10 -6
  16. package/templates/basic/nuxt/pages.[id].vue.eta +9 -7
  17. package/templates/basic/nuxt/pages.form.vue.eta +16 -36
  18. package/templates/basic/nuxt/pages.landing.vue.eta +42 -35
  19. package/templates/basic/nuxt/pages.viewer.vue.eta +4 -6
  20. package/templates/nest/.env._eta +0 -1
  21. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +14 -2
  22. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +32 -18
  23. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +76 -13
  24. package/templates/nuxt/assets/css/style.css._eta +19 -7
  25. package/templates/nuxt/assets/primevue/passthrough.ts._eta +20 -9
  26. package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
  27. package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
  28. package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
  29. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
  30. package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
  31. package/templates/nuxt/components/form/readme.md.eta +1 -0
  32. package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +13 -11
  33. package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +11 -17
  34. package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
  35. package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
  36. package/templates/nuxt/components/list/ListView.vue.eta +129 -60
  37. package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
  38. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
  39. package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
  40. package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
  41. package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
  42. package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
  43. package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
  44. package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
  45. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +201 -174
  46. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +115 -111
  47. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
  48. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -263
  49. package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
  50. package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
  51. package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
  52. package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
  53. package/templates/nuxt/composables/date.generate.ts.eta +14 -9
  54. package/templates/nuxt/i18n.config.ts.eta +1 -1
  55. package/templates/nuxt/lang/en.ts.eta +16 -0
  56. package/templates/nuxt/layouts/default.vue._eta +32 -17
  57. package/templates/nuxt/layouts/mobile.vue._eta +35 -12
  58. package/templates/nuxt/nuxt.config.ts._eta +3 -7
  59. package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
  60. package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
  61. package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
  62. package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
  63. package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +38 -4
  64. package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
  65. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +29 -292
  66. package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
  67. package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
  68. package/templates/nuxt/pages/[xorg]/user.vue.eta +88 -78
  69. package/templates/nuxt/pages/profile.vue.eta +12 -3
  70. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +2 -3
  71. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
  72. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +41 -2
  73. package/templates/nuxt/types/documentlist.ts.eta +0 -9
  74. package/templates/nuxt/types/events.ts.eta +1 -0
  75. package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
  76. package/templates/nuxt/types/user.ts.eta +2 -0
  77. package/templates/project/lang/default._json +5 -0
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
  80. package/templates/nuxt/lang/en.ts._eta +0 -6
  81. package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
  82. package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
  83. package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
  84. /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
@@ -1,107 +1,199 @@
1
1
  <template>
2
- <!-- dont modify this component -->
3
- <div class="simpleapp-tool-bar flex flex-row text-left gap-4">
4
- <div v-for="(menu,index) in menus" :key="index">
5
- <div>
6
- <ButtonDefault v-if="showMenuButton(menu)" @click="emitEvent(menu,$event)">{{ menu.label }}</ButtonDefault>
7
- </div>
8
-
9
- </div>
10
- <div v-for="(menu,index) in getDocActions()" :key="index">
11
- <div>
12
- <ButtonDefault @click="emitEvent(menu,$event)">{{ menu.label }}</ButtonDefault>
13
- </div>
14
-
15
- </div>
16
- <ConfirmPopup></ConfirmPopup>
17
- </div>
2
+ <div v-if="isMobile()" class="w-full">
3
+ <MobileToolbar>
4
+ <template #start>
5
+ <ButtonText class="text-xl" @click="callClose"
6
+ ><i class="pi pi-angle-left"></i
7
+ ></ButtonText>
8
+ </template>
9
+ <template #center>
10
+ <TextTitle>{{ title }}</TextTitle>
11
+ </template>
12
+ <template #end>
13
+ <div class="flex flex-row-reverse gap-1 w-full">
14
+ <ButtonText class="text-xl" @click="toggleMenu" v-if="isShow">
15
+ <i class="pi pi-ellipsis-v"></i>
16
+ </ButtonText>
17
+
18
+ <ButtonText
19
+ class="text text-xl"
20
+ @click="
21
+ emitEvent(
22
+ {
23
+ action: doc.isNew() ? 'create' : 'update',
24
+ label: '',
25
+ type: 'crud',
26
+ },
27
+ $event,
28
+ )
29
+ "
30
+ >
31
+ <i class="pi pi-save"></i>
32
+ </ButtonText>
33
+
34
+ <ContextMenu ref="menu" :model="menus as MenuItem[]" />
35
+ </div>
36
+ </template>
37
+ </MobileToolbar>
38
+ <ConfirmDialog></ConfirmDialog>
39
+ </div>
40
+ <div v-else class="simpleapp-tool-bar">
41
+ <Toolbar>
42
+ <template #start>
43
+ <div v-for="(menu, index) in menus" :key="index">
44
+ <div v-if="menu.label && menu.type == 'crud'">
45
+ <ButtonDefault @click="emitEvent(menu, $event)">{{
46
+ menu.label
47
+ }}</ButtonDefault>
48
+ </div>
49
+ </div>
50
+ </template>
51
+ <template #center>
52
+ <div v-for="(menu, index) in menus" :key="index">
53
+ <div v-if="menu.label && menu.type == 'docstatus'">
54
+ <ButtonDefault @click="emitEvent(menu, $event)">{{
55
+ menu.label
56
+ }}</ButtonDefault>
57
+ </div>
58
+ </div>
59
+ </template>
60
+ <template #end> </template>
61
+ </Toolbar>
62
+
63
+ <ConfirmPopup></ConfirmPopup>
64
+ </div>
18
65
  </template>
19
66
  <script setup lang="ts">
20
-
21
- import { SimpleAppClient } from '~/simpleapp/generate/clients/SimpleAppClient';
67
+ import { SimpleAppClient } from "~/simpleapp/generate/clients/SimpleAppClient";
22
68
  import { useConfirm } from "primevue/useconfirm";
69
+ import { FormActions, FormCrudEvent, FormMenu } from "~/types";
70
+ import { MenuItem } from "primevue/menuitem";
23
71
  const confirm = useConfirm();
24
- import {FormActions,FormMenu} from '~/types'
25
-
26
- const ismodify = ref(false)
72
+ const emits = defineEmits(["on", "close"]);
27
73
  const props = defineProps<{
28
- document: SimpleAppClient<any,any>,
29
- disableaction? : string[]
30
- }>()
74
+ document: SimpleAppClient<any, any>;
75
+ disableaction?: string[];
76
+ }>();
77
+ const createData = async () => await doc.create();
78
+ const updateData = async () => await doc.update();
79
+ const deleteData = async () => await doc.delete();
31
80
 
32
- const emits = defineEmits(['on'])
33
- const doc = props.document
34
- const data = doc.getReactiveData()
81
+ const doc = props.document;
82
+ const data = doc.getReactiveData();
83
+ type Datatype = keyof typeof data.value;
84
+ const config = doc.getSchema()["x-simpleapp-config"];
85
+ const titlefield = (config.documentTitle ?? config.documentTitle) as Datatype;
86
+ const title = ref<string>(
87
+ data.value[titlefield as Datatype]
88
+ ? data.value[titlefield as Datatype]
89
+ : t(doc.getDocName()),
90
+ );
91
+ const menu = ref();
92
+ const menus = computed(() =>
93
+ [...getActions(), { separator: true }, ...getDocActions()].filter((item) =>
94
+ showMenuButton(item),
95
+ ),
96
+ );
35
97
 
36
- const menus = ref<FormMenu[]>([])
98
+ const isShow = computed(
99
+ () => menus.value.filter((item) => item.action != undefined).length > 0,
100
+ );
101
+ const toggleMenu = (event: MouseEvent) => {
102
+ menu.value.toggle(event);
103
+ };
37
104
 
105
+ const callClose = (e:MouseEvent) => {
106
+ useNuxtApp().$event("CloseDialog", doc.getDocName());
107
+ emitEvent({action:'exit',type:'menu',label:''},e)
108
+ // async (menu: FormMenu, clickEvent: MouseEvent)
109
+ };
110
+ const emitMobileEvent = (itemevent: {
111
+ item: any;
112
+ originalEvent: MouseEvent;
113
+ }) => {
114
+ const actionname: string = itemevent.item.action;
115
+ const event = itemevent.originalEvent;
116
+ emitEvent({ action: actionname, type: "crud", label: "" }, event);
117
+ };
38
118
 
39
119
  const getActions = () => {
40
- const actions = doc.getActions()
41
-
42
- // Object.keys(actions).forEach((key)=>{ //crud, api, docstatus
43
- actions['crud'].forEach((item)=>{
44
- if(props.disableaction && props.disableaction.includes(item)){/*skip this item*/}
45
- else{
46
- menus.value.push({
47
- action: item,
48
- label: t(item),
49
- type: 'crud'
50
- })
51
- }
52
- })
53
- // })
54
- return actions
55
- }
120
+ const actions = doc.getActions();
121
+ const crudmenus: any[] = [];
122
+ // Object.keys(actions).forEach((key)=>{ //crud, api, docstatus
123
+ actions["crud"].forEach((item) => {
124
+ if (props.disableaction && props.disableaction.includes(item)) {
125
+ /*skip this item*/
126
+ } else {
127
+ crudmenus.push({
128
+ action: item,
129
+ label: t(item),
130
+ type: "crud",
131
+ command: emitMobileEvent,
132
+ });
133
+ }
134
+ });
135
+ // })
136
+ return crudmenus;
137
+ };
56
138
 
57
- getActions()
139
+ const emitEvent = async (menu: FormMenu, clickEvent: MouseEvent) => {
140
+ if (menu.action == "delete") {
141
+ confirm.require({
142
+ target: clickEvent.target as HTMLElement,
143
+ header: t("deleteRecord"),
144
+ message: `${t("deleteThisRecord?")}`,
58
145
 
59
- const emitEvent = (menu:FormMenu, clickEvent:any)=>{
60
- if(menu.action=='delete'){
61
- confirm.require({
62
- target: clickEvent.currentTarget as HTMLElement,
63
- message: `${t("delete")}?`,
64
- icon: "pi pi-exclamation-triangle",
65
- acceptClass: "p-button-danger",
66
- accept: () => emits('on',menu.action)
67
- });
68
- }else{
69
- emits('on',menu.action)
70
- }
71
-
72
- }
146
+ // icon: "pi pi-exclamation-triangle gap-4",
147
+ acceptClass: "p-button-danger",
148
+ accept: async () => {
149
+ if (await deleteData()) emits("on", FormCrudEvent.delete);
150
+ },
151
+ });
152
+ } else {
153
+ if (menu.action == "create") {
154
+ if (await createData()) emits("on", FormCrudEvent.create);
155
+ }
156
+ else if (menu.action == "update") {
157
+ if (await updateData()) emits("on", FormCrudEvent.update);
158
+ }
159
+ else if (menu.type == "setDocStatus")
160
+ emits("on", FormCrudEvent.setDocStatus, menu.action);
161
+ else if (menu.action == FormCrudEvent.exit)
162
+ emits("on", FormCrudEvent.exit);
163
+ }
164
+ };
73
165
 
166
+ const getDocActions = () => {
167
+ const docstatus: string = data.value.documentStatus;
168
+ const allstatus = doc.getSchema()["x-simpleapp-config"].allStatus;
169
+ let docactionmenus: FormMenu[] = [];
170
+ type stringlist = { [key: string]: string };
171
+ const statusNames: stringlist = {};
172
+ allstatus?.forEach((item) => {
173
+ statusNames[item.status] = t(item.statusName);
174
+ });
175
+ if (allstatus) {
176
+ const stateconfig = allstatus.find((item) => item.status === docstatus);
177
+ docactionmenus =
178
+ stateconfig?.actions.map((item) => ({
179
+ action: item,
180
+ label: statusNames[item],
181
+ type: "docstatus",
182
+ })) ?? [];
183
+ }
184
+ return docactionmenus;
185
+ };
186
+ const showMenuButton = (menu: FormMenu) => {
187
+ if (menu.separator) return true;
188
+ if (isMobile() && ["create", "update"].includes(menu.action)) return false;
189
+ if (!canPerform(doc.getDocName(), menu.action)) return false;
190
+ if (doc.isNew() && menu.action == "create") return true;
191
+ if (!doc.isNew() && menu.action == "new") return true;
192
+ if (!doc.isNew() && menu.action == "update") return true;
193
+ if (!doc.isNew() && menu.action == "delete") return true;
74
194
 
75
- const getDocActions = () =>{
76
- const docstatus:string = data.value.documentStatus
77
- const allstatus = doc.getSchema()['x-simpleapp-config'].allStatus
78
- let docactionmenus:FormMenu[] = []
79
- type stringlist = {[key:string]:string}
80
- const statusNames:stringlist = {}
81
- allstatus?.forEach(item=>{
82
- statusNames[item.status]=t(item.statusName)
83
- })
84
- if(allstatus){
85
- const stateconfig = allstatus.find((item)=>item.status===docstatus)
86
- docactionmenus = stateconfig?.actions.map(item=>({
87
- action: item,
88
- label: statusNames[item],
89
- type: 'docstatus'
90
- })) ?? []
91
- }
92
- return docactionmenus
93
-
94
- }
95
- const showMenuButton = (menu:FormMenu)=>{
96
-
97
- if(!canPerform(doc.getDocName(),menu.action)) return false
98
- if(doc.isNew() && menu.action == 'create') return true
99
- if(!doc.isNew() && menu.action == 'new') return true
100
- if(!doc.isNew() && menu.action == 'update') return true
101
- if(!doc.isNew() && menu.action == 'delete') return true
102
-
103
- if(menu.type == 'api' ) return false
104
- return false
105
- }
195
+ if (menu.type == "api") return false;
106
196
 
107
- </script>
197
+ return false;
198
+ };
199
+ </script>