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 #1442 from metasfresh/dev-1433
Browse files Browse the repository at this point in the history
Fix Lookup widget #1433
  • Loading branch information
teosarca committed Dec 13, 2017
2 parents 61d765a + e22b478 commit ef51aeb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
23 changes: 23 additions & 0 deletions src/actions/ViewAttributesActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ export function getViewAttributeDropdown(windowId, viewId, rowId, attribute) {
);
}

export function getViewAttributeTypeahead(
windowId,
viewId,
rowId,
attribute,
query
) {
return axios.get(
config.API_URL +
"/documentView" +
"/" +
windowId +
"/" +
viewId +
"/" +
rowId +
"/attributes/attribute/" +
attribute +
"/typeahead?query=" +
encodeURIComponent(query)
);
}

/**
*
* @param {*} windowId
Expand Down
5 changes: 3 additions & 2 deletions src/components/widget/Lookup/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Lookup extends Component {
) {
let nextProp = properties[nextIndex];

// TODO: Looks like this code was never used
if (nextProp.source === "list") {
this.linkedList.map(listComponent => {
if (listComponent && listComponent.props) {
Expand Down Expand Up @@ -239,7 +240,7 @@ class Lookup extends Component {
item.field
)[0];

if (item.source === "lookup" || item.widgetType === "Lookup") {
if (itemByProperty.widgetType === "Lookup") {
return (
<RawLookup
key={index}
Expand Down Expand Up @@ -284,7 +285,7 @@ class Lookup extends Component {
}}
/>
);
} else if (item.source === "list") {
} else if (itemByProperty.widgetType === "List") {
const isFirstProperty = index === 0;
const isCurrentProperty =
item.field === property && !autofocusDisabled;
Expand Down
27 changes: 8 additions & 19 deletions src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from "prop-types";
import React, { Component } from "react";
import { connect } from "react-redux";

import { autocompleteRequest } from "../../../actions/GenericActions";
import { getViewAttributeTypeahead } from "../../../actions/ViewAttributesActions";
import { openModal } from "../../../actions/WindowActions";
import LookupList from "./LookupList";

Expand Down Expand Up @@ -227,13 +227,6 @@ class RawLookup extends Component {
recent,
windowType,
dataId,
filterWidget,
parameterName,
tabId,
rowId,
entity,
subentity,
subentityId,
viewId,
mainProperty,
handleInputEmptyStatus,
Expand All @@ -252,17 +245,13 @@ class RawLookup extends Component {
isOpen: true
});

autocompleteRequest({
docId: filterWidget ? viewId : dataId,
docType: windowType,
entity,
propertyName: filterWidget ? parameterName : mainProperty[0].field,
query: this.inputSearch.value,
rowId,
subentity,
subentityId,
tabId
}).then(response => {
getViewAttributeTypeahead(
windowType,
viewId,
dataId,
mainProperty[0].field,
this.inputSearch.value
).then(response => {
let values = response.data.values || [];

this.setState({
Expand Down

0 comments on commit ef51aeb

Please sign in to comment.