Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

add pagination #59

wants to merge 7 commits into from

Conversation

LISBON11
Copy link
Collaborator

No description provided.

var pagination = Object.assign({ current: true }, this.data.pagination);
block('pager').content()(node => {
const { data } = node;
var pagination = Object.assign({ current: true }, data.pagination);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

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 = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const


return ['first', 'prev', 'current', 'next', 'last'].reduce((acc, type) => {
pagination[type] && acc.push({
var createItem = (type, index) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

};
};

for (var i = 1; i <= pageCount; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let i

result.push(createItem('number', i));
}

return ['first', 'prev'].reduce((acc, type, index) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

к этому блоку не хватает комментария

@skad0
Copy link
Collaborator

skad0 commented Jul 25, 2017

А еще это получается не добавление пагинации, а фикс/доработка

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] :
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.url

block('pager')
.elem('item')
.match(function() { return this.ctx.url !== true; })
.replace()(function() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow funcs

elem: 'item',
elemMods: { type: type },
url: pagination[type]
});
url: pagination[type] || `?page=${index}`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep other params

}

// собираем последовательность из стрелок начала, цифер и стрелок конца
return ['first', 'prev'].reduce((acc, type, index) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return [
    [].reduce(),
    result,
    [].reduce()
];

@LISBON11 LISBON11 force-pushed the pagination branch 4 times, most recently from d937b26 to 55254ce Compare August 2, 2017 12:17
delete params.page;

Location.change({ params: params });
window.location.reload();
Copy link
Collaborator

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 :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мы хотим здесь ajax?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, там уже ajax есть

block('pager').elem('item').match(function() { return this.ctx.url !== true; }).replace()(function() {
block('pager')
.elem('item')
.match(node => { return node.ctx.url !== true; })
Copy link
Member

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)

result.push(createItem('number', i));
}

// собираем последовательность из стрелок начала, цифер и стрелок конца
Copy link
Member

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 }
Copy link
Member

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

querystring.parse(issuesData.pagination.last).page :
parseInt(querystring.parse(issuesData.pagination.prev).page) + 1;

var exceptPagUrl = querystring.parse(issuesData.pagination.last || issuesData.pagination.prev);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var -> const

@LISBON11 LISBON11 force-pushed the pagination branch 3 times, most recently from 8a5022e to 437922a Compare August 8, 2017 08:55
querystring.parse(issuesPag.last).page :
parseInt(querystring.parse(issuesPag.prev).page) + 1;

let exceptPagUrl = querystring.parse(issuesPag.last || issuesPag.prev);
Copy link
Collaborator Author

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

let exceptPagUrl = querystring.parse(issuesPag.last || issuesPag.prev);
delete exceptPagUrl.page;

exceptPagUrl = Object.keys(exceptPagUrl).reduce((resStr, key) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use querystring.stringify() instead

labels: labelsData
labels: labelsData,
pageCount: paginationData.pageCount,
exceptPagUrl: paginationData.exceptPagUrl
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace *pag* with pagination

render(req, res, {
view: 'page-post'
},
Object.assign({
Copy link
Collaborator Author

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 :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation here and everywhere

@skad0 skad0 self-assigned this Oct 19, 2017
@skad0 skad0 removed their assignment Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants