File

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

Implements

AfterViewInit

Metadata

selector app-add-audit-dialog
styleUrls ./add-audit-dialog.component.scss
templateUrl ./add-audit-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
onCancel
onCancel()
Returns : void
onSubmit
onSubmit(audit: Audit)
Parameters :
Name Type Optional
audit Audit No
Returns : void

Properties

contactPersons$
Type : Observable<ContactPerson[]>
Decorators :
@Select(ContactPersonState.contactPersons)
dialog
Type : TemplateRef<any>
Decorators :
@ViewChild('dialog')
dialogRef
Type : NbDialogRef<any>
import { Component, ViewChild, TemplateRef, AfterViewInit } from '@angular/core';
import { NbDialogRef, NbDialogService } from '@nebular/theme';
import { Store, Select } from '@ngxs/store';
import { defaultDialogOptions } from '../default-dialog-options';
import { Audit } from 'src/app/core/data/models/audit.model';
import { AddAudit } from 'src/app/core/ngxs/actions/audit.actions';
import { Location } from '@angular/common';
import { Observable } from 'rxjs';
import { ContactPerson } from 'src/app/core/data/models/contact-person.model';
import { ContactPersonState } from 'src/app/core/ngxs/contact-person.state';

@Component({
  selector: 'app-add-audit-dialog',
  templateUrl: './add-audit-dialog.component.html',
  styleUrls: ['./add-audit-dialog.component.scss'],
})
export class AddAuditDialogComponent implements AfterViewInit {
  @ViewChild('dialog') dialog: TemplateRef<any>;
  @Select(ContactPersonState.contactPersons) contactPersons$: Observable<ContactPerson[]>;
  dialogRef: NbDialogRef<any>;

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

  ngAfterViewInit() {
    this.dialogRef = this.dialogService.open(this.dialog, {
      ...defaultDialogOptions,
      autoFocus: true,
    });
    this.dialogRef.onClose.subscribe(() => {
      this.location.back();
    });
  }

  onSubmit(audit: Audit) {
    this.store.dispatch(new AddAudit(audit)).subscribe(() => this.dialogRef.close());
  }

  onCancel() {
    this.dialogRef.close();
  }
}
<ng-template #dialog let-data let-ref="dialogRef">
  <div class="scrollable-container">
    <app-audit-form (cancelled)="onCancel()" (formSubmitted)="onSubmit($event)" [audit]="null" [submitButtonName]="'hinzufügen'" cancelButtonName="abbrechen"> </app-audit-form>
  </div>
</ng-template>

./add-audit-dialog.component.scss

@import 'src/sass/utils';

.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 ""