Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else {
- wbsTemplateChanges?.removed.forEach((record) => {
- record.wbs_status_id = 2;
- this.adminService.updateWbsTemplateData(record.data).then(() => {
- this.saveGrids(
- workCodeChanges,
- resolve
- );
- this.finishRequest(resolve);
- });
- });
- wbsTemplateChanges?.modified.forEach((record) => {
- this.adminService.updateWbsTemplateData(record.data).then(() => {
- this.saveGrids(
- workCodeChanges,
- resolve
- );
- this.finishRequest(resolve);
- });
- });
- wbsTemplateChanges?.added.forEach((record) => {
- this.adminService
- .createWbsTemplateData(record.data)
- .subscribe((wbs: { wbs_id: number }) => {
- record.data.wbs_id = wbs.wbs_id;
- console.log('wbs.wbs_id',wbs.wbs_id); // doesn't print
- // if (index === 0) {
- workCodeChanges?.added.forEach(
- (workCodeChange) => {
- console.log('we passing?');
- workCodeChange.wbs_id = wbs.wbs_id;
- }
- );
- workCodeChanges?.modified.forEach(
- (workCodeChange) => {
- workCodeChange.wbs_id = wbs.wbs_id;
- }
- );
- // }
- this.saveGrids(
- workCodeChanges,
- resolve
- );
- this.finishRequest(resolve);
- });
- });
- this.saveGrids(
- workCodeChanges,
- resolve
- );
- resolve();
- }
- saveGrids(
- workCodeChanges,
- resolve
- ) {
- // save absence workcodes
- if (workCodeChanges) {
- workCodeChanges.modified.forEach((workCode) => {
- this.adminService.updateWbsWorkCode(workCode).subscribe(
- () => {
- this.finishRequest(resolve);
- },
- (error) => {
- this.saving = false;
- this.notificationService.errorToast(
- 'update workcode',
- error
- );
- }
- );
- });
- workCodeChanges.added.forEach((workCode : any) => {
- this.adminService
- .createWbsWorkCode(workCode, this.selectedWbsTemplate.wbs_id)
- .subscribe(
- (res: any) => {
- console.log('we passing?',this.selectedWbsTemplate.wbs_id); // doesn't print
- workCode.wbs_work_code_id = +res.wbs_work_code_id;
- this.finishRequest(resolve);
- },
- (error) => {
- this.saving = false;
- this.notificationService.errorToast(
- 'add workcode to template',
- error
- );
- }
- );
- });
- workCodeChanges.removed.forEach((workCode) => {
- this.adminService
- .deleteWbsWorkCode(
- this.selectedWbsTemplate.wbs_id,
- workCode.data.work_code_id
- )
- .subscribe(
- () => {
- this.finishRequest(resolve);
- },
- (error) => {
- this.saving = false;
- this.notificationService.errorToast(
- 'remove workcode',
- error
- );
- }
- );
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement