Show and mange the statistics at the home page.#552
Conversation
| </div> | ||
|
|
||
| <div class="field"> | ||
| <%= form.check_box :show_statistics, label: t(".questions.show_statistics") %> |
There was a problem hiding this comment.
You might not need the label part here. If you need it, then add the missing locale
There was a problem hiding this comment.
I don't think it's needed, let's use the conventions found on other fields.
Current coverage is 97.17% (diff: 100%)@@ master #552 diff @@
==========================================
Files 257 257
Lines 4007 4031 +24
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 3895 3917 +22
- Misses 112 114 +2
Partials 0 0
|
oriolgual
left a comment
There was a problem hiding this comment.
Add show_statistics to the organization factory too
| @@ -0,0 +1,5 @@ | |||
| class AddShowStatisticsToOrganization < ActiveRecord::Migration[5.0] | |||
| def change | |||
| add_column :decidim_organizations, :show_statistics, :boolean, default: false | |||
There was a problem hiding this comment.
I'd set it as true as default
There was a problem hiding this comment.
@oriolgual don't quite like setting default values on the database. Looks like something that should be done at the model, as well as in the Form. When creating new models, Rails isn't able to inspect the table for default values, so the checkbox will show unchecked.
josepjaume
left a comment
There was a problem hiding this comment.
Real nice work 💅
Just as an observation: Statistics look like something we might leverage a presenter for, as well as most of the stuff present on the home page. Otherwise we'll keep cluttering the HomepageController.
No need to do it right now, just some food for thought.
| def users | ||
| @users ||= Decidim::User.where(organization: current_organization) | ||
| end | ||
|
|
| it "should have the correct values for the statistics" do | ||
| within ".users-count" do | ||
| expect(page).to have_content("4") | ||
| end |
| } | ||
|
|
||
| context "when organization show_statistics attribute is false" do | ||
| let(:organization) { create(:organization, show_statistics: false) } |
🎩 What? Why?
This PR adds to the homepage of Decidim some stats about it's current usage.
At the moment we only can show users and processes, because the other engines are not connected ( I guess it's a bad idea to create dependency between them ).
Also I added an option on the admin panel to show or not them at the home page.
📌 Related Issues
📋 Subtasks
📷 Screenshots (optional)
👻 GIF