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

pin:_tagname_ powertag to pin items to tops of inline-grids that match the tag #766

Closed
jywarren opened this issue Aug 31, 2016 · 20 comments

Comments

Projects
None yet
1 participant
@jywarren
Copy link
Contributor

commented Aug 31, 2016

adding a pin:balloon-mapping tag would push an item to the top of any inline grid with a matching tag, for example an inline grid like [wikis:balloon-mapping] or [notes:balloon-mapping].

To pin to a [activities:balloon-mapping] activities grid, you'd use: pin:activities:balloon-mapping.

This'd allow us to curate the FAQs, Activity Grids etc, as in https://publiclab.org/notes/liz/08-30-2016/check-out-these-activity-grids

This'd be implemented in this file: https://github.com/publiclab/plots2/tree/master/app/models/concerns/node_shared.rb#L190-L221

It could just add to the start of one of these nodes arrays:

      pinned = Node.where(status: 1)
                  .where("node.type = 'page' OR node.type = 'note'")
                  .includes(:revision, :tag)
                  .references(:term_data, :node_revisions)
                  .where('term_data.name = ?', "pin:#{tagname}")
      nodes = pinned + Node.where(status: 1)
                  .where("node.type = 'page' OR node.type = 'note'")
                  .includes(:revision, :tag)
                  .references(:term_data, :node_revisions)
                  .where('term_data.name = ?', tagname)
                  .not.where(nid: pinned.collect(&:nid)) # don't include pinned items twice
                  .order('node_revisions.timestamp DESC')

This would be so great!!!

@jywarren jywarren modified the milestone: Activity grids Aug 31, 2016

@jywarren jywarren changed the title pin:top powertag to pin items to tops of inline-grids pin:_tagname_ powertag to pin items to tops of inline-grids that match the tag May 7, 2019

@jywarren jywarren added the help wanted label May 7, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2019

This is a cool one - started on it here! #5681

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2019

Reopening this to repeat for other types of grids after testing in https://stable.publiclab.org !

now, it only works in [notes:______]

@jywarren jywarren reopened this May 20, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Cool! It kind of works, although it's not pulled to the top:

image

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Hmm, not sure why it's not at the top:

nodes = pinned + Node.where(status: 1)

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Aha! oops, i used pinned in the view but pin in the model!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Yep - ok, fixing!

image

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Fixed in 4ac6e9a !!!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

And, we should add a "pin this post" to the tagging menu, so this is easier to do!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Doing this in #5760, although it only tests nodes so we should expand the tests, as in:

test 'that pinned notes with "pinned:foo" tags appear at the top of [nodes:foo] inline tables' do
before = "Here are some nodes in a table: \n\n[nodes:test] \n\nThis is how you make it work:\n\n`[nodes:tagname]`\n\n `[nodes:tagname]`\n\nMake sense?"
nodes(:one).add_tag('pinned:test', User.first)
nodes(:one).add_tag('test', User.first) # ensure it would appear anyways (although we aren't yet asserting order below, we should)
html = NodeShared.nodes_grid(before)
assert html
assert_equal 1, html.scan('<table class="table inline-grid nodes-grid nodes-grid-test nodes-grid-test-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('nodes-grid-test').length
assert_equal 2, html.scan('<td class="author">').length # but not 3 because it shouldn't appear twice
assert_equal 1, html.scan(nodes(:one).title).length
end

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Wow, #5760 is done - no extra tests, but let's try it out on stable!

@jywarren jywarren reopened this May 22, 2019

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Also noting we may want a related feature of pinned people -- lead organizers, say, using a userTag... to be discussed!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

This works great. Unfortunately it doesn't pin separately for [questions:balloon-mapping] and [activities:balloon-mapping] and [notes:balloon-mapping]. pin:balloon-mapping pins to all three. We should fix that in node_shared.rb by tweaking the tagname variable???

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

And - follow-up -- pinning for comments!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

Separated out questions activities and such!

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 28, 2019

Hmm, the activity pinning isn't working...?

@jywarren

This comment has been minimized.

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 29, 2019

This seems right, though...

<% elsif node.has_tag("pin:activity:#{tagname}") %><i rel="tooltip" title="This item was pinned with the tag 'pin:activity:<%= tagname %>'." class="fa fa-thumb-tack"></i>

Aha! it was in the wrong section. Fixed in 49d58c3

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented May 29, 2019

Closing this out now to be addressed in other issues!

@jywarren jywarren closed this May 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.