Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { CareerPathService } from './../../../career-path/services/career-path.service';
- import { Component, OnInit } from '@angular/core';
- import { filter } from 'minimatch';
- @Component({
- selector: 'app-edit-description',
- templateUrl: './edit-description.component.html',
- styleUrls: ['./edit-description.component.scss']
- })
- export class EditDescriptionComponent implements OnInit {
- editing: any;
- departments: any;
- positions: any;
- descriptions: any;
- departmentDescription: any;
- constructor(private cpService : CareerPathService) {}
- get_departments() {
- this.cpService.getDepartments().subscribe((res : any)=>{
- this.departments = res;
- });
- }
- get_positions() {
- this.cpService.getPositions().subscribe((res : any)=> {
- this.positions = res;
- });
- }
- get_description() {
- this.cpService.getDescriptionType().subscribe((res : any)=> {
- this.descriptions = res;
- });
- }
- get_department_description() {
- this.cpService.getDescriptions().subscribe((res : any)=> {
- this.departmentDescription = res;
- });
- }
- post_description() {
- let description_text = document.getElementsByTagName('textarea')[0];
- let position_id = document.getElementsByTagName('select')[1].value;
- let description_type = document.getElementsByTagName('select')[2];
- let NewDescription = document.getElementsByTagName('select')[3];
- if(NewDescription.value == '0'){
- this.cpService.postDescription(description_text.value,Number(position_id), Number(description_type.value)).subscribe(res => {console.log(res)});
- }
- else {
- this.cpService.putDescription(description_text.value, Number(position_id), Number(description_type.value), NewDescription.value).subscribe(res => {console.log(res)});
- }
- description_type.selectedIndex = -1;
- NewDescription.selectedIndex = -1;
- description_text.value = "";
- }
- ngOnInit() {
- this.get_departments();
- this.get_positions();
- this.get_description();
- this.get_department_description();
- }
- filterDescriptions(id, secondId) {
- return this.departmentDescription.filter(item => {
- return item.position_id == id && item.description_type_id == secondId}
- );
- }
- filterDepartmentsById(id) {
- return this.positions.filter(item => item.department_id === id);
- }
- populateEdit(value) {
- if(value != 0)
- {
- let edit: any;
- this.cpService.getDescriptions().subscribe((res : any)=> {
- edit = res.filter(item => item.id == value);
- this.editing = edit[0].description;
- });
- }
- else {
- this.editing = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement