Skip to content

Commit 6af20b8

Browse files
committed
Process feedback
1 parent baafc94 commit 6af20b8

18 files changed

Lines changed: 113 additions & 114 deletions

.travis.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
sudo: required
22
language: node_js
33
node_js:
4-
- "8"
5-
addons:
6-
apt:
7-
sources:
8-
- google-chrome
9-
packages:
10-
- google-chrome-stable
4+
- "8.10.0"
115
before_install:
126
- npm i -g npm
137
- npm install grunt-cli -g

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![badge](https://img.shields.io/badge/mendix-7.14.1-green.svg)
66

77
# Dropdown
8-
An input widget used to display and edit associations
8+
An input widget used to display and edit associations for reference and reference sets
99

1010
## Features
1111
* Search for matching options
@@ -25,32 +25,32 @@ An input widget used to display and edit associations
2525
Mendix 7.13.1
2626

2727
## Demo project
28-
[https://dropdowntypeahead.mxapps.io]( https://dropdowntypeahead.mxapps.io)
28+
[https://dropdowntypeahead.mxapps.io](https://dropdowntypeahead.mxapps.io)
2929

3030
## Usage
3131
![dropdown-type-ahead](/assets/dropdown-typeahead-normal-loading.gif)
3232

33-
* Place the widget in data form within the context of an entity
33+
* Place the widget in data form within the context of an entity
3434
* Select entity path and attribute over reference for selectable objects
3535
* Select the data source
3636

3737
## Basic configuration
3838
For a basic configuration, set up the widget as indicated below:-
3939
### Data source
4040
![dropdown-typeahead-data-source](/assets/dropdown-typeahead-data-source.png)
41-
### Appearance
42-
![dropdown-typeahead-appearance](/assets/dropdown-typeahead-appearance.png)
41+
### Appearance
42+
![dropdown-typeahead-appearance](/assets/dropdown-typeahead-appearance.png)
4343
### Label
44-
![dropdown-typeahead-label](/assets/dropdown-typeahead-label.png)
44+
![dropdown-typeahead-label](/assets/dropdown-typeahead-label.png)
4545
### Selectable objects
46-
![dropdown-typeahead-selectable-objects](/assets/dropdown-typeahead-selectable.png)
46+
![dropdown-typeahead-selectable-objects](/assets/dropdown-typeahead-selectable.png)
4747
### Search
48-
![dropdown-typeahead-search](/assets/dropdown-typeahead-search.png)
48+
![dropdown-typeahead-search](/assets/dropdown-typeahead-search.png)
4949
### Events
5050
![dropdown-typeahead-events](/assets/dropdown-typeahead-events.png)
5151

5252
## Issues, suggestions and feature requests
53-
We are actively maintaining this widget, please report any issues or suggestion for improvement at
53+
We are actively maintaining this widget, please report any issues or suggestion for improvement at
5454
https://github.com/mendixlabs/dropdown-type-ahead/issues
5555

5656
## Development and contribution

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"copyright": "Mendix BV",
77
"scripts": {
88
"start": "webpack-dev-server --hot --open",
9-
"emit": "tsc",
9+
"typeCheck": "tsc --noEmit",
1010
"pretest": "tsc && npm run lint && npm run build",
1111
"test": "npm run test:unit && npm run test:conditional",
1212
"test:conditional": "node ./node_modules/mendix-widget-build-script/dist/CheckPullRequestFromFork.js && echo 'Skip tests on forked pull request' || npm run deployAndTest",
@@ -27,7 +27,7 @@
2727
"developmentPort": 3000
2828
},
2929
"pre-commit": [
30-
"emit",
30+
"typeCheck",
3131
"lint"
3232
],
3333
"repository": {

src/DropdownReference/DropdownReference.webmodeler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export class preview extends Component<ContainerProps, {}> {
3434
readOnlyStyle: this.props.readOnlyStyle,
3535
lazyFilter: this.props.lazyFilter,
3636
selectedValue,
37-
searchText: this.props.searchText,
3837
loadingText: this.props.loadingText,
3938
minimumCharacter: this.props.minimumCharacter,
4039
showLabel: this.props.showLabel,

src/DropdownReference/DropdownReference.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<widget id="com.mendix.widget.custom.dropdown.DropdownReference" needsEntityContext="true" offlineCapable="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../../../../../xsd/widget.xsd">
33
<name>Dropdown reference</name>
4-
<description/>
4+
<description>An input widget used to display and edit associations for reference</description>
55
<icon></icon>
66
<properties>
77
<property key="entityPath" type="entity" isPath="yes" pathType="reference">
@@ -36,6 +36,10 @@
3636
<caption>Empty caption</caption>
3737
<category>Appearance</category>
3838
<description>Text displayed when no selection is made</description>
39+
<translations>
40+
<translation lang="en_US">(no option selected)</translation>
41+
<translation lang="nl_NL">(geen option selecteerd)</translation>
42+
</translations>
3943
</property>
4044
<property key="readOnlyStyle" type="enumeration" defaultValue="control">
4145
<caption>Read-only style</caption>
@@ -115,7 +119,7 @@
115119
<property key="sortAttributes" type="object" isList="true" required="false">
116120
<caption>Sort order</caption>
117121
<category>Selectable objects</category>
118-
<description></description>
122+
<description>Sorting only applies to source 'Database'</description>
119123
<properties>
120124
<property key="name" type="attribute" required="false" isPath="optional" pathType="reference" entityProperty="../entityPath">
121125
<caption>Attribute</caption>
@@ -158,11 +162,6 @@
158162
<category>Selectable objects</category>
159163
<description>Attribute set with search text of the user, this could be used for filter results in microflow or nanoflow</description>
160164
<attributeTypes>
161-
<attributeType name="AutoNumber"/>
162-
<attributeType name="Enum"/>
163-
<attributeType name="Decimal"/>
164-
<attributeType name="Integer"/>
165-
<attributeType name="Long"/>
166165
<attributeType name="String"/>
167166
</attributeTypes>
168167
</property>

src/DropdownReference/components/DropdownReference.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export class DropdownReference extends Component<DropdownReferenceProps> {
2828
(document.getElementsByClassName("widget-dropdown-reference")[0] as HTMLElement).style.overflow = "hidden";
2929
const dropdown = document.getElementsByClassName("Select-menu-outer");
3030
scrollContainer.addEventListener("scroll", () => {
31-
dropdown[0] ? (dropdown[0] as HTMLElement).style.visibility = "hidden" : window.logger.warn("Dropdown not available");
31+
if (dropdown[0]) {
32+
(dropdown[0] as HTMLElement).style.visibility = "hidden";
33+
}
3234
const activeElement = document.activeElement;
3335
if (activeElement) {
3436
(activeElement as HTMLElement).blur();

src/DropdownReference/components/DropdownReferenceContainer.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as initializeReactFastclick from "react-fastclick";
33
import { hot } from "react-hot-loader";
44

55
import { AttributeType, DropdownReferenceProps, ReferenceOption, parseStyle, validateProps } from "../../SharedResources/utils/ContainerUtils";
6-
import { FetchDataOptions, Nanoflow, fetchData } from "../../SharedResources/utils/Data";
6+
import { FetchDataOptions, fetchData } from "../../SharedResources/utils/Data";
77
import { DropdownReference } from "./DropdownReference";
88

99
interface WrapperProps {
10-
class: string;
10+
"class": string;
1111
mxObject: mendix.lib.MxObject;
1212
mxform: mxui.lib.form._FormBase;
1313
style: string;
@@ -21,11 +21,10 @@ export interface ContainerProps extends WrapperProps, DropdownReferenceProps {
2121
entityConstraint: string;
2222
searchAttribute: string;
2323
source: "xpath" | "microflow" | "nanoflow";
24-
// sortOrder: "asc" | "desc";
2524
sortAttributes: AttributeType[];
26-
nanoflow: Nanoflow;
25+
nanoflow: mx.Nanoflow;
2726
microflow: string;
28-
onChangeNanoflow: Nanoflow;
27+
onChangeNanoflow: mx.Nanoflow;
2928
onChangeMicroflow: string;
3029
onChangeEvent: "callMicroflow" | "callNanoflow";
3130
editable: "default" | "never";
@@ -40,7 +39,7 @@ export interface ContainerState {
4039
class DropdownReferenceContainer extends Component<ContainerProps, ContainerState> {
4140
readonly state: ContainerState = {
4241
options: [],
43-
isClearable: this.props.isClearable ? true : false,
42+
isClearable: this.props.isClearable,
4443
selectedObject: {}
4544
};
4645

@@ -59,12 +58,11 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
5958
selectType: this.props.selectType,
6059
lazyFilter: this.props.lazyFilter,
6160
isReadOnly: this.isReadOnly(),
62-
labelCaption: this.props.labelCaption ? this.props.labelCaption.trim() : "",
61+
labelCaption: this.props.labelCaption ? this.props.labelCaption : "",
6362
labelOrientation: this.props.labelOrientation,
6463
labelWidth: this.props.labelWidth,
6564
location: this.props.mxform.place,
6665
readOnlyStyle: this.props.readOnlyStyle,
67-
searchText: this.props.searchText, // unused???
6866
loadingText: this.props.loadingText,
6967
minimumCharacter: this.props.minimumCharacter,
7068
selectedValue: this.state.selectedObject,
@@ -74,7 +72,7 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
7472
}
7573

7674
componentWillReceiveProps(newProps: ContainerProps) {
77-
if (newProps.mxObject && (newProps.mxObject !== this.props.mxObject)) {
75+
if (newProps.mxObject !== this.props.mxObject) {
7876
this.getSelectedValue(newProps);
7977
this.resetSubscriptions(newProps.mxObject);
8078
if (this.props.selectType === "normal") {
@@ -158,7 +156,6 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
158156

159157
private onChange = (selection: ReferenceOption) => {
160158
if (this.props.mxObject) {
161-
162159
if (!selection) {
163160
const references = this.props.mxObject.getReferences(this.association);
164161
this.props.mxObject.removeReferences(this.association, references);
@@ -180,19 +177,19 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
180177
context.setContext(mxObject.getEntity(), mxObject.getGuid());
181178
if (onChangeEvent === "callMicroflow" && onChangeMicroflow) {
182179
window.mx.ui.action(onChangeMicroflow, {
183-
error: error => window.mx.ui.error(`Error while executing onchange microflow ${onChangeMicroflow}: ${error.message}`), // tslint:disable-line max-line-length
184-
origin: mxform,
185180
params: {
186181
applyto: "selection",
187182
guids: [ mxObject.getGuid() ]
188-
}
183+
},
184+
origin: mxform,
185+
error: error => window.mx.ui.error(`Error while executing onchange microflow ${onChangeMicroflow}: ${error.message}`)
189186
});
190187
} else if (onChangeEvent === "callNanoflow" && onChangeNanoflow.nanoflow) {
191188
window.mx.data.callNanoflow({
192-
context,
193-
error: error => window.mx.ui.error(`Error while executing onchange nanoflow: ${error.message}`),
194189
nanoflow: onChangeNanoflow,
195-
origin: mxform
190+
origin: mxform,
191+
context,
192+
error: error => window.mx.ui.error(`Error while executing onchange nanoflow: ${error.message}`)
196193
});
197194
}
198195
}
@@ -224,13 +221,11 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
224221
}
225222

226223
private setOptions = (mendixObjects: mendix.lib.MxObject[]) => {
227-
const options: ReferenceOption[] = [];
228-
229-
mendixObjects.forEach(mxObject => {
230-
options.push({
224+
const options: ReferenceOption[] = mendixObjects.map(mxObject => {
225+
return {
231226
label: mx.parser.formatAttribute(mxObject, this.props.attribute),
232227
value: mxObject.getGuid()
233-
});
228+
};
234229
});
235230

236231
this.setState({ options });

src/DropdownReference/components/__tests__/DropdownReference.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe("DropdownReference", () => {
2727
readOnlyStyle: "control",
2828
labelOrientation: "horizontal",
2929
alertMessage: "No text",
30-
searchText: "search",
3130
loadingText: "loading",
3231
minimumCharacter: 1
3332
};

src/DropdownReferenceSet/DropdownReferenceSet.webmodeler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class preview extends Component<ContainerProps, {}> {
3636
selectedValue: this.props.selectedValue,
3737
showLabel: this.props.showLabel,
3838
styleObject: parseStyle(this.props.style),
39-
searchText: this.props.searchText,
4039
loadingText: this.props.loadingText,
4140
minimumCharacter: this.props.minimumCharacter
4241
});
@@ -74,7 +73,6 @@ export function getVisibleProperties(valueMap: ContainerProps, visibilityMap: Vi
7473

7574
if (valueMap.source !== "xpath") {
7675
visibilityMap.sortAttributes = false;
77-
visibilityMap.sortOrder = false;
7876
visibilityMap.entityConstraint = false;
7977
}
8078

src/DropdownReferenceSet/DropdownReferenceSet.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<widget id="com.mendix.widget.custom.dropdown.DropdownReferenceSet" needsEntityContext="true" offlineCapable="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../../../../../xsd/widget.xsd">
33
<name>Dropdown reference set</name>
4-
<description/>
4+
<description>An input widget used to display and edit associations for reference sets</description>
55
<icon></icon>
66
<properties>
77
<property key="entityPath" type="entity" isPath="yes" pathType="referenceSet">
@@ -36,6 +36,10 @@
3636
<caption>Empty caption</caption>
3737
<category>Appearance</category>
3838
<description>Text displayed when no selection is made</description>
39+
<translations>
40+
<translation lang="en_US">(no option selected)</translation>
41+
<translation lang="nl_NL">(geen option selecteerd)</translation>
42+
</translations>
3943
</property>
4044
<property key="readOnlyStyle" type="enumeration" defaultValue="control">
4145
<caption>Read-only style</caption>
@@ -115,7 +119,7 @@
115119
<property key="sortAttributes" type="object" isList="true" required="false">
116120
<caption>Sort order</caption>
117121
<category>Selectable objects</category>
118-
<description/>
122+
<description>Sorting only applies to source 'Database'</description>
119123
<properties>
120124
<property key="name" type="attribute" required="false" isPath="optional" pathType="referenceSet" entityProperty="../entityPath">
121125
<caption>Attribute</caption>
@@ -158,11 +162,6 @@
158162
<category>Selectable objects</category>
159163
<description>Attribute set with search text of the user, this could be used for filter results in microflow or nanoflow</description>
160164
<attributeTypes>
161-
<attributeType name="AutoNumber"/>
162-
<attributeType name="Enum"/>
163-
<attributeType name="Decimal"/>
164-
<attributeType name="Integer"/>
165-
<attributeType name="Long"/>
166165
<attributeType name="String"/>
167166
</attributeTypes>
168167
</property>

0 commit comments

Comments
 (0)