@slickgrid-universal/custom-footer-component
Advanced tools
Comparing version 5.11.0 to 5.12.0
@@ -56,4 +56,4 @@ "use strict"; | ||
this._enableTranslate = this.gridOptions?.enableTranslate ?? false; | ||
this._isLeftFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.leftFooterText); | ||
this._isRightFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.rightFooterText); | ||
this._isLeftFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.leftFooterText; | ||
this._isRightFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.rightFooterText; | ||
this.registerOnSelectedRowsChangedWhenEnabled(customFooterOptions); | ||
@@ -125,5 +125,7 @@ if (this._enableTranslate && (!this.translaterService || !this.translaterService.translate)) { | ||
this.customFooterOptions.metricTexts = this.customFooterOptions.metricTexts || {}; | ||
this.customFooterOptions.metricTexts.lastUpdate = this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.lastUpdate = | ||
this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.items = this.customFooterOptions.metricTexts.items || this.locales?.TEXT_ITEMS || 'TEXT_ITEMS'; | ||
this.customFooterOptions.metricTexts.itemsSelected = this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.itemsSelected = | ||
this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.of = this.customFooterOptions.metricTexts.of || this.locales?.TEXT_OF || 'TEXT_OF'; | ||
@@ -142,3 +144,3 @@ } | ||
height: `${this.customFooterOptions.footerHeight || 20}px`, | ||
} | ||
}, | ||
}); | ||
@@ -156,3 +158,5 @@ const leftFooterElm = (0, common_1.createDomElement)('div', { className: `left-footer ${this.customFooterOptions.leftContainerClass}` }); | ||
createFooterRightContainer() { | ||
const rightFooterElm = (0, common_1.createDomElement)('div', { className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}` }); | ||
const rightFooterElm = (0, common_1.createDomElement)('div', { | ||
className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}`, | ||
}); | ||
if (!this._isRightFooterOriginallyEmpty) { | ||
@@ -183,3 +187,6 @@ this.grid.applyHtmlCode(rightFooterElm, this.customFooterOptions.rightFooterText); | ||
rightFooterElm.appendChild(document.createTextNode('\r\n')); | ||
rightFooterElm.appendChild((0, common_1.createDomElement)('span', { className: 'text-items', textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} ` })); | ||
rightFooterElm.appendChild((0, common_1.createDomElement)('span', { | ||
className: 'text-items', | ||
textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} `, | ||
})); | ||
} | ||
@@ -192,2 +199,3 @@ return rightFooterElm; | ||
const lastUpdateText = this.customFooterOptions?.metricTexts?.lastUpdate ?? 'Last Update'; | ||
// prettier-ignore | ||
const lastUpdateTimestamp = this.metrics?.endTime ? (0, tempo_1.format)(this.metrics?.endTime, this.customFooterOptions.dateFormat, 'en-US') : ''; | ||
@@ -208,3 +216,3 @@ const lastUpdateContainerElm = (0, common_1.createDomElement)('span'); | ||
const isRowSelectionEnabled = this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection; | ||
if (isRowSelectionEnabled && customFooterOptions && (!customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty)) { | ||
if (isRowSelectionEnabled && customFooterOptions && !customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty) { | ||
this._isLeftFooterDisplayingSelectionRowCount = true; | ||
@@ -211,0 +219,0 @@ const selectedCountText = customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; |
import { format } from '@formkit/tempo'; | ||
import { Constants, createDomElement, SlickEventHandler, } from '@slickgrid-universal/common'; | ||
import { Constants, createDomElement, SlickEventHandler } from '@slickgrid-universal/common'; | ||
import {} from '@slickgrid-universal/event-pub-sub'; | ||
@@ -54,4 +54,4 @@ import { BindingHelper } from '@slickgrid-universal/binding'; | ||
this._enableTranslate = this.gridOptions?.enableTranslate ?? false; | ||
this._isLeftFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.leftFooterText); | ||
this._isRightFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.rightFooterText); | ||
this._isLeftFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.leftFooterText; | ||
this._isRightFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.rightFooterText; | ||
this.registerOnSelectedRowsChangedWhenEnabled(customFooterOptions); | ||
@@ -123,5 +123,7 @@ if (this._enableTranslate && (!this.translaterService || !this.translaterService.translate)) { | ||
this.customFooterOptions.metricTexts = this.customFooterOptions.metricTexts || {}; | ||
this.customFooterOptions.metricTexts.lastUpdate = this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.lastUpdate = | ||
this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.items = this.customFooterOptions.metricTexts.items || this.locales?.TEXT_ITEMS || 'TEXT_ITEMS'; | ||
this.customFooterOptions.metricTexts.itemsSelected = this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.itemsSelected = | ||
this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.of = this.customFooterOptions.metricTexts.of || this.locales?.TEXT_OF || 'TEXT_OF'; | ||
@@ -140,3 +142,3 @@ } | ||
height: `${this.customFooterOptions.footerHeight || 20}px`, | ||
} | ||
}, | ||
}); | ||
@@ -154,3 +156,5 @@ const leftFooterElm = createDomElement('div', { className: `left-footer ${this.customFooterOptions.leftContainerClass}` }); | ||
createFooterRightContainer() { | ||
const rightFooterElm = createDomElement('div', { className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}` }); | ||
const rightFooterElm = createDomElement('div', { | ||
className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}`, | ||
}); | ||
if (!this._isRightFooterOriginallyEmpty) { | ||
@@ -181,3 +185,6 @@ this.grid.applyHtmlCode(rightFooterElm, this.customFooterOptions.rightFooterText); | ||
rightFooterElm.appendChild(document.createTextNode('\r\n')); | ||
rightFooterElm.appendChild(createDomElement('span', { className: 'text-items', textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} ` })); | ||
rightFooterElm.appendChild(createDomElement('span', { | ||
className: 'text-items', | ||
textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} `, | ||
})); | ||
} | ||
@@ -190,2 +197,3 @@ return rightFooterElm; | ||
const lastUpdateText = this.customFooterOptions?.metricTexts?.lastUpdate ?? 'Last Update'; | ||
// prettier-ignore | ||
const lastUpdateTimestamp = this.metrics?.endTime ? format(this.metrics?.endTime, this.customFooterOptions.dateFormat, 'en-US') : ''; | ||
@@ -206,3 +214,3 @@ const lastUpdateContainerElm = createDomElement('span'); | ||
const isRowSelectionEnabled = this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection; | ||
if (isRowSelectionEnabled && customFooterOptions && (!customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty)) { | ||
if (isRowSelectionEnabled && customFooterOptions && !customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty) { | ||
this._isLeftFooterDisplayingSelectionRowCount = true; | ||
@@ -209,0 +217,0 @@ const selectedCountText = customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; |
{ | ||
"name": "@slickgrid-universal/custom-footer-component", | ||
"version": "5.11.0", | ||
"version": "5.12.0", | ||
"description": "Slick Custom Footer Component - Vanilla Implementation of a Custom Footer Component", | ||
@@ -42,6 +42,6 @@ "main": "./dist/cjs/index.js", | ||
"@formkit/tempo": "^0.1.2", | ||
"@slickgrid-universal/binding": "~5.10.2", | ||
"@slickgrid-universal/common": "~5.11.0" | ||
"@slickgrid-universal/binding": "~5.12.0", | ||
"@slickgrid-universal/common": "~5.12.0" | ||
}, | ||
"gitHead": "894ab0a2783d6f7c4cb9d28d4b81421eb9e05a89" | ||
"gitHead": "d7e892ebc1727d7c83cc1e5cc80db8302eef4f63" | ||
} |
@@ -12,3 +12,3 @@ import { format } from '@formkit/tempo'; | ||
} from '@slickgrid-universal/common'; | ||
import { Constants, createDomElement, SlickEventHandler, } from '@slickgrid-universal/common'; | ||
import { Constants, createDomElement, SlickEventHandler } from '@slickgrid-universal/common'; | ||
import { type BasePubSubService } from '@slickgrid-universal/event-pub-sub'; | ||
@@ -68,3 +68,8 @@ import { BindingHelper } from '@slickgrid-universal/binding'; | ||
constructor(protected readonly grid: SlickGrid, protected readonly customFooterOptions: CustomFooterOption, protected readonly pubSubService: BasePubSubService, protected readonly translaterService?: TranslaterService | undefined) { | ||
constructor( | ||
protected readonly grid: SlickGrid, | ||
protected readonly customFooterOptions: CustomFooterOption, | ||
protected readonly pubSubService: BasePubSubService, | ||
protected readonly translaterService?: TranslaterService | undefined | ||
) { | ||
this._bindingHelper = new BindingHelper(); | ||
@@ -74,8 +79,10 @@ this._bindingHelper.querySelectorPrefix = `.${this.gridUid} `; | ||
this._enableTranslate = this.gridOptions?.enableTranslate ?? false; | ||
this._isLeftFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.leftFooterText); | ||
this._isRightFooterOriginallyEmpty = !(this.gridOptions.customFooterOptions?.rightFooterText); | ||
this._isLeftFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.leftFooterText; | ||
this._isRightFooterOriginallyEmpty = !this.gridOptions.customFooterOptions?.rightFooterText; | ||
this.registerOnSelectedRowsChangedWhenEnabled(customFooterOptions); | ||
if (this._enableTranslate && (!this.translaterService || !this.translaterService.translate)) { | ||
throw new Error('[Slickgrid-Universal] requires a Translate Service to be installed and configured when the grid option "enableTranslate" is enabled.'); | ||
throw new Error( | ||
'[Slickgrid-Universal] requires a Translate Service to be installed and configured when the grid option "enableTranslate" is enabled.' | ||
); | ||
} | ||
@@ -86,5 +93,3 @@ this.translateCustomFooterTexts(); | ||
const translateEventName = this.translaterService?.eventName ?? 'onLanguageChange'; | ||
this._subscriptions.push( | ||
this.pubSubService.subscribe(translateEventName, () => this.translateCustomFooterTexts()) | ||
); | ||
this._subscriptions.push(this.pubSubService.subscribe(translateEventName, () => this.translateCustomFooterTexts())); | ||
} | ||
@@ -147,3 +152,5 @@ } | ||
const propNameWithoutKey = propName.substring(0, propName.lastIndexOf('Key')); | ||
this.customFooterOptions.metricTexts[propNameWithoutKey as keyof MetricTexts] = this.translaterService.translate(this.customFooterOptions.metricTexts[propName as keyof MetricTexts] || ' '); | ||
this.customFooterOptions.metricTexts[propNameWithoutKey as keyof MetricTexts] = this.translaterService.translate( | ||
this.customFooterOptions.metricTexts[propName as keyof MetricTexts] || ' ' | ||
); | ||
} | ||
@@ -158,5 +165,7 @@ } | ||
this.customFooterOptions.metricTexts = this.customFooterOptions.metricTexts || {}; | ||
this.customFooterOptions.metricTexts.lastUpdate = this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.lastUpdate = | ||
this.customFooterOptions.metricTexts.lastUpdate || this.locales?.TEXT_LAST_UPDATE || 'TEXT_LAST_UPDATE'; | ||
this.customFooterOptions.metricTexts.items = this.customFooterOptions.metricTexts.items || this.locales?.TEXT_ITEMS || 'TEXT_ITEMS'; | ||
this.customFooterOptions.metricTexts.itemsSelected = this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.itemsSelected = | ||
this.customFooterOptions.metricTexts.itemsSelected || this.locales?.TEXT_ITEMS_SELECTED || 'TEXT_ITEMS_SELECTED'; | ||
this.customFooterOptions.metricTexts.of = this.customFooterOptions.metricTexts.of || this.locales?.TEXT_OF || 'TEXT_OF'; | ||
@@ -177,3 +186,3 @@ } | ||
height: `${this.customFooterOptions.footerHeight || 20}px`, | ||
} | ||
}, | ||
}); | ||
@@ -194,3 +203,5 @@ | ||
protected createFooterRightContainer(): HTMLDivElement { | ||
const rightFooterElm = createDomElement('div', { className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}` }); | ||
const rightFooterElm = createDomElement('div', { | ||
className: `right-footer ${this.customFooterOptions.rightContainerClass || ''}`, | ||
}); | ||
@@ -211,5 +222,3 @@ if (!this._isRightFooterOriginallyEmpty) { | ||
// last update elements | ||
rightFooterElm.appendChild( | ||
createDomElement('span', { className: 'item-count', textContent: `${this.metrics?.itemCount ?? '0'}` }) | ||
); | ||
rightFooterElm.appendChild(createDomElement('span', { className: 'item-count', textContent: `${this.metrics?.itemCount ?? '0'}` })); | ||
@@ -234,3 +243,6 @@ // total count element (unless hidden) | ||
rightFooterElm.appendChild( | ||
createDomElement('span', { className: 'text-items', textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} ` }) | ||
createDomElement('span', { | ||
className: 'text-items', | ||
textContent: ` ${this.customFooterOptions.metricTexts?.items ?? 'items'} `, | ||
}) | ||
); | ||
@@ -246,2 +258,3 @@ } | ||
const lastUpdateText = this.customFooterOptions?.metricTexts?.lastUpdate ?? 'Last Update'; | ||
// prettier-ignore | ||
const lastUpdateTimestamp = this.metrics?.endTime ? format(this.metrics?.endTime, this.customFooterOptions.dateFormat, 'en-US') : ''; | ||
@@ -253,3 +266,5 @@ const lastUpdateContainerElm = createDomElement('span'); | ||
lastUpdateContainerElm.appendChild(createDomElement('span', { className: 'last-update-timestamp', textContent: lastUpdateTimestamp })); | ||
lastUpdateContainerElm.appendChild(createDomElement('span', { className: 'separator', textContent: ` ${this.customFooterOptions.metricSeparator || ''} ` })); | ||
lastUpdateContainerElm.appendChild( | ||
createDomElement('span', { className: 'separator', textContent: ` ${this.customFooterOptions.metricSeparator || ''} ` }) | ||
); | ||
@@ -266,5 +281,6 @@ return lastUpdateContainerElm; | ||
const isRowSelectionEnabled = this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection; | ||
if (isRowSelectionEnabled && customFooterOptions && (!customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty)) { | ||
if (isRowSelectionEnabled && customFooterOptions && !customFooterOptions.hideRowSelectionCount && this._isLeftFooterOriginallyEmpty) { | ||
this._isLeftFooterDisplayingSelectionRowCount = true; | ||
const selectedCountText = customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; | ||
const selectedCountText = | ||
customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; | ||
customFooterOptions.leftFooterText = `0 ${selectedCountText}`; | ||
@@ -274,3 +290,4 @@ | ||
this._selectedRowCount = args.rows.length; | ||
const selectedCountText2 = customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; | ||
const selectedCountText2 = | ||
customFooterOptions.metricTexts?.itemsSelected ?? this.locales?.TEXT_ITEMS_SELECTED ?? 'TEXT_ITEMS_SELECTED'; | ||
this.leftFooterText = `${this._selectedRowCount} ${selectedCountText2}`; | ||
@@ -277,0 +294,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
162351
764
+ Added@slickgrid-universal/binding@5.12.2(transitive)
+ Added@slickgrid-universal/common@5.12.2(transitive)
+ Added@slickgrid-universal/event-pub-sub@5.12.2(transitive)
+ Added@slickgrid-universal/utils@5.12.0(transitive)
- Removed@slickgrid-universal/binding@5.10.2(transitive)
- Removed@slickgrid-universal/common@5.11.0(transitive)
- Removed@slickgrid-universal/event-pub-sub@5.10.2(transitive)
- Removed@slickgrid-universal/utils@5.10.2(transitive)