-
Notifications
You must be signed in to change notification settings - Fork 14
Hometask7 #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sergeyBreslavets
wants to merge
10
commits into
romabelka:master
Choose a base branch
from
sergeyBreslavets:hometask7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hometask7 #89
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d181650
Merge pull request #1 from romabelka/master
sergeyBreslavets 430a4e6
Merge pull request #2 from romabelka/master
sergeyBreslavets 464d9d1
Merge pull request #3 from romabelka/master
sergeyBreslavets 297041f
Merge pull request #4 from romabelka/master
sergeyBreslavets 575604f
Merge pull request #5 from romabelka/master
sergeyBreslavets 80684ed
Merge pull request #6 from romabelka/master
sergeyBreslavets 30c45c4
Merge pull request #7 from romabelka/master
sergeyBreslavets f2f66d3
Добавил скелет
sergeyBreslavets f01c001
показал все коменты
sergeyBreslavets 7717892
вывод пагинации
sergeyBreslavets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import React, { Component } from 'react'; | ||
| import Paginator from './Paginator' | ||
| import {connect} from 'react-redux' | ||
| import { loadAllCommentsForPaginator} from '../AC' | ||
| import Comment from './Comment' | ||
| import { commentsAllSelector, commentsGetTotal } from '../selectors' | ||
|
|
||
| class AllComments extends Component { | ||
|
|
||
|
|
||
|
|
||
|
|
||
| componentDidMount() { // | ||
| const { page , path , total, loadAllCommentsForPaginator} = this.props | ||
| console.log("===="+ page ) | ||
| const {limit} = 0 | ||
| const {offset} = 0 | ||
| if( total ==0 ){ | ||
| this.props.loadAllCommentsForPaginator ( page, 0 , 0 ); } | ||
| // можно менять лимит и оффсет но это будет сново загрузка это плохо | ||
| } | ||
|
|
||
|
|
||
|
|
||
| render() { | ||
| const { page , path, comments, total } = this.props | ||
|
|
||
|
|
||
| if (!comments.length) return <h3>load</h3> | ||
| const maxpage = Math.floor(total / 5) + 1; | ||
| // console.log("==="+maxpage); | ||
|
|
||
|
|
||
| // console.log(comments) | ||
| const body = comments.map(comment => <li key = {comment.id}><Comment id = {comment.id} /> <br/> </li>) | ||
|
|
||
|
|
||
| return ( | ||
| <div> | ||
| PAGE = {page} <br/> | ||
| totalcom = {total} | ||
| <ul> | ||
| {body} | ||
| </ul> | ||
| <Paginator path = {path} page = {page} maxpage = {maxpage} /> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export default connect( (state, ownProps)=>{ | ||
| // console.log(ownProps.page) | ||
| return{ | ||
| comments: commentsAllSelector( state, ownProps), | ||
| total : commentsGetTotal(state), | ||
| } | ||
| } , { loadAllCommentsForPaginator} ) (AllComments) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import React, { Component } from 'react'; | ||
| import { NavLink } from 'react-router-dom' | ||
|
|
||
|
|
||
| export default class Paginator extends Component { | ||
| render() { | ||
|
|
||
| const {path , page , maxpage} = this.props | ||
| console.log({path}) | ||
|
|
||
| const paginatorMas = [] ; | ||
| for (let index = 1; index <= maxpage; index++) { | ||
| paginatorMas.push( { "to": path +'/'+index , "text": index } ) | ||
| } | ||
|
|
||
|
|
||
| const body = paginatorMas.map((linkPaginator, index) => | ||
| <li key={index}> <NavLink to = {linkPaginator.to} > {linkPaginator.text.toString()} </NavLink> </li> | ||
| ) | ||
|
|
||
|
|
||
| return ( | ||
| <div> | ||
| <ul> | ||
| {body} | ||
| </ul> | ||
| </div> | ||
| ) | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import React, { Component } from 'react'; | ||
| import AllComments from '../AllComments' | ||
| import {Route} from 'react-router-dom' | ||
|
|
||
|
|
||
| export default class CommentPaginator extends Component { | ||
| render() { | ||
|
|
||
| console.log(this.props.match) | ||
|
|
||
|
|
||
| return ( | ||
| <div> | ||
| <h4> ALL COMMENTS </h4> | ||
| <Route path = {`${this.props.match.path}/:page`} render = {this.getCommentsPaginator} /> | ||
|
|
||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| getCommentsPaginator = ({ match }) => { | ||
|
|
||
| console.log( match) | ||
|
|
||
| const page = match.params.page | ||
|
|
||
| if (!match) return <h2>Please select an article</h2> | ||
| return <AllComments page = {page} path = {this.props.match.path} /> | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
просто 'entities', не надо масссив