Skip to content

Commit

Permalink
Ordinal drag and drop using mouse events
Browse files Browse the repository at this point in the history
  • Loading branch information
sfnelson committed Sep 22, 2023
1 parent 9e215cf commit 8b3e3b7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

group :test do
gem "capybara"
gem "cuprite"
gem "cuprite", github: "rubycdp/cuprite"
gem "rack_session_access"
gem "rails-controller-testing"
gem "webmock"
Expand Down
15 changes: 10 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/rubycdp/cuprite.git
revision: cc26d526c5d6d784298f3282f8ea4a191eb0a177
specs:
cuprite (0.14.3)
capybara (~> 3.0)
ferrum (~> 0.13.0)

PATH
remote: .
specs:
Expand Down Expand Up @@ -124,9 +132,6 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
cuprite (0.14.3)
capybara (~> 3.0)
ferrum (~> 0.13.0)
dartsass-rails (0.5.0)
railties (>= 6.0.0)
sass-embedded (~> 1.63)
Expand Down Expand Up @@ -184,7 +189,7 @@ GEM
redlock (>= 1.2)
katalyst-kpop (2.0.9)
katalyst-navigation (1.4.1)
katalyst-tables (2.2.2)
katalyst-tables (2.2.4)
html-attributes-utils
view_component
language_server-protocol (3.17.0.3)
Expand Down Expand Up @@ -407,7 +412,7 @@ PLATFORMS
DEPENDENCIES
brakeman
capybara
cuprite
cuprite!
dartsass-rails
erb_lint
factory_bot_rails
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/koi/components/_index-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ $row-height: 48px !default;
text-overflow: ellipsis;
vertical-align: top;
white-space: nowrap;
background-color: white;

> a {
display: block;
Expand Down
17 changes: 17 additions & 0 deletions app/assets/stylesheets/koi/components/index-table/_ordinal.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
$width: 2rem !default;
$time: 125ms !default;

.index-table {
tr {
transition:
top $time ease-in-out,
transform $time ease-in-out;
}

tr[dragging] {
transition: transform $time ease-in-out;
filter: drop-shadow(0 0 0.5rem var(--row-border-color));
transform: scale(1.01);
td {
box-shadow: none;
}
}

th.ordinal {
width: $width;
padding-left: 0;
Expand All @@ -17,5 +33,6 @@ $width: 2rem !default;
width: $width;
padding-left: 0;
cursor: grab;
text-align: center;
}
}
4 changes: 2 additions & 2 deletions spec/system/index/ordinal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
end
end

it "supports mouse re-ordering", pending: "https://bugs.chromium.org/p/chromium/issues/detail?id=850071" do
it "supports mouse re-ordering" do
visit "/admin/banners"

within(".index-table tbody") do
first = page.find("tr:first-child td.ordinal")
last = page.find("tr:last-child td.ordinal")
first.drag_to(last)
first.drag_to(last, steps: 10)
end

expect(page).to have_css("tr:last-child td", text: "first")
Expand Down

0 comments on commit 8b3e3b7

Please sign in to comment.