Skip to content

Commit 2787716

Browse files
JatanaRam81
authored andcommittedOct 29, 2018
Add SearchBar for layers selection (Cloud-CV#400)
* Add SearchBar for layers selection * Remove commented code * Add new line to the end of css file * Fix searchbar error with only one letter pattern * Prettifying * Fix bug with no search results
1 parent a93e366 commit 2787716

File tree

8 files changed

+104
-5
lines changed

8 files changed

+104
-5
lines changed
 

‎.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"jsPlumbUtil": false,
1717
},
1818
"rules": {
19-
"max-len": [1, 150, 2, {ignoreComments: true}]
19+
"max-len": [1, 150, 2, {ignoreComments: true}],
20+
"no-console": "off"
2021
},
2122
"extends": ["eslint:recommended", "plugin:react/recommended"]
2223
}

‎ide/static/css/searchbar_style.css

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.insert-layer-title {
2+
position: relative;
3+
margin-top: 10px !important;
4+
margin-bottom: 21px !important;
5+
}
6+
7+
#layer-search-icon {
8+
position: absolute;
9+
left: -5px;
10+
top: 31px;
11+
}
12+
13+
#layer-search-icon:hover {
14+
cursor: pointer;
15+
}
16+
17+
#layer-search-input {
18+
position: absolute;
19+
top: 36px;
20+
left: 20px;
21+
font-size: 15px;
22+
background: none;
23+
border: none;
24+
color: rgb(69, 80, 97);
25+
outline: none;
26+
opacity: 1;
27+
transition: 0.3s;
28+
}
29+
30+
.layer-search-input-selected {
31+
opacity: 1 !important;
32+
}
33+
34+
.matched-search-char {
35+
color: rgb(69, 80, 97);
36+
}

‎ide/static/css/style.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1206,4 +1206,4 @@ input[type="file"] {
12061206
background: white;
12071207
transform: rotate(-45deg)
12081208
}
1209-
}
1209+
}

‎ide/static/js/content.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,11 @@ class Content extends React.Component {
12751275
/>
12761276
<h5 className="sidebar-heading">LOGIN</h5>
12771277
<Login setUserId={this.setUserId} setUserName={this.setUserName}></Login>
1278-
<h5 className="sidebar-heading">INSERT LAYER</h5>
1278+
<h5 className="sidebar-heading insert-layer-title">
1279+
<input id="layer-search-input" placeholder="Search for layer"></input>
1280+
<div id="insert-layer-sign">INSERT LAYER</div>
1281+
<i className="material-icons" id="layer-search-icon">search</i>
1282+
</h5>
12791283
<Pane
12801284
handleClick = {this.handleClick}
12811285
setDraggingLayer = {this.setDraggingLayer}

‎ide/static/js/layer.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Layer extends React.Component {
4646
let highlightUser = null;
4747
let highlightClass = '';
4848
let highlightColor = '#000';
49+
4950

5051
if(this.props.layer.highlight && this.props.layer.highlight.length > 0) {
5152
highlightClass = 'highlighted';

‎ide/static/js/pane.js

+55-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,61 @@ class Pane extends React.Component {
2626
}
2727
this.setState(obj);
2828
}
29-
render(){
29+
componentDidMount() {
30+
let filter = (pattern) => {
31+
let layerCompability = (searchQuery, layerName) => {
32+
let j = 0;
33+
let seq = [];
34+
let full_match = true;
35+
for (let i = 0; i < searchQuery.length; i++) {
36+
while (j < layerName.length && layerName[j].toLowerCase() != searchQuery[i].toLowerCase()) {
37+
seq[j] = false;
38+
j++;
39+
}
40+
if (j < layerName.length && layerName[j].toLowerCase() == searchQuery[i].toLowerCase()) {
41+
seq[j] = true;
42+
j++;
43+
} else {
44+
full_match = false;
45+
}
46+
}
47+
return {
48+
match: seq,
49+
full_match: full_match
50+
};
51+
}
52+
for (let elem of $('.drowpdown-button')) {
53+
let sub = elem.innerText;
54+
if (!sub) continue;
55+
let resp = layerCompability(pattern, sub);
56+
if (resp.full_match) {
57+
elem.style.display = 'block';
58+
let final = '';
59+
for (let i = 0; i < sub.length; i++) {
60+
if (resp.match[i]) {
61+
final += '<span class="matched-search-char">' + sub[i] + '</span>'
62+
} else {
63+
final += sub[i];
64+
}
65+
}
66+
elem.innerHTML = final;
67+
} else {
68+
elem.style.display = 'none';
69+
}
70+
}
71+
for (let elem of $('.panel-heading')) {
72+
let _p = pattern ? 'false' : 'true';
73+
if (elem.getAttribute('aria-expanded') == _p) {
74+
elem.click();
75+
}
76+
}
77+
}
78+
$('#layer-search-input').keyup((e) => {
79+
filter(e.target.value);
80+
});
81+
}
82+
83+
render() {
3084
return (
3185
<div className="panel-group" id="menu" role="tablist" aria-multiselectable="true">
3286
<div className="panel panel-default">

‎ide/static/js/tabs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ Tabs.propTypes = {
3535
selectedPhase: React.PropTypes.number
3636
};
3737

38-
export default Tabs;
38+
export default Tabs;

‎ide/templates/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<link rel="stylesheet" type="text/css" href="/static/fonts/font.css"/>
1010
<link rel="stylesheet" type="text/css" href="/static/lib/bootstrap-3.3.6-dist/css/bootstrap-social.css">
1111
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
12+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
13+
rel="stylesheet">
14+
<link rel="stylesheet" type="text/css" href="/static/css/searchbar_style.css">
1215

1316
<!-- Global site tag (gtag.js) - Google Analytics -->
1417
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-110495971-1"></script>

0 commit comments

Comments
 (0)
Please sign in to comment.