-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
executable file
·183 lines (176 loc) · 4.49 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import React, { Component } from "react";
import ReactStructuredQuerySearch from "react-structured-query-search";
import "react-structured-query-search/dist/index.css";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
SymbolData: []
};
// NOTE: The operator will seen to UI only if props isAllowOperator={true}
this.options = [
{
category: "Type",
type: "textoptions",
operator: ["==", "!="],
isAllowDuplicateCategories: false,
options: this.getSymbolOptions
},
{
category: "Classification",
type: "textoptions",
operator: ["==", "!="],
isAllowDuplicateCategories: false,
fuzzySearchKeyAttribute: "sectorName",
options: this.getSectorOptions
},
{
category: "Terms",
type: "textoptions",
operator: null,
isAllowDuplicateCategories: true,
options: this.getIndustryOptions
},
{
category: "Label",
type: "text",
isAllowDuplicateCategories: false,
operator: null
},
{
category: "Query",
isAllowDuplicateCategories: false,
type: "query",
isAllowCustomValue: true,
options: null,
operator: null,
fuzzySearchKeyAttribute: "displayName",
queryOptions: [
{
category: {
name: "QualifiedName",
displayName: "QualifiedName (string)",
group: "In house"
},
fuzzySearchKeyAttribute: "displayName",
type: "text",
operator: ["==", "!=", "contains", "begins with", "ends with", "is null", "is not null"],
options: null
},
{
category: {
name: "Description",
displayName: "Description (string)",
group: "In house"
},
fuzzySearchKeyAttribute: "displayName",
type: "text",
operator: ["==", "!=", "contains", "begins with", "ends with", "is null", "is not null"],
options: null
},
{
category: {
name: "Name",
displayName: "Name (string)",
group: "out source"
},
fuzzySearchKeyAttribute: "displayName",
type: "text",
operator: ["==", "!=", "contains", "begins with", "ends with", "is null", "is not null"],
options: null
},
{
category: {
name: "Owner",
displayName: "Owner (string)",
group: "out source"
},
fuzzySearchKeyAttribute: "displayName",
type: "textoptions",
operator: ["==", "!=", "contains", "begins with", "ends with", "is null", "is not null"],
options: [
{
name: "user1",
displayName: "User 1",
group: "In house"
},
{
name: "user2",
displayName: "User 2",
group: "out source"
},
{
name: "user3",
displayName: "User 3",
group: "In house"
}
]
}
]
}
];
}
/**
* [getSymbolOptions Get the values using Ajax call]
* @return {[type]}
*/
getSymbolOptions = () => {
if (this.state.SymbolData.length === 0) {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.setState({ SymbolData: ["TFSC", "PIL", "VNET"] }, () => {
return resolve(this.state.SymbolData);
});
}, 2000);
});
} else {
return this.state.SymbolData;
}
};
/**
* [getSectorOptions Get the values for sector category]
* @return {[array]}
*/
getSectorOptions() {
return [{ sectorName: "Finance", id: 1 }, { sectorName: "Consumer Services", id: 2 }, { sectorName: "Services", id: 3 }];
}
/**
* [getIndustryOptions Get the values for Industry category]
* @return {[array]}
*/
getIndustryOptions() {
return [{ name: "Business Services", id: 1 }, { name: "Other Specialty Stores", id: 2 }, { name: "demo test", id: 3 }];
}
getTokenItem(obj) {
let val = obj.children;
return <div>{`testing`}</div>;
}
render() {
return (
<div className="container">
<ReactStructuredQuerySearch
isAllowOperator={true}
defaultSelected={[]}
options={this.options}
placeholder="Add filters..."
// renderTokenItem={this.getTokenItem}
updateOptions={({ updatedValues, addedValue }) => {
if (addedValue && addedValue.category === "Symbol" && addedValue.value === "TFSC") {
this.options.push({
category: "New Category",
type: "text"
});
return this.options;
}
}}
onTokenAdd={val => console.log(val)}
customClasses={{
input: "filter-tokenizer-text-input",
results: "filter-tokenizer-list__container",
listItem: "filter-tokenizer-list__item"
}}
/>
</div>
);
}
}