forked from public/foundryvtt-reve-de-dragon
Utilisation d'async/await dans les listeners
Sans async await dans les feuilles, la feuille n'est pas toujours mise à jour, laissant visible des informations obsoletes
This commit is contained in:
@ -159,23 +159,19 @@ export class RdDItemSheet extends ItemSheet {
|
||||
|
||||
HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionnelles.isUsing('afficher-prix-joueurs')
|
||||
|| game.user.isGM
|
||||
|| !this.item.isOwned);
|
||||
HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique);
|
||||
|| !this.item.isOwned)
|
||||
HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique)
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
if (!this.options.editable) return
|
||||
|
||||
this.form.ondragstart = (event) => this._onDragStart(event);
|
||||
this.form.ondrop = (event) => this._onDrop(event);
|
||||
this.form.ondragstart = async event => await this._onDragStart(event)
|
||||
this.form.ondrop = async event => await this._onDrop(event)
|
||||
|
||||
// Select competence categorie
|
||||
this.html.find(".categorie").change(event => this._onSelectCategorie(event));
|
||||
this.html.find(".categorie").change(async event => await this._onSelectCategorie(event))
|
||||
|
||||
this.html.find('.sheet-competence-xp').change((event) => {
|
||||
if (this.item.isCompetencePersonnage()) {
|
||||
RdDUtility.checkThanatosXP(this.item.name);
|
||||
}
|
||||
});
|
||||
this.html.find('.sheet-competence-xp').change(event => RdDUtility.checkThanatosXP(this.item))
|
||||
this.html.find(".item-cout input[name='system.cout']").change(event => {
|
||||
if (this.item.isMonnaie()) {
|
||||
const value = event.currentTarget.value;
|
||||
@ -184,42 +180,41 @@ export class RdDItemSheet extends ItemSheet {
|
||||
}
|
||||
}
|
||||
})
|
||||
this.html.find('.delete-bonus-case').click((event) => {
|
||||
this.supprimerBonusCase(event.currentTarget.attributes['data-deleteCoord'].value)
|
||||
})
|
||||
|
||||
this.html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item));
|
||||
this.html.find('.creer-potion-base').click((event) => this._getEventActor(event).fabriquerDecoctionHerbe(this.item))
|
||||
this.html.find('input[name="system.cacher_points_de_tache"]').change(async event => await this.item.update({ 'system.cacher_points_de_tache': event.currentTarget.checked }));
|
||||
this.html.find('.delete-bonus-case').click(async event => await this.supprimerBonusCase(event.currentTarget.attributes['data-deleteCoord'].value))
|
||||
this.html.find('.creer-tache-livre').click(async event => await this._getEventActor(event).creerTacheDepuisLivre(this.item))
|
||||
this.html.find('.creer-potion-base').click(async event => await this._getEventActor(event).fabriquerDecoctionHerbe(this.item))
|
||||
this.html.find('input[name="system.cacher_points_de_tache"]').change(async event =>
|
||||
await this.item.update({ 'system.cacher_points_de_tache': event.currentTarget.checked })
|
||||
)
|
||||
|
||||
this.html.find('.roll-text').click(async event => await RdDTextEditor.rollText(event, this.actor))
|
||||
this.html.find('.chat-roll-text').click(async event => await RdDTextEditor.chatRollText(event))
|
||||
|
||||
if (this.actor) {
|
||||
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options))
|
||||
|
||||
this.html.find('.actionItem').click(async event => await ItemAction.onActionItem(event, this.actor, this.options))
|
||||
|
||||
// TODO: utiliser un itemAction?
|
||||
this.html.find('.item-potion-consommer').click(event => this.itemActionConsommer(event))
|
||||
this.html.find('.item-potion-consommer').click(async event => await this.itemActionConsommer(event))
|
||||
|
||||
this.html.find('.item-quantite-plus').click(async event => {
|
||||
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
|
||||
this.render()
|
||||
//this.render()
|
||||
})
|
||||
this.html.find('.item-quantite-moins').click(async event => {
|
||||
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
|
||||
this.render()
|
||||
//this.render()
|
||||
})
|
||||
}
|
||||
|
||||
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: foundry.utils.duplicate(timestamp) })
|
||||
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.debut', updateItemTimestamp);
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp);
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.debut', updateItemTimestamp)
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp)
|
||||
}
|
||||
|
||||
itemActionDelete(event) {
|
||||
async itemActionDelete(event) {
|
||||
const item = RdDSheetUtility.getItem(event, this.actor)
|
||||
return RdDUtility.confirmActorItemDelete(item, this.actor)
|
||||
return await RdDUtility.confirmActorItemDelete(item, this.actor)
|
||||
}
|
||||
|
||||
async itemActionConsommer(event) {
|
||||
@ -238,12 +233,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
}
|
||||
}
|
||||
|
||||
_getEventActor(event) {
|
||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
||||
let actor = game.actors.get(actorId);
|
||||
return actor;
|
||||
}
|
||||
|
||||
_getEventActor(event) { return game.actors.get(event.currentTarget.attributes['data-actor-id'].value) }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onSelectCategorie(event) {
|
||||
@ -285,7 +275,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
break
|
||||
}
|
||||
|
||||
return this.item.update(formData);
|
||||
return this.item.update(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -318,8 +308,9 @@ export class RdDItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDragStart(event) {
|
||||
}
|
||||
async _onDragStart(event) { }
|
||||
async _onDropItem(event, dragData) { }
|
||||
async _onDropActor(event, dragData) { }
|
||||
|
||||
async _onDrop(event) {
|
||||
// Try to extract the dragData
|
||||
@ -345,13 +336,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
return JSON.parse(eventData);
|
||||
}
|
||||
} catch (err) { }
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async _onDropItem(event, dragData) {
|
||||
}
|
||||
|
||||
async _onDropActor(event, dragData) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user