@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.
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +3 -1
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +3 -8
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +14 -14
- package/dist/generate.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/organization.ts +3 -1
- package/src/framework.ts +4 -8
- package/src/generate.ts +17 -16
- package/templates/basic/nest/controller.ts.eta +17 -0
- package/templates/basic/nest/default.ts.eta +6 -2
- package/templates/basic/nuxt/default.ts.eta +10 -6
- package/templates/basic/nuxt/pages.[id].vue.eta +9 -7
- package/templates/basic/nuxt/pages.form.vue.eta +16 -36
- package/templates/basic/nuxt/pages.landing.vue.eta +42 -35
- package/templates/basic/nuxt/pages.viewer.vue.eta +4 -6
- package/templates/nest/.env._eta +0 -1
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +14 -2
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +32 -18
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +76 -13
- package/templates/nuxt/assets/css/style.css._eta +19 -7
- package/templates/nuxt/assets/primevue/passthrough.ts._eta +20 -9
- package/templates/nuxt/components/button/ButtonDefault.vue._eta +1 -2
- package/templates/nuxt/components/button/ButtonMultiple.vue._eta +21 -0
- package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +3 -4
- package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +75 -65
- package/templates/nuxt/components/form/FormBranch.vue.eta +83 -0
- package/templates/nuxt/components/form/readme.md.eta +1 -0
- package/templates/nuxt/components/header/button/HeaderButtonMenuPicker.vue._eta +13 -11
- package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +11 -17
- package/templates/nuxt/components/list/ListDocument.vue.eta +25 -0
- package/templates/nuxt/components/list/ListDocumentTable.vue.eta +77 -0
- package/templates/nuxt/components/list/ListView.vue.eta +129 -60
- package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +10 -0
- package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +21 -0
- package/templates/nuxt/components/overlay/OverlayViewer.vue.eta +20 -0
- package/templates/nuxt/components/page/PageDocList.vue.eta +170 -0
- package/templates/nuxt/components/renderer/RendererBoolean.vue.eta +8 -4
- package/templates/nuxt/components/renderer/RendererDate.vue.eta +4 -4
- package/templates/nuxt/components/renderer/RendererLink.vue.eta +12 -20
- package/templates/nuxt/components/renderer/RendererViewer.vue.eta +27 -21
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +201 -174
- package/templates/nuxt/components/simpleApp/SimpleAppFieldContainer.vue.eta +115 -111
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue.eta +183 -91
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +383 -263
- package/templates/nuxt/components/table/TableDocuments.vue.eta +3 -3
- package/templates/nuxt/components/text/TextDanger.vue._eta +5 -0
- package/templates/nuxt/components/text/TextSubtitle.vue._eta +5 -0
- package/templates/nuxt/components/text/TextTitle.vue._eta +5 -0
- package/templates/nuxt/composables/date.generate.ts.eta +14 -9
- package/templates/nuxt/i18n.config.ts.eta +1 -1
- package/templates/nuxt/lang/en.ts.eta +16 -0
- package/templates/nuxt/layouts/default.vue._eta +32 -17
- package/templates/nuxt/layouts/mobile.vue._eta +35 -12
- package/templates/nuxt/nuxt.config.ts._eta +3 -7
- package/templates/nuxt/pages/[xorg]/organization/[id].vue.eta +39 -0
- package/templates/nuxt/pages/[xorg]/organization/new.vue.eta +30 -143
- package/templates/nuxt/pages/[xorg]/organization/viewer.vue.eta +3 -0
- package/templates/nuxt/pages/[xorg]/organization.vue.eta +81 -127
- package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +38 -4
- package/templates/nuxt/pages/[xorg]/user/form.vue.eta +329 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +29 -292
- package/templates/nuxt/pages/[xorg]/{organization/[id]/branches/[bid].vue → user/new.vue.eta} +10 -4
- package/templates/nuxt/pages/[xorg]/user/viewer.vue.eta +30 -0
- package/templates/nuxt/pages/[xorg]/user.vue.eta +88 -78
- package/templates/nuxt/pages/profile.vue.eta +12 -3
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +2 -3
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +41 -2
- package/templates/nuxt/types/documentlist.ts.eta +0 -9
- package/templates/nuxt/types/events.ts.eta +1 -0
- package/templates/nuxt/types/simpleappinput.ts.eta +12 -2
- package/templates/nuxt/types/user.ts.eta +2 -0
- package/templates/project/lang/default._json +5 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/templates/nuxt/components/docPage/DocPageList.vue.eta +0 -125
- package/templates/nuxt/lang/en.ts._eta +0 -6
- package/templates/nuxt/pages/[xorg]/organization/[bid].vue.eta +0 -14
- package/templates/nuxt/pages/[xorg]/organization/[id]/branches/new.vue +0 -149
- package/templates/nuxt/pages/[xorg]/organization/[id]/index.vue.eta +0 -1
- /package/templates/nuxt/lang/{df.ts.eta → df.ts.etaxxxx} +0 -0
|
@@ -1,55 +1,62 @@
|
|
|
1
|
+
<% const skipcolumns = ['_id','createdBy','created','updatedBy','updated','orgId','branchId','tenantId','doctype'] %>
|
|
1
2
|
<template>
|
|
2
3
|
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
<PageDocList :document="doc" :columns="columns" :data="docdata" :sorts="sorts">
|
|
5
|
+
<template #mobileList="{index,item}">
|
|
6
|
+
</template>
|
|
7
|
+
<template #dataTableColumns>
|
|
8
|
+
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
9
|
+
<%let obj=it.jsonschema.properties[key] %>
|
|
10
|
+
<%let config=it.jsonschema['x-simpleapp-config'] %>
|
|
11
|
+
<%if(skipcolumns.indexOf(key)>=0){%>
|
|
12
|
+
<%} else if(config['uniqueKey'] && (config['uniqueKey']==key || config['documentTitle']==key) ){%>
|
|
13
|
+
<Column #body="{index,data}" :header="t('<%=key%>')">
|
|
14
|
+
<RendererLink :value="data" :setting="{path:'<%=it.name%>'}" :fields="['<%=key%>']">{{ data.<%=key%> }}</RendererLink>
|
|
15
|
+
</Column>
|
|
16
|
+
|
|
17
|
+
<%} else if(['string','number','integer','boolean'].indexOf(obj.type)>=0){%>
|
|
18
|
+
<Column #body="{index,data}" :header="t('<%=key%>')">
|
|
19
|
+
{{data.<%=key%>}}
|
|
20
|
+
</Column>
|
|
21
|
+
<%} else if(obj.type =='object' && obj['x-foreignkey'] ){%>
|
|
22
|
+
<Column #body="{index,data}" :header="t('<%=key%>')">
|
|
23
|
+
<RendererViewer :value="data.<%=key%>" :setting="{documentName:'<%=obj["x-foreignkey"]%>'}" :fields="['<%=key%>']">{{ data.label }}</RendererViewer>
|
|
24
|
+
</Column>
|
|
25
|
+
<%}%>
|
|
26
|
+
<%})%>
|
|
27
|
+
</template>
|
|
28
|
+
<template #default><div><NuxtPage :_id="id ?? 'new'"/></div></template>
|
|
29
|
+
</PageDocList>
|
|
11
30
|
</template>
|
|
12
31
|
<script setup lang="ts">
|
|
13
32
|
/**
|
|
14
|
-
* This file was automatically generated by simpleapp
|
|
15
|
-
*
|
|
16
|
-
* prevent regenerate code override it.
|
|
33
|
+
* This file was automatically generated by simpleapp generator.
|
|
34
|
+
* --remove-this-line-to-prevent-override--
|
|
17
35
|
* last change 2023-09-09
|
|
18
36
|
* author: Ks Tan
|
|
19
37
|
*/
|
|
20
|
-
|
|
38
|
+
|
|
21
39
|
|
|
22
|
-
import { CellSetting } from "~/types";
|
|
23
40
|
const {$<%= it.typename %>Doc,$listen } = useNuxtApp();
|
|
24
41
|
const doc = $<%= it.typename %>Doc()
|
|
25
|
-
const
|
|
42
|
+
const docdata = doc.getReactiveData();
|
|
26
43
|
|
|
27
44
|
definePageMeta({
|
|
28
|
-
menuPath:'
|
|
45
|
+
menuPath:'nocategory/<%= it.name %>'
|
|
29
46
|
});
|
|
30
47
|
|
|
31
|
-
const columns
|
|
48
|
+
const columns= [<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
32
49
|
<%let obj=it.jsonschema.properties[key] %>
|
|
33
50
|
<%let config=it.jsonschema['x-simpleapp-config'] %>
|
|
34
|
-
<%if(skipcolumns.indexOf(key)>=0){
|
|
35
|
-
<%}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<%} else if(['string','number','integer'].indexOf(obj.type)>=0){%>'<%=key%>',
|
|
44
|
-
<%} else if(obj.type =='object' && obj['x-foreignkey'] ){%>
|
|
45
|
-
{
|
|
46
|
-
title:'<%=key%>',
|
|
47
|
-
field:'<%=key%>',
|
|
48
|
-
rendererName:'RendererForeignKey',
|
|
49
|
-
rendererSetting:{collection:'<%=obj["x-foreignkey"]%>' }
|
|
50
|
-
},
|
|
51
|
-
<%}%>
|
|
52
|
-
<%})%>] as CellSetting[]
|
|
51
|
+
<%if(skipcolumns.indexOf(key)>=0){%>
|
|
52
|
+
<%}else if(['string','number','integer','boolean'].indexOf(obj.type)>=0){%>'<%=key%>',
|
|
53
|
+
<%} %>
|
|
54
|
+
<%})%>]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
53
60
|
const sorts:string[][] = [
|
|
54
61
|
<%if(it.jsonschema['x-simpleapp-config'] && it.jsonschema['x-simpleapp-config']['uniqueKey']){%>
|
|
55
62
|
['<%=it.jsonschema['x-simpleapp-config']['uniqueKey']%>','asc'],
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<LazyForm<%=it.typename%> :_id="_id" @after="after" :paras="paras"/>
|
|
3
3
|
</template>
|
|
4
4
|
<script setup lang="ts">
|
|
5
5
|
/**
|
|
6
6
|
* This file was automatically generated by simpleapp everytime regenerate code.
|
|
7
|
-
*
|
|
8
|
-
* prevent regenerate code override it.
|
|
7
|
+
* --remove-this-line-to-prevent-override--
|
|
9
8
|
* last change 2023-09-09
|
|
10
9
|
* author: Ks Tan
|
|
11
10
|
*/
|
|
12
|
-
import Crud from './form.vue'
|
|
13
11
|
import {<%= it.typename %>} from '~/simpleapp/generate/types'
|
|
14
12
|
const props = defineProps<{_id:string,paras?:<%= it.typename %>}>();
|
|
15
13
|
const emits = defineEmits(["afterCreate","after"]);
|
|
16
14
|
|
|
17
|
-
const after = (actionName: string, data: <%= it.typename
|
|
15
|
+
const after = (actionName: string, data: <%= it.typename %>) => {
|
|
18
16
|
switch (actionName) {
|
|
19
17
|
case "new":
|
|
20
18
|
break;
|
|
@@ -26,6 +24,6 @@ const after = (actionName: string, data: <%= it.typename %>, result: any) => {
|
|
|
26
24
|
case "delete":
|
|
27
25
|
break;
|
|
28
26
|
}
|
|
29
|
-
emits("after",actionName,data
|
|
27
|
+
emits("after",actionName,data)
|
|
30
28
|
};
|
|
31
29
|
</script>
|
package/templates/nest/.env._eta
CHANGED
|
@@ -56,6 +56,8 @@ export class UserContext {
|
|
|
56
56
|
protected orgCode: string = '';
|
|
57
57
|
protected orgName: string = '';
|
|
58
58
|
protected timeZone: string = '';
|
|
59
|
+
protected country: string = '';
|
|
60
|
+
protected offsetMinute: number =0;
|
|
59
61
|
protected currency: string = '';
|
|
60
62
|
protected branches: any[] = [];
|
|
61
63
|
protected lastActivity: string = new Date().toISOString();
|
|
@@ -88,6 +90,8 @@ export class UserContext {
|
|
|
88
90
|
getBranchId = () => this.branchId;
|
|
89
91
|
getEmail = () => this.email;
|
|
90
92
|
getTimeZone = () => this.timeZone;
|
|
93
|
+
getCountry = () => this.country
|
|
94
|
+
getOffsetMinute = () => this.offsetMinute
|
|
91
95
|
getGroup = () => this.group;
|
|
92
96
|
getCurrency = () => this.currency;
|
|
93
97
|
getMoreProps = () => this.moreProps;
|
|
@@ -212,6 +216,8 @@ export class UserContext {
|
|
|
212
216
|
userinfo.orgName = myperm.currentorg[0].orgName;
|
|
213
217
|
userinfo.timeZone = myperm.currentorg[0].timeZone;
|
|
214
218
|
userinfo.currency = myperm.currentorg[0].currency;
|
|
219
|
+
userinfo.country = myperm.currentorg[0].country;
|
|
220
|
+
userinfo.offsetMinute = myperm.currentorg[0].offsetMinute;
|
|
215
221
|
}
|
|
216
222
|
} else {
|
|
217
223
|
userinfo.group = '';
|
|
@@ -262,7 +268,9 @@ export class UserContext {
|
|
|
262
268
|
this.orgCode = userinfo['orgCode'] ?? '';
|
|
263
269
|
this.orgName = userinfo['orgName'] ?? '';
|
|
264
270
|
this.timeZone = userinfo['timeZone'] ?? '';
|
|
265
|
-
this.currency= userinfo['currency'] ?? '';
|
|
271
|
+
this.currency = userinfo['currency'] ?? '';
|
|
272
|
+
this.country = userinfo['country'] ?? '';
|
|
273
|
+
this.offsetMinute = userinfo['offsetMinute'] ?? '';
|
|
266
274
|
this.orgRecordId = userinfo['orgRecordId'] ?? '';
|
|
267
275
|
this.branchRecordId = userinfo['branchRecordId'] ?? '';
|
|
268
276
|
this.group = userinfo['group'] ?? '';
|
|
@@ -384,6 +392,8 @@ export class UserContext {
|
|
|
384
392
|
orgName: this.orgName,
|
|
385
393
|
timeZone: this.getTimeZone(),
|
|
386
394
|
currency: this.getCurrency(),
|
|
395
|
+
country : this.getCountry(),
|
|
396
|
+
offsetMinute: this.getOffsetMinute(),
|
|
387
397
|
email: this.getEmail(),
|
|
388
398
|
uid: this.getUid(),
|
|
389
399
|
fullName: this.getFullname(),
|
|
@@ -681,8 +691,10 @@ export class UserContext {
|
|
|
681
691
|
'orgName',
|
|
682
692
|
'timeZone',
|
|
683
693
|
'currency',
|
|
694
|
+
'country',
|
|
695
|
+
'offsetMinute',
|
|
684
696
|
'tenantId',
|
|
685
|
-
'lastActivity',
|
|
697
|
+
'lastActivity',
|
|
686
698
|
'group',
|
|
687
699
|
'__v',
|
|
688
700
|
'uid',
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
Type,
|
|
16
16
|
} from '@nestjs/common';
|
|
17
17
|
// import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
18
|
-
import {UserContext} from '../commons/user.context'
|
|
19
|
-
import {SearchBody} from '../types';
|
|
18
|
+
import { UserContext } from '../commons/user.context';
|
|
19
|
+
import { SearchBody } from '../types';
|
|
20
20
|
const doctype = 'person'.toUpperCase();
|
|
21
21
|
type ServiceType = {
|
|
22
22
|
list: Function;
|
|
@@ -27,13 +27,18 @@ type ServiceType = {
|
|
|
27
27
|
findById: Function;
|
|
28
28
|
findIdThenDelete: Function;
|
|
29
29
|
findIdThenUpdate: Function;
|
|
30
|
+
findIdThenPatch: Function;
|
|
30
31
|
setData: Function;
|
|
31
32
|
getAutoComplete: Function;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
// @ApiTags(doctype)
|
|
35
36
|
// @Controller(doctype.toLowerCase())
|
|
36
|
-
export class SimpleAppAbstractController<
|
|
37
|
+
export class SimpleAppAbstractController<
|
|
38
|
+
TService extends ServiceType,
|
|
39
|
+
TApiSchema,
|
|
40
|
+
T,
|
|
41
|
+
> {
|
|
37
42
|
protected service: TService;
|
|
38
43
|
protected tryno: number;
|
|
39
44
|
// protected apiSchemaClass=
|
|
@@ -42,36 +47,45 @@ export class SimpleAppAbstractController<TService extends ServiceType, TApiSchem
|
|
|
42
47
|
this.service = service;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
async _list(appuser:UserContext) {
|
|
46
|
-
return this.service.list(appuser
|
|
50
|
+
async _list(appuser: UserContext) {
|
|
51
|
+
return this.service.list(appuser);
|
|
47
52
|
}
|
|
48
|
-
async _search(appuser:UserContext,searchObject:SearchBody) {
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
async _search(appuser: UserContext, searchObject: SearchBody) {
|
|
54
|
+
return this.service.search(
|
|
55
|
+
appuser,
|
|
56
|
+
searchObject['filter'],
|
|
57
|
+
searchObject['fields'],
|
|
58
|
+
searchObject['sorts'],
|
|
59
|
+
);
|
|
51
60
|
}
|
|
52
|
-
async _autocomplete(appuser:UserContext,keyword: string) {
|
|
53
|
-
return this.service.getAutoComplete(appuser,keyword);
|
|
61
|
+
async _autocomplete(appuser: UserContext, keyword: string) {
|
|
62
|
+
return this.service.getAutoComplete(appuser, keyword);
|
|
54
63
|
}
|
|
55
|
-
async _findOne(appuser:UserContext,id: string) {
|
|
56
|
-
const result = (await this.service.findById(appuser,id)) as TApiSchema;
|
|
64
|
+
async _findOne(appuser: UserContext, id: string) {
|
|
65
|
+
const result = (await this.service.findById(appuser, id)) as TApiSchema;
|
|
57
66
|
|
|
58
67
|
return result as Type<TApiSchema>;
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
async _create(appuser:UserContext,data: TApiSchema) {
|
|
70
|
+
async _create(appuser: UserContext, data: TApiSchema) {
|
|
62
71
|
//const newdata: persontype.Person = { ...data };
|
|
63
72
|
const newdata: T = {} as T; //= { ...data };
|
|
64
73
|
Object.assign(newdata, data); //
|
|
65
|
-
return this.service.create(appuser,newdata) as TApiSchema;
|
|
74
|
+
return this.service.create(appuser, newdata) as TApiSchema;
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
async _update(appuser:UserContext,id: string, data: TApiSchema) {
|
|
77
|
+
async _update(appuser: UserContext, id: string, data: TApiSchema) {
|
|
69
78
|
const newdata: T = {} as T; //= { ...data };
|
|
70
79
|
Object.assign(newdata, data); //
|
|
71
|
-
return this.service.findIdThenUpdate(appuser,id, newdata) as TApiSchema;
|
|
80
|
+
return this.service.findIdThenUpdate(appuser, id, newdata) as TApiSchema;
|
|
81
|
+
}
|
|
82
|
+
async _patch(appuser: UserContext, id: string, data: TApiSchema) {
|
|
83
|
+
const newdata: T = {} as T; //= { ...data };
|
|
84
|
+
Object.assign(newdata, data); //
|
|
85
|
+
return this.service.findIdThenPatch(appuser, id, newdata) as TApiSchema;
|
|
72
86
|
}
|
|
73
87
|
|
|
74
|
-
async _delete(appuser:UserContext,id: string) {
|
|
75
|
-
return this.service.findIdThenDelete(appuser,id);
|
|
88
|
+
async _delete(appuser: UserContext, id: string) {
|
|
89
|
+
return this.service.findIdThenDelete(appuser, id);
|
|
76
90
|
}
|
|
77
91
|
}
|
|
@@ -32,7 +32,12 @@ import {
|
|
|
32
32
|
} from '@nestjs/common/exceptions';
|
|
33
33
|
import { UserContext } from '../commons/user.context';
|
|
34
34
|
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
IsolationType,
|
|
37
|
+
DefaultHooks,
|
|
38
|
+
MoreProjectionType,
|
|
39
|
+
DeleteResultType,
|
|
40
|
+
} from '../types';
|
|
36
41
|
@Injectable()
|
|
37
42
|
export class SimpleAppService<T extends { _id?: string }> {
|
|
38
43
|
@Inject(EventEmitter2)
|
|
@@ -447,7 +452,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
447
452
|
try {
|
|
448
453
|
if (this.hooks.beforeDelete) await this.hooks.beforeDelete(appuser, id);
|
|
449
454
|
this.logger.debug('delete record', this.documentName, id);
|
|
450
|
-
dependency = await this.getRelatedRecords(appuser,id);
|
|
455
|
+
dependency = await this.getRelatedRecords(appuser, id);
|
|
451
456
|
//console.log('dependency', dependency);
|
|
452
457
|
if (!dependency) {
|
|
453
458
|
let filterIsolation = this.getIsolationFilter(appuser);
|
|
@@ -460,7 +465,10 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
460
465
|
.session(dbsession);
|
|
461
466
|
|
|
462
467
|
appuser.addDeletedRecordId(this.documentName, id);
|
|
463
|
-
const deleteresult:DeleteResultType<T> = {
|
|
468
|
+
const deleteresult: DeleteResultType<T> = {
|
|
469
|
+
result: result,
|
|
470
|
+
data: deletedata,
|
|
471
|
+
};
|
|
464
472
|
this.logger.debug(
|
|
465
473
|
deleteresult,
|
|
466
474
|
' delete result' + this.doc.collection.name,
|
|
@@ -472,9 +480,9 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
472
480
|
//this.doc.findByIdAndDelete(id);
|
|
473
481
|
return deleteresult;
|
|
474
482
|
} else {
|
|
475
|
-
console.log(
|
|
483
|
+
console.log('reject query', dependency);
|
|
476
484
|
|
|
477
|
-
throw new ForbiddenException(dependency,'Foreignkey constraint');
|
|
485
|
+
throw new ForbiddenException(dependency, 'Foreignkey constraint');
|
|
478
486
|
}
|
|
479
487
|
} catch (err) {
|
|
480
488
|
throw new InternalServerErrorException(err);
|
|
@@ -504,13 +512,13 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
504
512
|
if (!dbsession.inTransaction()) {
|
|
505
513
|
dbsession.startTransaction();
|
|
506
514
|
}
|
|
507
|
-
|
|
508
515
|
// try {
|
|
509
516
|
Object.assign(data, appuser.getUpdateFilter());
|
|
510
|
-
Object.assign(existingdata, data);
|
|
517
|
+
// Object.assign(existingdata, data);
|
|
511
518
|
delete data['_id'];
|
|
512
519
|
|
|
513
520
|
this.reCalculateValue(data);
|
|
521
|
+
|
|
514
522
|
// existingdata['_id']=''
|
|
515
523
|
// console.log("newdata",data)
|
|
516
524
|
await this.validateData(appuser, data);
|
|
@@ -520,10 +528,63 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
520
528
|
|
|
521
529
|
isolationFilter['_id'] = id;
|
|
522
530
|
this.applyNestedDateTime(appuser, data, 'update');
|
|
531
|
+
|
|
523
532
|
try {
|
|
524
|
-
const result = await this.doc
|
|
525
|
-
|
|
526
|
-
|
|
533
|
+
const result = await this.doc.findOneAndReplace(isolationFilter, data, {
|
|
534
|
+
session: dbsession,
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
538
|
+
|
|
539
|
+
if (this.hooks.afterUpdate)
|
|
540
|
+
await this.hooks.afterUpdate(appuser, id, result);
|
|
541
|
+
return await this.findById(appuser, id);
|
|
542
|
+
} catch (err) {
|
|
543
|
+
throw new InternalServerErrorException(err.message);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
findIdThenPatch = async (
|
|
548
|
+
appuser: UserContext,
|
|
549
|
+
id: string,
|
|
550
|
+
data: T,
|
|
551
|
+
session: mongo.ClientSession = undefined,
|
|
552
|
+
) => {
|
|
553
|
+
const existingdata = await this.findById(appuser, id);
|
|
554
|
+
if (!existingdata) {
|
|
555
|
+
throw new NotFoundException(`${id} not found`, 'not found');
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (this.hooks.beforeUpdate)
|
|
559
|
+
await this.hooks.beforeUpdate(appuser, id, data);
|
|
560
|
+
|
|
561
|
+
const dbsession = appuser.getDBSession();
|
|
562
|
+
if (!dbsession.inTransaction()) {
|
|
563
|
+
dbsession.startTransaction();
|
|
564
|
+
}
|
|
565
|
+
// try {
|
|
566
|
+
Object.assign(data, appuser.getUpdateFilter());
|
|
567
|
+
// Object.assign(existingdata, data);
|
|
568
|
+
delete data['_id'];
|
|
569
|
+
|
|
570
|
+
this.reCalculateValue(data);
|
|
571
|
+
|
|
572
|
+
// existingdata['_id']=''
|
|
573
|
+
// console.log("newdata",data)
|
|
574
|
+
//path record no validation
|
|
575
|
+
// await this.validateData(appuser, data);
|
|
576
|
+
|
|
577
|
+
const isolationFilter = { ...this.getIsolationFilter(appuser) };
|
|
578
|
+
this.polishIsolationFilter(isolationFilter);
|
|
579
|
+
|
|
580
|
+
isolationFilter['_id'] = id;
|
|
581
|
+
this.applyNestedDateTime(appuser, data, 'update');
|
|
582
|
+
|
|
583
|
+
try {
|
|
584
|
+
const result = await this.doc.findOneAndUpdate(isolationFilter, data, {
|
|
585
|
+
session: dbsession,
|
|
586
|
+
});
|
|
587
|
+
|
|
527
588
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
528
589
|
|
|
529
590
|
if (this.hooks.afterUpdate)
|
|
@@ -535,9 +596,9 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
535
596
|
};
|
|
536
597
|
|
|
537
598
|
//find what foreign key constraint
|
|
538
|
-
async getRelatedRecords(appuser:UserContext,id: string) {
|
|
599
|
+
async getRelatedRecords(appuser: UserContext, id: string) {
|
|
539
600
|
this.logger.debug('get foreignkey for delete:', id);
|
|
540
|
-
console.log(
|
|
601
|
+
console.log('session modifeds', appuser.getModifieds());
|
|
541
602
|
if (foreignkeys === undefined) {
|
|
542
603
|
this.logger.error('foreignkeys object undetected');
|
|
543
604
|
throw new InternalServerErrorException('foreignkeys object undetected');
|
|
@@ -562,7 +623,9 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
562
623
|
//not deleted in current session, check from database
|
|
563
624
|
let filter = {};
|
|
564
625
|
filter[fkey] = id;
|
|
565
|
-
const result = await collection.findOne(filter,{
|
|
626
|
+
const result = await collection.findOne(filter, {
|
|
627
|
+
session: appuser.getDBSession(),
|
|
628
|
+
});
|
|
566
629
|
if (result) {
|
|
567
630
|
this.logger.error(result, 'related result found');
|
|
568
631
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
[disabled] ,[readonly]{
|
|
3
|
-
@apply bg-gray-300 dark:bg-gray-
|
|
3
|
+
@apply bg-gray-300 dark:bg-gray-600
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
[aria-selected=true]{
|
|
@@ -13,21 +13,27 @@
|
|
|
13
13
|
[data-pc-section=pagebutton]{
|
|
14
14
|
@apply p-3 m-0 border
|
|
15
15
|
}
|
|
16
|
+
html {
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
overscroll-behavior: none;
|
|
19
|
+
touch-action: manipulation;
|
|
20
|
+
}
|
|
21
|
+
/* #__nuxt{
|
|
22
|
+
|
|
23
|
+
} */
|
|
16
24
|
|
|
17
25
|
body {
|
|
18
|
-
@apply bg-gray-
|
|
26
|
+
@apply bg-gray-100 dark:bg-slate-950 dark:text-gray-300 h-screen w-screen
|
|
27
|
+
/* overflow-y-scroll overflow-x-scroll */
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
input {
|
|
22
|
-
@apply bg-opacity-0 bg-black
|
|
23
|
-
}
|
|
24
30
|
|
|
25
31
|
.route-link-list {
|
|
26
|
-
@apply hover:
|
|
32
|
+
@apply text-black hover:text-secondary-200 dark:hover:text-primary-400
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
.router-link-exact-active{
|
|
30
|
-
@apply
|
|
36
|
+
@apply text-primary-100 dark:text-primary-600 block
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
.invisible{
|
|
@@ -39,6 +45,10 @@ input {
|
|
|
39
45
|
.subtitle-text{
|
|
40
46
|
@apply text-base text-gray-500
|
|
41
47
|
}
|
|
48
|
+
.p-inputnumber-input{
|
|
49
|
+
@apply text-right
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
|
|
43
53
|
.btn {
|
|
44
54
|
@apply font-medium text-gray-50 dark:text-gray-300 border
|
|
@@ -56,3 +66,5 @@ input {
|
|
|
56
66
|
.btn-warn {
|
|
57
67
|
@apply btn bg-warning-600 hover:bg-warning-400
|
|
58
68
|
}
|
|
69
|
+
|
|
70
|
+
|
|
@@ -16,13 +16,17 @@ const CustomTailwind = usePassThrough(
|
|
|
16
16
|
// buttonContainer:{class:'hidden'},
|
|
17
17
|
},
|
|
18
18
|
card:{
|
|
19
|
-
root:{class:'bg-white dark:bg-gray-
|
|
19
|
+
root:{class:'bg-white dark:bg-gray-800 shadow p-4 rounded-2xl'},
|
|
20
20
|
// title:{class:''},
|
|
21
21
|
// header:{class:''}
|
|
22
22
|
},
|
|
23
23
|
tabpanel:{
|
|
24
24
|
headerTitle:{class:'m-0 p-0'},
|
|
25
25
|
},
|
|
26
|
+
accordiontab:{
|
|
27
|
+
content:{style:'padding: 0.7rem;'}
|
|
28
|
+
|
|
29
|
+
},
|
|
26
30
|
selectbutton:{
|
|
27
31
|
root:{class:'flex flex-row gap-1 '},
|
|
28
32
|
button: ({ context }) => ({
|
|
@@ -41,7 +45,7 @@ const CustomTailwind = usePassThrough(
|
|
|
41
45
|
},
|
|
42
46
|
button:{root:{class: 'focus:outline-none transition duration-150 ease-in-out rounded p-2 m-1 border dark:border-gray-600'}},
|
|
43
47
|
dialog:{
|
|
44
|
-
root:{class:['
|
|
48
|
+
root:{class:[' w-full max-h-full max-w-full md:h-3/4 lg:h-1/2 p-2']},
|
|
45
49
|
header:{class: 'p-dialog-header flex items-center text-2xl justify-between shrink-0 bg-white text-gray-800 border-t-0 rounded-tl-lg rounded-tr-lg p-6 dark:bg-gray-900 dark:text-white/80'},
|
|
46
50
|
content:{class:'p-dialog-content overflow-y-auto bg-white text-gray-700 px-6 pb-8 pt-0 dark:bg-gray-900 dark:text-white/80 rounded-bl-lg rounded-br-lg h-full'}
|
|
47
51
|
},
|
|
@@ -50,14 +54,22 @@ const CustomTailwind = usePassThrough(
|
|
|
50
54
|
input:{class:'w-full p-inputtext p-component font-sans text-base text-gray-600 dark:text-white/80 bg-white dark:bg-gray-900 p-3 border border-gray-300 dark:border-blue-900/40 transition-colors duration-200 appearance-none hover:border-blue-500 rounded-lg'},
|
|
51
55
|
},
|
|
52
56
|
autocomplete:{
|
|
53
|
-
root:{class:'border border-gray-400 dark:!border-blue-900/40 rounded-lg flex flex-row'},
|
|
54
|
-
loadingIcon:{class:'hidden'},
|
|
57
|
+
// root:{class:'border border-gray-400 dark:!border-blue-900/40 rounded-lg flex flex-row'},
|
|
58
|
+
// loadingIcon:{class:'hidden'},
|
|
59
|
+
panel:{
|
|
60
|
+
class:'p-autocomplete-panel p-component p-2 w-full md:max-w-[500px] p-input-filled bg-white text-gray-700 border-0 rounded-md shadow-lg max-h-[200px] overflow-auto dark:bg-gray-900 dark:text-white/80'
|
|
61
|
+
},
|
|
55
62
|
dropdownbutton: {
|
|
56
63
|
root:' btn-primary dark:shadow-primary-800 dark:border-primary-900 text-white rounded-lg flex flex-row p-3 rounded-tl-none rounded-bl-none '
|
|
57
64
|
}
|
|
58
65
|
},
|
|
66
|
+
column:{
|
|
67
|
+
bodycell:{
|
|
68
|
+
style:'padding:5px;'
|
|
69
|
+
},
|
|
70
|
+
},
|
|
59
71
|
sidebar:{
|
|
60
|
-
root:{class:'w-full md:w-
|
|
72
|
+
root:{class:'w-full md:w-2/3 bg-white dark:bg-slate-950 p-0 h-full'},
|
|
61
73
|
header:{class:'dark:text-white text-2xl p-2'},
|
|
62
74
|
content:{class:'p-0 pt-0 h-full w-full grow overflow-y-auto'}
|
|
63
75
|
},
|
|
@@ -70,10 +82,9 @@ const CustomTailwind = usePassThrough(
|
|
|
70
82
|
breadcrumb:{
|
|
71
83
|
root:{class:''}
|
|
72
84
|
},
|
|
73
|
-
inputnumber:{
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
}
|
|
85
|
+
// inputnumber:{
|
|
86
|
+
// input:{class:'text-right text-yellow-700'}
|
|
87
|
+
// }
|
|
77
88
|
},
|
|
78
89
|
);
|
|
79
90
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-for="o in options">
|
|
3
|
+
<ButtonPrimary v-if="value == o.value" @click="switchButton(o.value)">{{
|
|
4
|
+
o.label
|
|
5
|
+
}}</ButtonPrimary>
|
|
6
|
+
<ButtonDefault v-else @click="switchButton(o.value)">{{
|
|
7
|
+
o.label
|
|
8
|
+
}}</ButtonDefault>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
type keyvalue = { label: string; value: string };
|
|
13
|
+
const emits = defineEmits(["switch"]);
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
options: keyvalue[];
|
|
16
|
+
value: string;
|
|
17
|
+
}>();
|
|
18
|
+
const switchButton = (v: string) => {
|
|
19
|
+
if (v != props.value) emits("switch", v);
|
|
20
|
+
};
|
|
21
|
+
</script>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="p-0
|
|
3
|
-
<
|
|
4
|
-
<i class="pi pi-code"></i>
|
|
5
|
-
{{ label }}</Button>
|
|
2
|
+
<div :class="`p-0 absolute bg-yellow-200 bottom-0 right-0`" v-if="isdebug=='1'">
|
|
3
|
+
<button @click="visible=true" class=" text-white text-xs bg-warning-800 p-0 m-0">
|
|
4
|
+
<i class="pi pi-code"></i>{{ label }}</button>
|
|
6
5
|
<Sidebar v-model:visible="visible" class="text-red-100">
|
|
7
6
|
|
|
8
7
|
<template #header >
|