Skip to content

Commit

Permalink
Samples table enhancements (#679)
Browse files Browse the repository at this point in the history
* feat: remove turbo streams for samples index action and change to using morphs to maintain page scrolling when updating table

* feat: make sample id and sample name column sticky in samples table, fix pagination links for samples table and morphing.

* chore: fix sort component to keep existing table functionality

* chore: fix single deletion and multiple all success deletion on samples tables

* chore: add back surrounding div for group and project samples tables

* chore: fix sorting component for samples table component

* chore: fix samples cloning

* chore: fix groups samples tests

* chore: fix more tests

* Cchore: fix samples test and update multi delete samples response behaviour

* chore: re-add solargraph gem

* chore: fix sticky columns to work in all browsers

* chore: fix spacing on Samples table

* chore: fix list filter component to work when page is morphed

* chore: fix selection controller reconnecting after morphing of samples table

* chore: fix morphing on samples table when sorting or paging

* chore: fix action links incorrectly reconnecting after morph

* chore: fix action link disabling on samples table after morph

* chore: revert checkbox colour change on samples table

* chore: revert other colour changes that were accidental

* chore: fix another accidental colour change

* chore: remove block from samples deletions destroy response that would never be hit
  • Loading branch information
ericenns authored Aug 2, 2024
1 parent beb0109 commit b601bbb
Show file tree
Hide file tree
Showing 31 changed files with 211 additions and 225 deletions.
35 changes: 17 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ GEM
bindex (0.8.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.2.4)
builder (3.3.0)
business_time (0.13.0)
activesupport (>= 3.2.0)
tzinfo
Expand All @@ -162,7 +162,7 @@ GEM
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
cgi (0.4.1)
concurrent-ruby (1.3.1)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
Expand Down Expand Up @@ -193,7 +193,7 @@ GEM
e2mmap (0.1.0)
erb-formatter (0.7.2)
syntax_tree (~> 6.0)
erubi (1.12.0)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
faker (3.4.1)
Expand Down Expand Up @@ -282,10 +282,10 @@ GEM
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.13.1)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jaro_winkler (1.5.6)
jaro_winkler (1.6.0)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -334,7 +334,7 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.23.1)
minitest (5.24.1)
msgpack (1.7.2)
multi_json (1.15.0)
multi_xml (0.7.1)
Expand All @@ -355,13 +355,13 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.5-aarch64-linux)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.5-arm64-darwin)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-darwin)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -402,8 +402,8 @@ GEM
puma (6.4.2)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.0)
rack (3.0.11)
racc (1.8.1)
rack (3.1.7)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
Expand Down Expand Up @@ -453,12 +453,11 @@ GEM
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (2.8.4)
psych (>= 4.0.0)
rdoc (6.7.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.9.2)
reline (0.5.8)
reline (0.5.9)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
Expand Down Expand Up @@ -556,7 +555,7 @@ GEM
sprockets (>= 3.0.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
stringio (3.1.1)
strscan (3.1.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
Expand All @@ -569,11 +568,11 @@ GEM
tailwindcss-rails (2.6.0-x86_64-linux)
railties (>= 7.0.0)
thor (1.3.1)
tilt (2.3.0)
tilt (2.4.0)
timecop (0.9.8)
timeout (0.4.1)
trailblazer-option (0.1.2)
turbo-rails (2.0.5)
turbo-rails (2.0.6)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -606,7 +605,7 @@ GEM
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.36)
zeitwerk (2.6.15)
zeitwerk (2.6.17)
zip_kit (6.3.0)

PLATFORMS
Expand Down
9 changes: 6 additions & 3 deletions app/components/list_filter_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

<template data-list-filter-target="template">
<%= viral_pill(color: :blue, classes: "search-tag inline-flex items-center filter-item mb-1 mr-1 py-1.5") do %>
<%= form.search_field :name_or_puid_in, multiple: true, class: "hidden" %>
<%= form.search_field :name_or_puid_in,
multiple: true,
class: "hidden",
data: "turbo-temporary" %>
<span class="label font-mono text-base font-semibold mr-1"></span>
<button
type="button"
Expand Down Expand Up @@ -55,8 +58,7 @@
data-list-filter-target="tags"
data-action="click->list-filter#focus"
>

<input
<input
type="text"
name="q[name_or_puid_in][]"
class="
Expand All @@ -67,6 +69,7 @@
data-action='
keydown->list-filter#handleInput
paste->list-filter#handlePaste
turbo:morph-element->list-filter#idempotentConnect
'
data-list-filter-target="input"
/>
Expand Down
8 changes: 2 additions & 6 deletions app/components/pagination_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
<% if prev_url %>
<%= link_to t("components.pagination.previous"),
prev_url,
data: {
turbo_stream: true
},
**link_arguments,
class: "button button--state-default button--size-default" %>
<% end %>
<% if next_url %>
<%= link_to t("components.pagination.next"),
next_url,
data: {
turbo_stream: true
},
**link_arguments,
class: "button button--state-default button--size-default" %>
<% end %>
</div>
Expand Down
13 changes: 12 additions & 1 deletion app/components/pagination_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@
class PaginationComponent < ViewComponent::Base
attr_reader :prev_url, :next_url, :info

def initialize(info:, prev_url: nil, next_url: nil)
def initialize(info:, prev_url: nil, next_url: nil, **link_arguments)
@info = info
@prev_url = prev_url
@next_url = next_url
@link_arguments = link_arguments
end

def link_arguments
if @link_arguments.empty?
{ data: {
turbo_stream: 'true'
} }
else
@link_arguments
end
end
end
4 changes: 2 additions & 2 deletions app/components/ransack/sort_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="<%= url %>" type="button" data-turbo-stream="true" class="flex items-center">
<%= render Viral::BaseComponent.new(tag: 'a', href: url, type: "button", classes: class_names('flex items-center'), **system_arguments) do %>
<%= label %>
<span class="flex-grow-0 ml-2 flex items-center"><%= viral_icon(name: icon, classes: "w-4 h-4 inline-block") %></span>
</a>
<% end %>
13 changes: 12 additions & 1 deletion app/components/ransack/sort_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@ module Ransack
class SortComponent < Component
attr_reader :ransack_obj, :label, :field, :url

def initialize(ransack_obj:, label:, url:, field:)
def initialize(ransack_obj:, label:, url:, field:, **system_arguments)
@ransack_obj = ransack_obj
@label = label
@url = url
@field = field
@system_arguments = system_arguments
end

def system_arguments
if @system_arguments.empty?
{ data: {
turbo_stream: 'true'
} }
else
@system_arguments
end
end

def icon
Expand Down
4 changes: 2 additions & 2 deletions app/components/samples/table_component.en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
en:
puid: ID
name: Sample
puid: Sample ID
name: Sample Name
project: Project
created_at: Created
updated_at: Last Updated
Expand Down
4 changes: 2 additions & 2 deletions app/components/samples/table_component.fr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fr:
puid: ID
name: Sample
puid: Sample ID
name: Sample Name
project: Project
created_at: Created
updated_at: Last Updated
Expand Down
Loading

0 comments on commit b601bbb

Please sign in to comment.