@WidgetComponent

nm-exportconfig

File

src/app/shared/widgets/buy/exportconfig/exportconfig.component.ts

Implements

OnInit

Metadata

selector nm-exportconfig
styleUrls exportconfig.component.scss
templateUrl ./exportconfig.component.html

Index

Widget inputs
Widget outputs
Properties
Methods
Inputs

Constructor

constructor(_exportConfigService: ExportConfigService, _halService: HalService, _notificationService: CustomNotificationService, _appdataStore: AppdataStore, router: Router, translateService: TranslateService, dialogRef: MatDialogRef)
Parameters :
Name Type Optional
_exportConfigService ExportConfigService no
_halService HalService no
_notificationService CustomNotificationService no
_appdataStore AppdataStore no
router Router no
translateService TranslateService no
dialogRef MatDialogRef<ExportConfigComponent> no

Inputs

formHref

Type: string

Default value: "actions?.download.formHref"

visible

Type: boolean

Methods

ngOnInit
ngOnInit()
Returns : void
onSubmit
onSubmit()
Returns : void
showExportDialog
showExportDialog()
Returns : void

Properties

Public action
action:
Public dialogRef
dialogRef: MatDialogRef<ExportConfigComponent>
Type : MatDialogRef<ExportConfigComponent>
Public formGroup
formGroup: FormGroup
Type : FormGroup
Public href
href: Subject<String>
Type : Subject<String>
Default value : new ReplaySubject<String>(1)
import { mergeMap, map, filter } from "rxjs/operators";
import { Component, Input, OnInit } from "@angular/core";
import { Subject, ReplaySubject } from "rxjs";
import { FormGroup } from "@angular/forms";
import { ExportConfigService } from "./exportconfig.service";
import { AppdataStore } from "../../../components/appdata/appdata.store";
import { HalService } from "../../../components/hal/index";

import { CustomNotificationService } from "../../../components/notification/customnotification.service";
import { Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { MatDialogRef } from "@angular/material/dialog";

@Component({
  selector: "nm-exportconfig",
  templateUrl: "./exportconfig.component.html",
  styleUrls: ["./exportconfig.component.scss"],
})
export class ExportConfigComponent implements OnInit {
  @Input("visible") visible: boolean;

  @Input("formHref") formHref: string = "actions?.download.formHref";

  public href: Subject<String> = new ReplaySubject<String>(1);
  public formGroup: FormGroup;
  public action;

  constructor(
    private _exportConfigService: ExportConfigService,
    private _halService: HalService,
    private _notificationService: CustomNotificationService,
    private _appdataStore: AppdataStore,
    private router: Router,
    private translateService: TranslateService,
    public dialogRef: MatDialogRef<ExportConfigComponent>
  ) {
    this.formGroup = new FormGroup({});
  }

  ngOnInit() {
    this._appdataStore
      .getAppdata()
      .pipe(
        map((data) => data["buy"]._links["cart"].href),
        mergeMap((cartHref) =>
          this._exportConfigService.getEportConfig(cartHref)
        )
      )
      .subscribe((data) => {
        this.action = data._actions.download;
      });

    this._halService
      .getActionEvents()
      .pipe(
        filter((event) => event.name === "download"),
        map((event) => (<any>event).response)
      )
      .subscribe((resp) => {
        if (resp && resp.body && resp.body.message) {
          this._notificationService.success(resp.body.title, resp.body.message);
        }

        this.dialogRef.close();
      });
  }
  onSubmit() {
    event.preventDefault();
  }

  showExportDialog() {
    this.visible = true;
  }
}
<nm-dialog [dialogRef]="dialogRef">
  <ng-container slot="title">
    {{ "export-config-title" | translate }}
  </ng-container>
  <ng-container slot="content">
    <form (ngSubmit)="onSubmit()">
      <nm-form [action]="action" [form]="formGroup"></nm-form>
    </form>
  </ng-container>

  <ng-container slot="actions">
    <button mat-button type="button" (click)="dialogRef.close(false)">
      {{ "button.cancel" | translate }}
    </button>

    <button
      mat-raised-button
      id="export_download"
      type="button"
      color="primary"
      [nm-action]="action"
      [action-name]="'download'"
      [action-payload]="formGroup.valueChanges | async"
    >
      {{ "export-config-save" | translate }}
    </button>
  </ng-container>
</nm-dialog>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""