Create pagination for the index page #198#201
Conversation
davydovanton
left a comment
There was a problem hiding this comment.
Sorry for the delay.
First of all: thanks for this great contribution 👍
Also, could you add some screenshots before merge and also fix style issues?
| end | ||
|
|
||
| def limit | ||
| 10 |
| def call(params) | ||
| @tasks = TaskRepository.new.find_by(search_params) | ||
| repo = TaskRepository.new.find_by(search_params) | ||
| @tasks = all_for_page(repo) |
There was a problem hiding this comment.
it's not a repo 🤔
let's rename it to relation
| end | ||
|
|
||
| def pagination | ||
| html.div(class: 'pagination') do |
There was a problem hiding this comment.
we really need all this code without any specs here?
There was a problem hiding this comment.
I wrote this code, because pagination function was not available in hanami-pagination gem.
Now i replaced it with gem function.
|
|
||
| def find_by(params = {}) | ||
| tasks.where(params).order { id.desc }.map_to(Task).to_a | ||
| tasks.where(params).order { id.desc }.map_to(Task) |
There was a problem hiding this comment.
WDYT if we split this code into two methods:
def find_by(params = {})
search_relation(params).to_a
end
def search_relation(params)
tasks.where(params).order { id.desc }.map_to(Task)
end| end | ||
|
|
||
| it 'returns 10 tasks on page' do | ||
|
|
| end | ||
| end | ||
|
|
||
| context 'when are on the first page' do |
There was a problem hiding this comment.
let's simplify specs here. For this we can use DI (dependency injection and wiki) for repository instance:
So, I found a problem in pagination davydovanton/hanami-pagination#10, thanks for this! 💯 🌟 🎉
|
|
||
| end | ||
|
|
||
|
|
There was a problem hiding this comment.
could you cut unnecessary spaces here and format specs? thanks!
There was a problem hiding this comment.
Ok, i will focus on it more.


Hello.
Nice issue for newby web programmers like me.