SearchResultListView.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Page from '../PageList/Page';
  4. class SearchResultListView extends React.Component {
  5. render() {
  6. return this.props.pages.map((page) => {
  7. // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
  8. const pageId = `#id_${page._id}`;
  9. return (
  10. <li key={page._id} className="nav-item page-list-li w-100 m-0 border-bottom">
  11. <a className="nav-link page-list-link d-flex align-items-baseline" href={pageId}>
  12. <div className="form-check my-auto">
  13. <input className="form-check-input my-auto" type="checkbox" value="" id="flexCheckDefault" />
  14. </div>
  15. {/* TODO: remove dummy snippet and adjust style */}
  16. <div className="d-block">
  17. <Page page={page} noLink />
  18. <div className="border-gray mt-5">{page.snippet}</div>
  19. </div>
  20. <div className="ml-auto d-flex">
  21. {this.props.deletionMode && (
  22. <div className="custom-control custom-checkbox custom-checkbox-danger">
  23. <input
  24. type="checkbox"
  25. id={`page-delete-check-${page._id}`}
  26. className="custom-control-input search-result-list-delete-checkbox"
  27. value={pageId}
  28. checked={this.props.selectedPages.has(page)}
  29. onChange={() => { return this.props.handleChange(page) }}
  30. />
  31. <label className="custom-control-label" htmlFor={`page-delete-check-${page._id}`}></label>
  32. </div>
  33. )}
  34. <div className="page-list-option">
  35. <button
  36. type="button"
  37. className="btn btn-link p-0"
  38. value={page.path}
  39. onClick={(e) => {
  40. window.location.href = e.currentTarget.value;
  41. }}
  42. >
  43. <i className="icon-login" />
  44. </button>
  45. </div>
  46. </div>
  47. </a>
  48. </li>
  49. );
  50. });
  51. }
  52. }
  53. SearchResultListView.propTypes = {
  54. pages: PropTypes.array.isRequired,
  55. deletionMode: PropTypes.bool.isRequired,
  56. selectedPages: PropTypes.array.isRequired,
  57. handleChange: PropTypes.func.isRequired,
  58. };
  59. export default SearchResultListView;