Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
Angular Confirm Dialog Requirement Problem

In my code, I have a confirm dialog component which I use in different parts of my app. It also has an input description field that is mandatory for some components. For my request-detail component, I don't want the input description field to be mandatory. But when I set this.confirmDialogRef.componentInstance.hasInput = true; to false, the input field disappears, and I don't want that. I can't make big changes to the confirm dialog component, since I still need the input description field to be mandatory for other components in my app. What should I do to achieve what I want?

Request Detail TS:

approveRequest() {
    this.confirmDialogRef = this._dialog.open(FuseConfirmDialogComponent, {
        disableClose: false,
    });

    this.confirmDialogRef.componentInstance.confirmMessage =
        "Do you want to approve";
    this.confirmDialogRef.componentInstance.hasInput = true;

    this.confirmDialogRef.afterClosed().subscribe((result) => {
        if (result) {
            this.request.ApprovementInfo.Description = result;
            this._requestService
                .approveRequest(this.request)
                .subscribe(() => {
                    this._requestService.getRequestDetail(
                        this.request.RequestId
                    );
                });
        }
    });
}

Confirm Dialog TS:

   public title: string = "Confirm";
    public confirmMessage: string = "";
    public hasInput: boolean;
    public hasInputEn: boolean;
    public inputDescription: string = "";
    public inputDescriptionEn: string = "";

    /**
     * Constructor
     *
     * @param {MatDialogRef<FuseConfirmDialogComponent>} dialogRef
     */
    constructor(
        public dialogRef: MatDialogRef<FuseConfirmDialogComponent>,
        private _messages: Messages
    ) {}

    confirm() {
        if (this.hasInput) {
            if (
                this.inputDescription == undefined ||
                this.inputDescription.length == 0
            ) {
                this._messages.Show("Please enter a description!", "WARNING", 4);
                return;
            }
            if (
                this.hasInputEn &&
                (this.inputDescriptionEn == undefined ||
                    this.inputDescriptionEn.length == 0)
            ) {
                this._messages.Show(
                    "Please enter a description in english!",
                    "WARNING",
                    4
                );
                return;
            }
            this.dialogRef.close(this.inputDescription);
        } else {
            this.dialogRef.close(this.inputDescription || true);
        }
    }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda