En mi código, tengo dos botones. Uno para guardar una oferta y el otro para enviar esa oferta. Quiero que el botón Enviar comience a funcionar si se hace clic en el botón Guardar una vez. Si el usuario intenta enviar la oferta sin hacer clic en el botón Guardar al menos una vez, se debe mostrar un mensaje de advertencia. Aquí está mi código, ¿cómo puedo lograr esto?
saveOffer() { this._offerService.saveOffer(this.offer).subscribe(() => { this._offerService.getOfferDetail(this.offer.OfferId); }); } sendOfferSupplier() { this.confirmDialogRef = this._dialog.open(FuseConfirmDialogComponent, { disableClose: false }); this.confirmDialogRef.componentInstance.confirmMessage = 'Do you want to send the offer?'; this.confirmDialogRef.afterClosed().subscribe(result => { if (result) { this.offer.ApprovementInfo.Description = result; this._offerService.sendOfferSupplier(this.offer).subscribe(() => { this._offerService.getOfferDetail(this.offer.OfferId); }); } }); }Cree una bandera bool y adminístrela para verificar el estado:
isOfferSaved = false; saveOffer() { this._offerService.saveOffer(this.offer).subscribe(() => { this._offerService.getOfferDetail(this.offer.OfferId); this.isOfferSaved = true; }); } sendOfferSupplier() { if(!this.isOfferSaved) { //Show warning message with a toast component alert('No offer saved yet!'); return; } this.confirmDialogRef = this._dialog.open(FuseConfirmDialogComponent, { disableClose: false }); this.confirmDialogRef.componentInstance.confirmMessage = 'Do you want to send the offer?'; this.confirmDialogRef.afterClosed().subscribe(result => { if (result) { this.offer.ApprovementInfo.Description = result; this._offerService.sendOfferSupplier(this.offer).subscribe(() => { this._offerService.getOfferDetail(this.offer.OfferId); }); } }); }