element_summary.erl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. -module(element_summary).
  2. %%-author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -export([
  5. render_element/1
  6. ]).
  7. render_element(Record) when Record#summary.show_if == false -> [<<>>];
  8. render_element(Record) ->
  9. List = [
  10. %% global
  11. {<<"accesskey">>, Record#summary.accesskey},
  12. {<<"class">>, Record#summary.class},
  13. {<<"contenteditable">>,
  14. case Record#summary.contenteditable of
  15. true -> "true";
  16. false -> "false";
  17. _ -> []
  18. end},
  19. {<<"contextmenu">>, Record#summary.contextmenu},
  20. {<<"dir">>,
  21. case Record#summary.dir of
  22. "ltr" -> "ltr";
  23. "rtl" -> "rtl";
  24. "auto" -> "auto";
  25. _ -> []
  26. end},
  27. {<<"draggable">>,
  28. case Record#summary.draggable of
  29. true -> "true";
  30. false -> "false";
  31. _ -> []
  32. end},
  33. {<<"dropzone">>, Record#summary.dropzone},
  34. {<<"hidden">>,
  35. case Record#summary.hidden of
  36. "hidden" -> "hidden";
  37. _ -> []
  38. end},
  39. {<<"id">>, Record#summary.id},
  40. {<<"lang">>, Record#summary.lang},
  41. {<<"spellcheck">>,
  42. case Record#summary.spellcheck of
  43. true -> "true";
  44. false -> "false";
  45. _ -> []
  46. end},
  47. {<<"style">>, Record#summary.style},
  48. {<<"tabindex">>, Record#summary.tabindex},
  49. {<<"title">>, Record#summary.title},
  50. {<<"translate">>,
  51. case Record#summary.contenteditable of
  52. "yes" -> "yes";
  53. "no" -> "no";
  54. _ -> []
  55. end} | Record#summary.data_fields
  56. ],
  57. wf_tags:emit_tag(<<"summary">>, nitro:render(Record#summary.body), List).