Skip to content

Filter meetings#399

Merged
mrcasals merged 27 commits intomasterfrom
filter_meetings
Jan 9, 2017
Merged

Filter meetings#399
mrcasals merged 27 commits intomasterfrom
filter_meetings

Conversation

@mrcasals
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals commented Dec 20, 2016

🎩 What? Why?

This PR adds a way to filter meetings by scope and to order them by start time.

📌 Related Issues

📋 Subtasks

  • Filter by scope
  • Order by start time
  • Paginate meetings
  • Fix specs for MeetingSearch
  • Fix i18n
  • Add categories to meetings
  • Filter by category
  • Move destroy callback to before_destroy
  • Add decidim_paginate helper to encapsulate the pagination logic
  • Add feature specs
  • Check if we can inject the current feature from the controller instead of passing IDs around
  • Remove the params.delete part (See @oriolgual's first review)

📷 Screenshots (optional)

Description

@codecov-io
Copy link
Copy Markdown

codecov-io commented Dec 21, 2016

Current coverage is 93.58% (diff: 100%)

Merging #399 into master will increase coverage by 0.07%

@@             master       #399   diff @@
==========================================
  Files           346        350     +4   
  Lines          5044       5115    +71   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           4717       4787    +70   
- Misses          327        328     +1   
  Partials          0          0          

Powered by Codecov. Last update cd7f557...759ac3c

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.

Please create a decidim_paginate helper so we don't mutate params.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This has to be changed in the proposals engine too.

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.

Also, this helper could also set the theme

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

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.

We should bind this event on turbolinks:load as well. I recommend moving this code into a class, something like MeetingFilterFormComponent. Then you can bind both events document:ready and turbolinks:load and create an instance of this class (or method, or whatev) to bind the form events.
Also I'm not a huge fan of exposing random globals so it's better if you use a namespace to include the previous class (or method, or whatev) into a global called DecidimMeetings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@beagleknight I'll need your help on this then.

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 it will be more maintainable if we move those regex into separate variables or just factor out some kind of function to extract the params. We can review it later @mrcasals

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use only ascii symbols in comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LOLWUT

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.

Docs? I used jsdoc to document my components. Take a look at decidim-comments components.

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 is not transpiled so I recommend using var instead of const.

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 code still feels very strange to me... I'm not really sure why we need to mix document events with turbolinks ones. Can you add some documentation about this so we remember why we didn't use turbolinks:load event instead of document ready event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

Wrongs docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

?? Shouldn't you use paginate_params?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, since the paginate helper uses the global params. paginate_params are extra parameters that need to be sent to the helper but do not affect the current URL.

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.

Since kaminari will merge the given params with the global ones, instead of deleting them from params we can pass "participatory_process_id" and "feature_id" as empty values.

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 don't like using ids here, see Admin::ProposalForm since it also has scope & category.

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.

Ditto

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.

Should be the same for category?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

Use objects instead of ids

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.

Ditto

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.

start_time.advance(hours: 2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

Ditttooooo

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.

You aren't passing the params here. Maybe we should pass the with params.to_h or .dup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't pass the URL params here, since paginate (from Kaminari) will keep using the global params object to generate the pagination. The hash containing random_seed is the one passed to the decidim_paginate helper as extra params.

_onPopState() {
this._clearForm();

let [sortValue] = this._getLocationParams(/order_start_time=([^&]*)/g) || ["asc"];
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.

So freaking sad that JavaScript doesn't have a built-in way to deal with GET parameters.

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.

6 participants