/modules/mod_admin/actions/action_admin_zmedia_choose.erl

http://github.com/zotonic/zotonic · Erlang · 48 lines · 17 code · 11 blank · 20 comment · 0 complexity · 3480ba188a6f65139c09218ffee48acd MD5 · raw file

  1. %% @author Arjan Scherpenisse <arjan@scherpenisse.net>
  2. %% @copyright 2009 Arjan Scherpenisse
  3. %% @doc A media item has been chosen for insertion in the body text.
  4. %% Copyright 2009 Arjan Scherpenisse
  5. %%
  6. %% Licensed under the Apache License, Version 2.0 (the "License");
  7. %% you may not use this file except in compliance with the License.
  8. %% You may obtain a copy of the License at
  9. %%
  10. %% http://www.apache.org/licenses/LICENSE-2.0
  11. %%
  12. %% Unless required by applicable law or agreed to in writing, software
  13. %% distributed under the License is distributed on an "AS IS" BASIS,
  14. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. %% See the License for the specific language governing permissions and
  16. %% limitations under the License.
  17. -module(action_admin_zmedia_choose).
  18. -author("Arjan Scherpenisse <arjan@scherpenisse.net>").
  19. -include("zotonic.hrl").
  20. %% interface functions
  21. -export([
  22. render_action/4,
  23. event/2
  24. ]).
  25. render_action(TriggerId, TargetId, Args, Context) ->
  26. Postback = {zmedia_choose, Args},
  27. {PostbackMsgJS, _PickledPostback} = z_render:make_postback(Postback, click, TriggerId, TargetId, ?MODULE, Context),
  28. {PostbackMsgJS, Context}.
  29. %% @spec event(Event, Context1) -> Context2
  30. event(#postback{message={zmedia_choose, []}}, Context) ->
  31. ?DEBUG(z_context:get("media_id", Context)),
  32. Args = [{id, z_context:get("media_id", Context)}],
  33. z_render:wire({zmedia_has_chosen, Args}, Context);
  34. %% @spec event(Event, Context1) -> Context2
  35. event(#postback{message={zmedia_choose, Args}}, Context) ->
  36. z_render:wire({zmedia_has_chosen, Args}, Context).
  37. %z_render:wire([{growl, [{text, "Yay."}]}], Context).