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 #1105 from metasfresh/dev-1095
Browse files Browse the repository at this point in the history
Sales Order Batch Entry with Key Shortcut not working #1095
  • Loading branch information
cadavre authored Aug 1, 2017
2 parents e9c6fb1 + 55bb10e commit 5c5b7f5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/components/widget/List/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ class List extends Component {

handleSelect = (option) => {
const {
onChange, lookupList, properties, setNextProperty, mainProperty
onChange, lookupList, properties, setNextProperty, mainProperty,
enableAutofocus
} = this.props;
const {prevValue} = this.state;

enableAutofocus();

if( prevValue !== (option && option[Object.keys(option)[0]] )) {
if(lookupList){
const promise = onChange(properties[0].field, option);
Expand All @@ -95,7 +98,7 @@ class List extends Component {
const {
rank, readonly, defaultValue, selected, align, updated, rowId,
emptyText, tabIndex, mandatory, validStatus, lookupList, autofocus,
blur, initialFocus
blur, initialFocus, lastProperty, disableAutofocus
} = this.props;
const {list, loading, selectedItem} = this.state;

Expand All @@ -121,6 +124,8 @@ class List extends Component {
lookupList={lookupList}
blur={blur}
initialFocus={initialFocus}
lastProperty={lastProperty}
disableAutofocus={disableAutofocus}
/>
)
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/widget/List/RawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ class RawList extends Component {
componentDidUpdate = (prevProps, prevState) => {
const {
list, mandatory, defaultValue, autofocus, blur, property,
initialFocus, selected, doNotOpenOnFocus
initialFocus, selected, doNotOpenOnFocus, lastProperty, loading,
disableAutofocus
} = this.props;

if(prevProps.blur != blur){
blur && this.handleBlur();
}

if(list.length === 0 && (prevProps.loading != loading) &&
loading === false && lastProperty){
disableAutofocus();
}

if(this.dropdown && autofocus) {
this.dropdown.focus();
if (prevState.selected !== this.state.selected) {
Expand Down
31 changes: 26 additions & 5 deletions src/components/widget/Lookup/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Lookup extends Component {
fireClickOutside: false,
initialFocus: false,
localClearing: false,
fireDropdownList: false
fireDropdownList: false,
autofocusDisabled: false
}
}

Expand Down Expand Up @@ -101,7 +102,20 @@ class Lookup extends Component {
isInputEmpty: true,
property: '',
initialFocus: true,
localClearing: true
localClearing: true,
autofocusDisabled: false
});
}

disableAutofocus= () => {
this.setState({
autofocusDisabled: true
});
}

enableAutofocus = () => {
this.setState({
autofocusDisabled: false
});
}

Expand All @@ -116,7 +130,7 @@ class Lookup extends Component {

const {
isInputEmpty, property, fireClickOutside, initialFocus,
localClearing, fireDropdownList
localClearing, fireDropdownList, autofocusDisabled
} = this.state;

return (
Expand Down Expand Up @@ -160,6 +174,7 @@ class Lookup extends Component {
setNextProperty={this.setNextProperty}
lookupEmpty={isInputEmpty}
fireDropdownList={fireDropdownList}
enableAutofocus={this.enableAutofocus}
{...{placeholder, readonly, tabIndex,
windowType, parameterName, entity, dataId,
isModal, recent, rank, updated, filterWidget,
Expand Down Expand Up @@ -194,7 +209,8 @@ class Lookup extends Component {
properties={[item]}
lookupList={true}
autofocus={
item.field == property ?
item.field == property &&
!autofocusDisabled ?
true : false
}
defaultValue={
Expand All @@ -204,10 +220,15 @@ class Lookup extends Component {
initialFocus={
index===0 ? initialFocus : false
}
lastProperty={
properties[properties.length-1].field ===property ? true : false
}
setNextProperty={this.setNextProperty}
mainProperty={[item]}
blur={!property?true:false}
readonly={disabled || readonly}
disableAutofocus={this.disableAutofocus}
enableAutofocus={this.enableAutofocus}
/>
</div>
}
Expand All @@ -217,7 +238,7 @@ class Lookup extends Component {
<div
className="input-icon input-icon-lg raw-lookup-wrapper"
onClick={this.openDropdownList}
>
>
{ !readonly &&
<i className="meta-icon-preview" />
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@ class RawLookup extends Component {
const {
recent, windowType, dataId, filterWidget, parameterName,
tabId, rowId, entity, subentity, subentityId, viewId, mainProperty,
handleInputEmptyStatus
handleInputEmptyStatus, enableAutofocus
} = this.props;

enableAutofocus();

if(this.inputSearch.value != '' || allowEmpty){

!allowEmpty && handleInputEmptyStatus(false);
Expand Down

0 comments on commit 5c5b7f5

Please sign in to comment.