Skip to content

Commit cc5bdb4

Browse files
Question search implemented.
1 parent 786bde2 commit cc5bdb4

File tree

6 files changed

+2445
-2463
lines changed

6 files changed

+2445
-2463
lines changed

package-lock.json

Lines changed: 2361 additions & 2393 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"chartjs-plugin-colorschemes": "^0.4.0",
2020
"chartjs-plugin-zoom": "^0.7.7",
2121
"inputmask-core": "^2.1.1",
22-
"intelligent-dag-select": "^0.7.6",
22+
"intelligent-tree-select": "^0.8.2",
2323
"jquery": "^3.4.1",
2424
"mdbreact": "^5.0.1",
2525
"moment": "^2.29.1",

src/components/search/AutocompleteTextField.js

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import React from 'react'
2+
3+
import "intelligent-tree-select/lib/styles.css"
4+
import 'bootstrap/dist/css/bootstrap.css';
5+
import API from "../../api";
6+
import {IntelligentTreeSelect} from 'intelligent-tree-select';
7+
8+
export class IntelligentQuestionSelector extends React.Component {
9+
10+
constructor() {
11+
super();
12+
this.state = {
13+
activeLabel: "",
14+
activeQuestionOrigin: "",
15+
activeQuestionOriginPath: ""
16+
}
17+
this.getAutocompleteValues = this.getAutocompleteValues.bind();
18+
this.refSelector = React.createRef();
19+
}
20+
21+
getAutocompleteValues = async () => {
22+
return API.get("/rest/search/select/options", {
23+
params: {
24+
projectName: this.props.projectName
25+
}
26+
}).then((response) => {
27+
return response.data;
28+
}).catch((error) => {
29+
console.log(error)
30+
}
31+
);
32+
}
33+
34+
render() {
35+
// TODO: remove "Create new option"
36+
37+
let dagSelectorComponent = <IntelligentTreeSelect
38+
ref={this.refSelector}
39+
fetchOptions={this.getAutocompleteValues}
40+
valueKey={"questionOriginPath"}
41+
labelKey={"label"}
42+
childrenKey={"subTerm"}
43+
simpleTreeData={true}
44+
isMenuOpen={true}
45+
multi={false}
46+
renderAsTree={true}
47+
onChange={opt => {
48+
this.refSelector.current._addSelectedOption(opt);
49+
50+
this.setState({
51+
activeLabel: opt["label"],
52+
activeQuestionOrigin: opt["questionOrigin"],
53+
activeQuestionOriginPath: opt["questionOriginPath"]
54+
})
55+
}}
56+
/>;
57+
58+
59+
return <div>
60+
{dagSelectorComponent}
61+
<div>
62+
<br/>
63+
<span>Label: <b>{this.state.activeLabel}</b></span>
64+
<br/>
65+
<span>Question origin: {this.state.activeQuestionOrigin}</span>
66+
<br/>
67+
<span>Question origin path: {this.state.activeQuestionOriginPath}</span>
68+
69+
</div>
70+
</div>;
71+
}
72+
}

src/components/search/SearchOptionsPicker.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import ListGroup from "react-bootstrap/ListGroup";
66
import Col from "react-bootstrap/Col";
77
import Form from "react-bootstrap/Form";
88
import {ExtensibleAutocompleteFields} from "./ExtensibleAutocompleteFields";
9-
import {DagDemo} from "./AutocompleteTextField";
109

1110

1211
export class SearchOptionsPicker extends React.Component {
@@ -62,14 +61,14 @@ export class SearchOptionsPicker extends React.Component {
6261
render() {
6362

6463
return <ListGroup>
65-
<ListGroup.Item>
66-
<Row>
67-
<Col xs={10}>
68-
<h5>Autocomplete</h5>
69-
<DagDemo/>
70-
</Col>
71-
</Row>
72-
</ListGroup.Item>
64+
{/*<ListGroup.Item>*/}
65+
{/* <Row>*/}
66+
{/* <Col xs={10}>*/}
67+
{/* <h5>Autocomplete</h5>*/}
68+
{/* <IntelligentQuestionSelector projectName={this.props.projectName}/>*/}
69+
{/* </Col>*/}
70+
{/* </Row>*/}
71+
{/*</ListGroup.Item>*/}
7372

7473
<ListGroup.Item>
7574
<Row>

src/components/search/SearchOverview.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {SearchResultList} from "./SearchResultList";
1010
import API from "../../api";
1111
import "@triply/yasgui/build/yasgui.min.css";
1212
import YasguiEditor from "./YasguiEditor";
13+
import {IntelligentQuestionSelector} from "./IntelligentQuestionSelector";
1314

1415
const LEFT_DISPLAY_VERSIONS_LIST = "DISPLAY_VERSIONS_LIST";
1516
const LEFT_DISPLAY_FORMS_LIST = "DISPLAY_FORMS_LIST";
@@ -100,6 +101,8 @@ export class SearchOverview extends React.Component {
100101
{/* onClick={() => this.setState({leftComponent: LEFT_DISPLAY_FORMS_LIST})}>*/}
101102
{/* Search in forms*/}
102103
{/*</Button>*/}
104+
<h5>Question smart search</h5>
105+
<IntelligentQuestionSelector projectName={this.props.match.params.projectName}/>
103106
<br/><br/>
104107
</Container>
105108
<Row>

0 commit comments

Comments
 (0)