From 5c8f9fd0376afc034251a73023e43ada4041aa34 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Thu, 28 Jan 2016 14:36:26 +0100 Subject: implementing search through articles --- src/web/js/components/MiddlePanel.react.js | 84 ++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'src/web/js/components/MiddlePanel.react.js') diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js index 01c8b696..b2107383 100644 --- a/src/web/js/components/MiddlePanel.react.js +++ b/src/web/js/components/MiddlePanel.react.js @@ -52,12 +52,75 @@ var TableLine = React.createClass({ }, }); +var MiddlePanelSearchRow = React.createClass({ + getInitialState: function() { + return {query: MiddlePanelStore._datas.query, + search_title: MiddlePanelStore._datas.search_title, + search_content: MiddlePanelStore._datas.search_content, + }; + }, + render: function() { + return ( +
+
+ + Title + + + + Content + + + +
+
+
+ ); + }, + setQuery: function(evnt) { + this.setState({query: evnt.target.value}); + }, + toogleSTitle: function() { + this.setState({search_title: !this.state.search_title}, + this.launchSearch); + }, + toogleSContent: function() { + this.setState({search_content: !this.state.search_content}, + this.launchSearch); + }, + launchSearch: function(evnt) { + if(this.state.query && (this.state.search_title + || this.state.search_content)) { + MiddlePanelActions.search({query: this.state.query, + title: this.state.search_title, + content: this.state.search_content}); + } + if(evnt) { + evnt.preventDefault(); + } + }, +}); + var MiddlePanelFilter = React.createClass({ getInitialState: function() { - return {filter: MiddlePanelStore._datas.filter}; + return {filter: MiddlePanelStore._datas.filter, + display_search: MiddlePanelStore._datas.display_search}; }, render: function() { - return ( + var search_row = null; + if(this.state.display_search) { + search_row = + } + return (
+ + bsSize="small"> + + + + + + {search_row} +
); }, setAllFilter: function() { @@ -88,6 +160,12 @@ var MiddlePanelFilter = React.createClass({ this.setState({filter: 'liked'}); MiddlePanelActions.setFilter('liked'); }, + toogleSearch: function() { + if(this.state.display_search) { + MiddlePanelActions.search_off(); + } + this.setState({display_search: !this.state.display_search}); + }, }); var MiddlePanel = React.createClass({ -- cgit