Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 2681596

Browse files
fix(footer): custom footer metric texts could not be changed, fixes #470 (#472)
- fixes #470 Co-authored-by: Ghislain Beaulac <[email protected]>
1 parent 92bf9e3 commit 2681596

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,45 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
13321332
});
13331333
});
13341334

1335+
it('should have a Custom Footer and custom texts when "showCustomFooter" is enabled with different metricTexts defined', (done) => {
1336+
const mockColDefs = [{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }];
1337+
1338+
component.gridOptions.enableTranslate = false;
1339+
component.gridOptions.showCustomFooter = true;
1340+
component.gridOptions.customFooterOptions = {
1341+
metricTexts: {
1342+
items: 'some items',
1343+
lastUpdate: 'some last update',
1344+
of: 'some of'
1345+
}
1346+
}
1347+
component.ngOnInit();
1348+
component.ngAfterViewInit();
1349+
component.columnDefinitions = mockColDefs;
1350+
1351+
setTimeout(() => {
1352+
expect(component.columnDefinitions).toEqual(mockColDefs);
1353+
expect(component.showCustomFooter).toBeTrue();
1354+
expect(component.customFooterOptions).toEqual({
1355+
dateFormat: 'yyyy-MM-dd hh:mm aaaaa\'m\'',
1356+
hideLastUpdateTimestamp: true,
1357+
hideTotalItemCount: false,
1358+
footerHeight: 20,
1359+
leftContainerClass: 'col-xs-12 col-sm-5',
1360+
metricSeparator: '|',
1361+
metricTexts: {
1362+
items: 'some items',
1363+
itemsKey: 'ITEMS',
1364+
lastUpdate: 'some last update',
1365+
of: 'some of',
1366+
ofKey: 'OF',
1367+
},
1368+
rightContainerClass: 'col-xs-6 col-sm-7',
1369+
});
1370+
done();
1371+
});
1372+
});
1373+
13351374
it('should NOT have a Custom Footer when "showCustomFooter" is enabled WITH Pagination in use', (done) => {
13361375
const mockColDefs = [{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }];
13371376

src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,14 +1010,14 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
10101010
*/
10111011
private optionallyShowCustomFooterWithMetrics() {
10121012
if (this.gridOptions) {
1013-
if ((this.gridOptions.enableTranslate || this.gridOptions.i18n)) {
1013+
if (this.gridOptions.enableTranslate) {
10141014
this.translateCustomFooterTexts();
10151015
} else if (this.gridOptions.customFooterOptions) {
10161016
const customFooterOptions = this.gridOptions.customFooterOptions;
10171017
customFooterOptions.metricTexts = customFooterOptions.metricTexts || {};
1018-
customFooterOptions.metricTexts.lastUpdate = this.locales && this.locales.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE';
1019-
customFooterOptions.metricTexts.items = this.locales && this.locales.TEXT_ITEMS || 'TEXT_ITEMS';
1020-
customFooterOptions.metricTexts.of = this.locales && this.locales.TEXT_OF || 'TEXT_OF';
1018+
customFooterOptions.metricTexts.lastUpdate = customFooterOptions.metricTexts.lastUpdate || this.locales && this.locales.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE';
1019+
customFooterOptions.metricTexts.items = customFooterOptions.metricTexts.items || this.locales && this.locales.TEXT_ITEMS || 'TEXT_ITEMS';
1020+
customFooterOptions.metricTexts.of = customFooterOptions.metricTexts.of || this.locales && this.locales.TEXT_OF || 'TEXT_OF';
10211021
}
10221022

10231023
// we will display the custom footer only when there's no Pagination

0 commit comments

Comments
 (0)