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

Commit

Permalink
Fix support various typeahead requests #1433
Browse files Browse the repository at this point in the history
  • Loading branch information
wiadev committed Dec 14, 2017
1 parent 29835db commit dcc8fb2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
39 changes: 32 additions & 7 deletions src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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,6 +228,13 @@ class RawLookup extends Component {
recent,
windowType,
dataId,
filterWidget,
parameterName,
tabId,
rowId,
entity,
subentity,
subentityId,
viewId,
mainProperty,
handleInputEmptyStatus,
Expand All @@ -245,13 +253,30 @@ class RawLookup extends Component {
isOpen: true
});

getViewAttributeTypeahead(
windowType,
viewId,
dataId,
mainProperty[0].field,
this.inputSearch.value
).then(response => {
let typeaheadRequest;
if (entity === "documentView" && !filterWidget) {
typeaheadRequest = getViewAttributeTypeahead(
windowType,
viewId,
dataId,
mainProperty[0].field,
this.inputSearch.value
);
} else {
typeaheadRequest = autocompleteRequest({
docId: filterWidget ? viewId : dataId,
docType: windowType,
entity,
propertyName: filterWidget ? parameterName : mainProperty[0].field,
query: this.inputSearch.value,
rowId,
subentity,
subentityId,
tabId
});
}

typeaheadRequest.then(response => {
let values = response.data.values || [];

this.setState({
Expand Down
4 changes: 2 additions & 2 deletions src/components/widget/RawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ RawWidget.propTypes = {
isModal: PropTypes.bool,
filterWidget: PropTypes.bool,
filterId: PropTypes.string,
id: PropTypes.string,
id: PropTypes.number,
range: PropTypes.bool,
onShow: PropTypes.func,
onHide: PropTypes.func,
Expand All @@ -941,7 +941,7 @@ RawWidget.propTypes = {
fields: PropTypes.array,
icon: PropTypes.string,
entity: PropTypes.string,
data: PropTypes.string,
data: PropTypes.any,
closeTableField: PropTypes.func,
attribute: PropTypes.bool,
allowShowPassword: PropTypes.bool, // NOTE: looks like this wasn't used
Expand Down

0 comments on commit dcc8fb2

Please sign in to comment.