Commit a3b05f0b authored by El Mghazli Yacine's avatar El Mghazli Yacine

confirm button ok

parent 61dab4c7
......@@ -3,6 +3,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { of } from 'rxjs/internal/observable/of';
import { map } from 'rxjs/internal/operators/map';
import { mergeMap } from 'rxjs/internal/operators/mergeMap';
import { filter } from 'rxjs/operators';
import { CommandsApi, IArgType, IColumn } from 'src/app/api/commands.api';
import { CmdCtrl } from 'src/app/controls/cmd.control';
import { EntryFC } from 'src/app/controls/entry.control';
......@@ -90,12 +91,12 @@ export class CommandsComponent {
onCmdSubmit(control: CmdCtrl) {
// const obs = control.confirm ? this.dialogService.openConfirmDialog(control.confirm) : of(null)
const obs = control.confirm
? this.dialogService.openConfirmDialog(control.confirm).pipe(filter(confirmed => confirmed))
: of(null)
// this.rows$ = obs.pipe(
// mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)),
this.rows$ = this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`).pipe(
this.rows$ = obs.pipe(
mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)),
mergeMap(resp => {
if (resp.display[0]) return this.dialogService.openRespDialog(resp, 'cmd ' + control.nameFC.value + ' response:')
else return of(resp)
......
<h1>Really ?</h1>
<h3>{{ data.title }}</h3>
<div fxLayoutGap="10px" mat-dialog-actions fxLayout="row" fxLayoutAlign="center start">
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Ok</button>
<button mat-button (click)="onNoClick()">Cancel</button>
......
/* eslint-disable @typescript-eslint/naming-convention */
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-confirm',
......@@ -10,8 +10,9 @@ import { MatDialogRef } from '@angular/material/dialog';
export class ConfirmDialogComponent {
constructor(
public dialogRef: MatDialogRef<void>
) { }
public dialogRef: MatDialogRef<void>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
onNoClick() {
this.dialogRef.close();
......
......@@ -3,14 +3,18 @@ import { ICommand } from '../api/commands.api';
const enum CmdFCN {
name = 'name',
confirm = 'confirm'
}
export class CmdCtrl extends FormGroup {
confirm?: string
constructor(cmd: ICommand) {
super({});
this.addControl(CmdFCN.name, new FormControl(cmd.name));
this.confirm = cmd.confirm
}
api() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment