element_command.erl 1.7 KB

12345678910111213141516171819202122232425262728293031
  1. -module(element_command).
  2. -author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -compile([export_all, nowarn_export_all]).
  5. render_element(Record) ->
  6. List = [
  7. %global
  8. {<<"accesskey">>, Record#command.accesskey},
  9. {<<"class">>, Record#command.class},
  10. {<<"contenteditable">>, case Record#command.contenteditable of true -> "true"; false -> "false"; _ -> undefined end},
  11. {<<"contextmenu">>, Record#command.contextmenu},
  12. {<<"dir">>, case Record#command.dir of "ltr" -> "ltr"; "rtl" -> "rtl"; "auto" -> "auto"; _ -> undefined end},
  13. {<<"draggable">>, case Record#command.draggable of true -> "true"; false -> "false"; _ -> undefined end},
  14. {<<"dropzone">>, Record#command.dropzone},
  15. {<<"hidden">>, case Record#command.hidden of "hidden" -> "hidden"; _ -> undefined end},
  16. {<<"id">>, Record#command.id},
  17. {<<"lang">>, Record#command.lang},
  18. {<<"spellcheck">>, case Record#command.spellcheck of true -> "true"; false -> "false"; _ -> undefined end},
  19. {<<"style">>, Record#command.style},
  20. {<<"tabindex">>, Record#command.tabindex},
  21. {<<"title">>, Record#command.title},
  22. {<<"translate">>, case Record#command.contenteditable of "yes" -> "yes"; "no" -> "no"; _ -> undefined end},
  23. % spec
  24. {<<"disabled">>, if Record#command.disabled == true -> "disabled"; true -> undefined end},
  25. {<<"icon">>, Record#command.icon},
  26. {<<"label">>, Record#command.label},
  27. {<<"radiogroup">>, Record#command.radiogroup},
  28. {<<"type">>, case Record#command.type of "command" -> "command"; "radio" -> "radio"; "checkbox" -> "checkbox"; _ -> undefined end} | Record#command.data_fields
  29. ],
  30. wf_tags:emit_tag(<<"command">>, List).