File

src/app/shared/components/dialogs/add-interview-dialog/add-interview-dialog.component.ts

Implements

AfterViewInit OnInit

Metadata

selector app-new-interview-dialog
styleUrls ./add-interview-dialog.component.scss
templateUrl ./add-interview-dialog.component.html

Index

Properties
Methods

Constructor

constructor(dialogService: NbDialogService, store: Store, location: Location)
Parameters :
Name Type Optional
dialogService NbDialogService No
store Store No
location Location No

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onCancel
onCancel()
Returns : void
onSubmit
onSubmit(interview: Interview, scope: FacCrit[])

Dispatches AddInterview action to add the submitted interview

Parameters :
Name Type Optional Description
interview Interview No

The interview filled out in the form

scope FacCrit[] No
Returns : void

Properties

audit$
Type : Observable<Audit>
auditId
Type : number
auditId$
Type : Observable<number>
Decorators :
@Select(AppRouterState.auditId)
dialog
Type : TemplateRef<any>
Decorators :
@ViewChild('dialog')
dialogRef
Type : NbDialogRef<any>
import { Component, ViewChild, TemplateRef, AfterViewInit, OnInit } from '@angular/core';
import { NbDialogService, NbDialogRef } from '@nebular/theme';
import { Store, Select } from '@ngxs/store';
import { Location } from '@angular/common';
import { defaultDialogOptions } from 'src/app/shared/components/dialogs/default-dialog-options';
import { AuditState } from 'src/app/core/ngxs/audit.state';
import { Observable } from 'rxjs';
import { Audit } from 'src/app/core/data/models/audit.model';
import { Interview } from 'src/app/core/data/models/interview.model';
import { AppRouterState } from 'src/app/core/ngxs/app-router.state';
import { AddInterview } from 'src/app/core/ngxs/actions/inteview.actions';
import { FacCrit } from 'src/app/core/data/models/faccrit.model';

@Component({
  selector: 'app-new-interview-dialog',
  templateUrl: './add-interview-dialog.component.html',
  styleUrls: ['./add-interview-dialog.component.scss'],
})
export class AddInterviewDialogComponent implements AfterViewInit, OnInit {
  @Select(AppRouterState.auditId) auditId$: Observable<number>;
  @ViewChild('dialog') dialog: TemplateRef<any>;
  dialogRef: NbDialogRef<any>;

  audit$: Observable<Audit>;
  auditId: number;

  constructor(
    private dialogService: NbDialogService,
    private store: Store,
    private location: Location,
  ) {}

  ngOnInit() {
    this.auditId$.subscribe(id => {
      this.auditId = id;
      this.audit$ = this.store.select(AuditState.audit(id));
    });
  }

  ngAfterViewInit() {
    this.dialogRef = this.dialogService.open(this.dialog, defaultDialogOptions);

    this.dialogRef.onClose.subscribe(() => {
      this.location.back();
    });
  }

  /**
   * Dispatches AddInterview action to add the submitted interview
   *
   * @param interview The interview filled out in the form
   */
  onSubmit(interview: Interview, scope: FacCrit[]) {
    this.store.dispatch(new AddInterview({ ...interview, auditId: this.auditId }, scope));
    this.dialogRef.close();
  }

  onCancel() {
    this.dialogRef.close();
  }
}
<ng-template #dialog let-data let-ref="dialogRef">
  <div class="scrollable-container">
    <app-interview-form (cancelled)="onCancel()" (formSubmitted)="onSubmit($event.interview, $event.scope)" [scope]="(audit$ | async).scope" [interview]="{}"></app-interview-form>
  </div>
</ng-template>

./add-interview-dialog.component.scss

.scrollable-container {
  overflow-y: auto !important;
  max-width: 95vw;
  max-height: 95vh;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""