element_command.erl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. -module(element_command).
  2. %%-author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -export([
  5. render_element/1
  6. ]).
  7. render_element(Record) ->
  8. List = [
  9. %% global
  10. {<<"accesskey">>, Record#command.accesskey},
  11. {<<"class">>, Record#command.class},
  12. {<<"contenteditable">>,
  13. case Record#command.contenteditable of
  14. true -> "true";
  15. false -> "false";
  16. _ -> undefined
  17. end},
  18. {<<"contextmenu">>, Record#command.contextmenu},
  19. {<<"dir">>,
  20. case Record#command.dir of
  21. "ltr" -> "ltr";
  22. "rtl" -> "rtl";
  23. "auto" -> "auto";
  24. _ -> undefined
  25. end},
  26. {<<"draggable">>,
  27. case Record#command.draggable of
  28. true -> "true";
  29. false -> "false";
  30. _ -> undefined
  31. end},
  32. {<<"dropzone">>, Record#command.dropzone},
  33. {<<"hidden">>,
  34. case Record#command.hidden of
  35. "hidden" -> "hidden";
  36. _ -> undefined
  37. end},
  38. {<<"id">>, Record#command.id},
  39. {<<"lang">>, Record#command.lang},
  40. {<<"spellcheck">>,
  41. case Record#command.spellcheck of
  42. true -> "true";
  43. false -> "false";
  44. _ -> undefined
  45. end},
  46. {<<"style">>, Record#command.style},
  47. {<<"tabindex">>, Record#command.tabindex},
  48. {<<"title">>, Record#command.title},
  49. {<<"translate">>,
  50. case Record#command.contenteditable of
  51. "yes" -> "yes";
  52. "no" -> "no";
  53. _ -> undefined
  54. end},
  55. %% spec
  56. {<<"disabled">>,
  57. case Record#command.disabled of
  58. true -> "disabled";
  59. _ -> undefined
  60. end},
  61. {<<"icon">>, Record#command.icon},
  62. {<<"label">>, Record#command.label},
  63. {<<"radiogroup">>, Record#command.radiogroup},
  64. {<<"type">>,
  65. case Record#command.type of
  66. "command" -> "command";
  67. "radio" -> "radio";
  68. "checkbox" -> "checkbox";
  69. _ -> undefined
  70. end} | Record#command.data_fields
  71. ],
  72. wf_tags:emit_tag(<<"command">>, List).