Skip to content

Commit 7af4b02

Browse files
authored
Follow up to #9849 - 2 normal tag cards and 1 power tag card shows up in the sidebar (#9863)
* only 2 tag cards in the sidebar * update post_test.rb * update post_test.rb * fixed display bug * fix failing system test * remove comments * fix system test * fix system test * added space between card and badge
1 parent 5a2b653 commit 7af4b02

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

app/views/tag/_tags.html.erb

+37-31
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
<% user = user || @user # allow overriding w/ local variable %>
2-
<style>
3-
.popover {
4-
max-width: 300px
5-
}
6-
</style>
7-
82
<div class="tags-list">
93
<% tags.each_with_index do |tag, i| %>
10-
<% if tag.try(:author) && !tag.try(:author).banned? %>
11-
<% if tag.class == NodeTag %>
4+
<% if tag.class == NodeTag %>
125
13-
<% if !power_tag && i < 2 # just the first 2 get special display, power tags excluded %>
14-
<%= render partial: 'tag/miniCard', locals: { tag: tag } %>
15-
<% else %>
6+
<% if !power_tag && i < 2 # just the first 2 get special display, power tags excluded %>
7+
<%= render partial: 'tag/miniCard', locals: { tag: tag } %>
8+
<% else %>
169
17-
<% if i == 2 && !power_tag %>
18-
<a class="show-more-tags" href="javascript:void(0);"><p style="float:left; color:#666; margin-top:14px; margin-left:5px;"><u><%= tags.length - 2 %> more</u> &nbsp </p></a>
19-
<% end %>
20-
21-
<%= render partial: 'tag/miniCard', locals: { tag: tag, grey: power_tag } %>
10+
<% if i == 2 && !power_tag %>
11+
<a class="show-more-tags" href="javascript:void(0);"><p style="float:left; color:#666; margin-top:14px; margin-left:5px;"><u><%= tags.length - 2 %> more</u> &nbsp </p></a>
12+
<% end %>
2213
14+
<% if (tag.name.include? ':') && i == 0 %>
15+
<p style="margin-top:14px;"><%= render partial: 'tag/miniCard', locals: { tag: tag, grey: power_tag } %></p>
16+
17+
<% else %>
18+
<p class="badge <%= badge_name %> pop more-tags" style="display:none;cursor:pointer;margin-bottom:3px;" id="tag_<%= tag.tid %>" data-toggle="popover" data-trigger="focus" data-count=0 data-placement="top" data-content="<p style='text-align:center;'><a href='/tag/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes</a> - <a href='/contributors/<%= tag.name %>'><%= Tag.contributors(tag.name).count %> people <br></a></p> <p style='text-align:center;font-size:12px;'><%if tag.description %><%= tag.description %> |<% end %> created by <a href='/profile/<%= tag.try(:author).try(:username) %>'><%= tag.try(:author).try(:username) %></a> <%= time_ago_in_words(Time.at(tag.date)) %> ago </p><div class='text-center'><a href='/subscribe/tag/<%= tag.name %>' class='btn btn-primary'>Follow</a></div>" data-html="true" title="<%= tag.name %>">
19+
<a class='tag-name' href='/tag/<%= tag.name %>'><%= tag.name %></a>
20+
<% if logged_in_as(['admin', 'moderator']) || (current_user && ( current_user.uid == @node.uid || current_user.uid == tag.uid)) %>
21+
<% if tag.name.include? ':' %>
22+
<a aria-label="Delete tag" data-confirm="This is a power tag (see https://publiclab.org/wiki/power-tags) -- and may drive a specific function on this page. Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete"><i class='fa fa-times-circle fa-white blue pl-1' aria-hidden='true' ></i></a>
23+
<% else %>
24+
<a data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete"><i class='fa fa-times-circle fa-white blue pl-1' aria-hidden='true' ></i></a>
25+
<% end %>
26+
<% end %>
27+
</p>
2328
<% end %>
2429
25-
<% elsif tag.class == UserTag && (tag.name[0..4] != "oauth" || (logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid))) %>
30+
<% end %>
2631
27-
<li style="width: 100%;">
28-
<span id="tag_<%= tag.id %>" class="badge <%= badge_name %> pop" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
29-
<a class='tag-name' href='/tag/<%= tag.name %>'>
30-
<% if tag.name[0..4] != "oauth" %>
31-
<%= tag.name %>
32-
<% else %>
33-
<%= tag.name[0..5] + tag.name.split(':')[1] %>
34-
<% end %>
35-
</a>
36-
<% if logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid) %>
37-
<a aria-label="Delete tag" data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/profile/tags/delete/<%= user.id %>?name=<%= tag.name %>" data-method="delete"><i class='fa fa-times-circle fa-white blue pl-1' aria-hidden='true' ></i></a>
32+
<% elsif tag.class == UserTag && (tag.name[0..4] != "oauth" || (logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid))) %>
33+
34+
<li style="width: 100%;">
35+
<span id="tag_<%= tag.id %>" class="badge <%= badge_name %> pop" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
36+
<a class='tag-name' href='/tag/<%= tag.name %>'>
37+
<% if tag.name[0..4] != "oauth" %>
38+
<%= tag.name %>
39+
<% else %>
40+
<%= tag.name[0..5] + tag.name.split(':')[1] %>
3841
<% end %>
39-
</span>
40-
</li>
42+
</a>
43+
<% if logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid) %>
44+
<a aria-label="Delete tag" data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/profile/tags/delete/<%= user.id %>?name=<%= tag.name %>" data-method="delete"><i class='fa fa-times-circle fa-white blue pl-1' aria-hidden='true' ></i></a>
45+
<% end %>
46+
</span>
47+
</li>
4148
42-
<% end %>
4349
<% end %>
4450
<% end %>
4551
<script type="text/javascript">

test/system/post_test.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ def setup
4949

5050
find('a#tags-open').click()
5151

52-
# There should be 3 tags that show up as a card
53-
page.assert_selector('.tags-list .card-body', :count => 3)
52+
# There should be 2 tags that show up as a card
53+
page.assert_selector('.tags-list .card-body', :count => 2)
5454

5555
find(".tags-list .card-body .ellipsis", match: :first).click()
5656

5757
accept_alert do
5858
find('.tags-list .card-body .tag-delete').click()
5959
end
6060

61-
# Make sure that 1 of the 3 tags is removed
61+
# Make sure that 1 of the 2 tags is removed
6262
page.assert_selector('.tags-list .card-body', :count => 2)
6363
end
6464

@@ -222,8 +222,8 @@ def assert_page_does_not_reload(message = "page should not reload")
222222
find('a#tags-open').click()
223223

224224
# Make sure proper latitude and longitude tags are added
225-
assert_selector('.tags-list .card-body a[href="/tag/lat:22"]', text: "lat:22")
226-
assert_selector('.tags-list .card-body a[href="/tag/lon:76"]', text: "lon:76")
225+
assert_selector('.tags-list .card a[href="/tag/lat:22"]', text: "lat:22") #This is displayed as a miniCard since it's the first power tag
226+
assert_selector('.tags-list .badge a[href="/tag/lon:76"]', text: "lon:76")
227227
end
228228

229229
test 'deleting a wiki' do

0 commit comments

Comments
 (0)