Project

General

Profile

1
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
2
import {FullInvoiceProcess} from '../../../../shared/models/full-invoice-process.interface';
3
import {ProcessHistory} from '../../../../shared/models/process-history.interface';
4
import {Observable} from 'rxjs';
5
import {InvoiceProcessesService} from '../../../../shared/services/invoice-processes.service';
6

    
7
@Component({
8
  selector: 'app-process-history',
9
  templateUrl: './process-history.component.html',
10
  styleUrls: ['./process-history.component.scss']
11
})
12
export class ProcessHistoryComponent implements OnInit, OnChanges {
13

    
14
  @Input() process: FullInvoiceProcess;
15
  processHistoryData: ProcessHistory[];
16

    
17
  first: number = 0;
18
  rows: number = 10;
19
  loading = false;
20

    
21
  constructor(private processService: InvoiceProcessesService) {
22
  }
23

    
24
  ngOnInit(): void {
25
    if ( Object.keys(this.process).length > 0 ) {
26
      this.getProcessHistoryData(this.process.id);
27
    } else {
28
      this.processHistoryData = [];
29
    }
30
  }
31

    
32
  ngOnChanges(changes: SimpleChanges) {
33
    if ( Object.keys(this.process).length > 0 ) {
34
      this.getProcessHistoryData(this.process.id);
35
    }
36
  }
37

    
38
  getProcessHistoryData(processId: number): void {
39
    this.processService.getProcessHistory(processId).subscribe(data => {
40
      this.processHistoryData = data;
41
    });
42
  }
43

    
44
  onPagination(event) {
45
    this.first = event.first;
46
  }
47

    
48
}
(4-4/4)