element_month.erl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. -module(element_month).
  2. -author('Vladimir Galunshchikov').
  3. -include_lib("nitro/include/nitro.hrl").
  4. -compile([export_all, nowarn_export_all]).
  5. render_element(Record) ->
  6. Id = case Record#month.postback of
  7. undefined -> Record#month.id;
  8. Postback ->
  9. ID = case Record#month.id of
  10. undefined -> nitro:temp_id();
  11. I -> I end,
  12. nitro:wire(#event{type=click, postback=Postback, target=ID,
  13. source=Record#month.source, delegate=Record#month.delegate }),
  14. ID end,
  15. List = [
  16. %global
  17. {<<"accesskey">>, Record#month.accesskey},
  18. {<<"class">>, Record#month.class},
  19. {<<"contenteditable">>, case Record#month.contenteditable of true -> "true"; false -> "false"; _ -> undefined end},
  20. {<<"contextmenu">>, Record#month.contextmenu},
  21. {<<"dir">>, case Record#month.dir of "ltr" -> "ltr"; "rtl" -> "rtl"; "auto" -> "auto"; _ -> undefined end},
  22. {<<"draggable">>, case Record#month.draggable of true -> "true"; false -> "false"; _ -> undefined end},
  23. {<<"dropzone">>, Record#month.dropzone},
  24. {<<"hidden">>, case Record#month.hidden of "hidden" -> "hidden"; _ -> undefined end},
  25. {<<"id">>, Id},
  26. {<<"lang">>, Record#month.lang},
  27. {<<"spellcheck">>, case Record#month.spellcheck of true -> "true"; false -> "false"; _ -> undefined end},
  28. {<<"style">>, Record#month.style},
  29. {<<"tabindex">>, Record#month.tabindex},
  30. {<<"title">>, Record#month.title},
  31. {<<"translate">>, case Record#month.contenteditable of "yes" -> "yes"; "no" -> "no"; _ -> undefined end},
  32. % spec
  33. {<<"alt">>,Record#month.alt},
  34. {<<"autofocus">>,if Record#month.autofocus == true -> "autofocus"; true -> undefined end},
  35. {<<"disabled">>, if Record#month.disabled == true -> "disabled"; true -> undefined end},
  36. {<<"form">>,Record#month.form},
  37. {<<"max">>,Record#month.max},
  38. {<<"min">>,Record#month.min},
  39. {<<"name">>,Record#month.name},
  40. {<<"readonly">>,if Record#month.readonly == true -> "readonly"; true -> undefined end},
  41. {<<"required">>,if Record#month.required == true -> "required"; true -> undefined end},
  42. {<<"step">>,Record#month.step},
  43. {<<"type">>, <<"month">>},
  44. {<<"value">>, Record#month.value} | Record#month.data_fields
  45. ],
  46. wf_tags:emit_tag(<<"input">>, nitro:render(Record#month.body), List).