@simitgroup/simpleapp-generator 1.3.5-alpha → 1.4.1-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.
- package/dist/buildinschemas/permission.d.ts.map +1 -1
- package/dist/buildinschemas/permission.js +10 -6
- package/dist/buildinschemas/permission.js.map +1 -1
- package/dist/buildinschemas/user.d.ts.map +1 -1
- package/dist/buildinschemas/user.js +22 -2
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/generate.js +20 -6
- package/dist/generate.js.map +1 -1
- package/dist/type.d.ts +2 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/permission.ts +10 -6
- package/src/buildinschemas/user.ts +23 -3
- package/src/generate.ts +19 -6
- package/src/type.ts +3 -1
- package/templates/basic/nest/service.ts.eta +7 -3
- package/templates/basic/nuxt/pages.[id].vue.eta +4 -4
- package/templates/basic/nuxt/pages.mobile.[id].vue.eta +39 -0
- package/templates/basic/nuxt/pages.mobile.landing.vue.eta +69 -0
- package/templates/nest/src/simpleapp/apischemas/index.ts._eta +29 -0
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +22 -12
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +26 -1
- package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +2 -1
- package/templates/nest/src/simpleapp/generate/workflow/workflow.service.ts.eta +1 -1
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +1 -1
- package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +1 -1
- package/templates/nest/src/simpleapp/services/perm.service.ts.eta +5 -7
- package/templates/nest/src/simpleapp/services/user.service.ts.eta.old +118 -0
- package/templates/nest/src/simpleapp/types/index.ts._eta +8 -0
- package/templates/nuxt/app.vue._eta +31 -17
- package/templates/nuxt/assets/primevue/passthrough.ts._eta +1 -1
- package/templates/nuxt/components/calendar/CalendarByResource.vue.eta +181 -163
- package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +8 -6
- package/templates/nuxt/components/form/FormDocnoformat.vue.eta +174 -0
- package/templates/nuxt/components/form/FormUser.vue._eta +91 -0
- package/templates/nuxt/components/form/user/FormUserPermission.vue.eta +83 -0
- package/templates/nuxt/components/header/HeaderBar.vue._eta +43 -39
- package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +7 -9
- package/templates/nuxt/components/page/PageDocList.vue.eta +6 -4
- package/templates/nuxt/components/renderer/RendererDateTime.vue.eta +13 -0
- package/templates/nuxt/components/renderer/RendererForeignKey.vue.eta +6 -3
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +3 -4
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +48 -4
- package/templates/nuxt/composables/date.generate.ts.eta +3 -1
- package/templates/nuxt/composables/goTo.generate.ts.eta +4 -1
- package/templates/nuxt/layouts/mobile.vue._eta +26 -12
- package/templates/nuxt/nuxt.config.ts._eta +27 -20
- package/templates/nuxt/pages/[xorg]/{user/index.vue.eta → docnoformat/[id].vue.eta} +11 -9
- package/templates/nuxt/pages/[xorg]/docnoformat.vue.eta +51 -20
- package/templates/nuxt/pages/[xorg]/mobile/docnoformat/index.vue.eta +59 -0
- package/templates/nuxt/pages/[xorg]/mobile/index.vue._eta +19 -0
- package/templates/nuxt/pages/[xorg]/mobile/organization/index.vue.eta +138 -0
- package/templates/nuxt/pages/[xorg]/mobile/pickgroup.vue._eta +35 -0
- package/templates/nuxt/pages/[xorg]/mobile/user/index.vue.eta +231 -0
- package/templates/nuxt/pages/[xorg]/pickgroup.vue._eta +35 -0
- package/templates/nuxt/pages/[xorg]/user.vue.eta +91 -74
- package/templates/nuxt/pages/profile.vue.eta +7 -7
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +14 -3
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +18 -16
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +1 -1
- package/templates/nuxt/types/events.ts.eta +1 -0
- package/templates/nuxt/types/simpleappinput.ts.eta +3 -2
- package/templates/nuxt/types/user.ts.eta +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/templates/nest/src/simpleapp/services/user.service.ts.etax +0 -66
- package/templates/nuxt/pages/[xorg]/docnoformat/[doctype]/[id].vue.eta +0 -13
- package/templates/nuxt/pages/[xorg]/docnoformat/[doctype]/new.vue.eta +0 -229
- package/templates/nuxt/pages/[xorg]/docnoformat/[doctype].vue.eta +0 -38
- package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +0 -11
- package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +0 -39
- package/templates/nuxt/pages/[xorg]/user/form.vue.eta +0 -334
- package/templates/nuxt/pages/[xorg]/user/new.vue.eta +0 -18
- package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +0 -29
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
4
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
5
|
-
* last change 2023-10-28
|
|
6
|
-
* Author: Ks Tan
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {SimpleAppInputType} from '~/types'
|
|
10
|
-
import ConfirmPopup from "primevue/confirmpopup";
|
|
11
|
-
import { useConfirm } from "primevue/useconfirm";
|
|
12
|
-
import moment from "moment";
|
|
13
|
-
const confirm = useConfirm();
|
|
14
|
-
const isReadOnly = ref(true);
|
|
15
|
-
const { $event, $listen, $DocnoformatDoc } = useNuxtApp();
|
|
16
|
-
const doc = $DocnoformatDoc();
|
|
17
|
-
const data = doc.getReactiveData();
|
|
18
|
-
const list = ref([]);
|
|
19
|
-
const sample = ref("");
|
|
20
|
-
const refresh = async () => {
|
|
21
|
-
$event("RefreshDocumentList", { documentName: doc.getDocName() });
|
|
22
|
-
isReadOnly.value = true;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const updateSample = () => {
|
|
26
|
-
sample.value = "Example: " + previewDocNo();
|
|
27
|
-
};
|
|
28
|
-
const createData = async () => {
|
|
29
|
-
// disabled.value=true
|
|
30
|
-
|
|
31
|
-
doc
|
|
32
|
-
.create()
|
|
33
|
-
.then((res) => {
|
|
34
|
-
refresh();
|
|
35
|
-
newData();
|
|
36
|
-
})
|
|
37
|
-
.catch((err) => {
|
|
38
|
-
console.error(err);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const updateData = async () => {
|
|
42
|
-
doc
|
|
43
|
-
.update()
|
|
44
|
-
.then(() => {
|
|
45
|
-
// visible.value=false
|
|
46
|
-
refresh();
|
|
47
|
-
})
|
|
48
|
-
.catch((err) => {
|
|
49
|
-
console.error(err);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const deleteData = (el: any) => {
|
|
53
|
-
confirm.require({
|
|
54
|
-
target: el.currentTarget as HTMLElement,
|
|
55
|
-
message: "Delete?",
|
|
56
|
-
icon: "pi pi-exclamation-triangle",
|
|
57
|
-
acceptClass: "p-button-danger",
|
|
58
|
-
accept: () => {
|
|
59
|
-
// disabled.value=true
|
|
60
|
-
doc.delete(data.value._id ?? "").then((res) => {
|
|
61
|
-
newData();
|
|
62
|
-
refresh();
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
reject: () => {
|
|
66
|
-
console.log("Cancel delete");
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
const newData = () => {
|
|
71
|
-
doc.setNew();
|
|
72
|
-
goTo(doc.getDocName(), String(useRoute().params.doctype) + "/new");
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const id = computed(() => String(useRoute().params.id ?? ""));
|
|
76
|
-
|
|
77
|
-
const fetchRecord = async () => {
|
|
78
|
-
if (id.value) {
|
|
79
|
-
isReadOnly.value = true;
|
|
80
|
-
await doc.getById(id.value);
|
|
81
|
-
} else {
|
|
82
|
-
isReadOnly.value = false;
|
|
83
|
-
data.value.docNoType = String(useRoute().params.doctype);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const previewDocNo = (): string => {
|
|
88
|
-
const pattern = data.value.docNoPattern;
|
|
89
|
-
if (pattern) {
|
|
90
|
-
const numberReg: RegExp = /\[(.*?)\]/g;
|
|
91
|
-
const dateReg: RegExp = /\{(.*?)\}/g;
|
|
92
|
-
let newvalue = pattern;
|
|
93
|
-
const numberpattern = pattern.match(numberReg);
|
|
94
|
-
const datepattern = pattern.match(dateReg);
|
|
95
|
-
|
|
96
|
-
if (numberpattern && numberpattern.length > 0) {
|
|
97
|
-
const numberlength = numberpattern[0]
|
|
98
|
-
.replace("[", "")
|
|
99
|
-
.replace("]", "").length;
|
|
100
|
-
|
|
101
|
-
let nextnumber = (data.value.nextNumber ?? 0).toString();
|
|
102
|
-
|
|
103
|
-
const numberdiff = numberlength - nextnumber.length;
|
|
104
|
-
|
|
105
|
-
for (let n = 0; n < numberdiff; n++) {
|
|
106
|
-
nextnumber = "0" + nextnumber;
|
|
107
|
-
}
|
|
108
|
-
newvalue = newvalue.replace(numberpattern[0], nextnumber);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (datepattern && datepattern.length > 0) {
|
|
112
|
-
for (let d = 0; d < datepattern.length; d++) {
|
|
113
|
-
const dpattern = datepattern[d];
|
|
114
|
-
const date = new Date();
|
|
115
|
-
const formatteddate = moment().format(
|
|
116
|
-
dpattern.replace("{", "").replace("}", ""),
|
|
117
|
-
);
|
|
118
|
-
newvalue = newvalue.replace(dpattern, formatteddate);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return newvalue;
|
|
122
|
-
} else {
|
|
123
|
-
return "";
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
fetchRecord();
|
|
128
|
-
</script>
|
|
129
|
-
<template>
|
|
130
|
-
<DebugDocumentData v-model="data" label="docnoformat" />
|
|
131
|
-
<div class="p-4">
|
|
132
|
-
<div v-if="isReadOnly" class="col-span-4 ">
|
|
133
|
-
<Button
|
|
134
|
-
class="btn-default"
|
|
135
|
-
@click="newData"
|
|
136
|
-
type="button"
|
|
137
|
-
v-if="canPerform(doc.getDocName(), 'create')"
|
|
138
|
-
>New
|
|
139
|
-
</Button>
|
|
140
|
-
<Button class="btn btn-primary" @click="isReadOnly = false">Edit</Button>
|
|
141
|
-
</div>
|
|
142
|
-
<div v-else class="simpleapp-tool-bar col-span-4 text-left gap-4">
|
|
143
|
-
<Button
|
|
144
|
-
class="btn-default"
|
|
145
|
-
@click="newData"
|
|
146
|
-
type="button"
|
|
147
|
-
v-if="canPerform(doc.getDocName(), 'create')"
|
|
148
|
-
>New
|
|
149
|
-
</Button>
|
|
150
|
-
<Button
|
|
151
|
-
class="btn btn-primary"
|
|
152
|
-
@click="createData"
|
|
153
|
-
type="button"
|
|
154
|
-
v-if="canPerform(doc.getDocName(), 'create') && doc.isNew()"
|
|
155
|
-
>
|
|
156
|
-
Create
|
|
157
|
-
</Button>
|
|
158
|
-
<Button
|
|
159
|
-
class="btn btn-primary"
|
|
160
|
-
@click="updateData"
|
|
161
|
-
type="button"
|
|
162
|
-
v-if="canPerform(doc.getDocName(), 'update') && !doc.isNew()"
|
|
163
|
-
>
|
|
164
|
-
Update
|
|
165
|
-
</Button>
|
|
166
|
-
<Button
|
|
167
|
-
class="btn btn-danger"
|
|
168
|
-
@click="deleteData($el)"
|
|
169
|
-
type="button"
|
|
170
|
-
v-if="canPerform(doc.getDocName(), 'delete') && !doc.isNew()"
|
|
171
|
-
>
|
|
172
|
-
Delete
|
|
173
|
-
</Button>
|
|
174
|
-
<ConfirmPopup></ConfirmPopup>
|
|
175
|
-
</div>
|
|
176
|
-
<SimpleAppForm :document="doc" #default="o" :readonly="isReadOnly">
|
|
177
|
-
<div class="grid grid-cols-4 gap-4">
|
|
178
|
-
<SimpleAppInput
|
|
179
|
-
autofocus
|
|
180
|
-
:input-type="SimpleAppInputType.text"
|
|
181
|
-
:setting="o.getField('#/properties/docNoFormatNo')"
|
|
182
|
-
v-model="data.docNoFormatNo"
|
|
183
|
-
/>
|
|
184
|
-
<SimpleAppInput
|
|
185
|
-
:input-type="SimpleAppInputType.text"
|
|
186
|
-
:setting="o.getField('#/properties/docNoFormatName')"
|
|
187
|
-
v-model="data.docNoFormatName"
|
|
188
|
-
/>
|
|
189
|
-
<SimpleAppInput
|
|
190
|
-
:input-type="SimpleAppInputType.autocomplete"
|
|
191
|
-
v-model="data.branch"
|
|
192
|
-
:setting="o.getField('#/properties/branch')"
|
|
193
|
-
/>
|
|
194
|
-
<SimpleAppInput
|
|
195
|
-
:input-type="SimpleAppInputType.checkbox"
|
|
196
|
-
:setting="o.getField('#/properties/active')"
|
|
197
|
-
v-model="data.active"
|
|
198
|
-
/>
|
|
199
|
-
|
|
200
|
-
<SimpleAppInput
|
|
201
|
-
:input-type="SimpleAppInputType.checkbox"
|
|
202
|
-
:setting="o.getField('#/properties/default')"
|
|
203
|
-
v-model="data.default"
|
|
204
|
-
/>
|
|
205
|
-
|
|
206
|
-
<SimpleAppInput
|
|
207
|
-
:input-type="SimpleAppInputType.text"
|
|
208
|
-
:setting="o.getField('#/properties/docNoPattern')"
|
|
209
|
-
v-model="data.docNoPattern"
|
|
210
|
-
@change="updateSample"
|
|
211
|
-
:description="sample"
|
|
212
|
-
v-tooltip="'Examples: PO-<00000>, SI{YY}/<000>, SI{YYMM}/<000>'"
|
|
213
|
-
/>
|
|
214
|
-
<SimpleAppInput
|
|
215
|
-
:readonly="true"
|
|
216
|
-
:input-type="SimpleAppInputType.text"
|
|
217
|
-
:setting="o.getField('#/properties/docNoType')"
|
|
218
|
-
v-model="data.docNoType"
|
|
219
|
-
description="Document Type"
|
|
220
|
-
/>
|
|
221
|
-
<SimpleAppInput
|
|
222
|
-
:input-type="SimpleAppInputType.number"
|
|
223
|
-
:setting="o.getField('#/properties/nextNumber')"
|
|
224
|
-
v-model="data.nextNumber"
|
|
225
|
-
/>
|
|
226
|
-
</div>
|
|
227
|
-
</SimpleAppForm>
|
|
228
|
-
</div>
|
|
229
|
-
</template>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
4
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
5
|
-
* last change 2023-10-28
|
|
6
|
-
* Author: Ks Tan
|
|
7
|
-
*/
|
|
8
|
-
const {$event,$listen, $DocnoformatDoc} = useNuxtApp()
|
|
9
|
-
const doc = $DocnoformatDoc()
|
|
10
|
-
const data = doc.getReactiveData()
|
|
11
|
-
const list = ref([])
|
|
12
|
-
const refresh = async ()=>{
|
|
13
|
-
list.value = await doc.search({
|
|
14
|
-
filter:{docNoType: useRoute().params.doctype}
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
refresh()
|
|
19
|
-
|
|
20
|
-
$listen('RefreshDocumentList',(data)=>{
|
|
21
|
-
if(data.documentName=="docnoformat"){
|
|
22
|
-
refresh()
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
</script>
|
|
26
|
-
<template>
|
|
27
|
-
<div class="grid grid-cols-3 p-4">
|
|
28
|
-
<div>
|
|
29
|
-
<ListView :list="list"
|
|
30
|
-
titleField="docNoFormatName"
|
|
31
|
-
subTitleField="docNoFormatNo"
|
|
32
|
-
:url="`${getDocumentUrl('docnoformat')}/${useRoute().params.doctype}`"></ListView>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="col-span-2">
|
|
35
|
-
<NuxtPage></NuxtPage>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Crud :_id="userid" @after="after" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
/**
|
|
7
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
8
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
9
|
-
* last change 2023-10-28
|
|
10
|
-
* Author: Ks Tan
|
|
11
|
-
*/
|
|
12
|
-
import Crud from "./form.vue";
|
|
13
|
-
import { User } from "~/simpleapp/generate/types";
|
|
14
|
-
const userid = computed(() => getPathPara("id"));
|
|
15
|
-
const doc = useNuxtApp().$UserDoc();
|
|
16
|
-
|
|
17
|
-
const props = defineProps<{ _id: string }>();
|
|
18
|
-
const after = (actionName: string, data: User, result: any) => {
|
|
19
|
-
switch (actionName) {
|
|
20
|
-
case "new":
|
|
21
|
-
goTo(doc.getDocName(),);
|
|
22
|
-
break;
|
|
23
|
-
case "create":
|
|
24
|
-
refreshDocumentList("user");
|
|
25
|
-
if (isMobile()) goTo("user");
|
|
26
|
-
else goTo(doc.getDocName(), data._id);
|
|
27
|
-
break;
|
|
28
|
-
case "update":
|
|
29
|
-
refreshDocumentList("user");
|
|
30
|
-
if (isMobile()) goTo("user");
|
|
31
|
-
break;
|
|
32
|
-
case "delete":
|
|
33
|
-
refreshDocumentList("user");
|
|
34
|
-
goTo(doc.getDocName(), );
|
|
35
|
-
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
</script>
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="grid grid-cols-1 xl:grid-cols-2">
|
|
3
|
-
<div v-if="isMobile()"
|
|
4
|
-
class="flex flex-1 absolute w-full h h-16 z z-20 dark:bg-gray-900 place-items-center content-center">
|
|
5
|
-
<ButtonText @click="goTo('user')">{{ t("cancel") }}</ButtonText>
|
|
6
|
-
<TextTitle class="flex-1 text-center">{{userdata.fullName ?? t("user")}}</TextTitle>
|
|
7
|
-
<ButtonText @click="actionListener('update')">{{ t('save') }}</ButtonText>
|
|
8
|
-
</div>
|
|
9
|
-
<div v-else class="h h-16"></div>
|
|
10
|
-
<Card>
|
|
11
|
-
<template #header>
|
|
12
|
-
<h1 class="font-bold">{{ usertitle }}</h1>
|
|
13
|
-
</template>
|
|
14
|
-
<template #content>
|
|
15
|
-
<SimpleAppForm :document="userdoc" #default="o">
|
|
16
|
-
<div class="flex flex-col gap-2">
|
|
17
|
-
<SimpleAppInput
|
|
18
|
-
:input-type="SimpleAppInputType.text"
|
|
19
|
-
autofocus
|
|
20
|
-
:setting="o.getField('#/properties/fullName')"
|
|
21
|
-
v-model="userdata.fullName"
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
<SimpleAppInput
|
|
25
|
-
:input-type="SimpleAppInputType.text"
|
|
26
|
-
type="email"
|
|
27
|
-
:setting="o.getField('#/properties/email')"
|
|
28
|
-
v-model="userdata.email"
|
|
29
|
-
/>
|
|
30
|
-
|
|
31
|
-
<SimpleAppInput
|
|
32
|
-
:input-type="SimpleAppInputType.checkbox"
|
|
33
|
-
:setting="o.getField('#/properties/active')"
|
|
34
|
-
v-model="userdata.active"
|
|
35
|
-
/>
|
|
36
|
-
<SimpleAppInput
|
|
37
|
-
:input-type="SimpleAppInputType.textarea"
|
|
38
|
-
:setting="o.getField('#/properties/description')"
|
|
39
|
-
v-model="userdata.description"
|
|
40
|
-
/>
|
|
41
|
-
<div>
|
|
42
|
-
<ButtonPrimary v-if="!isMobile()" @click="actionListener('update')">{{ t('save') }}</ButtonPrimary>
|
|
43
|
-
<ButtonDanger
|
|
44
|
-
v-if="!userdata.uid"
|
|
45
|
-
@click="actionListener('delete')"
|
|
46
|
-
class="btn btn-danger"
|
|
47
|
-
>{{ t('delete') }}</ButtonDanger
|
|
48
|
-
>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</SimpleAppForm>
|
|
52
|
-
</template>
|
|
53
|
-
</Card>
|
|
54
|
-
|
|
55
|
-
<Card class="m-2">
|
|
56
|
-
<template #header>
|
|
57
|
-
<div class="relative w-full ...">
|
|
58
|
-
<h1 class="font-bold">{{ permissiontitle }}</h1>
|
|
59
|
-
<div class="absolute top-0 right-0 h-16 w-16 ...">
|
|
60
|
-
<UserButtonPermissionInfo></UserButtonPermissionInfo>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</template>
|
|
64
|
-
<template #content>
|
|
65
|
-
<BlockUI :blocked="blockscreen">
|
|
66
|
-
<!-- <div class="text-right m mr-2">
|
|
67
|
-
|
|
68
|
-
</div> -->
|
|
69
|
-
|
|
70
|
-
<div class="">
|
|
71
|
-
<Card
|
|
72
|
-
v-if="currentpermissions.length > 0"
|
|
73
|
-
v-for="o in orglist"
|
|
74
|
-
class="m-2"
|
|
75
|
-
>
|
|
76
|
-
<template #title>{{ o.orgName }}</template>
|
|
77
|
-
<template #content>
|
|
78
|
-
<table class="w w-full">
|
|
79
|
-
<tr v-for="(b, index) in branchlist">
|
|
80
|
-
<td v-if="checkBranchInOrg(o, b)" class="text-center">
|
|
81
|
-
{{ b.branchCode }}
|
|
82
|
-
</td>
|
|
83
|
-
<td
|
|
84
|
-
v-if="checkBranchInOrg(o, b)"
|
|
85
|
-
class="text-center flex flex-row"
|
|
86
|
-
>
|
|
87
|
-
<div>
|
|
88
|
-
<SelectButton
|
|
89
|
-
v-model="currentpermissions[index]['group']"
|
|
90
|
-
:options="grouplist"
|
|
91
|
-
option-label="label"
|
|
92
|
-
option-value="value"
|
|
93
|
-
@change="applyPermission(currentpermissions[index])"
|
|
94
|
-
></SelectButton>
|
|
95
|
-
</div>
|
|
96
|
-
</td>
|
|
97
|
-
</tr>
|
|
98
|
-
</table>
|
|
99
|
-
</template>
|
|
100
|
-
</Card>
|
|
101
|
-
</div>
|
|
102
|
-
</BlockUI>
|
|
103
|
-
</template>
|
|
104
|
-
</Card>
|
|
105
|
-
</div>
|
|
106
|
-
</template>
|
|
107
|
-
<script setup lang="ts">
|
|
108
|
-
/**
|
|
109
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
110
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
111
|
-
* last change 2023-10-28
|
|
112
|
-
* Author: Ks Tan
|
|
113
|
-
*/
|
|
114
|
-
import { SimpleAppInputType } from "~/types";
|
|
115
|
-
import { Permission, User } from "../../../simpleapp/generate/openapi/api";
|
|
116
|
-
import _ from "lodash";
|
|
117
|
-
import SelectButton from "primevue/selectbutton";
|
|
118
|
-
import { SearchBody, EventType } from "~/types";
|
|
119
|
-
import {
|
|
120
|
-
UserListItem,
|
|
121
|
-
NotificationStatus,
|
|
122
|
-
Notification,
|
|
123
|
-
BranchListItem,
|
|
124
|
-
OrgListItem,
|
|
125
|
-
PermissionListItem,
|
|
126
|
-
} from "~/types";
|
|
127
|
-
const {
|
|
128
|
-
$event,
|
|
129
|
-
$PermissionDoc,
|
|
130
|
-
$OrganizationDoc,
|
|
131
|
-
$BranchDoc,
|
|
132
|
-
$UserDoc,
|
|
133
|
-
// $InvitationDoc,
|
|
134
|
-
} = useNuxtApp();
|
|
135
|
-
const emits = defineEmits(['after'])
|
|
136
|
-
const props = defineProps<{_id:string}>()
|
|
137
|
-
const userdoc = $UserDoc();
|
|
138
|
-
const userdata = userdoc.getReactiveData();
|
|
139
|
-
const currentpermissions = ref<Permission[]>([]);
|
|
140
|
-
currentpermissions.value = [];
|
|
141
|
-
const blockscreen = ref(false);
|
|
142
|
-
const permlist = ref<PermissionListItem[]>([]);
|
|
143
|
-
// const userlist = ref<UserListItem[]>([]);
|
|
144
|
-
const orglist = ref<OrgListItem[]>([]);
|
|
145
|
-
const branchlist = ref<BranchListItem[]>([]);
|
|
146
|
-
const permdoc = $PermissionDoc();
|
|
147
|
-
const orgdoc = $OrganizationDoc();
|
|
148
|
-
const branchdoc = $BranchDoc();
|
|
149
|
-
const permissiontitle = "Permission Information";
|
|
150
|
-
const usertitle = "User Information";
|
|
151
|
-
const grouplist = getAllGroups().map((item) => {
|
|
152
|
-
return { value: item, label: _.capitalize(item) };
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const newData = () => userdoc.setNew();
|
|
157
|
-
const createData = async () => await userdoc.create();
|
|
158
|
-
const updateData = async () => await userdoc.update();
|
|
159
|
-
const deleteData = async () => await userdoc.delete(userdata.value._id ?? "");
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* delete user
|
|
164
|
-
* @param user:User object
|
|
165
|
-
*/
|
|
166
|
-
const deleteUser = async (user: any) => {
|
|
167
|
-
await userdoc.delete(String(userdata.value._id));
|
|
168
|
-
//NotificationEvent
|
|
169
|
-
$event("RefreshUser", "");
|
|
170
|
-
goTo("user");
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/**********applPermission ******/
|
|
174
|
-
/**
|
|
175
|
-
* apply permission:
|
|
176
|
-
* _id:'', group:'' => skip
|
|
177
|
-
* _id: '', group:'something' => create
|
|
178
|
-
* _id:'something', 'group':'something' => update
|
|
179
|
-
* _id:'something', group:'' => remove
|
|
180
|
-
*/
|
|
181
|
-
const applyPermission = async (d: Permission) => {
|
|
182
|
-
let result;
|
|
183
|
-
// console.log("apply permission", d);
|
|
184
|
-
blockscreen.value = true;
|
|
185
|
-
d._id = String(d._id ?? "");
|
|
186
|
-
d.group = String(d.group ?? "");
|
|
187
|
-
permdoc.setNew();
|
|
188
|
-
const data = permdoc.getReactiveData();
|
|
189
|
-
data.value = {
|
|
190
|
-
orgId: d.orgId,
|
|
191
|
-
branchId: d.branchId,
|
|
192
|
-
group: d.group,
|
|
193
|
-
userId: d.userId,
|
|
194
|
-
};
|
|
195
|
-
// console.log("apply permission", data.value);
|
|
196
|
-
if (!d._id && !d.group) {
|
|
197
|
-
//no changes
|
|
198
|
-
} else if (!d._id && d.group) {
|
|
199
|
-
result = await permdoc.create();
|
|
200
|
-
} else if (d._id && d.group) {
|
|
201
|
-
data.value = d;
|
|
202
|
-
result = await permdoc.update();
|
|
203
|
-
} else if (d._id && !d.group) {
|
|
204
|
-
d.group = "";
|
|
205
|
-
data.value = d;
|
|
206
|
-
result = await permdoc.delete(d._id);
|
|
207
|
-
} else {
|
|
208
|
-
console.warn("unknown apply permission", result);
|
|
209
|
-
}
|
|
210
|
-
// refreshList(false);
|
|
211
|
-
onSelectUser(String(d.userId));
|
|
212
|
-
blockscreen.value = false;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const checkBranchInOrg = (org: OrgListItem, branch: BranchListItem) => {
|
|
216
|
-
return org.orgId === branch.orgId;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const onSelectUser = async (userId: string) => {
|
|
221
|
-
console.log("onSelectUser", userId);
|
|
222
|
-
// .addRoute()
|
|
223
|
-
// const user: UserListItem = { ...menuitem };
|
|
224
|
-
const orgsearchbody: SearchBody = {
|
|
225
|
-
fields: ["orgId", "orgCode", "orgName", "active"],
|
|
226
|
-
};
|
|
227
|
-
const branchsearchbody: SearchBody = {
|
|
228
|
-
fields: ["orgId", "branchId", "branchCode", "branchName", "active"],
|
|
229
|
-
};
|
|
230
|
-
const permsearchbody: SearchBody = {
|
|
231
|
-
filter: { userId: userId },
|
|
232
|
-
fields: [
|
|
233
|
-
"uid",
|
|
234
|
-
"userId",
|
|
235
|
-
"branchId",
|
|
236
|
-
"tenantId",
|
|
237
|
-
"orgId",
|
|
238
|
-
"active",
|
|
239
|
-
"group",
|
|
240
|
-
"created",
|
|
241
|
-
],
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
orglist.value = await orgdoc.search(orgsearchbody);
|
|
245
|
-
branchlist.value = await branchdoc.search(branchsearchbody);
|
|
246
|
-
permlist.value = await permdoc.search(permsearchbody);
|
|
247
|
-
await userdoc.getById(userId);
|
|
248
|
-
// console.log("orglist.value", orglist.value);
|
|
249
|
-
// console.log("branchlist.value", branchlist.value);
|
|
250
|
-
// console.log("permlist.value", permlist.value);
|
|
251
|
-
// selected.value = String(user._id);
|
|
252
|
-
|
|
253
|
-
// activeuser.value = user.fullName;
|
|
254
|
-
//sso id from keycloak
|
|
255
|
-
// const uid = String(user.uid);
|
|
256
|
-
//_id from mongodb
|
|
257
|
-
|
|
258
|
-
currentpermissions.value = [];
|
|
259
|
-
|
|
260
|
-
for (let i = 0; i < branchlist.value.length; i++) {
|
|
261
|
-
const b = branchlist.value[i];
|
|
262
|
-
const permdata = getPermssionData(userId, b.branchId);
|
|
263
|
-
const tmp: Permission = {
|
|
264
|
-
_id: permdata?._id,
|
|
265
|
-
userId: userId,
|
|
266
|
-
tenantId: b.tenantId,
|
|
267
|
-
orgId: b.orgId,
|
|
268
|
-
branchId: b.branchId,
|
|
269
|
-
group: permdata.group,
|
|
270
|
-
};
|
|
271
|
-
currentpermissions.value.push(tmp);
|
|
272
|
-
}
|
|
273
|
-
// console.log("currentpermissions", currentpermissions);
|
|
274
|
-
blockscreen.value = false;
|
|
275
|
-
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* prepare dataobj (existing or empty dummy data) for each branch permission
|
|
279
|
-
* @param uid
|
|
280
|
-
* @param branchId
|
|
281
|
-
*/
|
|
282
|
-
const getPermssionData = (userId: string, branchId: number) => {
|
|
283
|
-
// console.log("getPermssionData", userId, branchId);
|
|
284
|
-
const result = permlist.value.find((item: any) => {
|
|
285
|
-
// console.log(
|
|
286
|
-
// item.userId,
|
|
287
|
-
// "== ",
|
|
288
|
-
// userId,
|
|
289
|
-
// " &&",
|
|
290
|
-
// item.branchId,
|
|
291
|
-
// "==",
|
|
292
|
-
// branchId,
|
|
293
|
-
// );
|
|
294
|
-
return item.userId == userId && item.branchId == branchId;
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// console.log("permlist.value.",permlist.value,result)
|
|
298
|
-
let pm: Permission = {
|
|
299
|
-
_id: result?._id ?? "",
|
|
300
|
-
orgId: result?.orgId ?? 0,
|
|
301
|
-
tenantId: result?.tenantId ?? 0,
|
|
302
|
-
branchId: branchId,
|
|
303
|
-
userId: userId,
|
|
304
|
-
group: result?.group ?? "",
|
|
305
|
-
};
|
|
306
|
-
return pm;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const actionListener = async (actionName: string) => {
|
|
311
|
-
switch (actionName) {
|
|
312
|
-
case "create":
|
|
313
|
-
await createData();
|
|
314
|
-
break;
|
|
315
|
-
case "update":
|
|
316
|
-
await updateData();
|
|
317
|
-
break;
|
|
318
|
-
case "delete":
|
|
319
|
-
await deleteData();
|
|
320
|
-
break;
|
|
321
|
-
case "new":
|
|
322
|
-
await newData();
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
emits("after", actionName);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
onMounted(() => {
|
|
331
|
-
onSelectUser(props._id);
|
|
332
|
-
});
|
|
333
|
-
</script>
|
|
334
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Crud _id="new" @after-create="redirect" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
/**
|
|
7
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
8
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
9
|
-
* last change 2023-10-28
|
|
10
|
-
* Author: Ks Tan
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import Crud from "./form.vue";const { $UserDoc } = useNuxtApp();
|
|
14
|
-
const doc = $UserDoc();
|
|
15
|
-
const redirect = (data: any) => {
|
|
16
|
-
goTo(doc.getDocName(), data._id);
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Crud :_id="_id" @after="after" :paras="paras" />
|
|
3
|
-
</template>
|
|
4
|
-
<script setup lang="ts">
|
|
5
|
-
/**
|
|
6
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
7
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
8
|
-
* last change 2023-10-28
|
|
9
|
-
* Author: Ks Tan
|
|
10
|
-
*/
|
|
11
|
-
import Crud from "./form.vue";import { User } from "~/simpleapp/generate/types";
|
|
12
|
-
const props = defineProps<{ _id: string; paras?: User }>();
|
|
13
|
-
const emits = defineEmits(["afterCreate", "after"]);
|
|
14
|
-
|
|
15
|
-
const after = (actionName: string, data: User, result: any) => {
|
|
16
|
-
switch (actionName) {
|
|
17
|
-
case "new":
|
|
18
|
-
break;
|
|
19
|
-
case "create":
|
|
20
|
-
emits("afterCreate", data);
|
|
21
|
-
break;
|
|
22
|
-
case "update":
|
|
23
|
-
break;
|
|
24
|
-
case "delete":
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
emits("after", actionName, data, result);
|
|
28
|
-
};
|
|
29
|
-
</script>
|