From d7f0ec922448939774d09b1a9eeb5d4201551dda Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 15 Jul 2024 09:59:49 +0200 Subject: [PATCH] fix: replace deprecated mx logger --- .../components/CheckBoxFilterContainer.ts | 2 +- .../components/DropDownFilterContainer.ts | 2 +- .../components/DropDownSortContainer.ts | 2 +- .../components/PaginationContainer.ts | 30 +++++++++---------- src/Pagination/utils/ContainerUtils.ts | 8 ++--- .../DataSourceHelper/DataSourceHelper.ts | 18 +++++------ src/Shared/FormViewState.ts | 2 +- src/Shared/ListViewPrototype.ts | 10 +++---- tslint.json | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/CheckBoxFilter/components/CheckBoxFilterContainer.ts b/src/CheckBoxFilter/components/CheckBoxFilterContainer.ts index eeaed979..009f6f66 100644 --- a/src/CheckBoxFilter/components/CheckBoxFilterContainer.ts +++ b/src/CheckBoxFilter/components/CheckBoxFilterContainer.ts @@ -127,7 +127,7 @@ export default class CheckboxFilterContainer extends Component 0) { const { offset, pageSize } = this.state; - mx.logger.debug(this.props.uniqueid, ".renderPageButton pagesize, offset, listsize", pageSize, offset, this.state.targetListView!._datasource.getSetSize()); + console.debug(this.props.uniqueid, ".renderPageButton pagesize, offset, listsize", pageSize, offset, this.state.targetListView!._datasource.getSetSize()); return createElement(Pagination, { getMessageStatus: this.translateMessageStatus, @@ -152,7 +152,7 @@ class PaginationContainer extends Component { - mx.logger.debug(this.props.uniqueid, "_renderData.before"); + console.debug(this.props.uniqueid, "_renderData.before"); const datasource = targetListView._datasource; if (datasource.getSetSize() === 0) { @@ -229,7 +229,7 @@ class PaginationContainer extends Component { - mx.logger.debug(this.props.uniqueid, "_renderData.after"); + console.debug(this.props.uniqueid, "_renderData.after"); resetListViewHeight(targetListView.domNode as HTMLElement); }); } diff --git a/src/Pagination/utils/ContainerUtils.ts b/src/Pagination/utils/ContainerUtils.ts index 6ef27c3c..67e8a34d 100644 --- a/src/Pagination/utils/ContainerUtils.ts +++ b/src/Pagination/utils/ContainerUtils.ts @@ -44,7 +44,7 @@ export const getListNode = (targetNode: HTMLElement): HTMLUListElement => { }; export const setListNodeToEmpty = (targetNode: HTMLElement) => { - mx.logger.debug("setListNodeToEmpty"); + console.debug("setListNodeToEmpty"); // Explicitly remove children as IE does not like listNode.innerHTML = ""; const listNode = targetNode.querySelector("ul") as HTMLUListElement; while (listNode.firstChild) { @@ -53,12 +53,12 @@ export const setListNodeToEmpty = (targetNode: HTMLElement) => { }; export const showLoader = (targetListView: DataSourceHelperListView) => { - mx.logger.debug("showLoader"); + console.debug("showLoader"); targetListView.domNode.classList.add("widget-pagination-loading"); }; export const hideLoader = (targetListView: DataSourceHelperListView) => { - mx.logger.debug("hideLoader"); + console.debug("hideLoader"); targetListView.domNode.classList.remove("widget-pagination-loading"); }; @@ -84,6 +84,6 @@ export const getTranslations = async (): Promise => { const localeIndex = metadataJson.languages.indexOf(localeCode); window.__widgets_translations = Object.keys(systemTexts).reduce((translations, currentKey) => ({ ...translations, [currentKey]: systemTexts[currentKey][localeIndex] }), {}); } else { - mx.logger.error("Error while loading translations"); + console.error("Error while loading translations"); } }; diff --git a/src/Shared/DataSourceHelper/DataSourceHelper.ts b/src/Shared/DataSourceHelper/DataSourceHelper.ts index d6c3a718..643c0118 100644 --- a/src/Shared/DataSourceHelper/DataSourceHelper.ts +++ b/src/Shared/DataSourceHelper/DataSourceHelper.ts @@ -48,7 +48,7 @@ export class DataSourceHelper { this.originalSort = window.mx.isOffline() ? this.widget._datasource._sort : this.widget._datasource._sorting; aspect.after(widget, "storeState", (store: (key: string, value: any) => void) => { - mx.logger.debug("after storeState"); + console.debug("after storeState"); if (widget.__customWidgetDataSourceHelper) { const sorting = widget.__customWidgetDataSourceHelper.sorting.length > 0 ? widget.__customWidgetDataSourceHelper.sorting : widget.__customWidgetDataSourceHelper.originalSort; store("lvcSorting", sorting); @@ -99,13 +99,13 @@ export class DataSourceHelper { } private registerUpdate(restoreState: boolean) { - mx.logger.debug("DataSourceHelper .registerUpdate"); + console.debug("DataSourceHelper .registerUpdate"); if (this.timeoutHandle) { window.clearTimeout(this.timeoutHandle); } if (!this.updateInProgress) { this.timeoutHandle = window.setTimeout(() => { - mx.logger.debug("DataSourceHelper .execute"); + console.debug("DataSourceHelper .execute"); this.updateInProgress = true; // TODO Check if there's currently no update happening on the listView coming from another // Feature/functionality/widget which does not use DataSourceHelper @@ -216,12 +216,12 @@ export class DataSourceHelper { } else { this.widget._datasource._sorting = sorting; } - mx.logger.debug("DataSourceHelper .set sort and constraint"); + console.debug("DataSourceHelper .set sort and constraint"); const offset = this.widget._datasource.getOffset(); const pageSize = this.widget._datasource.getPageSize(); if (!this.widget.__lvcPagingEnabled && offset > 0) { // In case load more is used, the data source have to reload the full content - mx.logger.debug("reset offset"); + console.debug("reset offset"); this.widget._datasource.setOffset(0); this.widget._datasource.setPageSize(pageSize + offset); } @@ -230,9 +230,9 @@ export class DataSourceHelper { } this.widget.update(null, () => { - mx.logger.debug("DataSourceHelper .updated"); + console.debug("DataSourceHelper .updated"); if (!this.widget.__lvcPagingEnabled && offset > 0) { - mx.logger.debug("restore offset"); + console.debug("restore offset"); // Restore the original paging and offset for load more. this.widget._datasource.setOffset(offset); this.widget._datasource.setPageSize(pageSize); @@ -292,13 +292,13 @@ export class DataSourceHelper { }; if (changed) { - mx.logger.debug(".updateDatasource changed", offset, pageSize); + console.debug(".updateDatasource changed", offset, pageSize); this.widget.__customWidgetPagingLoading = true; this.showLoader(); this.widget.sequence([ "_sourceReload", "_renderData" ], () => { this.widget.__customWidgetPagingLoading = false; resetListViewHeight(this.widget.domNode); - mx.logger.debug(".updateDatasource updated"); + console.debug(".updateDatasource updated"); this.hideLoader(); }); } diff --git a/src/Shared/FormViewState.ts b/src/Shared/FormViewState.ts index ce73d297..5f243506 100644 --- a/src/Shared/FormViewState.ts +++ b/src/Shared/FormViewState.ts @@ -14,7 +14,7 @@ export class FormViewState { const mxform = this.form; const widgetViewState = mxform && mxform.viewState ? mxform.viewState[this.widgetId] : void 0; const state = widgetViewState && widgetViewState[key] !== undefined ? widgetViewState[key] : defaultValue; - mx.logger.debug("getPageState", this.widgetId, key, defaultValue, state); + console.debug("getPageState", this.widgetId, key, defaultValue, state); return state; } diff --git a/src/Shared/ListViewPrototype.ts b/src/Shared/ListViewPrototype.ts index 42241e36..df72d4a6 100644 --- a/src/Shared/ListViewPrototype.ts +++ b/src/Shared/ListViewPrototype.ts @@ -14,7 +14,7 @@ import { v4 as uuid } from "uuid"; ListView.prototype.__lvcPrototypeUpdated = true; ListView.prototype.__postCreateOriginal = ListView.prototype.postCreate; ListView.prototype.postCreate = function(this: DataSourceHelperListView) { - mx.logger.debug("list view control, overwrites postCreate prototype"); + console.debug("list view control, overwrites postCreate prototype"); this.__postCreateOriginal(); if (!listviewInstanceCompatible(this)) return; @@ -41,7 +41,7 @@ import { v4 as uuid } from "uuid"; ListView.prototype.__loadDataOriginal = ListView.prototype._loadData; ListView.prototype._loadData = function(this: DataSourceHelperListView, callback: () => void) { - mx.logger.debug("List view control, overwrites _loadData prototype"); + console.debug("List view control, overwrites _loadData prototype"); if (!listviewInstanceCompatible(this)) { this.__loadDataOriginal(callback); return; @@ -78,7 +78,7 @@ import { v4 as uuid } from "uuid"; }); }; } else { - mx.logger.debug("Prototype update called unexpected again"); + console.debug("Prototype update called unexpected again"); } function listviewPrototypeCompatible(listview: DataSourceHelperListView) { @@ -90,7 +90,7 @@ import { v4 as uuid } from "uuid"; && listview._renderData ); if (!compatible) { - mx.logger.error("This Mendix version is not compatible with list view controls. The List view prototype could not be updated."); + console.error("This Mendix version is not compatible with list view controls. The List view prototype could not be updated."); } return compatible; } @@ -113,7 +113,7 @@ import { v4 as uuid } from "uuid"; && listview._datasource.getOffset ); if (!compatible) { - mx.logger.error("This Mendix version is not compatible with list view controls. The List view controls use is limited."); + console.error("This Mendix version is not compatible with list view controls. The List view controls use is limited."); } return compatible; } diff --git a/tslint.json b/tslint.json index 8f5721a2..ad8ec2f6 100644 --- a/tslint.json +++ b/tslint.json @@ -22,7 +22,7 @@ "no-bitwise": true, "no-conditional-assignment": true, "no-console": [ - true + false ], "no-debugger": true, "no-duplicate-variable": true,