-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
108 lines (98 loc) · 2.57 KB
/
main.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
import {
default as React, Component } from 'react';
var ReactDOM = require('react-dom');
import {
ReactiveBase,
DataController,
ReactiveList
} from '../../app/app.js';
import { Img } from "../../app/stories/Img.js";
class Main extends Component {
constructor(props) {
super(props);
this.CustomQuery = this.CustomQuery.bind(this);
this.state = {
defaultSelected: "Default"
};
this.handleInputChange = this.handleInputChange.bind(this);
}
CustomQuery(value) {
return {
query: {
match_all: {}
}
};
}
onData(markerData) {
const marker = markerData._source;
return (
<a
className="full_row single-record single_record_for_clone"
href="#"
key={markerData._id}
>
<div className="text-container full_row" style={{ paddingLeft: "10px" }}>
<div className="text-head text-overflow full_row">
<span className="text-head-info text-overflow">
{marker.name ? marker.name : ""} - {marker.brand ? marker.brand : ""}
</span>
<span className="text-head-city">{marker.brand ? marker.brand : ""}</span>
</div>
<div className="text-description text-overflow full_row">
<ul className="highlight_tags">
{marker.price ? `Priced at $${marker.price}` : "Free Test Drive"}
</ul>
</div>
</div>
</a>
);
}
handleInputChange(e) {
const defaultSelected = e.target.value;
this.setState({
defaultSelected
});
}
render() {
return (
<ReactiveBase
app="car-store"
credentials="cf7QByt5e:d2d60548-82a9-43cc-8b40-93cbbe75c34c"
>
<div className="row">
<div className="col s6 col-xs-6">
<DataController
componentId="CustomSensor"
dataField="name"
customQuery={this.CustomQuery}
URLParams={true}
defaultSelected={this.state.defaultSelected}
filterLabel="Name label"
beforeValueChange={() => new Promise((resolve) => resolve())}
onQueryChange={(prev, next) => {
console.log("prevQuery", prev);
console.log("nextQuery", next);
}}
onValueChange={value => console.log("onValueChange:", value)}
/>
<input value={this.state.defaultSelected} onChange={this.handleInputChange} placeholder="defaultSelected" />
</div>
<div className="col s6 col-xs-6">
<ReactiveList
componentId="SearchResult"
dataField="name"
title="Cars"
from={0}
size={20}
onData={this.onData}
react={{
and: "CustomSensor"
}}
/>
</div>
</div>
</ReactiveBase>
);
}
}
ReactDOM.render(<Main />, document.getElementById('map'));