diff --git a/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts b/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts index 10d588f66..5b6c71139 100644 --- a/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts +++ b/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts @@ -1332,6 +1332,45 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () = }); }); + it('should have a Custom Footer and custom texts when "showCustomFooter" is enabled with different metricTexts defined', (done) => { + const mockColDefs = [{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }]; + + component.gridOptions.enableTranslate = false; + component.gridOptions.showCustomFooter = true; + component.gridOptions.customFooterOptions = { + metricTexts: { + items: 'some items', + lastUpdate: 'some last update', + of: 'some of' + } + } + component.ngOnInit(); + component.ngAfterViewInit(); + component.columnDefinitions = mockColDefs; + + setTimeout(() => { + expect(component.columnDefinitions).toEqual(mockColDefs); + expect(component.showCustomFooter).toBeTrue(); + expect(component.customFooterOptions).toEqual({ + dateFormat: 'yyyy-MM-dd hh:mm aaaaa\'m\'', + hideLastUpdateTimestamp: true, + hideTotalItemCount: false, + footerHeight: 20, + leftContainerClass: 'col-xs-12 col-sm-5', + metricSeparator: '|', + metricTexts: { + items: 'some items', + itemsKey: 'ITEMS', + lastUpdate: 'some last update', + of: 'some of', + ofKey: 'OF', + }, + rightContainerClass: 'col-xs-6 col-sm-7', + }); + done(); + }); + }); + it('should NOT have a Custom Footer when "showCustomFooter" is enabled WITH Pagination in use', (done) => { const mockColDefs = [{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }]; diff --git a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts index c9f235131..a548adc0a 100644 --- a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +++ b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts @@ -1010,14 +1010,14 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn */ private optionallyShowCustomFooterWithMetrics() { if (this.gridOptions) { - if ((this.gridOptions.enableTranslate || this.gridOptions.i18n)) { + if (this.gridOptions.enableTranslate) { this.translateCustomFooterTexts(); } else if (this.gridOptions.customFooterOptions) { const customFooterOptions = this.gridOptions.customFooterOptions; customFooterOptions.metricTexts = customFooterOptions.metricTexts || {}; - customFooterOptions.metricTexts.lastUpdate = this.locales && this.locales.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; - customFooterOptions.metricTexts.items = this.locales && this.locales.TEXT_ITEMS || 'TEXT_ITEMS'; - customFooterOptions.metricTexts.of = this.locales && this.locales.TEXT_OF || 'TEXT_OF'; + customFooterOptions.metricTexts.lastUpdate = customFooterOptions.metricTexts.lastUpdate || this.locales && this.locales.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; + customFooterOptions.metricTexts.items = customFooterOptions.metricTexts.items || this.locales && this.locales.TEXT_ITEMS || 'TEXT_ITEMS'; + customFooterOptions.metricTexts.of = customFooterOptions.metricTexts.of || this.locales && this.locales.TEXT_OF || 'TEXT_OF'; } // we will display the custom footer only when there's no Pagination