Skip to content

Commit a38e3e2

Browse files
committed
Fix listen to grid
1 parent a034b9f commit a38e3e2

9 files changed

Lines changed: 320 additions & 88 deletions

File tree

package-lock.json

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

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@
4545
"@types/enzyme-adapter-react-16": "^1.0.2",
4646
"@types/jasmine": "^3.3.1",
4747
"@types/karma": "^3.0.1",
48-
"@types/node": "^10.12.12",
49-
"@types/react": "^16.7.13",
48+
"@types/node": "^10.12.15",
49+
"@types/react": "^16.7.17",
5050
"@types/react-dom": "^16.0.11",
5151
"@types/react-select": "^1.3.0",
5252
"@types/webdriverio": "^4.13.0",
5353
"check-dependencies": "^1.0.1",
5454
"copy-webpack-plugin": "^4.6.0",
5555
"core-js": "^2.6.0",
5656
"css-loader": "^2.0.0",
57-
"enzyme": "^3.7.0",
57+
"enzyme": "^3.8.0",
5858
"enzyme-adapter-react-16": "^1.7.1",
5959
"extract-text-webpack-plugin": "^4.0.0-beta.0",
60-
"fork-ts-checker-webpack-plugin": "^0.5.0",
60+
"fork-ts-checker-webpack-plugin": "^0.5.2",
6161
"grunt": "^1.0.3",
6262
"grunt-check-dependencies": "^1.0.0",
6363
"grunt-contrib-clean": "^2.0.0",
@@ -79,14 +79,14 @@
7979
"karma-sourcemap-loader": "^0.3.7",
8080
"karma-spec-reporter": "0.0.32",
8181
"karma-webpack": "^3.0.5",
82-
"mendix-client": "^7.15.5",
83-
"mendix-widget-build-script": "^1.0.0-rc2",
82+
"mendix-client": "^7.15.6",
83+
"mendix-widget-build-script": "^1.0.3",
8484
"node-sass": "^4.11.0",
8585
"pre-commit": "^1.2.2",
86-
"raw-loader": "^0.5.1",
86+
"raw-loader": "^1.0.0",
8787
"react": "^16.6.3",
8888
"react-dom": "^16.6.3",
89-
"react-hot-loader": "^4.3.11",
89+
"react-hot-loader": "^4.6.0",
9090
"react-test-renderer": "^16.6.3",
9191
"remap-istanbul": "^0.12.0",
9292
"sass-loader": "^7.0.3",
@@ -99,7 +99,7 @@
9999
"typescript": "^3.2.2",
100100
"wdio-dot-reporter": "0.0.10",
101101
"wdio-jasmine-framework": "^0.3.8",
102-
"wdio-selenium-standalone-service": "0.0.11",
102+
"wdio-selenium-standalone-service": "0.0.12",
103103
"wdio-spec-reporter": "^0.1.3",
104104
"webdriverio": "^4.14.1",
105105
"webpack": "^4.27.1",

src/DropdownReference/components/DropdownReference.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export class DropdownReference extends Component<DropdownProps> {
4747
};
4848

4949
if (this.props.readOnlyStyle === "control" || (this.props.readOnlyStyle === "text" && !this.props.isReadOnly)) {
50+
const loadOptions = (input?: string) => (this.props.asyncData as (input?: string) => Promise<{}>)(input);
51+
5052
return createElement("div", {
5153
className: "widget-dropdown-reference",
5254
onClick: this.setDropdownSize
@@ -58,7 +60,7 @@ export class DropdownReference extends Component<DropdownProps> {
5860
})
5961
: createElement(Async, {
6062
searchPromptText: this.props.searchPromptText,
61-
loadOptions: debounce(this.props.asyncData, 200),
63+
loadOptions: debounce(loadOptions, 200),
6264
...commonProps
6365
}),
6466
createElement(Alert, { className: "widget-dropdown-reference-alert" }, this.props.alertMessage)

src/DropdownReference/components/DropdownReferenceContainer.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
7373
}
7474

7575
componentWillReceiveProps(newProps: ContainerProps) {
76-
if (newProps.mxObject !== this.props.mxObject) {
76+
if (newProps.mxObject && newProps.mxObject !== this.props.mxObject) {
7777
this.getSelectedValue(newProps);
7878
this.resetSubscriptions(newProps.mxObject);
79-
if (this.props.selectType === "normal") {
79+
if (this.props.selectType === "normal" && newProps.mxObject) {
8080
this.retrieveOptions(newProps);
8181
}
8282
} else {
@@ -238,9 +238,6 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
238238
if (input && input.length >= this.props.minimumCharacter) {
239239
return this.retrieveOptions(this.props, input)
240240
.then(() => Promise.resolve({ options: this.state.options }));
241-
} else {
242-
return this.getSelectedValue(this.props)
243-
.then(() => Promise.resolve({ options: [] }));
244241
}
245242
}
246243

src/DropdownReferenceSet/components/DropdownReferenceSet.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "react-select/dist/react-select.css";
1010
import "../../SharedResources/ui/Dropdown.scss";
1111

1212
export interface ReferenceOption {
13-
value: string | boolean;
13+
value: string;
1414
label: string;
1515
}
1616

@@ -54,6 +54,8 @@ export class DropdownReferenceSet extends Component<DropdownProps> {
5454
};
5555

5656
if (this.props.readOnlyStyle === "control" || (this.props.readOnlyStyle === "text" && !this.props.isReadOnly)) {
57+
const loadOptions = (input?: string) => (this.props.asyncData as (input?: string) => Promise<{}>)(input);
58+
5759
return createElement("div", {
5860
className: "widget-dropdown-reference-set",
5961
onClick: this.setDropdownSize
@@ -74,7 +76,7 @@ export class DropdownReferenceSet extends Component<DropdownProps> {
7476
: createElement(Async, {
7577
autoload: false,
7678
autoFocus: true,
77-
loadOptions: debounce(this.props.asyncData, 200),
79+
loadOptions: debounce(loadOptions, 200),
7880
searchPromptText: this.props.searchPromptText,
7981
...commonProps
8082
}),

src/DropdownReferenceSet/components/DropdownReferenceSetContainer.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ContainerProps extends WrapperProps, DropdownProps {
3333
export interface ContainerState {
3434
isClearable: boolean;
3535
options: ReferenceOption[];
36-
selected: any;
36+
selected: ReferenceOption[] | any;
3737
}
3838

3939
class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerState> {
@@ -45,7 +45,6 @@ class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerS
4545

4646
private subscriptionHandles: number[] = [];
4747
private association: string = this.props.entityPath.split("/")[0];
48-
private readonly handleOnClick: (selectedOption: ReferenceOption | any) => void = this.onChange.bind(this);
4948

5049
render() {
5150
return createElement(DropdownReferenceSet, {
@@ -54,7 +53,7 @@ class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerS
5453
data: this.state.options,
5554
asyncData: this.setAsyncOptions,
5655
emptyOptionCaption: this.props.emptyOptionCaption,
57-
handleOnchange: this.handleOnClick,
56+
handleOnchange: this.onChange,
5857
isClearable: this.props.isClearable,
5958
selectType: this.props.selectType,
6059
lazyFilter: this.props.lazyFilter,
@@ -74,7 +73,7 @@ class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerS
7473
}
7574

7675
componentWillReceiveProps(newProps: ContainerProps) {
77-
if (newProps.mxObject !== this.props.mxObject) {
76+
if (newProps.mxObject && newProps.mxObject !== this.props.mxObject) {
7877
const selected = newProps.mxObject.get(this.association);
7978
this.getSelectedValues(newProps);
8079
this.resetSubscriptions(newProps.mxObject);
@@ -130,7 +129,7 @@ class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerS
130129
}
131130
}
132131

133-
private onChange(recentSelection: ReferenceOption[]) {
132+
private onChange = (recentSelection: ReferenceOption[] | any) => {
134133
if (this.props.mxObject) {
135134
const selectedOptions: string[] = [];
136135

@@ -245,9 +244,6 @@ class DropdownReferenceSetContainer extends Component<ContainerProps, ContainerS
245244
if (input && input.length >= this.props.minimumCharacter) {
246245
return this.retrieveOptions(this.props, input)
247246
.then(() => Promise.resolve({ options: this.state.options }));
248-
} else {
249-
return this.getSelectedValues(this.props)
250-
.then(() => Promise.resolve({ options: [] }));
251247
}
252248
}
253249

src/SharedResources/components/__tests__/Alert.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ describe("Alert", () => {
2222
});
2323

2424
it("renders with the specified class", () => {
25-
const alert = renderAlert({ className: "widget-color-picker-alert" }, alertMessage);
25+
const alert = renderAlert({ className: "widget-dropdown-reference-alert" }, alertMessage);
2626

27-
expect(alert).toHaveClass("widget-color-picker-alert");
27+
expect(alert).toHaveClass("widget-dropdown-reference-alert");
2828
});
2929

3030
it("with no bootstrap style specified renders with the class alert-danger", () => {

src/SharedResources/ui/Dropdown.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@import "variables";
22
.widget-dropdown-reference, .widget-dropdown-reference-set {
3+
.widget-dropdown-reference-alert {
4+
margin-top: 5px;
5+
}
6+
37
.Select-arrow {
48
display: none;
59
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require("path");
33
const CopyWebpackPlugin = require("copy-webpack-plugin");
44
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
55

6+
const packageName = process.env.npm_package_name;
67
const mxHost = process.env.npm_package_config_mendixHost || "http://localhost:8080";
78
const developmentPort = process.env.npm_package_config_developmentPort || "3000";
89

0 commit comments

Comments
 (0)