Просмотр исходного кода

Merge branch 'feat/77525-80783-control-selected-pages' into feat/77525-80785-implement-select-all

SULLEY\ryo-h 4 лет назад
Родитель
Сommit
8ed0c58f6d

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

@@ -19,6 +19,7 @@ class SearchResultList extends React.Component {
               key={page._id}
               key={page._id}
               page={page}
               page={page}
               onClickInvoked={this.props.onClickInvoked}
               onClickInvoked={this.props.onClickInvoked}
+              onChangedInvoked={this.props.onChangedInvoked}
               isSelected={page._id === focusedPageId || false}
               isSelected={page._id === focusedPageId || false}
               noLink
               noLink
             />
             />
@@ -49,7 +50,7 @@ SearchResultList.propTypes = {
   activePage: PropTypes.number.isRequired,
   activePage: PropTypes.number.isRequired,
   pagingLimit: PropTypes.number,
   pagingLimit: PropTypes.number,
   onClickInvoked: PropTypes.func,
   onClickInvoked: PropTypes.func,
-  onChangeInvoked: PropTypes.func,
+  onChangedInvoked: PropTypes.func,
   onPagingNumberChanged: PropTypes.func,
   onPagingNumberChanged: PropTypes.func,
 };
 };
 
 

+ 21 - 11
packages/app/src/components/SearchPage/SearchResultListItem.tsx

@@ -5,25 +5,22 @@ import { DevidedPagePath } from '@growi/core';
 
 
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
+import { ISearchedPage } from '../../interfaces/page';
+
 const logger = loggerFactory('growi:searchResultList');
 const logger = loggerFactory('growi:searchResultList');
 
 
 type Props ={
 type Props ={
-  page: {
-    _id: string,
-    path: string,
-    noLink: boolean,
-    lastUpdateUser: any
-    elasticSearchResult: {
-      snippet: string,
-    }
-  },
+  page: ISearchedPage,
   isSelected: boolean,
   isSelected: boolean,
   onClickInvoked?: (data: string) => void,
   onClickInvoked?: (data: string) => void,
+  onChangedInvoked?: (page: ISearchedPage) => void,
 }
 }
 
 
 const SearchResultListItem: FC<Props> = (props:Props) => {
 const SearchResultListItem: FC<Props> = (props:Props) => {
 
 
-  const { page, isSelected, onClickInvoked } = props;
+  const {
+    page, isSelected, onClickInvoked, onChangedInvoked,
+  } = 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.
   // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
   const pageId = `#${page._id}`;
   const pageId = `#${page._id}`;
@@ -53,7 +50,20 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
         <div className="d-flex">
         <div className="d-flex">
           {/* checkbox */}
           {/* checkbox */}
           <div className="form-check my-auto mr-3">
           <div className="form-check my-auto mr-3">
-            <input className="form-check-input my-auto" type="checkbox" value="" id="flexCheckDefault" />
+            <input
+              className="form-check-input my-auto"
+              type="checkbox"
+              id="flexCheckDefault"
+              onClick={() => {
+                try {
+                  if (onChangedInvoked == null) { throw new Error('onChangedInvoked is null') }
+                  onChangedInvoked(page);
+                }
+                catch (error) {
+                  logger.error(error);
+                }
+              }}
+            />
           </div>
           </div>
           <div className="w-100">
           <div className="w-100">
             {/* page path */}
             {/* page path */}

+ 9 - 0
packages/app/src/interfaces/page.ts

@@ -12,3 +12,12 @@ export type IPage = {
   updatedAt: Date,
   updatedAt: Date,
   seenUsers: string[]
   seenUsers: string[]
 }
 }
+
+export type ISearchedPage = IPage & {
+  _id: string,
+  noLink: boolean,
+  lastUpdateUser: any,
+  elasticSearchResult: {
+    snippet: string,
+  }
+}