- Fixed error in sheetworker and added logging

- Turned back on the static attributes as the Layout would break without them
This commit is contained in:
Peter Bjerg Mogensen
2020-12-17 20:15:36 +01:00
parent 2f41c9cf18
commit 87b80b278f
2 changed files with 25 additions and 7 deletions
+10 -6
View File
@@ -3,17 +3,21 @@
var sheetName = 'AD&D 2E Revised';
var sheetVersion = '3.3.2';
function moveStaticToRepeating(fieldsToMove) {
function moveStaticToRepeating(section, fieldsToMove) {
getAttrs(fieldsToMove, function (values) {
if (values[fieldsToMove[0]]) {
let newrowid = generateRowID();
let newValue = {};
console.log(`New rowId ${newrowid}`);
for (const [key, value] of Object.entries(values)) {
newValue[`repeating_weaponprofs_${newrowid}_${key}`] = value
newValue[`repeating_${section}_${newrowid}_${key}`] = value;
newValue[key] = '';
}
console.log(newValue);
setAttrs(newValue);
}
});
@@ -65,9 +69,9 @@ on('sheet:opened', function(){
})
.execute();
moveStaticToRepeating(['weaponprofname', 'weapprofnum', 'expert', 'specialist', 'mastery', 'high-mastery', 'grand-mastery', 'chosen-weapon']);
moveStaticToRepeating(['profname', 'profslots', 'profstatnum', 'profmod']);
moveStaticToRepeating(['langname', 'lang-rw']);
moveStaticToRepeating('weaponprofs', ['weaponprofname', 'weapprofnum', 'expert', 'specialist', 'mastery', 'high-mastery', 'grand-mastery', 'chosen-weapon']);
moveStaticToRepeating('profs', ['profname', 'profslots', 'profstatnum', 'profmod']);
moveStaticToRepeating('langs', ['langname', 'lang-rw']);
}
});
+15 -1
View File
@@ -3487,6 +3487,16 @@
<td class="sheet-centering" title="Grand Mastery">GM</td>
<td class="sheet-centering" title="Chosen Weapon">CW</td>
</tr>
<tr class="sheet-collapse">
<td><input type="text" name="attr_weapprofname" title="@{weaponprofname}" class="sheet-middle" placeholder="Name of Weapon Prof"></td>
<td><input type="number" name="attr_weapprofnum" title="@{weapprofnum}" class="sheet-short" placeholder="Slots"></td>
<td><label><input type="checkbox" name="attr_expert" title="@{expert}" value="1"/><span></span></label></td>
<td><label><input type="checkbox" name="attr_specialist" title="@{specialist}" value="1"/><span></span></label></td>
<td><label><input type="checkbox" name="attr_mastery" title="@{mastery}" value="1"/><span></span></label></td>
<td><label><input type="checkbox" name="attr_high-mastery" title="@{high-mastery}" value="1"/><span></span></label></td>
<td><label><input type="checkbox" name="attr_grand-mastery" title="@{grand-mastery}" value="1"/><span></span></label></td>
<td><label><input type="checkbox" name="attr_chosen-weapon" title="@{chosen-weapon}" value="1"/><span></span></label></td>
</tr>
</table>
<fieldset name="repeating_weaponprofs" title="@{weaponprofs}" class="repeating_weaponprofs">
<table>
@@ -3557,7 +3567,7 @@
<td colspan="2">Ability Score</td>
<td colspan="3">Modifier</td>
</tr>
<tr>
<tr class="sheet-collapse">
<td><input type="text" name="attr_profname" title="@{profname}" placeholder="Name of NonWepProf" /></td>
<td><input type="number" name="attr_profslots" title="@{profslots}" class="sheet-short" placeholder="Slots" /></td>
<td><input type="text" name="attr_profstatnum" title="@{profstatnum}" placeholder="@{abilityScore}" class="sheet-maxtext"></td>
@@ -3585,6 +3595,10 @@
<td>Language</td>
<td>Reading/Writing</td>
</tr>
<tr class="sheet-centering sheet-collapse">
<td><input type="text" name="attr_langname" title="@{langname}" placeholder="Name of Language"></td>
<td><label><input type="checkbox" name="attr_lang-rw" title="@{lang-rw}" value="1"/><span></span></label></td>
</tr>
</table>
<fieldset name="repeating_langs" title="@{langs}" class="repeating_langs">
<table>