Skip to content

[RFC] Use cells for meeting m cards#3022

Merged
oriolgual merged 28 commits intomasterfrom
cells-reloaded-meetings
Mar 21, 2018
Merged

[RFC] Use cells for meeting m cards#3022
oriolgual merged 28 commits intomasterfrom
cells-reloaded-meetings

Conversation

@agustibr
Copy link
Copy Markdown
Contributor

@agustibr agustibr commented Mar 16, 2018

🎩 What? Why?

This PR starts from commit ea666c7 from @mrcasals and is possible to merge with PR #2897 that includes proposal_m cell.

This PR is done with the idea to make the code review easier.

Adding card_for helper in decidim-core to facilitate te use of cards from everywhere, the Component should have the attribute card pointing to the cell's component path, making it possible (size is optional):

<%= card_for my_meeting, size: :m %>

Adding the meeting_cell component to decidim-meetings (decidim-core already has cells from @decidim/lot-core) in two sizes or variations; medium and list_item, the following will render the medium size:

<%= cell "decidim/meetings/meeting", my_meeting %>
<%= cell "decidim/meetings/meeting", my_meeting, size: :m %>
<%= cell "decidim/meetings/meeting_m", my_meeting %>

The medium cell includes a subcell header:

# when used *inside* the `meeting_m` cell
<%= render :head %>

# when used *outside* the `meeting_m` cell
<%= cell("decidim/meetings/meeting", my_meeting).head %>

he following will render the list_iteml size:

<%= cell "decidim/meetings/meeting", meeting, size: :list_item %>

📌 Related Issues

📋 Subtasks

  • Add CHANGELOG entry
  • decidim-core:
    • Introduce ViewModel and Cells to make it possible to add cards to resources.
    • Add CardHelper with card_for that returns a card given an instance of a the Component attribute card from the ComponentManifest.
    • Add AuthorBoxCell and ProfileCell; Remove shared/author_reference partials.
  • decidim: Add documentation for ViewModel and CardCells docs/advanced/view_models_aka_cells.md
  • decidim-dev: Add rspec-cells for testing Cells
  • decidim-meetings:
    • Introduce ViewModel and Cells. Add MeetingCell with two variations: MeetingMCell and MeetingListItemCell.
    • Add the card attribute to the component's manifest shared/author_reference partials.

📷 Screenshots (optional)

meeting :m card:

screenshot from 2018-03-16 14-19-22

meeting :h card:

screenshot from 2018-03-16 14-20-47

@ghost ghost assigned agustibr Mar 16, 2018
@ghost ghost added the status: WIP label Mar 16, 2018
@agustibr agustibr force-pushed the cells-reloaded-meetings branch from 3801b85 to 8eb8a76 Compare March 16, 2018 13:21
<div class="column">
<article class="card card--meeting">
<div class="card__content">
<%= cell("decidim/meetings/meeting_m", model).header %>
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.

<%= render :header %>, I think

Copy link
Copy Markdown
Contributor Author

@agustibr agustibr Mar 16, 2018

Choose a reason for hiding this comment

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

I've tried it, it also works, do you prefer <%= render :header %>?

@tramuntanal tramuntanal mentioned this pull request Mar 19, 2018
8 tasks
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2018

Codecov Report

Merging #3022 into master will decrease coverage by 0.02%.
The diff coverage is 90.64%.

@@            Coverage Diff             @@
##           master    #3022      +/-   ##
==========================================
- Coverage   98.62%   98.59%   -0.03%     
==========================================
  Files        1699     1711      +12     
  Lines       40602    40788     +186     
==========================================
+ Hits        40042    40216     +174     
- Misses        560      572      +12

@agustibr agustibr force-pushed the cells-reloaded-meetings branch 2 times, most recently from 3b05d3d to a3a526d Compare March 20, 2018 09:01
@agustibr agustibr force-pushed the cells-reloaded-meetings branch from a3a526d to 576a6f7 Compare March 20, 2018 09:01
@ghost ghost added the status: WIP label Mar 20, 2018
@agustibr agustibr force-pushed the cells-reloaded-meetings branch from da05d74 to 68a74db Compare March 20, 2018 13:04
@mrcasals
Copy link
Copy Markdown
Contributor

@agustibr there are some conflicts 😄

let!(:meeting) { create(:meeting) }

context "when rendering" do
it 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.

it "renders the card"?

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.

Ok, i'll add the description

let!(:meeting) { create(:meeting) }

context "when rendering" do
it 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.

it "renders the card"?

let!(:meeting) { create(:meeting) }

context "when rendering" do
it 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.

it "renders the card"?

@agustibr
Copy link
Copy Markdown
Contributor Author

@mrcasals I've fixed the merge conflict

@agustibr agustibr mentioned this pull request Mar 20, 2018
2 tasks
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.

Nice work @agustibr! Just some minor things.


delegate :user_signed_in?, to: :parent_controller

delegate :current_user, to: :parent_controller
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.

Could you please merge this two delegates?

end

def resource_cell
model.component.manifest.card
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.

Maybe memoize this?

@resource_cell ||= model.component.manifest.card


module Decidim
class CardCell < Decidim::ViewModel
# This cell renders the card of the given instance of a Component
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.

Could you please move the docs above the class?


delegate :user_signed_in?, to: :parent_controller

delegate :current_user, to: :parent_controller
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.

Can you also merge these?

module Meetings
class MeetingCell < Decidim::Meetings::ViewModel
# This cell renders the meeting card for an instance of a Meeting
# the default size is the Medium Card (:m)
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.

Can you move the docs above the class?

module Decidim
module Meetings
class MeetingListItemCell < Decidim::Meetings::MeetingCell
# This cell renders the List Item Card (:list_item) meeting card
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.

Can you move the docs above the class?

module Decidim
module Meetings
class MeetingMCell < Decidim::Meetings::MeetingCell
# This cell renders the Medium (:m) meeting card
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.

Can you move the docs above the class?

@ghost ghost added the status: WIP label Mar 21, 2018
@agustibr
Copy link
Copy Markdown
Contributor Author

@oriolgual thanks, I have updated/reviewed the PR considering your comments.

@oriolgual oriolgual merged commit 89b050d into master Mar 21, 2018
@oriolgual oriolgual deleted the cells-reloaded-meetings branch March 21, 2018 11:22
@mrcasals
Copy link
Copy Markdown
Contributor

OMG 😍 🎉 🎈 🎊

rbngzlv added a commit that referenced this pull request Mar 21, 2018
* master:
  [RFC] Use cells for meeting m cards (#3022)
  Do not force Postgresql user to be admin when enabling trigram extension (#3053)
  Make organization reference_prefix required (#3056)
  admin can duplicate/copy meetings (#3051)
  Fix question form errors not being displayed (#3046)
  Erb whitespace cutting (#3047)
  Show debates statistics on space show and homepage (#3016)
  Fix broken translated field after form errors (#3026)
  Move decidim executable to "exe" folder (#3028)
  Friendlier buttons (#3027)
  Feedback needed after Endorsing when user has no user_groups (#2998)
  Fix seeding error on generator specs (#3021)
  fix spelling error in threshold (#3019)
  Migration plus seeds (#2933)
@agustibr
Copy link
Copy Markdown
Contributor Author

YAY! 🏄‍♂️ 🎉
I'll go for #2897 🏇

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