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

Remove "Show More" button from tables #10891

Merged
merged 8 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
})()
</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