Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- recursivePost(item, index, resolve, absenceWorkCodeChanges, hoursWorkCodeChanges, bonusWorkCodeChanges, wbsPersonChanges) {
- if (!item.alreadySaved) {
- console.log('item.alreadySaved', item.alreadySaved);
- this.wbsService.parseDatesBeforeSave(item.data);
- this.wbsService.createWbsData(item.data).subscribe((id : {wbs_id : number}) =>
- {
- item.alreadySaved = true;
- item.id = id.wbs_id;
- item.wbs_id = id.wbs_id;
- if (item.poi && !item.poi_id) {
- this.numberRequest++;
- this.wbsService
- .createWbsPOI(item.poi, item.data.wbs_id)
- .subscribe((newPOI) => {
- item.data.poi_id = newPOI.poi_id;
- item.poi_id = newPOI.poi_id;
- this.finishRequest(resolve);
- });
- }
- if (index === 0) {
- absenceWorkCodeChanges?.added.forEach(
- (absenceWorkCodeChange) => {
- absenceWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- absenceWorkCodeChanges?.modified.forEach(
- (absenceWorkCodeChange) => {
- absenceWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- hoursWorkCodeChanges?.added.forEach(
- (hoursWorkCodeChange) => {
- hoursWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- hoursWorkCodeChanges?.modified.forEach(
- (hoursWorkCodeChange) => {
- hoursWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- bonusWorkCodeChanges?.added.forEach(
- (bonusWorkCodeChange) => {
- bonusWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- bonusWorkCodeChanges?.modified.forEach(
- (bonusWorkCodeChange) => {
- bonusWorkCodeChange.wbs_id = id.wbs_id;
- }
- );
- wbsPersonChanges?.added.forEach((wbsPersonChange) => {
- wbsPersonChange.wbs_id = id.wbs_id;
- });
- wbsPersonChanges?.modified.forEach((wbsPersonChange) => {
- wbsPersonChange.wbs_id = id.wbs_id;
- });
- }
- if(item.children?.length > 0) {
- item.children.forEach((child) => {
- child.parent_wbs_id = id.wbs_id;
- this.wbsService.updateWbsData(child.data).then(() => {
- this.finishRequest(resolve);
- });
- this.recursivePost(item, index, resolve, absenceWorkCodeChanges, hoursWorkCodeChanges, bonusWorkCodeChanges, wbsPersonChanges);
- })
- }
- }
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment