Warn the user when not meetings or upcoming meetings scheduled.#995
Warn the user when not meetings or upcoming meetings scheduled.#995lastpotion merged 9 commits intomasterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #995 +/- ##
==========================================
+ Coverage 97.18% 97.19% +<.01%
==========================================
Files 385 385
Lines 6363 6371 +8
==========================================
+ Hits 6184 6192 +8
Misses 179 179
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #995 +/- ##
==========================================
+ Coverage 97.19% 97.19% +<.01%
==========================================
Files 386 386
Lines 6384 6385 +1
==========================================
+ Hits 6205 6206 +1
Misses 179 179
Continue to review full report at Codecov.
|
| } | ||
| results = search_klass.new(search_params).results | ||
| if results.length == 0 | ||
| params[:filter] = { |
There was a problem hiding this comment.
I'm unsure that mutating the params hash is a good option here (or anywhere). Thoughts @oriolgual? You're more acquainted with the code.
| if !params[:filter] && results.length == 0 | ||
| params[:filter] = { | ||
| date: "past", | ||
| meetings_warning: true |
There was a problem hiding this comment.
This could probably be done by checking if any filter is applied, instead of propagating the parameter around. Looks a bit convoluted to me and we're mixing view logic with controller logic.
| </div> | ||
|
|
||
| <%= form.collection_radio_buttons :date, [["upcoming", t(".upcoming")], ["past", t(".past")]], :first, :last, legend_title: t(".date") %> | ||
| <% unless @meetings_warning %> |
There was a problem hiding this comment.
I'd use a more meaningful variable name here: @upcoming_meetings or something like that.
| @@ -1,5 +1,17 @@ | |||
| <% if @meetings_warning %> | |||
There was a problem hiding this comment.
All the states in this view should be handled directly. Looks like the controller knows too much about view logic. See https://github.com/AjuntamentdeBarcelona/decidim/pull/995/files#r101773425
There was a problem hiding this comment.
I'd simplify this, if meetings.length == 0 just show a message telling the user that there are no meetings, no need to have two different warnings.
There was a problem hiding this comment.
@oriolgual I think it's useful to have two different warnings. If we change the behavior on load time (past instead of upcoming) it's nice to show a warning to the user.
There was a problem hiding this comment.
@josepjaume but following this logic we could have a different message based on the filters you have selected.
| end | ||
| end | ||
|
|
||
| context "No upcoming meetings scheduled" do |
There was a problem hiding this comment.
Tests are OK so fortunately you should be able to refactor the internals 👍
| } | ||
| results = search_klass.new(search_params).results | ||
| if results.length == 0 | ||
| params[:filter] = { |
There was a problem hiding this comment.
I think we need to take another approach on this, and create a different search object instead of creating the results object, this way we can still use all the helper methods.
There was a problem hiding this comment.
Something like:
def index
if search.results.length == 0 && params.dig("filter", "date") != "past" # Maybe this could be extracted to a method
@search = search_klass.new(search_params.merge(filter: { date: "past" }))
end
end| @@ -1,5 +1,17 @@ | |||
| <% if @meetings_warning %> | |||
There was a problem hiding this comment.
I'd simplify this, if meetings.length == 0 just show a message telling the user that there are no meetings, no need to have two different warnings.
| params[:filter] ||= {} | ||
| @meetings_alert = params[:filter]["meetings_alert"] | ||
| @meetings_warning = params[:filter]["meetings_warning"] | ||
| @meetings = results.page(params[:page]).per(12) |
There was a problem hiding this comment.
And revert all this to helper methods.
ad52dc5 to
5acf5d6
Compare
| @geocoded_meetings ||= search.results.select(&:geocoded?) | ||
| end | ||
|
|
||
| def static_map |
| end | ||
| end | ||
|
|
||
| private |
| index: | ||
| view_meeting: View meeting | ||
| meetings: | ||
| no_meetings_warning: At the moment, this process doesn't have any meeting scheduled. |
There was a problem hiding this comment.
This seems a weird translation from Catalan, what about:
"No meetings match your search criteria or no there isn't any meeting scheduled".
| end | ||
|
|
||
| context "No meetings scheduled" do | ||
| let!(:meetings){[]} |
There was a problem hiding this comment.
missing spaces: let!(:meetings) { [] }
| start_time: date.beginning_of_day, | ||
| end_time: date.end_of_day | ||
| ) | ||
|
|
| context "without category or scope" do | ||
| it "does not show any tag" do | ||
| expect(page).not_to have_selector("ul.tags.tags--meeting") | ||
| expect(page).not_to have_selector("ul.tags.tags--meeting") |
There was a problem hiding this comment.
Fix indentation everywhere
| @meeting = Meeting.where(feature: current_feature).find(params[:id]) | ||
| send_data StaticMapGenerator.new(@meeting).data, type: "image/jpeg", disposition: "inline" | ||
| def index | ||
| if search.results.length == 0 && params.dig("filter", "date") != "past" # Maybe this could be extracted to a method |
There was a problem hiding this comment.
Remove the comment (sorry I told you to keep it while offline xD)
josepjaume
left a comment
There was a problem hiding this comment.
Good work, way simpler! Please check my comment about a translation and that's it!
| index: | ||
| view_meeting: View meeting | ||
| meetings: | ||
| no_meetings_warning: No meetings match your search criteria or no there isn't any meeting scheduled. |
🎩 What? Why?
This PR adds a couple of warnings when there's no upcoming meetings or there's not meetings at all. Also, now we're showing all the past meetings the process had if aren't any upcoming meetings scheduled.
📌 Related Issues
📷 Screenshots (optional)
👻 GIF