Skip to content

Implementing confirm option for action component #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 3, 2020

Conversation

fiedl
Copy link
Collaborator

@fiedl fiedl commented Dec 17, 2019

Fixes Issue #257: Add confirm option to action component

Changes

  • Implementing confirm option for action component
  • Adding specs
  • Adding documentation

Documentation

This extends the existing action-component documentation.

Confirm Option

When specified, a browser-native confirm dialog is shown before the action is actually performed. The action only is performed after the user confirms. The action is not performed if the user declines to confirm dialog.

confirm: {
  text: "Do you really want to delete this item?"
}

If no text is given, the default text "Are you sure?" will be used.

confirm: true

Example

class ActionTestController < TestController
  def destroy
    render json: {}, status: 200
  end
end

Rails.application.routes.draw do
  delete '/action_test', to: 'action_test#destroy', as: 'action_destroy_test'
end

class ExamplePage < Matestack::Ui::Page

  def response
    components {
      action action_config do
        button text: "Click me!"
      end
      async show_on: "my_action_success", hide_after: 300 do
        plain "Well done!"
      end
    }
  end

  def action_config
    return {
      method: :delete,
      path: :action_destroy_test_path,
      data: {
        foo: "bar"
      },
      confirm: {
        text: "Are you sure?"
      },
      success: {
        emit: "my_action_success"
      }
    }
  end

end

@fiedl fiedl requested a review from jonasjabari December 17, 2019 22:38
jonasjabari
jonasjabari previously approved these changes Jan 3, 2020
@jonasjabari jonasjabari merged commit 8938cf6 into develop Jan 3, 2020
@pascalwengerter pascalwengerter deleted the sf/action-confirm-option-issue-257 branch January 27, 2020 15:27
@jonasjabari jonasjabari added this to the 0.7.4 milestone Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants