/modules/mod_base/actions/action_base_alert.erl

http://github.com/zotonic/zotonic · Erlang · 42 lines · 17 code · 6 blank · 19 comment · 0 complexity · f1b55b9a5e5a36fd6fb9a2813e7f8d2c MD5 · raw file

  1. %% @author Marc Worrell <marc@worrell.nl>
  2. %% @copyright 2009 Marc Worrell
  3. %%
  4. %% Based on code copyright (c) 2008-2009 Rusty Klophaus
  5. %% Copyright 2009 Marc Worrell
  6. %%
  7. %% Licensed under the Apache License, Version 2.0 (the "License");
  8. %% you may not use this file except in compliance with the License.
  9. %% You may obtain a copy of the License at
  10. %%
  11. %% http://www.apache.org/licenses/LICENSE-2.0
  12. %%
  13. %% Unless required by applicable law or agreed to in writing, software
  14. %% distributed under the License is distributed on an "AS IS" BASIS,
  15. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. %% See the License for the specific language governing permissions and
  17. %% limitations under the License.
  18. -module(action_base_alert).
  19. -include("zotonic.hrl").
  20. -export([
  21. render_action/4,
  22. event/2
  23. ]).
  24. render_action(TriggerId, TargetId, Args, Context) ->
  25. {PostbackMsgJS, _PickledPostback} = z_render:make_postback({alert, Args}, click, TriggerId, TargetId, ?MODULE, Context),
  26. {PostbackMsgJS, Context}.
  27. %% @doc Fill the dialog with the delete confirmation template. The next step will ask to delete the resource
  28. %% @spec event(Event, Context1) -> Context2
  29. event(#postback{message={alert, Args}}, Context) ->
  30. Title = proplists:get_value(title, Args, ?__(<<"Alert">>, Context)),
  31. Vars = [
  32. {title, Title},
  33. {action, proplists:get_all_values(action, Args)}
  34. | Args
  35. ],
  36. z_render:dialog(Title, "_action_dialog_alert.tpl", Vars, Context).