Fix: édition de sorts d'Actor

L'édition était impossible parce que le formData ne contient pas
de noeud system, mais des propriétés 'system.portee', ...
This commit is contained in:
Vincent Vandemeulebrouck 2022-10-21 02:10:37 +02:00
parent e4f9b0f589
commit 362fd964d0
2 changed files with 12 additions and 17 deletions

View File

@ -250,9 +250,9 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) { // Deprecated en v0.8 à clarifier
_updateObject(event, formData) {
// Données de bonus de cases ?
formData = RdDItemSort.buildBonusCaseStringFromFormData(formData);
formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue);
return this.item.update(formData);
}

View File

@ -63,26 +63,21 @@ export class RdDItemSort extends Item {
/** Met à jour les données de formulaire
* si static des bonus de cases sont présents
* */
static buildBonusCaseStringFromFormData( formData ) {
if ( formData.bonusValue ) {
static buildBonusCaseStringFromFormData( bonuses, cases ) {
if ( bonuses ) {
let list = [];
let caseCheck = {};
for(let i=0; i<formData.bonusValue.length; i++) {
let coord = formData.caseValue[i] || 'A1';
coord = coord.toUpperCase();
if ( TMRUtility.verifyTMRCoord( coord ) ) { // Sanity check
let bonus = formData.bonusValue[i] || 0;
if ( bonus > 0 && caseCheck[coord] == undefined ) {
caseCheck[coord] = bonus;
list.push( coord+":"+bonus );
}
for (let i=0; i<bonuses.length; i++) {
let coord = cases[i]?.toUpperCase() || 'A1';
let bonus = bonuses[i] || 0;
if ( TMRUtility.verifyTMRCoord( coord ) && bonus > 0 && caseCheck[coord] == undefined ) {
caseCheck[coord] = bonus;
list.push( coord+":"+bonus );
}
}
formData.bonusValue = undefined;
formData.caseValue = undefined;
formData.system.bonuscase = list.toString(); // Reset
return list.toString();
}
return formData;
return undefined;
}
/* -------------------------------------------- */