element_command.erl 1.7 KB

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