Hi there!
I’m trying to find out if there is a way to observe or if an event is fired for all the alerts and loading dismisses in a page, where i have to setFocus() on an input where a scanner have to write.
The thing is that I have a async service function that provides me info about the product code scanned, and this one have a loading that cancel the myAlert.onDidDismiss().then(() => { this.myInput.setFocus() }).
const editAlert = await this.alertController.create({
header: 'Editando Packs de:',
message: `<p>` + itemToEdit.sscc + `</p>
<p>` + itemToEdit.layout + `</p>`,
inputs: [
{
name: 'packs',
type: 'number',
value: itemToEdit.packs,
placeholder: 'Nº de Packs'
}
],
buttons: [
{
text: 'Volver',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
option.close();
this.ssccInput.setFocus();
}
},
{
text: 'Confirmar',
handler: async data => {
if (itemToEdit.packs !== data.packs) {
if (data.packs > originalProduction[0].packs) {
await this.alertWithTimeoutAndSetFocusOnSSCC(
'Error',
'El número de packs especificado <strong>supera</strong> a los disponibles',
2000
);
} else {
let newNumberOfBottles = (data.packs * itemToEdit.bottles) / itemToEdit.packs;
let newWeightOfSSCC = Math.round(((itemToEdit.weight * newNumberOfBottles) / itemToEdit.bottles) * 10) / 10;
itemToEdit.bottles = newNumberOfBottles;
let oldWeightOfSSCC = itemToEdit.weight;
this.currentLoad -= oldWeightOfSSCC;
this.currentLoad += newWeightOfSSCC;
itemToEdit.weight = newWeightOfSSCC;
itemToEdit.packs = data.packs;
this.sqlServerServices.updateEditedTransaction(
this.newWaybillSleepId,
newNumberOfBottles,
data.packs,
newWeightOfSSCC,
itemToEdit.sscc
).then(() => {
option.close();
this.ssccInput.setFocus();
});
}
}
}
}
]
});
editAlert.present();
editAlert.onDidDismiss().then(() => {
this.ssccInput.setFocus();
});
I have also tryied what im used to use async await, but nothing changes.
itemToEdit.packs = data.packs;
await this.sqlServerServices.updateEditedTransaction(
this.newWaybillSleepId,
newNumberOfBottles,
data.packs,
newWeightOfSSCC,
itemToEdit.sscc
);
option.close();
this.ssccInput.setFocus();
}
}
}
}
]
});
editAlert.present();
editAlert.onDidDismiss().then(() => {
this.ssccInput.setFocus();
});
With and without the onDidDismiss at the end.