SHARE
TWEET

Untitled

a guest Jul 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { CareerPathService } from './../../../career-path/services/career-path.service';
  2. import { Component, OnInit } from '@angular/core';
  3. import { filter } from 'minimatch';
  4.  
  5. @Component({
  6.   selector: 'app-edit-description',
  7.   templateUrl: './edit-description.component.html',
  8.   styleUrls: ['./edit-description.component.scss']
  9. })
  10. export class EditDescriptionComponent implements OnInit {
  11.   editing: any;
  12.   departments: any;
  13.   positions: any;
  14.   descriptions: any;
  15.   departmentDescription: any;
  16.   constructor(private cpService : CareerPathService) {}
  17.  
  18.   get_departments() {
  19.     this.cpService.getDepartments().subscribe((res : any)=>{
  20.       this.departments = res;
  21.     });
  22.   }
  23.  
  24.   get_positions() {
  25.    this.cpService.getPositions().subscribe((res : any)=> {
  26.       this.positions = res;
  27.     });
  28.   }
  29.  
  30.   get_description() {
  31.     this.cpService.getDescriptionType().subscribe((res : any)=> {
  32.       this.descriptions = res;
  33.     });
  34.   }
  35.  
  36.   get_department_description() {
  37.     this.cpService.getDescriptions().subscribe((res : any)=> {
  38.       this.departmentDescription = res;
  39.     });
  40.   }
  41.  
  42.   post_description() {
  43.     let description_text = document.getElementsByTagName('textarea')[0];
  44.     let position_id = document.getElementsByTagName('select')[1].value;
  45.     let description_type = document.getElementsByTagName('select')[2];  
  46.     let NewDescription = document.getElementsByTagName('select')[3];
  47.  
  48.     if(NewDescription.value == '0'){
  49.       this.cpService.postDescription(description_text.value,Number(position_id), Number(description_type.value)).subscribe(res => {console.log(res)});
  50.   }
  51.    else {
  52.       this.cpService.putDescription(description_text.value, Number(position_id), Number(description_type.value), NewDescription.value).subscribe(res => {console.log(res)});
  53.    }
  54.    description_type.selectedIndex = -1;
  55.    NewDescription.selectedIndex = -1;
  56.    description_text.value = "";
  57.   }
  58.   ngOnInit() {
  59.     this.get_departments();
  60.     this.get_positions();
  61.     this.get_description();
  62.     this.get_department_description();
  63.   }
  64.  
  65.   filterDescriptions(id, secondId) {
  66.     return this.departmentDescription.filter(item => {  
  67.       return item.position_id == id && item.description_type_id == secondId}
  68.       );
  69.   }
  70.  
  71.   filterDepartmentsById(id) {
  72.     return this.positions.filter(item => item.department_id === id);
  73.   }
  74.  
  75.  
  76.   populateEdit(value) {
  77.     if(value != 0)
  78.     {
  79.       let edit: any;
  80.       this.cpService.getDescriptions().subscribe((res : any)=> {
  81.       edit = res.filter(item => item.id == value);
  82.       this.editing = edit[0].description;
  83.     });
  84.     }
  85.     else {
  86.       this.editing = "";
  87.     }
  88.  
  89.  }
  90. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top