Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Browse other activities" next to "replicate this" prompt #754

Closed
jywarren opened this issue Aug 30, 2016 · 11 comments
Closed

"Browse other activities" next to "replicate this" prompt #754

jywarren opened this issue Aug 30, 2016 · 11 comments
Labels
enhancement explains that the issue is to improve upon one of our existing features fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby

Comments

@jywarren
Copy link
Member

jywarren commented Aug 30, 2016

This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @jywarren to get it labelled.

Or just solve it yourself!


A link next to the button would let people more easily horizontally browse activities:

screenshot 2016-08-30 at 2 13 06 pm

It could go on this line of code, though you should break it up unto multiple lines so it's easier to read:

https://github.com/publiclab/plots2/blob/master/app/views/notes/_responses.html.erb#L8

To determine where the link should lead to, we look for the tagname, and go to the page with a tag such as activities:<tagname>, so:

DrupalTag.where(name: "activities:" + @node.power_tag('activity')).first.nodes.first.path

However, we must account for the possibility that:

  • the DrupalTag doesn't exist and we can't run .first on an empty returned array
  • the DrupalTag does exist but has no nodes (say, they've been deleted) and we can't call .first on an empty .nodes array

So we'll have to add some if statements to protect against that possibility.

But once you have the URL, you can just add it in a link, like <a href="/...">Browser other activities</a>

@jywarren jywarren added the enhancement explains that the issue is to improve upon one of our existing features label Aug 30, 2016
@jywarren jywarren modified the milestone: Activity grids Aug 31, 2016
@jywarren jywarren added fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby labels Nov 15, 2016
@500swapnil
Copy link
Collaborator

I would like to help with this issue. Can u explain further on how?

@jywarren
Copy link
Member Author

Maybe a good place to begin here would be to look over this test, which lays out what we expect to happen in that template:

https://github.com/publiclab/plots2/blob/master/test/integration/node_insert_extras_test.rb#L40-L53

Here, we're adding the tag activity:test for purposes of testing. So we'd then want this new code to also display a link (an <a> tag) pointed at a page which bears the tag activities:test -- that's the idea of this feature.

You could add that expectation to the test and create a PR, which we should expect to fail, initially.

But -- once it does, we can then begin writing the code to get that test to pass -- and we have a clear way to tell when it's working; to run the tests. Make sense?

I think if we take that as our first step, and you create pull request, we can start there and move forward. Sound good?

Thanks!!

@jywarren
Copy link
Member Author

Oh, and see how the assert_select statements look for specific HTML elements? That's how we can add the new expectation.

@500swapnil
Copy link
Collaborator

Yeah it sounds great. I will have a look

@jywarren
Copy link
Member Author

jywarren commented Dec 7, 2016

Oh - or perhaps you'd like to re-start on this one? Thank you!

@500swapnil
Copy link
Collaborator

Yeah I think I should finish this one first.

@500swapnil
Copy link
Collaborator

#1081

@500swapnil
Copy link
Collaborator

#1083 is the new PR

@500swapnil
Copy link
Collaborator

so the tagname of the URL will be = DrupalTag.where(name: "activities:" + @node.power_tag('activity')).first.nodes.first.path
And how should the rest of the URL and if statements be?

@jywarren
Copy link
Member Author

Hi, so the link would be to a node, and that node would have a tag named activities:balloon-mapping for the tagname balloon-mapping.

So we need to know what the tagname is -- we find that out by using the node.power_tag method, which looks up the "value" of the "activity" powertag for the current node for this page:

@node.power_tag('activity')

IF it returns something, we then use the resulting string to search for a tag matching activities:<tagname> -- like activities:balloon-mapping, for example:

DrupalTag.where(name: @node.power_tag('activity'))

IF we find tags there, we want to use the first one returned (since where() returns an array of results, even if there's only one), then find nodes for that tag, using:

tag.nodes.first

So basically at each stage of this, we need to use an if statement to ensure we're not working with a nil or an empty array. Make sense?

@500swapnil
Copy link
Collaborator

I have added the if statements. Cant understand how to add it to the link. I have opened a PR #1090.
Please have a look! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement explains that the issue is to improve upon one of our existing features fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby
Projects
No open projects
Outreach and coordination
  
recently-completed
Development

No branches or pull requests

2 participants