Explorar o código

80785 fix function and name

SULLEY\ryo-h %!s(int64=4) %!d(string=hai) anos
pai
achega
8c47b0f26e

+ 9 - 14
packages/app/src/components/SearchPage.jsx

@@ -50,7 +50,6 @@ class SearchPage extends React.Component {
     this.onExcludeUsersHome = this.onExcludeUsersHome.bind(this);
     this.onExcludeTrash = this.onExcludeTrash.bind(this);
     this.onPagingNumberChanged = this.onPagingNumberChanged.bind(this);
-    this.onClickAllSelectButton = this.onClickAllSelectButton.bind(this);
   }
 
   componentDidMount() {
@@ -80,10 +79,6 @@ class SearchPage extends React.Component {
     this.setState({ excludeTrash: !this.state.excludeTrash });
   }
 
-  onClickAllSelectButton(nextCheckboxState) {
-    this.setState({ checkboxState: nextCheckboxState });
-  }
-
   changeURL(keyword, refreshHash) {
     let hash = window.location.hash || '';
     // TODO 整理する
@@ -190,19 +185,20 @@ class SearchPage extends React.Component {
     });
   }
 
-  updateCheckboxState = () => {
-    let currentCheckboxState;
+  getCheckboxType = () => {
     switch (this.state.selectedPages.size) {
       case 0:
-        currentCheckboxState = CheckboxType.NONE_CHECKED;
-        break;
+        return CheckboxType.NONE_CHECKED;
       case this.state.searchedPages.length:
-        currentCheckboxState = CheckboxType.ALL_CHECKED;
-        break;
+        return CheckboxType.ALL_CHECKED;
       default:
-        currentCheckboxState = CheckboxType.INDETERMINATE;
-        break;
+        return CheckboxType.INDETERMINATE;
     }
+  }
+
+  updateCheckboxState = () => {
+    const currentCheckboxState = this.getCheckboxType;
+    console.log(currentCheckboxState);
     this.setState({ checkboxState: currentCheckboxState });
   }
 
@@ -265,7 +261,6 @@ class SearchPage extends React.Component {
         onExcludeTrash={this.onExcludeTrash}
         onClickInvoked={this.toggleAllCheckBox}
         checkboxState={this.state.checkboxState}
-        onClickAllSelectButton={this.onClickAllSelectButton}
       >
       </SearchControl>
     );

+ 6 - 1
packages/app/src/components/SearchPage/DeleteSelectedPageGroup.tsx

@@ -17,6 +17,11 @@ const DeleteSelectedPageGroup:FC<Props> = (props:Props) => {
     checkboxState, onClickInvoked, onCheckInvoked,
   } = props;
 
+  const onCheckAllPages = () => {
+    if (props.onClickInvoked == null) { logger.error('onClickInvoked is null') }
+    else { props.onClickInvoked() }
+  };
+
   return (
     <>
       {/** todo: implement the design for CheckboxType = INDETERMINATE */}
@@ -26,7 +31,7 @@ const DeleteSelectedPageGroup:FC<Props> = (props:Props) => {
         type="checkbox"
         name="check-all-pages"
         className="custom-control custom-checkbox ml-1 align-self-center"
-        onClick={onCheckInvoked}
+        onClick={onCheckAllPages}
         checked={checkboxState !== CheckboxType.NONE_CHECKED}
       />
       <button

+ 1 - 7
packages/app/src/components/SearchPage/SearchControl.tsx

@@ -17,7 +17,6 @@ type Props = {
   onExcludeUsersHome?: () => void,
   onExcludeTrash?: () => void,
   onClickInvoked?: () => void,
-  onClickAllSelectButton?: () => void,
 }
 
 const SearchControl: FC <Props> = (props: Props) => {
@@ -45,11 +44,6 @@ const SearchControl: FC <Props> = (props: Props) => {
     // https://estoc.weseek.co.jp/redmine/issues/77525
   };
 
-  const onCheckAllPagesInvoked = () => {
-    if (props.onClickInvoked == null) { logger.error('onClickInvoked is null') }
-    else { props.onClickInvoked() }
-  };
-
   return (
     <div className="">
       <div className="search-page-input sps sps--abv">
@@ -65,7 +59,7 @@ const SearchControl: FC <Props> = (props: Props) => {
         <DeleteSelectedPageGroup
           checkboxState={props.checkboxState}
           onClickInvoked={onDeleteSelectedPageHandler}
-          onCheckInvoked={onCheckAllPagesInvoked}
+          onCheckInvoked={props.onClickInvoked}
         />
         <div className="d-flex align-items-center border rounded border-gray px-2 py-1 mr-2 ml-auto">
           <label className="my-0 mr-2" htmlFor="flexCheckDefault">

+ 1 - 1
packages/app/src/components/SearchPage/SearchResultList.tsx

@@ -35,7 +35,7 @@ const SearchResultList: FC<Props> = (props:Props) => {
             key={page._id}
             page={page}
             onClickInvoked={props.onClickInvoked}
-            onChangedInvoked={props.onChangedInvoked}
+            onClickCheckboxInvoked={props.onChangedInvoked}
             isSelected={page._id === focusedPageId || false}
           />
         );

+ 4 - 4
packages/app/src/components/SearchPage/SearchResultListItem.tsx

@@ -66,14 +66,14 @@ const PageItemControl: FC<PageItemControlProps> = (props: {page: ISearchedPage})
 type Props = {
   page: ISearchedPage,
   isSelected: boolean,
-  onChangedInvoked?: (page: ISearchedPage) => void,
+  onClickCheckboxInvoked?: (page: ISearchedPage) => void,
   onClickInvoked?: (pageId: string) => void,
 }
 
 const SearchResultListItem: FC<Props> = (props:Props) => {
 
   const {
-    page, isSelected, onClickInvoked, onChangedInvoked,
+    page, isSelected, onClickInvoked, onClickCheckboxInvoked,
   } = props;
 
   // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
@@ -106,8 +106,8 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
               id="flexCheckDefault"
               onClick={() => {
                 try {
-                  if (onChangedInvoked == null) { throw new Error('onChangedInvoked is null') }
-                  onChangedInvoked(page);
+                  if (onClickCheckboxInvoked == null) { throw new Error('onClickCheckboxInvoked is null') }
+                  onClickCheckboxInvoked(page);
                 }
                 catch (error) {
                   logger.error(error);