Advertisement
psi_mmobile

Untitled

Aug 14th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. else {
  2. wbsTemplateChanges?.removed.forEach((record) => {
  3. record.wbs_status_id = 2;
  4. this.adminService.updateWbsTemplateData(record.data).then(() => {
  5. this.saveGrids(
  6. workCodeChanges,
  7. resolve
  8. );
  9. this.finishRequest(resolve);
  10. });
  11. });
  12. wbsTemplateChanges?.modified.forEach((record) => {
  13. this.adminService.updateWbsTemplateData(record.data).then(() => {
  14. this.saveGrids(
  15. workCodeChanges,
  16. resolve
  17. );
  18. this.finishRequest(resolve);
  19. });
  20. });
  21.  
  22. wbsTemplateChanges?.added.forEach((record) => {
  23. this.adminService
  24. .createWbsTemplateData(record.data)
  25. .subscribe((wbs: { wbs_id: number }) => {
  26. record.data.wbs_id = wbs.wbs_id;
  27. console.log('wbs.wbs_id',wbs.wbs_id); // doesn't print
  28. // if (index === 0) {
  29. workCodeChanges?.added.forEach(
  30. (workCodeChange) => {
  31. console.log('we passing?');
  32. workCodeChange.wbs_id = wbs.wbs_id;
  33. }
  34. );
  35. workCodeChanges?.modified.forEach(
  36. (workCodeChange) => {
  37. workCodeChange.wbs_id = wbs.wbs_id;
  38. }
  39. );
  40. // }
  41. this.saveGrids(
  42. workCodeChanges,
  43. resolve
  44. );
  45. this.finishRequest(resolve);
  46. });
  47. });
  48. this.saveGrids(
  49. workCodeChanges,
  50. resolve
  51. );
  52. resolve();
  53. }
  54.  
  55.  
  56. saveGrids(
  57. workCodeChanges,
  58. resolve
  59. ) {
  60. // save absence workcodes
  61. if (workCodeChanges) {
  62. workCodeChanges.modified.forEach((workCode) => {
  63. this.adminService.updateWbsWorkCode(workCode).subscribe(
  64. () => {
  65. this.finishRequest(resolve);
  66. },
  67. (error) => {
  68. this.saving = false;
  69. this.notificationService.errorToast(
  70. 'update workcode',
  71. error
  72. );
  73. }
  74. );
  75. });
  76. workCodeChanges.added.forEach((workCode : any) => {
  77. this.adminService
  78. .createWbsWorkCode(workCode, this.selectedWbsTemplate.wbs_id)
  79. .subscribe(
  80. (res: any) => {
  81.  
  82. console.log('we passing?',this.selectedWbsTemplate.wbs_id); // doesn't print
  83. workCode.wbs_work_code_id = +res.wbs_work_code_id;
  84. this.finishRequest(resolve);
  85. },
  86. (error) => {
  87. this.saving = false;
  88. this.notificationService.errorToast(
  89. 'add workcode to template',
  90. error
  91. );
  92. }
  93. );
  94. });
  95. workCodeChanges.removed.forEach((workCode) => {
  96. this.adminService
  97. .deleteWbsWorkCode(
  98. this.selectedWbsTemplate.wbs_id,
  99. workCode.data.work_code_id
  100. )
  101. .subscribe(
  102. () => {
  103. this.finishRequest(resolve);
  104. },
  105. (error) => {
  106. this.saving = false;
  107. this.notificationService.errorToast(
  108. 'remove workcode',
  109. error
  110. );
  111. }
  112. );
  113. });
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement