Not sure how to add a resolved class
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

How do I add a resolved class?

I know I can do

<% if proof %>
  Resolved
<% else %>
  Unresolved
<% end %>

But I feel the unresolved/resolved classes should actually be next to timeline-icon but I'm not sure if that's the correct way to make resolved/unresolved work.

Here's the code that I'm referring.

If you would be able to JSFiddle me something with resolved and unresolved classes working, that would be great!

awarded to alixaxel

Crowdsource coding tasks.

1 Solution

Winning solution

You should add the resolved/unresolved/pending classes in the li, otherwise you'll only be styling the icon.

The classes also control whether the next action date is shown or not and give you the flexibility of, for instance, changing the entire .timeline-content background color or show/hide certain elements (proofs).

In Handlebars (we don't have complex conditions there) I created a helper function to randomly choose a state, if the JSON was dynamic I could as well provide the requirement to that function and it could evaluate it in several aspects and return a corresponding state class:

  • does a proof exists and is it still valid?
    • is the deadline within 15 days? pending
    • otherwise? resolved
  • otherwise? unresolved

I guess that would be a way to do it in RoR. But switches like you're doing are also a good way to go about it.

Sorry for the lack of jsFiddle, but I really don't think you need it.

Here's what I did <% if proof = requirement.proof_for(current_user) %> <li class="resolved"> <% else %> <li class="unresolved"> <% end %>
akshatpradhan 5 years ago