@simitgroup/simpleapp-generator 1.2.7 → 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 (106) 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 +4 -9
  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 +5 -9
  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/app.vue.eta +7 -3
  25. package/templates/nuxt/assets/css/calendar.css._eta +21 -8
  26. package/templates/nuxt/assets/css/style.css._eta +17 -10
  27. package/templates/nuxt/assets/primevue/passthrough.ts._eta +44 -22
  28. package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
  29. package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
  30. package/templates/nuxt/components/calendar/CalendarByResource.vue.eta +29 -8
  31. package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
  32. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
  33. package/templates/nuxt/components/event/EventNotification.vue._eta +23 -2
  34. package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
  35. package/templates/nuxt/components/form/readme.md.eta +1 -0
  36. package/templates/nuxt/components/header/HeaderBar.vue._eta +9 -9
  37. package/templates/nuxt/components/header/HeaderBreadcrumb.vue.eta +2 -2
  38. package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +16 -22
  39. package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +29 -46
  40. package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
  41. package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
  42. package/templates/nuxt/components/list/ListView.vue.eta +129 -58
  43. package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
  44. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
  45. package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
  46. package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
  47. package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
  48. package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
  49. package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
  50. package/templates/nuxt/components/renderer/RendererMoney.vue.eta +10 -2
  51. package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
  52. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +202 -150
  53. package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +7 -1
  54. package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +112 -101
  55. package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
  56. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -246
  57. package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +4 -3
  58. package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
  59. package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
  60. package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
  61. package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
  62. package/templates/nuxt/components/user/UserProfileListItem.vue.eta +2 -2
  63. package/templates/nuxt/composables/date.generate.ts.eta +21 -0
  64. package/templates/nuxt/composables/goTo.generate.ts.eta +1 -0
  65. package/templates/nuxt/composables/stringHelper.generate.ts.eta +0 -5
  66. package/templates/nuxt/error.vue._eta +3 -3
  67. package/templates/nuxt/i18n.config.ts.eta +1 -1
  68. package/templates/nuxt/lang/en.ts.eta +16 -0
  69. package/templates/nuxt/layouts/default.vue._eta +34 -34
  70. package/templates/nuxt/layouts/loginlayout.vue._eta +3 -0
  71. package/templates/nuxt/layouts/mobile.vue._eta +52 -0
  72. package/templates/nuxt/nuxt.config.ts._eta +28 -22
  73. package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
  74. package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
  75. package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
  76. package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
  77. package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +40 -0
  78. package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
  79. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +37 -0
  80. package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
  81. package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
  82. package/templates/nuxt/pages/[xorg]/{user.vue._eta → user.vue.eta} +88 -78
  83. package/templates/nuxt/pages/login.vue._eta +34 -0
  84. package/templates/nuxt/pages/profile.vue.eta +12 -3
  85. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +36 -35
  86. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
  87. package/templates/nuxt/server/api/[xorg]/[...].ts.eta +7 -40
  88. package/templates/nuxt/server/api/profile/[...].ts.eta +3 -32
  89. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +42 -3
  90. package/templates/nuxt/types/calendar.ts.eta +8 -1
  91. package/templates/nuxt/types/documentlist.ts.eta +0 -9
  92. package/templates/nuxt/types/events.ts.eta +1 -0
  93. package/templates/nuxt/types/others.ts.eta +4 -1
  94. package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
  95. package/templates/nuxt/types/user.ts.eta +2 -0
  96. package/templates/project/lang/default._json +9 -1
  97. package/tsconfig.tsbuildinfo +1 -1
  98. package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
  99. package/templates/nuxt/lang/en.ts._eta +0 -6
  100. package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
  101. package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
  102. package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
  103. package/templates/nuxt/pages/[xorg]/user/[id].vue._eta +0 -6
  104. package/templates/nuxt/pages/[xorg]/user/index.vue._eta +0 -302
  105. package/templates/nuxt/pages/login.vue.eta +0 -30
  106. /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
@@ -1,123 +1,134 @@
1
1
  <template>
2
- <div v-if="schema" class="flex flex-col">
3
- <div v-if="hidelabel"></div>
4
- <label v-else-if="error" class="simpleapp-input-label text-danger-600 overflow-hidden" :for="uuid">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label>
5
- <label v-else :for="uuid" class="simpleapp-input-label whitespace-nowrap text-gray-500 truncate">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label>
6
-
7
- <!-- <div :uuid="uuid" >{{ modelValue }}</div> -->
8
- <!-- <div v-if="typeof modelValue =='object' && typeof modelValue['_id']!='undefined' && typeof modelValue['label']!='undefined' && readonly ==true " :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue['label'] }}</div> -->
9
- <!-- <div v-else-if="readonly==true" :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue }}</div> -->
10
- <!-- <slot v-else name="default" :uuid="uuid" :error="error"></slot> -->
11
- <slot name="default" :uuid="uuid" :error="error"></slot>
2
+ <div v-if="schema" :class="getLayoutClass()">
3
+ <label v-if="hidelabel"></label>
4
+ <label v-else :for="uuid" :class="getLabelClass()"
5
+ >{{ fieldlabel }}
6
+ <span
7
+ v-if="props.setting.isrequired && fieldlabel"
8
+ class="text-danger-600 dark:text-danger-400"
9
+ >*</span
10
+ ></label
11
+ >
12
+ <!-- <label v-else-if="error" class="simpleapp-input-label text-danger-600 overflow-hidden" :for="uuid">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label>
13
+ <label v-else :for="uuid" class="simpleapp-input-label whitespace-nowrap text-gray-500 truncate">{{ fieldlabel }} <span v-if="props.setting.isrequired && fieldlabel" class="text-danger-600">*</span></label> -->
12
14
 
13
- <small v-if="error" class="text-danger-600">{{ error }}</small>
14
- <small v-else class="input-desc">{{ fielddesc }}</small>
15
- </div>
16
- <div v-else :class="defaultcssclass">
17
- <label class="etext-danger-600">wrong path in getField()</label>
18
- <div class="text-danger-600">{{ props.setting.path }}</div>
19
- </div>
15
+ <!-- <div :uuid="uuid" >{{ modelValue }}</div> -->
16
+ <!-- <div v-if="typeof modelValue =='object' && typeof modelValue['_id']!='undefined' && typeof modelValue['label']!='undefined' && readonly ==true " :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue['label'] }}</div> -->
17
+ <!-- <div v-else-if="readonly==true" :uuid="uuid" class="simpleapp-value-readonly">{{ modelValue }}</div> -->
18
+ <!-- <slot v-else name="default" :uuid="uuid" :error="error"></slot> -->
19
+ <slot name="default" :uuid="uuid" :error="error"></slot>
20
+
21
+
22
+ <small v-if="error" class="text-danger-600 dark:text-danger-400">{{ error }}</small>
23
+ <small v-else class="input-desc">{{ fielddesc }}</small>
24
+ </div>
25
+ <div v-else :class="defaultcssclass">
26
+ <label class="etext-danger-600 dark:text-danger-400">wrong path in getField()</label>
27
+ <div class="text-danger-600 dark:text-danger-400">{{ props.setting.path }}</div>
28
+ </div>
20
29
  </template>
21
30
  <script setup lang="ts">
22
- import SimpleAppValue from './SimpleAppValue.vue'
31
+ import SimpleAppValue from "./SimpleAppValue.vue";
23
32
  // import {camelCaseToWords} from './helper'
24
33
  // import {computed,setBlockTracking,watch} from 'vue'
25
34
 
26
- import {ref} from 'vue'
27
-
35
+ import { ref } from "vue";
28
36
 
29
- const uuid = randomUUID();
37
+ const uuid = randomUUID();
30
38
  // const fieldlabel = ref('')
31
39
  // const fielddesc = ref('')
32
- const defaultcssclass='simpleapp-input-container'
33
- const fieldcontainerclass = ref(defaultcssclass)
34
- let instancepath = ref('')
40
+ const defaultcssclass = "simpleapp-input-container";
41
+ const fieldcontainerclass = ref(defaultcssclass);
42
+ let instancepath = ref("");
35
43
  const props = defineProps<{
36
- label?: string,
37
- description?: string,
38
- instancepath?:string,
39
- hidelabel?:boolean,
40
- readonly?:boolean
41
- // error?:string,
42
- setting:any
43
- }>()
44
+ label?: string;
45
+ inputType: string;
46
+ description?: string;
47
+ instancepath?: string;
48
+ hidelabel?: boolean;
49
+ readonly?: boolean;
50
+ // error?:string,
51
+ setting: any;
52
+ }>();
44
53
 
45
- const readonly = computed(()=>{
46
- return props.readonly ?? props.setting.readonly ?? false
47
- })
48
- // if(props.readonly !== undefined){
49
- // readonly.value=props.readonly
50
- // }else if(props.setting.readonly !==undefined){
51
- // readonly.value=props.readonly
52
- // }
53
- // console.log("props.setting.format",props.setting.format)
54
- const modelValue = defineModel()
55
- const readonlyclass="simpleapp-value-readonly"
54
+ const readonly = computed(() => {
55
+ return props.readonly ?? props.setting.readonly ?? false;
56
+ });
57
+
58
+ const modelValue = defineModel<any>(); //this model value support all kind of data, string, number, autocomplete and etc
59
+ const readonlyclass = "simpleapp-value-readonly";
56
60
  // console.log('props.setting',modelValue.value,props.setting)
57
- let schema:any
61
+ let schema: any;
58
62
 
59
- const fielddesc = computed(()=>{
60
- return props.description ?? ''
61
- })
63
+ const getLayoutClass = () =>
64
+ `simpleapp-input-container flex ${
65
+ props.inputType == "checkbox"
66
+ ? " flex-row gap-4 mt-1 ml-1 "
67
+ : "flex flex-col "
68
+ }`;
62
69
 
63
- if(props.setting.fieldsetting && props.setting.fieldsetting.type){
64
-
65
- schema = props.setting.fieldsetting
66
- // console.log("schema setting",props.setting,schema)
67
- if(props?.instancepath) instancepath.value =props.instancepath
68
- else if(props.setting?.instancepath) instancepath.value = props.setting.instancepath
69
- else instancepath.value='/unknown'
70
+ const getLabelClass = () => {
71
+ let class1 =
72
+ "simpleapp-input-label text-left text-gray-500 dark:text-gray-200 ";
70
73
 
71
- const fieldnamearr = instancepath.value.split('/')
72
- const fieldname = camelCaseToWords(fieldnamearr[fieldnamearr.length-1])
74
+ if (!isMobile()) class1 += "whitespace-nowrap truncate";
75
+ else if (props.inputType == "checkbox") class1 += " ml-1 dark:text-gray-200";
76
+ else if (props.inputType != "autocomplete" && modelValue.value)
77
+ class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
78
+ else if (props.inputType == "autocomplete" && modelValue.value?.label)
79
+ class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
80
+ else if (modelValue.value !== undefined)
81
+ class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100";
82
+ else class1 += "-mb-4 ml-1 z-10 text-xs dark:text-gray-100 hidden";
83
+ return class1;
84
+ };
73
85
 
74
-
75
-
76
-
77
- // if(props.description)fielddesc.value = props.description
78
- // else if (schema?.description != 'undefined') fielddesc.value=schema.description
79
- // else fielddesc.value=''
86
+ const fielddesc = computed(() => {
87
+ return props.description ?? "";
88
+ });
89
+
90
+ if (props.setting.fieldsetting && props.setting.fieldsetting.type) {
91
+ schema = props.setting.fieldsetting;
92
+ // console.log("schema setting",props.setting,schema)
93
+ if (props?.instancepath) instancepath.value = props.instancepath;
94
+ else if (props.setting?.instancepath)
95
+ instancepath.value = props.setting.instancepath;
96
+ else instancepath.value = "/unknown";
80
97
 
81
-
98
+ const fieldnamearr = instancepath.value.split("/");
99
+ const fieldname = camelCaseToWords(fieldnamearr[fieldnamearr.length - 1]);
82
100
 
101
+ // if(props.description)fielddesc.value = props.description
102
+ // else if (schema?.description != 'undefined') fielddesc.value=schema.description
103
+ // else fielddesc.value=''
83
104
  }
84
- const fieldlabel = computed(()=>{
85
-
86
- if(props.label){
87
- return t(props.label)
88
- }
89
- else if (schema.title ) {
90
- return t(schema.title)
91
- }
92
- else{
93
- return t(props.setting.key)
94
- }
95
- })
96
- const errormsg = computed(()=>{
97
-
98
- props.setting.errors[instancepath.value]
99
- })
100
- const error = ref("")
101
- watch(props.setting.errors,(newvalue,oldvalue)=>{
102
- //it is array
103
- error.value=''
104
- if(newvalue[instancepath.value]){
105
- const errlist:any[] = newvalue[instancepath.value]
106
- for(let i=0;i<errlist.length;i++){
107
- error.value += errlist[i].message +','
108
- }
109
- fieldcontainerclass.value=defaultcssclass + ' input-error'
110
- }else{
111
- error.value=''
112
- fieldcontainerclass.value=defaultcssclass
105
+ const fieldlabel = computed(() => {
106
+ if (props.label) {
107
+ return t(props.label);
108
+ } else if (schema.title) {
109
+ return t(schema.title);
110
+ } else {
111
+ return t(props.setting.key);
112
+ }
113
+ });
114
+ const errormsg = computed(() => {
115
+ props.setting.errors[instancepath.value];
116
+ });
117
+ const error = ref("");
118
+ watch(props.setting.errors, (newvalue, oldvalue) => {
119
+ //it is array
120
+ error.value = "";
121
+ if (newvalue[instancepath.value]) {
122
+ const errlist: any[] = newvalue[instancepath.value];
123
+ for (let i = 0; i < errlist.length; i++) {
124
+ error.value += errlist[i].message + ",";
113
125
  }
114
- // console.log("validation result",props.setting.instancepath,)
115
- // error.value = newvalue[props.setting.instancepath].message
116
- })
117
-
126
+ fieldcontainerclass.value = defaultcssclass + " input-error";
127
+ } else {
128
+ error.value = "";
129
+ fieldcontainerclass.value = defaultcssclass;
130
+ }
131
+ // console.log("validation result",props.setting.instancepath,)
132
+ // error.value = newvalue[props.setting.instancepath].message
133
+ });
118
134
  </script>
119
- <style scoped>
120
- .simpleapp-input-container{
121
- @apply flex flex-col
122
- }
123
- </style>
@@ -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>