psi_mmobile

Untitled

Oct 9th, 2025
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. recursivePost(item, index, resolve, absenceWorkCodeChanges, hoursWorkCodeChanges, bonusWorkCodeChanges, wbsPersonChanges) {
  2. if (!item.alreadySaved) {
  3. console.log('item.alreadySaved', item.alreadySaved);
  4. this.wbsService.parseDatesBeforeSave(item.data);
  5. this.wbsService.createWbsData(item.data).subscribe((id : {wbs_id : number}) =>
  6. {
  7. item.alreadySaved = true;
  8. item.id = id.wbs_id;
  9. item.wbs_id = id.wbs_id;
  10. if (item.poi && !item.poi_id) {
  11. this.numberRequest++;
  12. this.wbsService
  13. .createWbsPOI(item.poi, item.data.wbs_id)
  14. .subscribe((newPOI) => {
  15. item.data.poi_id = newPOI.poi_id;
  16. item.poi_id = newPOI.poi_id;
  17. this.finishRequest(resolve);
  18. });
  19. }
  20. if (index === 0) {
  21. absenceWorkCodeChanges?.added.forEach(
  22. (absenceWorkCodeChange) => {
  23. absenceWorkCodeChange.wbs_id = id.wbs_id;
  24. }
  25. );
  26. absenceWorkCodeChanges?.modified.forEach(
  27. (absenceWorkCodeChange) => {
  28. absenceWorkCodeChange.wbs_id = id.wbs_id;
  29. }
  30. );
  31.  
  32. hoursWorkCodeChanges?.added.forEach(
  33. (hoursWorkCodeChange) => {
  34. hoursWorkCodeChange.wbs_id = id.wbs_id;
  35. }
  36. );
  37. hoursWorkCodeChanges?.modified.forEach(
  38. (hoursWorkCodeChange) => {
  39. hoursWorkCodeChange.wbs_id = id.wbs_id;
  40. }
  41. );
  42.  
  43. bonusWorkCodeChanges?.added.forEach(
  44. (bonusWorkCodeChange) => {
  45. bonusWorkCodeChange.wbs_id = id.wbs_id;
  46. }
  47. );
  48. bonusWorkCodeChanges?.modified.forEach(
  49. (bonusWorkCodeChange) => {
  50. bonusWorkCodeChange.wbs_id = id.wbs_id;
  51. }
  52. );
  53.  
  54. wbsPersonChanges?.added.forEach((wbsPersonChange) => {
  55. wbsPersonChange.wbs_id = id.wbs_id;
  56. });
  57. wbsPersonChanges?.modified.forEach((wbsPersonChange) => {
  58. wbsPersonChange.wbs_id = id.wbs_id;
  59. });
  60. }
  61. if(item.children?.length > 0) {
  62. item.children.forEach((child) => {
  63. child.parent_wbs_id = id.wbs_id;
  64. this.wbsService.updateWbsData(child.data).then(() => {
  65. this.finishRequest(resolve);
  66. });
  67. this.recursivePost(item, index, resolve, absenceWorkCodeChanges, hoursWorkCodeChanges, bonusWorkCodeChanges, wbsPersonChanges);
  68. })
  69. }
  70. }
  71. )
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment