create-report.component.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { Component } from '@angular/core';
  2. import { Location } from '@angular/common';
  3. import { MatDialog } from '@angular/material';
  4. import { ReportDataService } from './services/reportData.service';
  5. import 'rxjs/add/operator/switchMap';
  6. import { BaseReportComponent } from './base-report.component';
  7. import { NewReport } from './types';
  8. @Component({
  9. selector: 'ps-report',
  10. templateUrl: './report.component.html',
  11. styleUrls: ['./report.component.css']
  12. })
  13. export class CreateReportComponent extends BaseReportComponent {
  14. title = 'Create new expense report';
  15. constructor(location: Location,
  16. dialog: MatDialog,
  17. reportDataService: ReportDataService) {
  18. super(location, dialog, reportDataService);
  19. }
  20. save(): void {
  21. const newReport: NewReport = {
  22. date: new Date(),
  23. approved: false,
  24. description: this.description,
  25. items: this.itemsDataBase.data
  26. };
  27. this.reportDataService.add(newReport);
  28. this.location.back();
  29. }
  30. }