- 21 classes Dialog → DialogV2 - 2 classes Application → ApplicationV2 + HandlebarsApplicationMixin - 1 classe FormApplication → ApplicationV2 - 10 appels new Dialog() → DialogV2 (rdd-confirm, rdd-commands, etc.) - base-actor-sheet.mjs : 3 appels new Dialog → DialogV2 - Sheet journal : JournalTextPageSheet → JournalEntryPageProseMirrorSheet - CSS : backdrop-filter, box-shadow, bordures V2 supprimes pour calendar/astrologie - FenetreRechercheTirage : _getWindowControls + dragDrop ajoutes - HtmlUtility.showControlWhen : compat jQuery + DOM natif - rdd-main.js : init calendrier en setTimeout - Constantes : duplicate → deepClone, _id → id - renderTemplate global → foundry.applications.handlebars.renderTemplate
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { renderTemplate } from "./constants.js";
|
|
|
|
export class DialogSplitItem extends foundry.applications.api.DialogV2 {
|
|
static async create(item, callback) {
|
|
const splitData = {
|
|
item: item,
|
|
choix: { quantite: 1, max: item.system.quantite - 1 }
|
|
}
|
|
const content = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-item-split.hbs", splitData)
|
|
return new DialogSplitItem(item, splitData, content, callback)
|
|
}
|
|
|
|
constructor(item, splitData, content, callback) {
|
|
super({
|
|
title: "Séparer en deux",
|
|
content,
|
|
classes: ["dialogsplit"],
|
|
position: { width: 300, height: 'fit-content' },
|
|
buttons: [
|
|
{ label: "Séparer", action: "separer", callback: () => this.onSplit() }
|
|
]
|
|
})
|
|
this.callback = callback
|
|
this.item = item
|
|
this.splitData = splitData
|
|
}
|
|
|
|
_onRender(context) {
|
|
super._onRender(context)
|
|
this.element.querySelector(".choix-quantite")?.addEventListener("change", event => {
|
|
this.splitData.choix.quantite = Number(event.currentTarget.value)
|
|
})
|
|
}
|
|
|
|
async onSplit() {
|
|
const input = this.element.querySelector(".choix-quantite")
|
|
if (input) {
|
|
input.dispatchEvent(new Event("change"))
|
|
}
|
|
this.callback(this.item, this.splitData.choix.quantite)
|
|
}
|
|
}
|