-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
173 lines (164 loc) · 6.8 KB
/
index.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
import React, { Component } from 'react';
import InputGroup from 'react-bootstrap/InputGroup';
import FormControl from 'react-bootstrap/FormControl';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button';
import Select from 'react-select';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faAngleLeft,
faTag,
faUser,
faSearch,
faFileAlt
} from '@fortawesome/free-solid-svg-icons';
import colourStyles from '../LabelsList/select-color-styles.js';
import speakersColorStyles from './select-speakers-color-styles.js';
class SearchBarTranscripts extends Component {
constructor(props) {
super(props);
this.state = {
isShowingFilterOptions: false,
showParagraphsMatchingSearch: false,
showTextSearchPreferences: false,
showSpeakersSearchPreferences: false,
showLabelsSearchPreferences: false,
selectedOptionTranscriptSearch: false
};
}
handleSpeakersSearchChange = selectedOptionSpeakerSearch => {
this.props.handleSpeakersSearchChange(selectedOptionSpeakerSearch);
};
handleLabelsSearchChange = selectedOptionLabelSearch => {
this.props.handleLabelsSearchChange(selectedOptionLabelSearch);
};
handleShowParagraphsMatchingSearch = () => {
this.setState((state) => {
this.props.handleShowParagraphsMatchingSearch( !state.showParagraphsMatchingSearch);
return { showParagraphsMatchingSearch: !state.showParagraphsMatchingSearch };
}, () => {
});
}
handleTranscriptSearchChange = selectedOptionTranscriptSearch => {
this.props.handleTranscriptSearchChange(selectedOptionTranscriptSearch);
this.setState({ selectedOptionTranscriptSearch });
};
/* TODO: move SearchBarTranscripts to a Search Toolbar component? */
render() {
return (
<>
<Row className="mb-3">
<Col xs={ 1 } sm={ 1 } md={ 1 } ld={ 1 } xl={ 1 }>
<Button
// block
variant="outline-secondary"
onClick={this.props.handleShowAdvancedSearchViewSearchingAcrossTranscripts}
title={"close search across transcript in a project"}
>
<FontAwesomeIcon
icon={ faAngleLeft }
/>
</Button>
</Col>
<Col xs={ 10 } sm={ 11 } md={ 11 } ld={ 11 } xl={ 11 }>
<InputGroup >
{/* Search */}
<FormControl
// TODO: pass labels, speakers, and paragraph pref
onChange={ (e) => { this.props.handleSearch(e, {
showParagraphsMatchingSearch: this.state.showParagraphsMatchingSearch,
showLabelsSearchPreferences: this.state.showLabelsSearchPreferences,
showSpeakersSearchPreferences: this.state.showSpeakersSearchPreferences,
selectedOptionTranscriptSearch: this.state.selectedOptionTranscriptSearch
});} }
value={ this.props.searchValue }
placeholder="Search text..."
aria-label="search"
aria-describedby="search"
/>
<InputGroup.Append>
<InputGroup.Text>
<FontAwesomeIcon icon={ faSearch } />
</InputGroup.Text>
</InputGroup.Append>
</InputGroup>
{/* <Form.Text className="text-muted">
Search Text within a transcript
</Form.Text> */}
</Col>
</Row>
<Row className="mb-3">
<Col xs={ 1 } sm={ 1 } md={ 1 } ld={ 1 } xl={ 1 }>
<InputGroup.Prepend>
<InputGroup.Text>
<FontAwesomeIcon icon={ faFileAlt } />
</InputGroup.Text>
</InputGroup.Prepend>
</Col>
<Col xs={ 10 } sm={ 11 } md={ 11 } ld={ 11 } xl={ 11 }>
<Select
value={ this.state.selectedOptionTranscriptSearch }
onChange={ this.handleTranscriptSearchChange }
isMulti
isSearchable
options={ this.props.transcriptOptions }
styles={ speakersColorStyles }
placeholder={ 'Filter by transcripts...' }
/>
{/* <Form.Text className="text-muted">
Filter by transcripts in the current project
</Form.Text> */}
</Col>
</Row>
<Row className="mb-3">
<Col xs={ 1 } sm={ 1 } md={ 1 } ld={ 1 } xl={ 1 }>
<InputGroup.Prepend>
<InputGroup.Text>
<FontAwesomeIcon icon={ faUser } />
</InputGroup.Text>
</InputGroup.Prepend>
</Col>
<Col xs={ 10 } sm={ 11 } md={ 11 } ld={ 11 } xl={ 11 }>
<Select
value={ this.state.selectedOptionSpeakerSearch }
onChange={ this.handleSpeakersSearchChange }
isMulti
isSearchable
options={ this.props.speakersOptions }
styles={ speakersColorStyles }
placeholder={ 'Filter by speakers...' }
/>
{/* <Form.Text className="text-muted">
Filter by speaker in the current project
</Form.Text> */}
</Col>
</Row>
<Row className="mb-3">
<Col xs={ 1 } sm={ 1 } md={ 1 } ld={ 1 } xl={ 1 }>
<InputGroup.Prepend>
<InputGroup.Text>
<FontAwesomeIcon icon={ faTag } />
</InputGroup.Text>
</InputGroup.Prepend>
</Col>
<Col xs={ 10 } sm={ 11 } md={ 11 } ld={ 11 } xl={ 11 }>
<Select
value={ this.state.selectedOptionLabelSearch }
onChange={ this.handleLabelsSearchChange }
isMulti
isSearchable
options={ this.props.labelsOptions }
styles={ colourStyles }
placeholder={ 'Filter by labels...' }
/>
{/* <Form.Text className="text-muted">
Filter by labels in the current project
</Form.Text> */}
</Col>
</Row>
</>
);
}
}
export default SearchBarTranscripts;