class Shimmer::RemoteNavigator

Public Class Methods

new(controller) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 52
def initialize(controller)
  @controller = controller
end

Public Instance Methods

append(id, with:, **locals) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 76
def append(id, with:, **locals)
  queued_updates.push turbo_stream.append(id, partial: with, locals: locals)
end
close_modal() click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 88
def close_modal
  run_javascript "ui.modal.close()"
end
close_popover() click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 96
def close_popover
  run_javascript "ui.popover.close()"
end
navigate_to(path) click to toggle source
open_modal(path, id: nil, size: nil, close: true) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 84
def open_modal(path, id: nil, size: nil, close: true)
  run_javascript "ui.modal.open(#{{url: url, id: id, size: size, close: close}.to_json})"
end
open_popover(path, selector:, placement: nil) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 92
def open_popover(path, selector:, placement: nil)
  run_javascript "ui.popover.open(#{{url: url, selector: selector, placement: placement}.to_json})"
end
prepend(id, with:, **locals) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 72
def prepend(id, with:, **locals)
  queued_updates.push turbo_stream.prepend(id, partial: with, locals: locals)
end
queued_updates() click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 56
def queued_updates
  @queued_updates ||= []
end
remove(id) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 80
def remove(id)
  queued_updates.push turbo_stream.remove(id)
end
replace(id, with: id, **locals) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 68
def replace(id, with: id, **locals)
  queued_updates.push turbo_stream.replace(id, partial: with, locals: locals)
end
run_javascript(script) click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 64
def run_javascript(script)
  queued_updates.push turbo_stream.append "shimmer", "<div class='hidden' data-controller='remote-navigation'>#{script}</div>"
end
updates?() click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 60
def updates?
  queued_updates.any?
end

Private Instance Methods

turbo_stream() click to toggle source
# File lib/shimmer/utils/remote_navigation.rb, line 108
def turbo_stream
  @controller.send(:turbo_stream)
end