Skip to content

Commit

Permalink
Remove "Show More" button from tables (#10891)
Browse files Browse the repository at this point in the history
* Remove "Show More" button from tables

Fixes #10817

* Resolve failing tests

I wasn't sure about the 5 to 3 part, and has changed the z-index right now, as it was the only plausible change I could figure out.

* Update _notes.html.erb

* Update _notes.html.erb

* Update node_shared_test.rb
  • Loading branch information
Yavnikaa authored Apr 12, 2022
1 parent db0515b commit 68eafcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
25 changes: 2 additions & 23 deletions app/views/grids/_notes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@
<% end %>
</tr>
<% end %>
<% if nodes.count > 10 %>
<tfoot>
<th class="show-all" id="notes-table-footer" style="min-width: 110px;"><a style="cursor: pointer;">Show more <b class="caret"></b></a></th>
<th></th>
<th></th>
<th></th>
</tfoot>
<% end %>
</table>
</div>

Expand All @@ -91,26 +83,13 @@
<p><i>Activities should include a materials list, costs and a step-by-step guide to construction with photos. Learn what <a href="https://publiclab.org/notes/warren/09-17-2016/what-makes-a-good-activity">makes a good activity here</a>.</i>
</p>
<% end %>

<script>
(function(){
$(".<%= className %>-<%= randomSeed %> .show-all a").click(function(event) {
var cName = ".<%= className %>-<%= randomSeed %>";
var sName = cName + " tr.extra";
$(sName).toggleClass("hide");
if ($(sName)[0].classList.contains("hide"))
var hiding = true;
var myElement = event.target;
if (event.target.classList.contains("caret"))
myElement = event.target.parentElement;
if (!hiding)
myElement.innerHTML = 'Show less <b class="caret" style = "transform: rotate(180deg);"></b>';
else
myElement.innerHTML = 'Show more <b class="caret"></b>';
});
//setupGridSorters(".<%= className %>-<%= randomSeed %>"); Should order the items by time. Commented out because it reorders the items each time show more/less is clicked
})()
</script>

<style>
th {
position: sticky;
Expand Down
20 changes: 10 additions & 10 deletions test/unit/node_shared_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid notes-grid notes-grid-test notes-grid-test-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('notes-grid-test').length
assert_equal 3, html.scan('notes-grid-test').length
assert html.scan('<td class="title">').length > 1
end

Expand Down Expand Up @@ -80,7 +80,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid notes-grid notes-grid-activity-spectrometer notes-grid-activity-spectrometer-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('notes-grid-activity-spectrometer').length
assert_equal 3, html.scan('notes-grid-activity-spectrometer').length
assert_equal 1, html.scan('<td class="title">').length
end

Expand All @@ -90,7 +90,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid questions-grid questions-grid-spectrometer questions-grid-spectrometer-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('questions-grid-spectrometer').length
assert_equal 3, html.scan('questions-grid-spectrometer').length
assert html.scan('<td class="title">').length > 1
end

Expand All @@ -102,7 +102,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert_equal 1, html.scan('<table class="table inline-grid activity-grid activity-grid-spectrometer activity-grid-spectrometer-').length
assert_equal 7, html.scan('<td').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('activity-grid-spectrometer').length
assert_equal 3, html.scan('activity-grid-spectrometer').length
assert_equal 1, html.scan('<td class="title">').length
end

Expand All @@ -112,7 +112,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid upgrades-grid upgrades-grid-latest upgrades-grid-latest-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('upgrades-grid-latest').length
assert_equal 3, html.scan('upgrades-grid-latest').length
assert html.scan('<td class="title">').length > 1
end

Expand Down Expand Up @@ -203,7 +203,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid notes-grid notes-grid-test notes-grid-test-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('notes-grid-test').length
assert_equal 3, html.scan('notes-grid-test').length
assert_equal 5, html.scan('<td').length
end

Expand All @@ -213,7 +213,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid questions-grid questions-grid-spectrometer questions-grid-spectrometer-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('questions-grid-spectrometer').length
assert_equal 3, html.scan('questions-grid-spectrometer').length
assert html.scan('<td class="title">').length > 1
end

Expand All @@ -223,7 +223,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid questions-grid questions-grid-spectrometer questions-grid-spectrometer-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('questions-grid-spectrometer').length
assert_equal 3, html.scan('questions-grid-spectrometer').length
assert html.scan('<td class="title">').length > 1
end

Expand All @@ -235,7 +235,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert_equal 1, html.scan('<table class="table inline-grid activity-grid activity-grid-spectrometer activity-grid-spectrometer-').length
assert_equal 4, html.scan('<td').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('activity-grid-spectrometer').length
assert_equal 3, html.scan('activity-grid-spectrometer').length
end

test 'about ability of power tags to exclude tags like [upgrades:foo!foo1]' do
Expand All @@ -244,7 +244,7 @@ class NodeSharedTest < ActiveSupport::TestCase
assert html
assert_equal 1, html.scan('<table class="table inline-grid upgrades-grid upgrades-grid-latest upgrades-grid-latest-').length
assert_equal 1, html.scan('<table').length
assert_equal 5, html.scan('upgrades-grid-latest').length
assert_equal 3, html.scan('upgrades-grid-latest').length
assert html.scan('<td class="title">').length > 1
end

Expand Down

0 comments on commit 68eafcb

Please sign in to comment.