Skip to content

Commit

Permalink
fix event dispatch so that the events bubble and can be consumed by o…
Browse files Browse the repository at this point in the history
…ther controllers (#218)
  • Loading branch information
resistorsoftware authored and kirillplatonov committed Apr 11, 2022
1 parent 38acbbd commit 9cafa36
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 62 deletions.
119 changes: 59 additions & 60 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
PATH
remote: .
specs:
polaris_view_components (0.9.0)
polaris_view_components (0.9.1)
rails (>= 5.0.0)
view_component (>= 2.0.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.2.2)
actionpack (= 7.0.2.2)
activesupport (= 7.0.2.2)
actioncable (7.0.2.3)
actionpack (= 7.0.2.3)
activesupport (= 7.0.2.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.2.2)
actionpack (= 7.0.2.2)
activejob (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
actionmailbox (7.0.2.3)
actionpack (= 7.0.2.3)
activejob (= 7.0.2.3)
activerecord (= 7.0.2.3)
activestorage (= 7.0.2.3)
activesupport (= 7.0.2.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.2.2)
actionpack (= 7.0.2.2)
actionview (= 7.0.2.2)
activejob (= 7.0.2.2)
activesupport (= 7.0.2.2)
actionmailer (7.0.2.3)
actionpack (= 7.0.2.3)
actionview (= 7.0.2.3)
activejob (= 7.0.2.3)
activesupport (= 7.0.2.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.2.2)
actionview (= 7.0.2.2)
activesupport (= 7.0.2.2)
actionpack (7.0.2.3)
actionview (= 7.0.2.3)
activesupport (= 7.0.2.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.2.2)
actionpack (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
actiontext (7.0.2.3)
actionpack (= 7.0.2.3)
activerecord (= 7.0.2.3)
activestorage (= 7.0.2.3)
activesupport (= 7.0.2.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.2.2)
activesupport (= 7.0.2.2)
actionview (7.0.2.3)
activesupport (= 7.0.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.2.2)
activesupport (= 7.0.2.2)
activejob (7.0.2.3)
activesupport (= 7.0.2.3)
globalid (>= 0.3.6)
activemodel (7.0.2.2)
activesupport (= 7.0.2.2)
activerecord (7.0.2.2)
activemodel (= 7.0.2.2)
activesupport (= 7.0.2.2)
activestorage (7.0.2.2)
actionpack (= 7.0.2.2)
activejob (= 7.0.2.2)
activerecord (= 7.0.2.2)
activesupport (= 7.0.2.2)
activemodel (7.0.2.3)
activesupport (= 7.0.2.3)
activerecord (7.0.2.3)
activemodel (= 7.0.2.3)
activesupport (= 7.0.2.3)
activestorage (7.0.2.3)
actionpack (= 7.0.2.3)
activejob (= 7.0.2.3)
activerecord (= 7.0.2.3)
activesupport (= 7.0.2.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.2.2)
activesupport (7.0.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -87,7 +87,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
coderay (1.1.3)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
crass (1.0.6)
digest (3.1.0)
erubi (1.10.0)
Expand All @@ -96,8 +96,7 @@ GEM
activesupport (>= 5.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
io-wait (0.2.1)
loofah (2.14.0)
loofah (2.16.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -115,8 +114,7 @@ GEM
digest
net-protocol
timeout
net-protocol (0.1.2)
io-wait
net-protocol (0.1.3)
timeout
net-smtp (0.3.1)
digest
Expand All @@ -140,28 +138,28 @@ GEM
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (7.0.2.2)
actioncable (= 7.0.2.2)
actionmailbox (= 7.0.2.2)
actionmailer (= 7.0.2.2)
actionpack (= 7.0.2.2)
actiontext (= 7.0.2.2)
actionview (= 7.0.2.2)
activejob (= 7.0.2.2)
activemodel (= 7.0.2.2)
activerecord (= 7.0.2.2)
activestorage (= 7.0.2.2)
activesupport (= 7.0.2.2)
rails (7.0.2.3)
actioncable (= 7.0.2.3)
actionmailbox (= 7.0.2.3)
actionmailer (= 7.0.2.3)
actionpack (= 7.0.2.3)
actiontext (= 7.0.2.3)
actionview (= 7.0.2.3)
activejob (= 7.0.2.3)
activemodel (= 7.0.2.3)
activerecord (= 7.0.2.3)
activestorage (= 7.0.2.3)
activesupport (= 7.0.2.3)
bundler (>= 1.15.0)
railties (= 7.0.2.2)
railties (= 7.0.2.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (7.0.2.2)
actionpack (= 7.0.2.2)
activesupport (= 7.0.2.2)
railties (7.0.2.3)
actionpack (= 7.0.2.3)
activesupport (= 7.0.2.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -195,7 +193,7 @@ GEM
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
view_component (2.49.1)
view_component (2.52.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
websocket-driver (0.7.5)
Expand All @@ -209,6 +207,7 @@ PLATFORMS
arm64-darwin-20
arm64-darwin-21
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export default class extends Controller {
this.toggleErrorOverlay(true)

const dropRejectedEvent = new CustomEvent('polaris-dropzone:drop-rejected', {
bubbles: true,
detail: { rejectedFiles: this.rejectedFiles }
})
this.element.dispatchEvent(dropRejectedEvent)
Expand All @@ -279,12 +280,14 @@ export default class extends Controller {
this.toggleErrorOverlay(false)

const dropAcceptedEvent = new CustomEvent('polaris-dropzone:drop-accepted', {
bubbles: true,
detail: {acceptedFiles: this.acceptedFiles }
})
this.element.dispatchEvent(dropAcceptedEvent)
}

const dropEvent = new CustomEvent('polaris-dropzone:drop', {
bubbles: true,
detail: {
files: this.files,
acceptedFiles: this.acceptedFiles,
Expand Down
5 changes: 4 additions & 1 deletion demo/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
polaris_view_components (0.9.0)
polaris_view_components (0.9.1)
rails (>= 5.0.0)
view_component (>= 2.0.0)

Expand Down Expand Up @@ -132,6 +132,8 @@ GEM
nio4r (2.5.8)
nokogiri (1.13.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.0-x86_64-linux)
racc (~> 1.4)
pry (0.14.1)
Expand Down Expand Up @@ -213,6 +215,7 @@ GEM
PLATFORMS
arm64-darwin-20
arm64-darwin-21
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
2 changes: 1 addition & 1 deletion lib/polaris/view_components/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Polaris
module ViewComponents
VERSION = "0.9.0"
VERSION = "0.9.1"
end
end

0 comments on commit 9cafa36

Please sign in to comment.