fix: valider le champs des dialogs

Forcer la validation des champs saisis avant de fermer les dialogs et
d'appeler le callback pour avoir la dernière valuer saisie par
l'utilisateur
This commit is contained in:
Vincent Vandemeulebrouck 2021-06-04 19:35:27 +02:00
parent b5c8bb85fd
commit 0524540f5a
5 changed files with 31 additions and 14 deletions

View File

@ -39,6 +39,8 @@ export class DialogCreateSigneDraconique extends Dialog {
} }
async _onCreerSigneActeurs() { async _onCreerSigneActeurs() {
await $("[name='signe.data.ephemere']").change();
await $(".signe-xp-sort").change();
this.validerSigne(); this.validerSigne();
this.dialogData.actors.filter(it => it.selected).map(it => game.actors.get(it._id)) this.dialogData.actors.filter(it => it.selected).map(it => game.actors.get(it._id))
.forEach(actor => this._createSigneForActor(actor, this.dialogData.signe)); .forEach(actor => this._createSigneForActor(actor, this.dialogData.signe));
@ -75,6 +77,7 @@ export class DialogCreateSigneDraconique extends Dialog {
html.find(".select-actor").change((event) => this.onSelectActor(event)); html.find(".select-actor").change((event) => this.onSelectActor(event));
html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event)); html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event));
} }
async setSigneAleatoire() { async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true}); const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true});

View File

@ -64,6 +64,7 @@ export class DialogItemAchat extends Dialog {
} }
async onAchat() { async onAchat() {
await $(".nombreLots").change();
(this.vendeur ?? this.acheteur).achatVente( (this.vendeur ?? this.acheteur).achatVente(
this.vendeur?.id, this.vendeur?.id,
this.acheteur?.id, this.acheteur?.id,

View File

@ -17,9 +17,7 @@ export class DialogConsommer extends Dialog {
default: consommerData.buttonName, default: consommerData.buttonName,
buttons: { buttons: {
[consommerData.buttonName]: { [consommerData.buttonName]: {
label: consommerData.buttonName, callback: it => { label: consommerData.buttonName, callback: it => this.onConsommer(it)
this.actor.consommer(this.item, this.consommerData.choix);
}
} }
} }
}; };
@ -31,6 +29,12 @@ export class DialogConsommer extends Dialog {
this.consommerData = consommerData; this.consommerData = consommerData;
} }
async onConsommer(event) {
await $(".se-forcer").change();
await $(".consommer-doses").change();
this.actor.consommer(this.item, this.consommerData.choix);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static prepareData(actor, item, options) { static prepareData(actor, item, options) {
const itemData = duplicate(Misc.data(item)); const itemData = duplicate(Misc.data(item));
@ -68,15 +72,19 @@ export class DialogConsommer extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
html.find(".se-forcer").change(event => { html.find(".se-forcer").change(event => this.setSeForcer(event));
this.consommerData.choix.seForcer = event.currentTarget.checked; html.find(".consommer-doses").change(event => this.selectDoses(event));
});
html.find(".consommer-doses").change(event => {
this.consommerData.choix.doses = Number(event.currentTarget.value);
DialogConsommer.calculDoses(this.consommerData);
$(".total-sust").text(this.consommerData.totalSust)
$(".total-desaltere").text(this.consommerData.totalDesaltere)
});
} }
setSeForcer(event) {
this.consommerData.choix.seForcer = event.currentTarget.checked;
}
selectDoses(event) {
this.consommerData.choix.doses = Number(event.currentTarget.value);
DialogConsommer.calculDoses(this.consommerData);
$(".total-sust").text(this.consommerData.totalSust);
$(".total-desaltere").text(this.consommerData.totalDesaltere);
}
} }

View File

@ -30,7 +30,7 @@ export class DialogItemVente extends Dialog {
title: "Proposer", title: "Proposer",
content: html, content: html,
default: "proposer", default: "proposer",
buttons: { "proposer": { label: "Proposer", callback: it => { this.onProposer(); } } } buttons: { "proposer": { label: "Proposer", callback: it => { this.onProposer(it); } } }
}; };
super(conf, options); super(conf, options);
@ -38,7 +38,11 @@ export class DialogItemVente extends Dialog {
this.venteData = venteData; this.venteData = venteData;
} }
async onProposer() { async onProposer(it) {
await $(".tailleLot").change();
await $(".quantiteNbLots").change();
await $(".quantiteIllimite").change();
await $(".prixLot").change();
this.callback(this.venteData); this.callback(this.venteData);
} }

View File

@ -36,6 +36,7 @@ export class DialogSplitItem extends Dialog {
} }
async onSplit(){ async onSplit(){
await $(".choix-quantite").change();
this.callback(this.item, this.splitData.choix.quantite); this.callback(this.item, this.splitData.choix.quantite);
} }