Advertisement
repente

Untitled

May 18th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. "use strict";
  2.  
  3. import m from "mithril";
  4.  
  5. import { deliveries, productList } from "../models/deliveries.js";
  6. import { Menu } from "./menu";
  7. var form = {
  8. oninit: productList.getListProduct,
  9. view: function(){
  10. return m("main.container", [
  11. m("h1", "Ny inleverans"),
  12. m("form", {
  13. onsubmit: function (event) {
  14. event.preventDefault();
  15. deliveries.save();
  16. m.route.set("/");
  17. }
  18. }, [
  19.  
  20. m("label.input-label", "Produkt"),
  21. m("select", {
  22. onchange: function (e) {
  23. deliveries.currentDelivery.product_id = parseInt(e.target.value.split("-")[1]);
  24.  
  25. }
  26. }, productList.currentList.map(function(product){
  27. return m("option", {id_product:product.id}, product.name + "-" +product.id);
  28. })
  29. ),
  30.  
  31. m("label.input-label", "Leveransdarum"),
  32. m("input[type=date].input", {
  33. oninput: function (e) {
  34. deliveries.currentDelivery.delivery_date = e.target.value;
  35. }
  36. }),
  37.  
  38.  
  39. m("label.input-label", "Antal"),
  40. m("input[type=number].input", {
  41. oninput: function (e) {
  42. deliveries.currentDelivery.amount = parseInt(e.target.value);
  43. }
  44. }),
  45.  
  46. m("label.input-label", "Kommentar"),
  47. m("textarea[placeholder=Comment].textarea", {
  48. oninput: function (e) {
  49. deliveries.currentDelivery.comment = e.target.value;
  50. }
  51. }),
  52. m("input[type=submit][value=Spara].button","Spara"),
  53. m(Menu),
  54. ]),
  55.  
  56. ]);
  57. }
  58. }
  59.  
  60. export { form };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement