From a057864568984afea1a607a6f919214bfd549e70 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Wed, 24 Jul 2024 22:59:56 -0400 Subject: [PATCH] feat: Infinite Scroll for GraphQL Backend Service - add new Example 27 for GraphQL with Infinite Scroll demo --- .../src/app-routing.ts | 2 + .../vite-demo-vanilla-bundle/src/app.html | 3 + .../src/examples/example09.ts | 7 +- .../src/examples/example15.ts | 2 +- .../src/examples/example26.html | 1 - .../src/examples/example26.ts | 23 +- .../src/examples/example27.html | 69 ++++ .../src/examples/example27.scss | 8 + .../src/examples/example27.ts | 362 ++++++++++++++++++ .../interfaces/backendService.interface.ts | 2 +- .../interfaces/backendServiceApi.interface.ts | 17 +- .../src/services/backendUtility.service.ts | 2 +- .../graphqlPaginatedResult.interface.ts | 10 +- .../graphql/src/services/graphql.service.ts | 69 +++- .../components/slick-vanilla-grid-bundle.ts | 41 +- test/cypress/e2e/example27.cy.ts | 161 ++++++++ 16 files changed, 727 insertions(+), 52 deletions(-) create mode 100644 examples/vite-demo-vanilla-bundle/src/examples/example27.html create mode 100644 examples/vite-demo-vanilla-bundle/src/examples/example27.scss create mode 100644 examples/vite-demo-vanilla-bundle/src/examples/example27.ts create mode 100644 test/cypress/e2e/example27.cy.ts diff --git a/examples/vite-demo-vanilla-bundle/src/app-routing.ts b/examples/vite-demo-vanilla-bundle/src/app-routing.ts index aba400e9b..9a1c40a0e 100644 --- a/examples/vite-demo-vanilla-bundle/src/app-routing.ts +++ b/examples/vite-demo-vanilla-bundle/src/app-routing.ts @@ -27,6 +27,7 @@ import Example23 from './examples/example23'; import Example24 from './examples/example24'; import Example25 from './examples/example25'; import Example26 from './examples/example26'; +import Example27 from './examples/example27'; export class AppRouting { constructor(private config: RouterConfig) { @@ -59,6 +60,7 @@ export class AppRouting { { route: 'example24', name: 'example24', view: './examples/example24.html', viewModel: Example24, title: 'Example24', }, { route: 'example25', name: 'example25', view: './examples/example25.html', viewModel: Example25, title: 'Example25', }, { route: 'example26', name: 'example26', view: './examples/example26.html', viewModel: Example26, title: 'Example26', }, + { route: 'example27', name: 'example27', view: './examples/example27.html', viewModel: Example27, title: 'Example27', }, { route: '', redirect: 'example01' }, { route: '**', redirect: 'example01' } ]; diff --git a/examples/vite-demo-vanilla-bundle/src/app.html b/examples/vite-demo-vanilla-bundle/src/app.html index e8f257cac..0c852df25 100644 --- a/examples/vite-demo-vanilla-bundle/src/app.html +++ b/examples/vite-demo-vanilla-bundle/src/app.html @@ -114,6 +114,9 @@

Slickgrid-Universal

Example26 - OData with Infinite Scroll + + Example27 - GraphQL with Infinite Scroll + diff --git a/examples/vite-demo-vanilla-bundle/src/examples/example09.ts b/examples/vite-demo-vanilla-bundle/src/examples/example09.ts index ea6930db9..37c31726f 100644 --- a/examples/vite-demo-vanilla-bundle/src/examples/example09.ts +++ b/examples/vite-demo-vanilla-bundle/src/examples/example09.ts @@ -100,7 +100,10 @@ export default class Example09 { } }, { id: 'company', name: 'Company', field: 'company', filterable: true, sortable: true }, - { id: 'category_name', name: 'Category', field: 'category/name', filterable: true, sortable: true } + { + id: 'category_name', name: 'Category', field: 'category/name', filterable: true, sortable: true, + formatter: (row, cell, val, colDef, dataContext) => dataContext['category']?.['name'] || '' + } ]; this.gridOptions = { @@ -190,7 +193,7 @@ export default class Example09 { getCustomerCallback(data) { // totalItems property needs to be filled for pagination to work correctly - // however we need to force Aurelia to do a dirty check, doing a clone object will do just that + // however we need to force a dirty check, doing a clone object will do just that let totalItemCount: number = data['totalRecordCount']; // you can use "totalRecordCount" or any name or "odata.count" when "enableCount" is set if (this.isCountEnabled) { totalItemCount = (this.odataVersion === 4) ? data['@odata.count'] : data['d']['__count']; diff --git a/examples/vite-demo-vanilla-bundle/src/examples/example15.ts b/examples/vite-demo-vanilla-bundle/src/examples/example15.ts index 95b41222b..c7903089f 100644 --- a/examples/vite-demo-vanilla-bundle/src/examples/example15.ts +++ b/examples/vite-demo-vanilla-bundle/src/examples/example15.ts @@ -223,7 +223,7 @@ export default class Example15 { getCustomerCallback(data) { // totalItems property needs to be filled for pagination to work correctly - // however we need to force Aurelia to do a dirty check, doing a clone object will do just that + // however we need to force a dirty check, doing a clone object will do just that let countPropName = 'totalRecordCount'; // you can use "totalRecordCount" or any name or "odata.count" when "enableCount" is set if (this.isCountEnabled) { countPropName = (this.odataVersion === 4) ? '@odata.count' : 'odata.count'; diff --git a/examples/vite-demo-vanilla-bundle/src/examples/example26.html b/examples/vite-demo-vanilla-bundle/src/examples/example26.html index 6abc82bd8..01668bc01 100644 --- a/examples/vite-demo-vanilla-bundle/src/examples/example26.html +++ b/examples/vite-demo-vanilla-bundle/src/examples/example26.html @@ -1,5 +1,4 @@
-

Example 26 - OData (v4) Backend Service with Infinite Scroll