Skip to content

Commit

Permalink
mod_base: add 'is_danger' flag to the confirm dialog.
Browse files Browse the repository at this point in the history
This will show the 'ok' button with the 'btn-danger' style.
  • Loading branch information
mworrell committed Feb 17, 2017
1 parent 2c1aa8b commit 183776c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/ref/actions/action_confirm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ postback Event to be sent back to the server
delegate Erlang module handling the postback.
Defaults to the controller
generating the page. delegate="my_event_module"
is_danger If the 'ok' button should be flagged is_danger
as dangerous.
============= ==================================== =====================================

.. seealso:: actions :ref:`action-alert` and :ref:`action-growl`.
1 change: 1 addition & 0 deletions modules/mod_base/actions/action_base_confirm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ event(#postback{message={confirm, Args}}, Context) ->
{title, Title},
{text, Text},
{is_template, IsTemplate},
{is_danger, proplists:get_value(is_danger, Args, false)},
{ok, proplists:get_value(ok, Args)},
{cancel, proplists:get_value(cancel, Args)},
{action, proplists:get_all_values(action, Args)},
Expand Down
9 changes: 7 additions & 2 deletions modules/mod_base/templates/_action_dialog_confirm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
</div>

<div class="modal-footer">
{% button class="btn btn-default" text=cancel|default:_"Cancel" action={dialog_close} action=on_cancel delegate=delegate tag="a" %}
{% button class="btn btn-primary" text=ok|default:_"OK" action={dialog_close} delegate=delegate postback=postback action=action %}
{% if is_danger %}
{% button class="btn btn-default" text=cancel|default:_"Cancel" action={dialog_close} action=on_cancel delegate=delegate %}
{% button class="btn btn-danger" text=ok|default:_"OK" action={dialog_close} delegate=delegate postback=postback action=action tag="a" %}
{% else %}
{% button class="btn btn-default" text=cancel|default:_"Cancel" action={dialog_close} action=on_cancel delegate=delegate tag="a" %}
{% button class="btn btn-primary" text=ok|default:_"OK" action={dialog_close} delegate=delegate postback=postback action=action %}
{% endif %}
</div>

0 comments on commit 183776c

Please sign in to comment.