@simitgroup/simpleapp-generator 1.2.3 → 1.2.5

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 (25) hide show
  1. package/dist/framework.d.ts.map +1 -1
  2. package/dist/framework.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/framework.ts +1 -0
  5. package/templates/basic/nuxt/pages.form.vue.eta +4 -0
  6. package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +5 -9
  7. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +69 -26
  8. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +13 -12
  9. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +41 -30
  10. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +34 -29
  11. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +22 -77
  12. package/templates/nuxt/components/user/UserButtonCreateTenant.vue.eta +1 -1
  13. package/templates/nuxt/composables/getUserStore.generate.ts.eta +3 -3
  14. package/templates/nuxt/composables/stringHelper.generate.ts.eta +1 -3
  15. package/templates/nuxt/error.vue._eta +9 -4
  16. package/templates/nuxt/lang/df.ts.eta +2 -3
  17. package/templates/nuxt/nuxt.config.ts._eta +1 -2
  18. package/templates/nuxt/pages/[xorg]/organization.vue.eta +10 -9
  19. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +16 -22
  20. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +7 -20
  21. package/templates/nuxt/server/api/[xorg]/[...].ts.eta +20 -29
  22. package/templates/nuxt/server/api/profile/[...].ts.eta +18 -21
  23. package/templates/nuxt/types/events.ts.eta +2 -0
  24. package/templates/project/lang/default._json +10 -4
  25. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"framework.d.ts","sourceRoot":"","sources":["../src/framework.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,gBAAgB,2BAE5B,CAAA;AAED,eAAO,MAAM,aAAa,aAAY,QAAQ,SAc7C,CAAA;AAED,eAAO,MAAM,aAAa,aAAa,QAAQ,SAU9C,CAAA;AAED,eAAO,MAAM,WAAW,aAAa,QAAQ,SAqC5C,CAAA;AAED,eAAO,MAAM,cAAc,kCAiD1B,CAAA;AAED,eAAO,MAAM,WAAW,aAAa,QAAQ,SAgE5C,CAAA;AAED,eAAO,MAAM,UAAU,YAKtB,CAAA;AACD,eAAO,MAAM,UAAU,YAEtB,CAAA;AAED,eAAO,MAAM,oBAAoB,YAOhC,CAAA"}
1
+ {"version":3,"file":"framework.d.ts","sourceRoot":"","sources":["../src/framework.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,gBAAgB,2BAE5B,CAAA;AAED,eAAO,MAAM,aAAa,aAAY,QAAQ,SAc7C,CAAA;AAED,eAAO,MAAM,aAAa,aAAa,QAAQ,SAU9C,CAAA;AAED,eAAO,MAAM,WAAW,aAAa,QAAQ,SAsC5C,CAAA;AAED,eAAO,MAAM,cAAc,kCAiD1B,CAAA;AAED,eAAO,MAAM,WAAW,aAAa,QAAQ,SAgE5C,CAAA;AAED,eAAO,MAAM,UAAU,YAKtB,CAAA;AACD,eAAO,MAAM,UAAU,YAEtB,CAAA;AAED,eAAO,MAAM,oBAAoB,YAOhC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"framework.js","sourceRoot":"","sources":["../src/framework.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA0E;AAC1E,iDAAwC;AACxC,oDAAsB;AACtB,iCAAwC;AACxC,sDAAuC;AACvC,6BAA0B;AAC1B,MAAM,GAAG,GAAoB,IAAI,cAAM,EAAE,CAAC;AAE1C,IAAI,MAAM,GAAG;IACT,kBAAkB,EAAC,eAAe;IAClC,YAAY,EAAC,EAAE;IACf,eAAe,EAAC,WAAW;IAC3B,aAAa,EAAC,UAAU;IACxB,YAAY,EAAC,QAAQ;IACrB,aAAa,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
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/framework.ts CHANGED
@@ -69,6 +69,7 @@ export const prepareNest = (callback:Function)=>{
69
69
  const targetfolder =config.backendFolder
70
70
  log.info(`creating backend project ${targetfolder}`)
71
71
  if(!fs.existsSync(`${targetfolder}/.env`)){
72
+
72
73
 
73
74
 
74
75
  exec(`cd ${targetfolder};pnpm install --save @nestjs/event-emitter dayjs bpmn-server@2.0.8-alpha2 moment @casl/ability jsonpath yaml lodash @types/lodash nest-keycloak-connect keycloak-connect bpmn-client @nestjs/serve-static jsonwebtoken axios @darkwolf/base64url json-schema @wearenova/mongoose-tenant @nestjs/swagger @nestjs/mongoose mongoose ajv ajv-formats ajv-errors @nestjs/config`,async (error, stdout, stderr)=>{
@@ -190,10 +190,14 @@ const actionListener = async (actionName: string) => {
190
190
  case "new":
191
191
  result =await newData();
192
192
  break;
193
+ case "mount":
194
+ break;
193
195
  }
194
196
 
195
197
  emits('after',actionName,data.value,doc,result)
196
198
  };
199
+ onMounted(async ()=> await actionListener('mount'))
200
+
197
201
  /************ start api methods ****************/
198
202
 
199
203
  <%for(let i=0;i<it.apiSettings.length;i++){%>
@@ -10,6 +10,7 @@ import {
10
10
  Logger,
11
11
  Scope,
12
12
  Inject,
13
+ BadRequestException,
13
14
  } from '@nestjs/common';
14
15
  import { Request, Response, NextFunction } from 'express';
15
16
  import { InjectModel } from '@nestjs/mongoose';
@@ -27,13 +28,12 @@ import { UserContext } from '../user.context';
27
28
  @Injectable()
28
29
  export class TenantMiddleware implements NestMiddleware {
29
30
  protected defaultxorg = Base64URL.encodeText('0-0-0');
30
- protected excludeXorgs = ['/profile', '/profile/tenant','/profile/session'];
31
+ protected excludeXorgs = ['/profile', '/profile/tenant', '/profile/session'];
31
32
  protected logger = new Logger();
32
33
  protected transController;
33
34
  constructor(
34
35
  @InjectModel('User') private readonly usermodel: Model<User>,
35
36
  @InjectModel('Permission') private readonly permmodel: Model<Permission>,
36
-
37
37
  ) {}
38
38
 
39
39
  requireXorg(baseurl: string): boolean {
@@ -62,7 +62,8 @@ export class TenantMiddleware implements NestMiddleware {
62
62
  'undefine x-org and require that at ' + req.baseUrl,
63
63
  'TenantMiddleware',
64
64
  );
65
- return res.status(401).send('undefine header string x-org');
65
+ throw new BadRequestException('undefine header string x-org')
66
+ // return res.status(401).send('undefine header string x-org');
66
67
  }
67
68
  // const session = await this.connection.startSession();
68
69
  const u = new UserContext(this.usermodel, this.permmodel);
@@ -93,13 +94,8 @@ export class TenantMiddleware implements NestMiddleware {
93
94
  next();
94
95
  }
95
96
  } catch (err) {
96
- this.logger.warn(err, 'invalid xorg or user info');
97
97
  this.logger.error(err);
98
- if (err == 'invalid x-org') {
99
- return res.status(401).send(err);
100
- } else {
101
- return res.status(401).send(err);
102
- }
98
+ throw new BadRequestException(err,)
103
99
  }
104
100
  }
105
101
  }
@@ -10,10 +10,11 @@ import {
10
10
  Inject,
11
11
  Logger,
12
12
  BadRequestException,
13
+ ForbiddenException,
13
14
  } from '@nestjs/common';
14
15
  import { Model, model, connect, PipelineStage } from 'mongoose';
15
16
  import { ModifiedCollection, ModifiedRecords } from '../types';
16
- import _ from 'lodash';
17
+ import _, { isNumber } from 'lodash';
17
18
  import { Module } from '@nestjs/common';
18
19
  import * as jwt from 'jsonwebtoken';
19
20
  import { Role } from './roles/roles.enum';
@@ -54,11 +55,12 @@ export class UserContext {
54
55
  protected branchName: string = '';
55
56
  protected orgCode: string = '';
56
57
  protected orgName: string = '';
58
+ protected timeZone:string=''
57
59
  protected branches: any[] = [];
58
60
  protected lastActivity: string = new Date().toISOString();
59
61
  protected invites: any[] = []; //User + field tenant:Tenant[]
60
62
  protected roles: string[] = [];
61
- protected moreProps: any[] =[]
63
+ protected moreProps: any[] = [];
62
64
  private dbsession: ClientSession;
63
65
  protected modifiedRecords: ModifiedRecords = {
64
66
  createds: {},
@@ -84,6 +86,7 @@ export class UserContext {
84
86
  getOrgId = () => this.orgId;
85
87
  getBranchId = () => this.branchId;
86
88
  getEmail = () => this.email;
89
+ getTimeZone = () => this.timeZone;
87
90
  getGroup = () => this.group;
88
91
  getMoreProps = () => this.moreProps;
89
92
  getRoles = () => this.roles;
@@ -205,6 +208,7 @@ export class UserContext {
205
208
  userinfo.orgRecordId = myperm.currentorg[0]._id;
206
209
  userinfo.orgCode = myperm.currentorg[0].orgCode;
207
210
  userinfo.orgName = myperm.currentorg[0].orgName;
211
+ userinfo.timeZone = myperm.currentorg[0].timeZone;
208
212
  }
209
213
  } else {
210
214
  userinfo.group = '';
@@ -254,11 +258,12 @@ export class UserContext {
254
258
  this.branchName = userinfo['branchName'] ?? '';
255
259
  this.orgCode = userinfo['orgCode'] ?? '';
256
260
  this.orgName = userinfo['orgName'] ?? '';
261
+ this.timeZone = userinfo['timeZone']?? '';
257
262
  this.orgRecordId = userinfo['orgRecordId'] ?? '';
258
263
  this.branchRecordId = userinfo['branchRecordId'] ?? '';
259
264
  this.group = userinfo['group'] ?? '';
260
265
  this.roles = userinfo['roles'] ?? [Role.Everyone, Role.User];
261
- this.moreProps = this.setMoreProps(userinfo)
266
+ this.moreProps = this.setMoreProps(userinfo);
262
267
  } else {
263
268
  this.logger.debug(`Set unknown id of current user`, 'setUserToken');
264
269
  // this.group = ''
@@ -339,18 +344,23 @@ export class UserContext {
339
344
  setXorg = (xorg) => {
340
345
  try {
341
346
  const decodedText: string = Base64URL.decodeText(xorg);
342
- const arrXorg = decodedText.split('-');
343
-
344
- if (arrXorg.length == 3) {
347
+ const x = decodedText.includes('/')
348
+ ? decodedText.split('/')
349
+ : decodedText.split('-');
350
+
351
+ const x1 = Number(x[0]);
352
+ const x2 = Number(x[1]);
353
+ const x3 = Number(x[2]);
354
+ if (x.length == 3 && !isNaN(x1) && !isNaN(x2) && !isNaN(x3)) {
345
355
  const u = this;
346
- u.tenantId = Number(arrXorg[0]);
347
- u.orgId = Number(arrXorg[1]);
348
- u.branchId = Number(arrXorg[2]);
356
+ u.tenantId = x1;
357
+ u.orgId = x2;
358
+ u.branchId = x3;
349
359
  } else {
350
- throw 'invalid x-org';
360
+ throw new BadRequestException('invalidXorg');
351
361
  }
352
362
  } catch (err) {
353
- throw err;
363
+ throw new BadRequestException(err);
354
364
  }
355
365
  };
356
366
 
@@ -368,6 +378,7 @@ export class UserContext {
368
378
  branchName: this.branchName,
369
379
  orgCode: this.orgCode,
370
380
  orgName: this.orgName,
381
+ timeZone: this.getTimeZone(),
371
382
  email: this.getEmail(),
372
383
  uid: this.getUid(),
373
384
  fullName: this.getFullname(),
@@ -375,7 +386,7 @@ export class UserContext {
375
386
  roles: this.getRoles(),
376
387
  branches: this.getBranches(),
377
388
  invites: await this.getInvites(),
378
- morePros: this.getMoreProps()
389
+ moreProps: this.getMoreProps(),
379
390
  };
380
391
  this.logger.debug(userinfo, 'init getUserInfo()');
381
392
 
@@ -438,10 +449,8 @@ export class UserContext {
438
449
  userinfo.branches = this.getBranches();
439
450
  userinfo.invites = this.getInvites();
440
451
  // this.logger.debug(`getUserInfo result ${userinfo}`)
441
- } else {
442
- this.logger.log(
443
- `${this.getUid()} does not exists in current tenant (${this.tenantId})`,
444
- );
452
+ } else if (this.getTenantId() > 0) {
453
+ throw new ForbiddenException(`userNotExistInTenant`, 'access deny');
445
454
  }
446
455
 
447
456
  return userinfo;
@@ -501,6 +510,18 @@ export class UserContext {
501
510
  (item) => item === _id,
502
511
  );
503
512
  }
513
+ searchDeletedRecordId(collection: string, _id: string) {
514
+ console.log('check is deleted: ', collection, _id);
515
+ const deletedlist = this.modifiedRecords.deleteds[collection];
516
+
517
+ if (deletedlist) {
518
+ return this.modifiedRecords.deleteds[collection].find(
519
+ (item) => item === _id,
520
+ );
521
+ } else {
522
+ return undefined;
523
+ }
524
+ }
504
525
  addInsertedRecordId(collection: string, _id: string) {
505
526
  if (this.modifiedRecords.createds[collection]) {
506
527
  this.modifiedRecords.createds[collection].push(_id);
@@ -635,17 +656,39 @@ export class UserContext {
635
656
  /**
636
657
  * define additional properties from user into moreProps
637
658
  */
638
- setMoreProps(userinfo:any){
639
- const allprops = Object.keys(userinfo)
640
- const excludekeys=['created','createdBy','updated','updatedBy','_id','email','fullName','permissions','roles','branchCode','branchId','branchName','orgCode','orgId','orgName','tenantId','lastActivity','group','__v','uid','orgRecordId']
641
- let data:any = {}
642
- for(let i=0; i< allprops.length; i++){
643
- const key = allprops[i]
644
- if(!excludekeys.includes(key)){
645
- data[key] = userinfo[key]
659
+ setMoreProps(userinfo: any) {
660
+ const allprops = Object.keys(userinfo);
661
+ const excludekeys = [
662
+ 'created',
663
+ 'createdBy',
664
+ 'updated',
665
+ 'updatedBy',
666
+ '_id',
667
+ 'email',
668
+ 'fullName',
669
+ 'permissions',
670
+ 'roles',
671
+ 'branchCode',
672
+ 'branchId',
673
+ 'branchName',
674
+ 'orgCode',
675
+ 'orgId',
676
+ 'orgName',
677
+ 'timeZone',
678
+ 'tenantId',
679
+ 'lastActivity',
680
+ 'group',
681
+ '__v',
682
+ 'uid',
683
+ 'orgRecordId',
684
+ ];
685
+ let data: any = {};
686
+ for (let i = 0; i < allprops.length; i++) {
687
+ const key = allprops[i];
688
+ if (!excludekeys.includes(key)) {
689
+ data[key] = userinfo[key];
646
690
  }
647
-
648
691
  }
649
- return data
692
+ return data;
650
693
  }
651
694
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was automatically generated by simpleapp generator. Every
3
3
  * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2023-10-28
4
+ * last change 2024-01-27
5
5
  * Author: Ks Tan
6
6
  */
7
7
  import { Injectable, Logger, Inject } from '@nestjs/common';
@@ -32,7 +32,7 @@ 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 { IsolationType, DefaultHooks, MoreProjectionType } from '../types';
35
+ import { IsolationType, DefaultHooks, MoreProjectionType,DeleteResultType } from '../types';
36
36
  @Injectable()
37
37
  export class SimpleAppService<T extends { _id?: string }> {
38
38
  @Inject(EventEmitter2)
@@ -78,7 +78,8 @@ export class SimpleAppService<T extends { _id?: string }> {
78
78
  // this.tenantdoc = tenantdoc
79
79
  }
80
80
  getDocumentType = () => this.documentType;
81
- getDocumentName = (capFirst:boolean=false) => capFirst ? _.upperFirst(this.documentName) :this.documentName;
81
+ getDocumentName = (capFirst: boolean = false) =>
82
+ capFirst ? _.upperFirst(this.documentName) : this.documentName;
82
83
  getRecordId = (): string => this.data._id;
83
84
  setSchema = (newschema) => (this.jsonschema = newschema);
84
85
  getSchema = () => this.doc.schema.obj;
@@ -446,7 +447,7 @@ export class SimpleAppService<T extends { _id?: string }> {
446
447
  try {
447
448
  if (this.hooks.beforeDelete) await this.hooks.beforeDelete(appuser, id);
448
449
  this.logger.debug('delete record', this.documentName, id);
449
- dependency = await this.getRelatedRecords(id);
450
+ dependency = await this.getRelatedRecords(appuser,id);
450
451
  //console.log('dependency', dependency);
451
452
  if (!dependency) {
452
453
  let filterIsolation = this.getIsolationFilter(appuser);
@@ -458,8 +459,8 @@ export class SimpleAppService<T extends { _id?: string }> {
458
459
  .deleteOne(filterIsolation)
459
460
  .session(dbsession);
460
461
 
461
- appuser.addUpdatedRecordId(this.documentName, id);
462
- const deleteresult = { result: result, data: deletedata };
462
+ appuser.addDeletedRecordId(this.documentName, id);
463
+ const deleteresult:DeleteResultType<T> = { result: result, data: deletedata };
463
464
  this.logger.debug(
464
465
  deleteresult,
465
466
  ' delete result' + this.doc.collection.name,
@@ -471,9 +472,9 @@ export class SimpleAppService<T extends { _id?: string }> {
471
472
  //this.doc.findByIdAndDelete(id);
472
473
  return deleteresult;
473
474
  } else {
474
- //console.log("reject query",dependency)
475
+ console.log("reject query",dependency)
475
476
 
476
- throw new ForbiddenException('Foreignkey constraint', dependency);
477
+ throw new ForbiddenException(dependency,'Foreignkey constraint');
477
478
  }
478
479
  } catch (err) {
479
480
  throw new InternalServerErrorException(err);
@@ -534,9 +535,9 @@ export class SimpleAppService<T extends { _id?: string }> {
534
535
  };
535
536
 
536
537
  //find what foreign key constraint
537
- async getRelatedRecords(id: string) {
538
+ async getRelatedRecords(appuser:UserContext,id: string) {
538
539
  this.logger.debug('get foreignkey for delete:', id);
539
-
540
+ console.log("session modifeds",appuser.getModifieds())
540
541
  if (foreignkeys === undefined) {
541
542
  this.logger.error('foreignkeys object undetected');
542
543
  throw new InternalServerErrorException('foreignkeys object undetected');
@@ -558,10 +559,10 @@ export class SimpleAppService<T extends { _id?: string }> {
558
559
  //single schema may have multiple foreign key link here, loop all
559
560
  for (let j = 0; j < fobjs.length; j++) {
560
561
  const fkey = fobjs[j];
562
+ //not deleted in current session, check from database
561
563
  let filter = {};
562
564
  filter[fkey] = id;
563
-
564
- const result = await collection.findOne(filter);
565
+ const result = await collection.findOne(filter,{session:appuser.getDBSession()});
565
566
  if (result) {
566
567
  this.logger.error(result, 'related result found');
567
568
  return result;
@@ -31,7 +31,6 @@ export type SearchBody = {
31
31
  sorts?: any[];
32
32
  };
33
33
 
34
-
35
34
  export enum IsolationType {
36
35
  'none' = 'none',
37
36
  'org' = 'org',
@@ -39,38 +38,50 @@ export enum IsolationType {
39
38
  'branch' = 'branch',
40
39
  }
41
40
  export type DefaultHooks<T> = {
42
- init?: () => Promise<void> ;
43
- beforeSearch?: (appuser:UserContext,filter:any) => Promise<void> ;
44
- afterSearch?: (appuser:UserContext,data:T[]) => Promise<void> ;
45
- beforeValidation?: (appuser:UserContext,data:T) => Promise<boolean> ;
46
- afterValidation?: (appuser:UserContext,data:T) => Promise<void> ;
47
- beforeCreate?: (appuser:UserContext,data:T) => Promise<void> ;
48
- afterCreate?: (appuser:UserContext,data:T) => Promise<void> ;
49
- beforeUpdate?: (appuser:UserContext,id:string,data:T) => Promise<void> ;
50
- afterUpdate?: (appuser:UserContext,id:string,data:T) => Promise<void> ;
51
- beforeDelete?: (appuser:UserContext,id:string) => Promise<void> ;
52
- afterDelete?: (appuser:UserContext,data:any,id:string) => Promise<void> ;
53
- beforeFetchRecord?: (appuser:UserContext,id:string) => Promise<void> ;
54
- afterFetchRecord?: (appuser:UserContext,data:T) => Promise<void> ;
55
- beforeSetStatus?: (appuser:UserContext,id:string,data:T) => Promise<void> ;
56
- afterSetStatus ?: (appuser:UserContext,id:string,data:T) => Promise<void> ;
41
+ init?: () => Promise<void>;
42
+ beforeSearch?: (appuser: UserContext, filter: any) => Promise<void>;
43
+ afterSearch?: (appuser: UserContext, data: T[]) => Promise<void>;
44
+ beforeValidation?: (appuser: UserContext, data: T) => Promise<boolean>;
45
+ afterValidation?: (appuser: UserContext, data: T) => Promise<void>;
46
+ beforeCreate?: (appuser: UserContext, data: T) => Promise<void>;
47
+ afterCreate?: (appuser: UserContext, data: T) => Promise<void>;
48
+ beforeUpdate?: (appuser: UserContext, id: string, data: T) => Promise<void>;
49
+ afterUpdate?: (appuser: UserContext, id: string, data: T) => Promise<void>;
50
+ beforeDelete?: (appuser: UserContext, id: string) => Promise<void>;
51
+ afterDelete?: (appuser: UserContext, result: DeleteResultType<T>, id: string) => Promise<void>;
52
+ beforeFetchRecord?: (appuser: UserContext, id: string) => Promise<void>;
53
+ afterFetchRecord?: (appuser: UserContext, data: T) => Promise<void>;
54
+ beforeSetStatus?: (
55
+ appuser: UserContext,
56
+ id: string,
57
+ data: T,
58
+ ) => Promise<void>;
59
+ afterSetStatus?: (appuser: UserContext, id: string, data: T) => Promise<void>;
57
60
  };
58
61
  export type MoreProjectionType = {
59
62
  [key: string]: string;
60
63
  };
61
64
  export type ApiEvent = {
62
- _id: string
63
- created: string
64
- updated?:string
65
- duration: number
66
- createdBy: string
67
- path: string
68
- ip: string
69
- method: string
70
- headers: any
71
- data?: any
72
- statusCode:number
73
- status:string
74
- errMsg?:string
75
- errData?: any
65
+ _id: string;
66
+ created: string;
67
+ updated?: string;
68
+ duration: number;
69
+ createdBy: string;
70
+ path: string;
71
+ ip: string;
72
+ method: string;
73
+ headers: any;
74
+ data?: any;
75
+ statusCode: number;
76
+ status: string;
77
+ errMsg?: string;
78
+ errData?: any;
79
+ };
80
+
81
+ export type DeleteResultType <T> = {
82
+ data:T
83
+ result: {
84
+ acknowledged: boolean
85
+ deletedCount:number
86
+ }
76
87
  }
@@ -1,17 +1,24 @@
1
1
  <template>
2
- <Dialog v-model:visible="visible"
3
- @update:visible="closeDialog"
2
+ <Dialog v-model:visible="visible"
4
3
  :pt="{root:{class:'w-5/6 h-5/6'}}"
5
4
  :modal="true"
6
5
  :close-on-escape="false" >
6
+
7
+
7
8
  <template #header>
8
- <div class="flex flex-row">
9
- <Chip v-for="(v,index) in allview" :label="v.label" @remove="deleteTab" :removable="index == allview.length-1"/>
9
+ <div class="flex flex-row gap-4">
10
+ <Chip v-for="(v,k) in allview" :label="v.label" @remove="deleteTab" :removable="true"
11
+ />
10
12
  </div>
11
13
  </template>
12
- <template #default>
13
- <div v-for="(v,index) in allview">
14
- <component v-if="index == allview.length-1" :is="defineAsyncComponent(v.viewer)" :_id="v._id" :readonly="v.readonly" @after-create="callback(v,$event)" :skipRedirect="true"></component>
14
+ <template #default>
15
+ <div v-for="(v,k) in allview" v-memo="[k]" class="viewer-item flex flex-col">
16
+ <component
17
+ :is="defineAsyncComponent(v.viewer)"
18
+ :_id="v._id"
19
+ :readonly="v.readonly"
20
+ @after-create="callback(v,$event)"
21
+ />
15
22
  </div>
16
23
  </template>
17
24
  </Dialog>
@@ -20,27 +27,20 @@
20
27
  /**
21
28
  * This file was automatically generated by simpleapp generator during initialization.
22
29
  * IT WONT OVERRIDE AND YOU CAN MODIFY IT.
23
- * last change 2023-09-09
30
+ * last change 2024-01-27
24
31
  * author: Ks Tan
25
32
  */
26
33
  import { onKeyStroke } from '@vueuse/core'
27
-
28
34
  import { useDialog } from 'primevue/usedialog';
29
35
  import {defineAsyncComponent} from 'vue'
30
36
  import { ViewRecord } from '~/types';
31
37
  // import TabView from 'primevue/tabview';
32
38
  import Chip from 'primevue/chip';
33
39
 
34
- const tabindex =ref(0)
35
- const activetabindex=ref(0)
36
- const findindex = ref(0)
37
- const dialog = useDialog()
40
+
38
41
  const {$listen,} = useNuxtApp()
39
42
  const visible = ref(false)
40
- const _id = ref('')
41
- const ViewRecordComponent = ref()
42
- const readonly = ref<boolean>()
43
- const allview = ref<ViewRecord[]>([])
43
+ const allview = ref<{[key:string]:ViewRecord}>({})
44
44
 
45
45
  const callback = (v:ViewRecord,data:any)=>{
46
46
  if(v.afterCreate){
@@ -55,24 +55,29 @@ onKeyStroke('Escape', (e) => {
55
55
 
56
56
  const deleteTab=()=>{
57
57
 
58
- const index = allview.value.length- 1
59
- allview.value.splice(index,1)
60
-
61
- if(allview.value.length==0){
58
+ const keys = Object.keys(allview.value)
59
+ const lastkey = keys[keys.length-1]
60
+ delete allview.value[lastkey]
61
+ // updateprops.value++
62
+ if(Object.keys(allview.value).length==0){
62
63
  visible.value=false
63
64
  return
64
- }else{
65
- activetabindex.value = activetabindex.value >0 ? activetabindex.value - 1 : 0
66
65
  }
67
66
  }
68
- const closeDialog = ()=>{
69
- allview.value=[]
70
- }
67
+
71
68
  $listen('ViewRecord',(setting)=>{
72
69
  visible.value=true
73
- allview.value.push(setting)
74
- activetabindex.value = allview.value.length-1
70
+ allview.value[setting.eventId]=setting
75
71
 
76
72
  })
77
73
 
78
- </script>
74
+ </script>
75
+
76
+ <style scoped>
77
+ .viewer-item{
78
+ display: none;
79
+ }
80
+ .viewer-item:last-child{
81
+ display: flex;
82
+ }
83
+ </style>