Преглед изворни кода

77833 changed event handler name

Mao пре 4 година
родитељ
комит
282f5d30e7

+ 11 - 11
packages/app/src/components/SearchPage.jsx

@@ -29,16 +29,16 @@ class SearchPage extends React.Component {
       selectedPages: new Set(),
     };
 
-    this.search = this.search.bind(this);
     this.changeURL = this.changeURL.bind(this);
-    this.selectPageToShow = this.selectPageToShow.bind(this);
-    this.toggleCheckBox = this.toggleCheckBox.bind(this);
+    this.onSearchInvoked = this.onSearchInvoked.bind(this);
+    this.onSelectPageToShowInvoked = this.onSelectPageToShowInvoked.bind(this);
+    this.onToggleCheckBoxInvoked = this.onToggleCheckBoxInvoked.bind(this);
   }
 
   componentDidMount() {
     const keyword = this.state.searchingKeyword;
     if (keyword !== '') {
-      this.search({ keyword });
+      this.onSearchInvoked({ keyword });
     }
   }
 
@@ -65,7 +65,8 @@ class SearchPage extends React.Component {
     }
   }
 
-  search(data) {
+
+  onSearchInvoked(data) {
     const keyword = data.keyword;
     if (keyword === '') {
       this.setState({
@@ -80,7 +81,6 @@ class SearchPage extends React.Component {
     this.setState({
       searchingKeyword: keyword,
     });
-
     this.props.appContainer.apiGet('/search', { q: keyword })
       .then((res) => {
         this.changeURL(keyword);
@@ -103,7 +103,7 @@ class SearchPage extends React.Component {
       });
   }
 
-  selectPageToShow= (pageId) => {
+  onSelectPageToShowInvoked= (pageId) => {
     // TODO : this part can be improved.
     // pageId is this form: #id_613eda3717b2d80c4874dfb9
     let index;
@@ -118,7 +118,7 @@ class SearchPage extends React.Component {
     });
   }
 
-  toggleCheckBox = (page) => {
+  onToggleCheckBoxInvoked = (page) => {
     if (this.state.selectedPages.has(page)) {
       this.state.selectedPages.delete(page);
     }
@@ -145,8 +145,8 @@ class SearchPage extends React.Component {
         deletionMode={false}
         selectedPage={this.state.selectedPage}
         selectedPages={this.state.selectedPages}
-        handleChange={this.toggleCheckBox}
-        clickHandler={this.selectPageToShow}
+        clickHandler={this.onSelectPageToShowInvoked}
+        toggleChangeHandler={this.onToggleCheckBoxInvoked}
       >
       </SearchResultList>
     );
@@ -158,7 +158,7 @@ class SearchPage extends React.Component {
         t={this.props.t}
         searchingKeyword={this.state.searchingKeyword}
         appContainer={this.props.appContainer}
-        search={this.search}
+        onSearchInvoked={this.onSearchInvoked}
       >
       </SearchControl>
     );

+ 2 - 2
packages/app/src/components/SearchPage/SearchControl.jsx

@@ -13,7 +13,7 @@ const SearchControl = (props) => {
           t={props.t}
           keyword={props.searchingKeyword}
           appContainer={props.appContainer}
-          onSearchFormChanged={props.search}
+          onSearchFormChanged={props.onSearchInvoked}
         />
       </div>
       {/* TODO: place deleteAll button , relevance button , include specificPath button */}
@@ -25,7 +25,7 @@ SearchControl.propTypes = {
   t: PropTypes.func.isRequired,
   searchingKeyword:  PropTypes.string.isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
-  search: PropTypes.func.isRequired,
+  onSearchInvoked: PropTypes.func.isRequired,
 };
 
 export default SearchControl;

+ 1 - 1
packages/app/src/components/SearchPage/SearchPageForm.jsx

@@ -24,7 +24,7 @@ class SearchPageForm extends React.Component {
   }
 
   search() {
-    if (this.props.onSearchFormChanged == null) {
+    if (this.props.onSearchFormChanged != null) {
       const keyword = this.state.keyword;
       this.props.onSearchFormChanged({ keyword });
       this.setState({ searchedKeyword: keyword });

+ 2 - 2
packages/app/src/components/SearchPage/SearchResultList.jsx

@@ -28,7 +28,7 @@ class SearchResultList extends React.Component {
                     className="custom-control-input search-result-list-delete-checkbox"
                     value={pageId}
                     checked={this.props.selectedPages.has(page)}
-                    onChange={() => { return this.props.handleChange(page) }}
+                    onChange={() => { return this.props.toggleChangeHandler(page) }}
                   />
                   <label className="custom-control-label" htmlFor={`page-delete-check-${page._id}`}></label>
                 </div>
@@ -59,8 +59,8 @@ SearchResultList.propTypes = {
   pages: PropTypes.array.isRequired,
   deletionMode: PropTypes.bool.isRequired,
   selectedPages: PropTypes.array.isRequired,
-  handleChange: PropTypes.func.isRequired,
   clickHandler: PropTypes.func.isRequired,
+  toggleChangeHandler: PropTypes.func.isRequired,
 };