Skip to content
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

Feature request: confirm_action, but with configurable choices #13

Open
kbakk opened this issue May 20, 2023 · 0 comments
Open

Feature request: confirm_action, but with configurable choices #13

kbakk opened this issue May 20, 2023 · 0 comments

Comments

@kbakk
Copy link

kbakk commented May 20, 2023

The confirm action is useful when the user is presented with one option and some information about the action.

For some cases it could be useful to present the user with multiple options. A further extension to this could be to add some description on each option.

Some mockup:

**Do you want to mark order 123 from customer jane@example.com as paid?**

<Button: Mark as paid without sending receipt>
Will only mark as paid. 


<Button: Mark as paid and send receipt>
Will send an email after marking the order as paid

API

    @button(
        label="Manage payment",
    )
    def mark_as_paid(self, request, pk):
        order: shop.models.Order = self.get_object(request, pk)

        @multi_action(label="Mark as paid without sending receipt", description="Will only mark as paid.") 
        def _action_charge_order(_request):
            order.charge()
            self.message_user(_request, message="Charged.")

        @multi_action(label="Mark as paid and send receipt", description="Will send an email after marking the order as paid.")
        def _action_charge_order_and_email(_request):
            order.charge_and_email()
            self.message_user(_request, message="Charged and emailed.")

        return confirm_action(
            self,
            request,
            actions=[_action_charge_order, _action_charge_order_and_email],
            message=f"Do you want to mark order {order.pk} from customer {order.custome} as paid",
        )
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

No branches or pull requests

1 participant