Skip to content

Commit e742c79

Browse files
author
JelteMX
committed
Update widget to 2.3.1 - fix MX9
1 parent cf734ae commit e742c79

File tree

6 files changed

+66
-70
lines changed

6 files changed

+66
-70
lines changed

package-lock.json

Lines changed: 11 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mxtreetable",
33
"widgetName": "MxTreeTable",
4-
"version": "2.3.0",
4+
"version": "2.3.1",
55
"description": "TreeTable widget",
66
"copyright": "Mendix 2019",
77
"author": "Jelte Lagendijk <jelte.lagendijk@mendix.com>",
@@ -53,7 +53,7 @@
5353
"webpack-bundle-analyzer": "^3.6.0"
5454
},
5555
"dependencies": {
56-
"@jeltemx/mendix-react-widget-utils": "^0.7.0",
56+
"@jeltemx/mendix-react-widget-utils": "^0.9.0",
5757
"antd": "^4.8.5",
5858
"array-to-tree": "^3.3.2",
5959
"big.js": "^5.2.2",

src/MxTreeTable.tsx

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Component, ReactNode, createElement } from "react";
2-
import { hot } from "react-hot-loader/root";
1+
import { Component, ReactNode, createElement, createRef } from "react";
32
import { findDOMNode } from "react-dom";
43
import { observer } from "mobx-react";
54
import store from "store2";
@@ -17,7 +16,8 @@ import {
1716
createObject,
1817
OpenPageAs,
1918
entityIsPersistable,
20-
executeAction
19+
executeAction,
20+
debug
2121
} from "@jeltemx/mendix-react-widget-utils";
2222

2323
import { NodeStore, NodeStoreConstructorOptions } from "./store";
@@ -48,6 +48,8 @@ export interface TransformNanoflows {
4848

4949
@observer
5050
class MxTreeTable extends Component<MxTreeTableContainerProps> {
51+
ref = createRef<HTMLDivElement>();
52+
5153
private store: NodeStore;
5254
private widgetId?: string;
5355

@@ -150,26 +152,39 @@ class MxTreeTable extends Component<MxTreeTableContainerProps> {
150152
this.store = new NodeStore(storeOpts);
151153

152154
// @ts-ignore
153-
window._STORE = this.store;
155+
// window._STORE = this.store;
154156
}
155157

156158
// **********************
157159
// DEFAULT REACT METHODS
158160
// **********************
159161

160-
componentDidUpdate(): void {
161-
if (this.widgetId) {
162-
const domNode = findDOMNode(this);
163-
// @ts-ignore
164-
domNode.setAttribute("widgetId", this.widgetId);
165-
}
166-
}
162+
// componentDidUpdate(): void {
163+
// // if (this.widgetId && this.ref.current) {
164+
// // try {
165+
// // const domNode = findDOMNode(this);
166+
// // // @ts-ignore
167+
// // domNode.setAttribute("widgetId", this.widgetId);
168+
// // } catch (error) {
169+
// // const domNode = findDOMNode(this.ref.current);
170+
// // // @ts-ignore
171+
// // domNode.setAttribute("widgetId", this.widgetId);
172+
// // }
173+
// // }
174+
// }
167175

168176
componentWillReceiveProps(nextProps: MxTreeTableContainerProps): void {
169-
if (!this.widgetId) {
170-
const domNode = findDOMNode(this);
171-
// @ts-ignore
172-
this.widgetId = domNode.getAttribute("widgetId") || undefined;
177+
if (!this.widgetId && this.ref.current) {
178+
try {
179+
const domNode = findDOMNode(this);
180+
// @ts-ignore
181+
this.widgetId = domNode.getAttribute("widgetId") || undefined;
182+
} catch (error) {
183+
const domNode = findDOMNode(this.ref.current);
184+
// @ts-ignore
185+
const alternativeID = domNode.getAttribute("data-mendix-id") || undefined;
186+
this.widgetId = alternativeID;
187+
}
173188
}
174189

175190
if (nextProps.experimentalExposeSetSelected && this.store.contextObject) {
@@ -238,7 +253,7 @@ class MxTreeTable extends Component<MxTreeTableContainerProps> {
238253
);
239254
}
240255

241-
return createElement(TreeTable, {
256+
const treeTableProps = {
242257
store: this.store,
243258
className: this.props.class,
244259
expanderFunc: this.expanderFunction,
@@ -252,7 +267,13 @@ class MxTreeTable extends Component<MxTreeTableContainerProps> {
252267
clickToSelect: selectClickSelect,
253268
hideSelectBoxes: selectHideCheckboxes,
254269
renderExpandButton: this.props.loadScenario === "all" && this.props.uiRenderExpandButton
255-
});
270+
};
271+
272+
return (
273+
<div ref={this.ref}>
274+
<TreeTable {...treeTableProps} />
275+
</div>
276+
);
256277
}
257278

258279
// **********************
@@ -620,6 +641,13 @@ class MxTreeTable extends Component<MxTreeTableContainerProps> {
620641
if (!helperObject) {
621642
return;
622643
}
644+
645+
if (helperObject.isPersistable()) {
646+
this.debug(
647+
"Created helper object is persistable, please see the widget. This object should NOT be persistable"
648+
);
649+
}
650+
623651
const context = new window.mendix.lib.MxContext();
624652
context.setContext(helperObject.getEntity(), helperObject.getGuid());
625653

@@ -926,11 +954,9 @@ Your context object is of type "${contextEntity}". Please check the configuratio
926954
}
927955

928956
private _debug(...args: unknown[]): void {
929-
const id = this.props.friendlyId || this.widgetId;
930-
if (window.logger) {
931-
window.logger.debug(`${id}:`, ...args);
932-
}
957+
const id = this.props.friendlyId || this.widgetId || "mendix.treetable.TreeTable";
958+
debug(id, ...args);
933959
}
934960
}
935961

936-
export default hot(MxTreeTable);
962+
export default MxTreeTable;

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="MxTreeTable" version="2.3.0" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="MxTreeTable" version="2.3.1" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="MxTreeTable.xml"/>
66
</widgetFiles>

src/store/objects/row.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { observable, action, computed, flow, toJS } from "mobx";
22
import { RowObjectMxProperties } from "..";
33
import { TreeColumnProps } from "../../util/columns";
4-
import { getFormattedValue } from "@jeltemx/mendix-react-widget-utils";
4+
import { debug, getFormattedValue } from "@jeltemx/mendix-react-widget-utils";
55

66
export interface RowObjectOptions {
77
mxObject: mendix.lib.MxObject;
@@ -103,14 +103,10 @@ export class RowObject {
103103
const subscription = subscribe({
104104
guid: this._obj.getGuid(),
105105
callback: guid => {
106-
if (window.logger) {
107-
window.logger.debug(`TreeTable subscription fired row: ${guid}`, this._keyValCorePairs);
108-
}
106+
debug("treeTable store", `TreeTable subscription fired row: ${guid}`, this._keyValCorePairs);
109107
this._changeHandler(`${guid}`, removed => {
110108
if (removed) {
111-
if (window.logger) {
112-
window.logger.debug(`Removed row: ${guid}`);
113-
}
109+
debug("treeTable store", `Removed row: ${guid}`);
114110
} else {
115111
this.fixAttributes();
116112
}

src/util/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MxTreeTableContainerProps } from "../../typings/MxTreeTableProps";
22
import { ValidationMessage } from "@jeltemx/mendix-react-widget-utils/lib/validation";
33

44
export interface ExtraMXValidateProps {
5-
helperObjectPersistence?: boolean;
5+
helperObjectPersistence?: boolean | null;
66
}
77

88
export const validateProps = (

0 commit comments

Comments
 (0)