Saisie de valeurs négatives
This commit is contained in:
@@ -65,12 +65,7 @@ export class RollPartConditions extends RollPart {
|
||||
async _onRender(rollDialog, context, options) {
|
||||
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
|
||||
|
||||
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
|
||||
}
|
||||
|
||||
onInputChange(event, rollDialog) {
|
||||
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
|
||||
rollDialog.render()
|
||||
input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,12 +73,7 @@ export class RollPartDiff extends RollPart {
|
||||
async _onRender(rollDialog, context, options) {
|
||||
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
|
||||
|
||||
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
|
||||
}
|
||||
|
||||
onInputChange(event, rollDialog) {
|
||||
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
|
||||
rollDialog.render()
|
||||
input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ALL_ROLL_TYPES } from "./roll-dialog.mjs"
|
||||
|
||||
export const ROLLDIALOG_SECTION = {
|
||||
ACTION: 'action',
|
||||
CARAC: 'carac',
|
||||
@@ -9,7 +7,6 @@ export const ROLLDIALOG_SECTION = {
|
||||
AJUSTEMENTS: 'ajustements',
|
||||
}
|
||||
|
||||
|
||||
export class RollPart {
|
||||
static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` }
|
||||
|
||||
@@ -75,7 +72,7 @@ export class RollPart {
|
||||
isValid(rollData) { return true }
|
||||
visible(rollData) { return true }
|
||||
|
||||
onReady() { }
|
||||
onReady(rollParts) { }
|
||||
loadRefs(rollData) { }
|
||||
|
||||
prepareContext(rollData) { }
|
||||
@@ -103,4 +100,13 @@ export class RollPart {
|
||||
async _onRender(rollDialog, context, options) { }
|
||||
|
||||
getHooks() { return [] }
|
||||
|
||||
onNumericInputChange(event, rollDialog, setValue = value => this.getCurrent(rollDialog.rollData).value = value) {
|
||||
if (isNaN(event.currentTarget.value) || event.currentTarget.value == "") {
|
||||
return
|
||||
}
|
||||
setValue(parseInt(event.currentTarget.value))
|
||||
rollDialog.render()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user