create-report.component.ts 1.0 KB

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