Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1151 from metasfresh/dev-1140
Browse files Browse the repository at this point in the history
WIP: Adjusts field switch logic for composite lookup controls #1140
  • Loading branch information
teosarca committed Aug 21, 2017
2 parents 6ed9984 + f6c229d commit 5baabb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/components/widget/List/List.js
Expand Up @@ -61,28 +61,29 @@ class List extends Component {
dataId, tabId, rowId, entity, subentity, subentityId, viewId,
attribute
).then( (res) => {
let values = res.data.values;

if (forceSelection && values && (values.length === 1)) {
let value = values[0];
let values = res.data.values || [];
let singleOption = values && (values.length === 1);

if (forceSelection && singleOption) {
this.previousValue = '';

this.setState({
list: values,
loading: false
});

this.handleSelect(value);
}
else {
let firstListValue = values[0];
if (firstListValue) {
this.handleSelect(firstListValue);
}
} else {
this.setState({
list: values,
loading: false
});
}

if (forceFocus && values && (values.length > 1)) {
if (forceFocus && values && (values.length > 0)) {
this.focus();
}
});
Expand Down
10 changes: 7 additions & 3 deletions src/components/widget/Lookup/Lookup.js
Expand Up @@ -65,11 +65,15 @@ class Lookup extends Component {

if (nextProp.source === 'list') {
this.linkedList.map( (listComponent) => {
if (listComponent && listComponent.props && (propValue.source !== 'lookup')) {
if (listComponent && listComponent.props) {
let listProp = listComponent.props.mainProperty;

if (listProp && (listProp[0].field === nextProp.field) && listComponent.activate) {
listComponent.activate();
if (listProp && Array.isArray(listProp) && (listProp.length > 0)) {
const listPropField = listProp[0].field;

if (listComponent.activate && (listPropField === nextProp.field)) {
listComponent.activate();
}
}
}
});
Expand Down

0 comments on commit 5baabb1

Please sign in to comment.