-
Notifications
You must be signed in to change notification settings - Fork 6
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
add pagination #59
base: master
Are you sure you want to change the base?
add pagination #59
Conversation
common.blocks/pager/pager.bemtree.js
Outdated
var pagination = Object.assign({ current: true }, this.data.pagination); | ||
block('pager').content()(node => { | ||
const { data } = node; | ||
var pagination = Object.assign({ current: true }, data.pagination); |
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.
const
common.blocks/pager/pager.bemtree.js
Outdated
var pagination = Object.assign({ current: true }, data.pagination); | ||
const pageCount = pagination.last ? pagination.last.match(/\&page=(\d+)/i)[1] : | ||
parseInt(pagination.prev.match(/\&page=(\d+)/i)[1]) + 1; | ||
var result = []; |
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.
const
common.blocks/pager/pager.bemtree.js
Outdated
|
||
return ['first', 'prev', 'current', 'next', 'last'].reduce((acc, type) => { | ||
pagination[type] && acc.push({ | ||
var createItem = (type, index) => { |
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.
const
common.blocks/pager/pager.bemtree.js
Outdated
}; | ||
}; | ||
|
||
for (var i = 1; i <= pageCount; i++) { |
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.
let i
common.blocks/pager/pager.bemtree.js
Outdated
result.push(createItem('number', i)); | ||
} | ||
|
||
return ['first', 'prev'].reduce((acc, type, index) => { |
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.
к этому блоку не хватает комментария
А еще это получается не добавление пагинации, а фикс/доработка |
common.blocks/pager/pager.bemtree.js
Outdated
block('pager').content()(node => { | ||
const { data } = node; | ||
const pagination = Object.assign({ current: true }, data.pagination); | ||
const pageCount = pagination.last ? pagination.last.match(/\&page=(\d+)/i)[1] : |
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.
data.url
common.blocks/pager/pager.bemhtml.js
Outdated
block('pager') | ||
.elem('item') | ||
.match(function() { return this.ctx.url !== true; }) | ||
.replace()(function() { |
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.
arrow funcs
common.blocks/pager/pager.bemtree.js
Outdated
elem: 'item', | ||
elemMods: { type: type }, | ||
url: pagination[type] | ||
}); | ||
url: pagination[type] || `?page=${index}`, |
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.
keep other params
common.blocks/pager/pager.bemtree.js
Outdated
} | ||
|
||
// собираем последовательность из стрелок начала, цифер и стрелок конца | ||
return ['first', 'prev'].reduce((acc, type, index) => { |
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.
return [
[].reduce(),
result,
[].reduce()
];
d937b26
to
55254ce
Compare
delete params.page; | ||
|
||
Location.change({ params: params }); | ||
window.location.reload(); |
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.
Ajax will not work with location.reload :(
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.
мы хотим здесь ajax?
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.
да, там уже ajax есть
common.blocks/pager/pager.bemhtml.js
Outdated
block('pager').elem('item').match(function() { return this.ctx.url !== true; }).replace()(function() { | ||
block('pager') | ||
.elem('item') | ||
.match(node => { return node.ctx.url !== true; }) |
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.
- .match(node => { return node.ctx.url !== true; })
+ .match(node => node.ctx.url !== true)
common.blocks/pager/pager.bemtree.js
Outdated
result.push(createItem('number', i)); | ||
} | ||
|
||
// собираем последовательность из стрелок начала, цифер и стрелок конца |
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.
- цифер
+ цифр
but let's keep comments in English ;)
}, | ||
|
||
_getParams: function(sort, direction) { | ||
return Object.assign( | ||
Location.getUri().queryParams, | ||
{ sort, direction }, | ||
{ pagination: undefined } | ||
{ sort, direction } |
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.
only ES5 on client side
server/controllers/gh.js
Outdated
querystring.parse(issuesData.pagination.last).page : | ||
parseInt(querystring.parse(issuesData.pagination.prev).page) + 1; | ||
|
||
var exceptPagUrl = querystring.parse(issuesData.pagination.last || issuesData.pagination.prev); |
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.
var -> const
8a5022e
to
437922a
Compare
server/controllers/gh.js
Outdated
querystring.parse(issuesPag.last).page : | ||
parseInt(querystring.parse(issuesPag.prev).page) + 1; | ||
|
||
let exceptPagUrl = querystring.parse(issuesPag.last || issuesPag.prev); |
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.
if there is ?
at the beginning use .substr(1)
here
server/controllers/gh.js
Outdated
let exceptPagUrl = querystring.parse(issuesPag.last || issuesPag.prev); | ||
delete exceptPagUrl.page; | ||
|
||
exceptPagUrl = Object.keys(exceptPagUrl).reduce((resStr, key) => { |
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.
use querystring.stringify()
instead
server/controllers/gh.js
Outdated
labels: labelsData | ||
labels: labelsData, | ||
pageCount: paginationData.pageCount, | ||
exceptPagUrl: paginationData.exceptPagUrl |
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.
replace *pag*
with pagination
server/controllers/gh.js
Outdated
render(req, res, { | ||
view: 'page-post' | ||
}, | ||
Object.assign({ |
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.
extra indent
function getPaginationData(issuesPag) { | ||
const querystring = require('querystring'), | ||
pageCount = issuesPag.last ? | ||
querystring.parse(issuesPag.last).page : |
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.
indentation here and everywhere
No description provided.