Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. import {JetView} from "webix-jet";
  2. import {types} from "models/types";
  3. import {users} from "models/users";
  4. import {setActivities, getActivity} from "models/activities";
  5.  
  6.  
  7. export default class SaveActivity extends JetView{
  8.  
  9. config() {
  10.  
  11. const form = {
  12. view: "form",
  13. id: "activityForm",
  14. width: 420,
  15. bordeless: true,
  16. elements: [
  17. {view: "textarea", label: "Details", name: "Details"},
  18. {view: "richselect",
  19. label: "Type",
  20. name: "TypeID",
  21. options: {
  22. data: types,
  23. body: {
  24. template: "#Value#"
  25. }
  26. }
  27. },
  28. {view: "richselect",
  29. id: "",
  30. label: "Contact",
  31. name: "ContactID",
  32. options: {
  33. data: users,
  34. body: {
  35. template: "#FirstName# #LastName# #Email#"
  36. }
  37. }
  38. },
  39. {view: "datepicker", name: "DueDate", label: "Date", format: "%d-%m-%Y", stringResult: true},
  40.  
  41. {label: "Completed", name: "State", view: "checkbox", width: 120, labelWidth: 100, checkValue: "Close", uncheckValue: "Open"},
  42.  
  43. {cols: [
  44. {view: "button", type: "iconButton", icon: "plus", label: "Add (*save)", click: saveForm},
  45. {view: "button", type: "iconButton", icon: "edit", label: "Cancel", click: function(){
  46. this.getTopParentView().hide();
  47. }}
  48. ]}
  49. ],
  50. rules: {
  51. TypeID: webix.rules.isNotEmpty,
  52. ContactID: webix.rules.isNotEmpty
  53. }
  54. };
  55.  
  56. const popup = {
  57. view: "window",
  58. width: 300,
  59. position: "center",
  60. modal: true,
  61. head: "Add (*edit) activity",
  62. body: form
  63. };
  64.  
  65. return popup;
  66.  
  67. }
  68.  
  69. showWindow(id) {
  70. this.getRoot().show();
  71. if (id) {
  72. $$("activityForm").setValues(getActivity(id));
  73. }else{
  74. $$("activityForm").clear();
  75. }
  76. }
  77.  
  78. }
  79.  
  80.  
  81. function saveForm() {
  82. if ($$("activityForm").validate()) {
  83. webix.message("Data entered correctly");
  84. const takenData = $$("activityForm").getValues();
  85. setActivities(takenData.id, takenData);
  86. this.getTopParentView().hide();
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement