element_command.erl 2.0 KB

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