Sha256: 949b547815c5d737af15025dd50a581adddb3c66df0440513495801015fac251

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

Voom::Presenters.define(:last_response_action) do
  helpers Demo::Helpers::IndentedGrid
  attach :top_nav
  attach :events_drawer

  indented_grid do
    heading 'Last Response'
    body 'You can access the last response and forward its data to a snackbar or posts|updates|deletes|replaces|loads.'
    title 'Posts'
    button 'quote' do
      event :click do
        posts '_echo_', {quote: 'Compromise is the shared hypotenuse of the conjoined triangles of success.'}
        posts '_echo_', echo: {quote: last_response.quote}, headers: {'X-Custom'=>'Boom!'}
        snackbar last_response.echo.quote
      end
    end

    title 'Replaces'
    button 'replaces' do
      event :click do
        posts '_echo_', {quote: 'Compromise is the shared hypotenuse of the conjoined triangles of success.'}
        replaces :replace_me, :replace_text, text: last_response.quote
      end
    end
    attach :replace_text

    blank
    title "Loads another presesnter"
    text "Will reload this page passing a value from the last response of another action"
    text "Quote from last response: {c:blue}#{context.fetch(:quote, nil)}{/c}" unless context.fetch(:quote, nil).nil?
    button 'Reloads this page' do
      event :click do
        posts '_echo_', {quote: 'Compromise is the shared hypotenuse of the conjoined triangles of success.'}
        loads :last_response_action, reloaded: true, quote: last_response.quote
      end
    end
    heading context['reloaded'] ? "Reloaded" : 'Loaded'
  end
  attach :code, file: __FILE__
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 app/demo/events/actions/last_response.pom
voom-presenters-2.1.0 app/demo/events/actions/last_response.pom
voom-presenters-2.0.3 app/demo/events/actions/last_response.pom
voom-presenters-2.0.2 app/demo/events/actions/last_response.pom
voom-presenters-2.0.1 app/demo/events/actions/last_response.pom
voom-presenters-2.0.0 app/demo/events/actions/last_response.pom