Advertisement
repente

Untitled

May 14th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. // import m from 'mithril';
  2. import { computer } from "../models/computer";
  3.  
  4. let computerForm = {
  5. oninit: function(vnode) {
  6. computer.load(vnode.attrs.id);
  7. },
  8. view: function() {
  9. return m("form", {
  10. onsubmit: function(event) {
  11. event.preventDefault();
  12. computer.save();
  13. } }, [
  14. m("label.input-label", "Name"),
  15. m("input.input[type=text][placeholder=Name]", {
  16. oninput: function (e) {
  17. computer.current.name = e.target.value;
  18. },
  19. value: computer.current.name
  20. }),
  21. m("label.input-label", "Year"),
  22. m("input.input[type=number][placeholder=Year]", {
  23. oninput: function (e) {
  24. computer.current.year = e.target.value;
  25. },
  26. value: computer.current.year
  27. }),
  28. m("label.input-label", "Operating System"),
  29. m("select.input", {
  30. onchange: function (e) {
  31. computer.current.os = parseInt(e.target.value);
  32. }
  33. }, computer.operatingSystems.map(function(os) {
  34. return m("option", { value: os.id }, os.name);
  35. })),
  36. m("input[type=submit][value=Save].button", "Save")
  37. ]);
  38. }
  39. };
  40.  
  41. export { computerForm };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement