Skip to content

Warn the user when not meetings or upcoming meetings scheduled.#995

Merged
lastpotion merged 9 commits intomasterfrom
fix/meetings/no_upcoming_meetings
Feb 21, 2017
Merged

Warn the user when not meetings or upcoming meetings scheduled.#995
lastpotion merged 9 commits intomasterfrom
fix/meetings/no_upcoming_meetings

Conversation

@lastpotion
Copy link
Copy Markdown
Contributor

@lastpotion lastpotion commented Feb 17, 2017

🎩 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)

screen shot 2017-02-17 at 10 32 29

screen shot 2017-02-16 at 15 59 21

👻 GIF

@lastpotion lastpotion changed the title Fix/meetings/no upcoming meetings Warn the user when not meetings or upcoming meetings schedulded. Feb 17, 2017
@lastpotion lastpotion changed the title Warn the user when not meetings or upcoming meetings schedulded. Warn the user when not meetings or upcoming meetings scheduled. Feb 17, 2017
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #995 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #995      +/-   ##
==========================================
+ Coverage   97.18%   97.19%   +<.01%     
==========================================
  Files         385      385              
  Lines        6363     6371       +8     
==========================================
+ Hits         6184     6192       +8     
  Misses        179      179
Impacted Files Coverage Δ
...ontrollers/decidim/meetings/meetings_controller.rb 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4eb0a1...ad52dc5. Read the comment docs.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 17, 2017

Codecov Report

Merging #995 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #995      +/-   ##
==========================================
+ Coverage   97.19%   97.19%   +<.01%     
==========================================
  Files         386      386              
  Lines        6384     6385       +1     
==========================================
+ Hits         6205     6206       +1     
  Misses        179      179
Impacted Files Coverage Δ
...ontrollers/decidim/meetings/meetings_controller.rb 100% <100%> (ø)
decidim-core/db/seeds.rb 100% <ø> (ø)
...decidim/admin/update_participatory_process_step.rb 100% <ø> (ø)
...dim-core/lib/decidim/core/api/process_step_type.rb 100% <ø> (ø)
...s/decidim/admin/participatory_process_step_form.rb 100% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 014eba1...7cd79c3. Read the comment docs.

}
results = search_klass.new(search_params).results
if results.length == 0
params[:filter] = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd use a more meaningful variable name here: @upcoming_meetings or something like that.

@@ -1,5 +1,17 @@
<% if @meetings_warning %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests are OK so fortunately you should be able to refactor the internals 👍

Copy link
Copy Markdown
Contributor

@oriolgual oriolgual left a comment

Choose a reason for hiding this comment

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

Remember to add specs

}
results = search_klass.new(search_params).results
if results.length == 0
params[:filter] = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And revert all this to helper methods.

@lastpotion lastpotion force-pushed the fix/meetings/no_upcoming_meetings branch from ad52dc5 to 5acf5d6 Compare February 20, 2017 13:36
@geocoded_meetings ||= search.results.select(&:geocoded?)
end

def static_map
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wat

end
end

private
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't remove this

Comment thread decidim-meetings/config/locales/en.yml Outdated
index:
view_meeting: View meeting
meetings:
no_meetings_warning: At the moment, this process doesn't have any meeting scheduled.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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){[]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing spaces: let!(:meetings) { [] }

start_time: date.beginning_of_day,
end_time: date.end_of_day
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't remove this line

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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the comment (sorry I told you to keep it while offline xD)

Copy link
Copy Markdown
Contributor

@josepjaume josepjaume left a comment

Choose a reason for hiding this comment

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

Good work, way simpler! Please check my comment about a translation and that's it!

Comment thread decidim-meetings/config/locales/en.yml Outdated
index:
view_meeting: View meeting
meetings:
no_meetings_warning: No meetings match your search criteria or no there isn't any meeting scheduled.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo: "Or there isn't"

@lastpotion lastpotion merged commit 3384621 into master Feb 21, 2017
@lastpotion lastpotion deleted the fix/meetings/no_upcoming_meetings branch February 21, 2017 15:22
Quentinchampenois added a commit to Quentinchampenois/decidim that referenced this pull request Nov 12, 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