-
Notifications
You must be signed in to change notification settings - Fork 19
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
split up orders into three tabs: all, open, closed (63114) #234
base: master
Are you sure you want to change the base?
Conversation
Leave the property of filtering out orders which have 0 hours fo 'all' tab present
Some new requirements were introduced, hence this is again wip. |
…wser back button for navigating between tabs (63952)
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.
The direction is good in general. One method needed a little change to become more readable to me.
With a few tests, this is good to go.
return orders if params[:status_preselection].blank? | ||
if params[:status_preselection] == 'closed' | ||
return orders.where(order_statuses: { closed: true }) | ||
.where(period.where_condition('closed_at')) | ||
end | ||
return unless params[:status_preselection] == 'in_progress' | ||
orders.where(order_statuses: { closed: false }) | ||
|
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.
This needs at least reformatting, let's see... If I reformat, I notice that we are checking the same param over and over, so I switched to a case (pun intended)
return orders if params[:status_preselection].blank? | |
if params[:status_preselection] == 'closed' | |
return orders.where(order_statuses: { closed: true }) | |
.where(period.where_condition('closed_at')) | |
end | |
return unless params[:status_preselection] == 'in_progress' | |
orders.where(order_statuses: { closed: false }) | |
case params[:status_preselection] | |
when nil, "" | |
orders | |
when 'closed' | |
orders.where(order_statuses: { closed: true }) | |
.where(period.where_condition('closed_at')) | |
when 'in_progress' | |
orders.where(order_statuses: { closed: false }) | |
end |
This also nicely obsoletes the mixture of if and unless which made this an excellent cylon detector.
The first case could be a guard statement as well. My proposal is to keep this all at the same level.
At the moment, in the 'Laufende' Tab, as it was before, all orders with 0 hours booked onto them are filtered out. I left this as it is (now for the tab 'Alle'), but I don't understand 100% why this was implemented this way. I could also remove it, if this is desired.