Actor sheet -> working !!!
This commit is contained in:
@@ -3,6 +3,18 @@
|
||||
* Fonctions factory retournant des objets SchemaField réutilisables.
|
||||
*/
|
||||
|
||||
const fields = foundry.data.fields
|
||||
|
||||
/** NumberField qui accepte les strings vides en les remplaçant par `initial`. */
|
||||
class LooseNumberField extends fields.NumberField {
|
||||
clean(value, options) {
|
||||
if (value === "" || value === null || value === undefined) {
|
||||
return this.initial ?? 0
|
||||
}
|
||||
return super.clean(value, options)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un schema pour une blessure (minor/major/deadly)
|
||||
* @param {number} defaultThreshold
|
||||
@@ -63,7 +75,7 @@ export function attributeSchema(defaultVal = 0, defaultMin = 0, defaultMax = 10)
|
||||
const fields = foundry.data.fields
|
||||
const reqInt = { required: true, nullable: false, integer: true }
|
||||
return new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...reqInt, initial: defaultVal, min: defaultMin }),
|
||||
value: new LooseNumberField({ ...reqInt, initial: defaultVal, min: defaultMin }),
|
||||
min: new fields.NumberField({ ...reqInt, initial: defaultMin, min: 0 }),
|
||||
max: new fields.NumberField({ ...reqInt, initial: defaultMax, min: 0 })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user