@simitgroup/simpleapp-generator 2.0.2-c-alpha → 2.0.2-d-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/ReleaseNote.md CHANGED
@@ -1,3 +1,8 @@
1
+ [2.0.2d-alpha]
2
+
3
+ 1. fix pagination issue
4
+
5
+
1
6
  [2.0.2c-alpha]
2
7
 
3
8
  1. support environment variable off mongodb transaction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.2c-alpha",
3
+ "version": "2.0.2d-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -79,12 +79,20 @@ export class MiniApp<%= pascalName %>BridgeService {
79
79
  <% if (value !== true && typeof value !== 'object') { return; } %>
80
80
 
81
81
  <% if(action === 'list') { %>
82
- protected async handleList(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
83
- return (await this.api!.runSearch({
84
- fields: message.params.body?.fields,
85
- sorts: message.params.body?.sorts,
86
- filter: message.params.body?.filters,
87
- })).data;
82
+ protected async handleList(message: MiniAppBridgeMessageApi<MiniAppStudentActions>) {
83
+ const rawBody: any = message.params.body ?? {};
84
+ const pageSize = rawBody.pagination?.pageSize ?? rawBody.pageSize ?? 200;
85
+ const pageNo = rawBody.pagination?.pageNo ?? rawBody.pageNo ?? 0;
86
+ const res = await this.api!.runSearch({
87
+ filter: rawBody.filters,
88
+ fields: rawBody.fields,
89
+ sorts: rawBody.sorts,
90
+ pagination: {
91
+ pageSize,
92
+ pageNo,
93
+ },
94
+ } as any);
95
+ return res.data;
88
96
  }
89
97
  <% } else if(action === 'detail') { %>
90
98
  protected async handleDetail(message: MiniAppBridgeMessageApi<<%= typeActionName %>>) {
@@ -51,8 +51,7 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema> {
51
51
  return this.service.fullTextSearch(appuser, body);
52
52
  }
53
53
 
54
- async _search(appuser: UserContext, searchObject: SearchBody, res?: Response) {
55
- //return this.service.search(appuser, searchObject['filter'], searchObject['fields'], searchObject['sorts'], searchObject['lookup']);
54
+ async _search(appuser: UserContext, searchObject: SearchBody, res?: Response) {
56
55
  const items = await this.service.searchWithPageInfo(
57
56
  appuser,
58
57
  searchObject['filter'],
@@ -61,11 +60,7 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema> {
61
60
  searchObject['lookup'],
62
61
  searchObject['pagination'],
63
62
  );
64
-
65
- if (res && searchObject['pagination']) {
66
- const total = await this.service.getTotalCount(appuser, searchObject['filter'] || {});
67
- this.service.setPaginationHeaders(res, total, searchObject['pagination']);
68
- }
63
+
69
64
  return items;
70
65
  }
71
66
 
@@ -413,15 +413,15 @@ export class SimpleAppService<T extends SchemaFields> {
413
413
  if (total !== undefined && total !== null && pagination) {
414
414
  const { pageSize, pageNo } = this.buildPagination(pagination);
415
415
  const pageCount = pageSize > 0 && total > 0 ? Math.ceil(total / pageSize) : (total > 0 ? 1 : 0);
416
- res.setHeader('x-page-count', pageCount.toString());
417
- res.setHeader('x-page-size', pageSize.toString());
418
- res.setHeader('x-page-no', pageNo.toString());
419
- res.setHeader('x-total-count', total.toString());
416
+ res.setHeader('x-page-count', pageCount);
417
+ res.setHeader('x-page-size', pageSize);
418
+ res.setHeader('x-page-no', pageNo);
419
+ res.setHeader('x-total-count', total);
420
420
  } else {
421
- res.setHeader('x-page-count', '0');
422
- res.setHeader('x-page-size', '0');
423
- res.setHeader('x-page-no', '0');
424
- res.setHeader('x-total-count', '0');
421
+ res.setHeader('x-page-count', 0);
422
+ res.setHeader('x-page-size', 0);
423
+ res.setHeader('x-page-no', 0);
424
+ res.setHeader('x-total-count', 0);
425
425
  }
426
426
  }
427
427
 
@@ -54,9 +54,9 @@ onMounted(async()=>{
54
54
  const currentgroup = useCookie('currentGroup').value
55
55
  //if no xorg, no enforce pick group
56
56
  if(getCurrentXorg()===''){
57
- goTo('picktenant')
57
+ navigateTo('/picktenant')
58
58
  }else if(!currentgroup){
59
- navigateTo('/pickgroup')
59
+ goTo('/pickgroup')
60
60
  }
61
61
  setGraphqlServer()
62
62
  }else{
@@ -1,9 +1,9 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { ShallowRef } from "vue";
3
- import { Customfield, CUSTOMFIELDApi } from "~/simpleapp/generate/openapi";
3
+ import { CustomField, CUSTOMFIELDApi } from "~/simpleapp/generate/openapi";
4
4
 
5
5
  type CustomFieldStoreData = Pick<
6
- Customfield,
6
+ CustomField,
7
7
  "_id" | "collectionName" | "form" | "list"
8
8
  >[];
9
9
 
@@ -79,6 +79,10 @@ export type SearchBody = {
79
79
 
80
80
  sorts?: any[];
81
81
  lookup?: { [key: string]: string };
82
+ pagination?: {
83
+ pageSize?: number;
84
+ pageNo?: number;
85
+ };
82
86
  };
83
87
 
84
88
  export type DynamicObject = {