Add remaining text fields

This commit is contained in:
walcutt 2024-12-04 16:20:08 -05:00
parent 3fe3161f49
commit 1ef45ee919
3 changed files with 47 additions and 11 deletions

View File

@ -75,13 +75,16 @@ export function updateField(actor, dataPathString, value) {
console.log(`Converted ${dataPathString} to:`); console.log(`Converted ${dataPathString} to:`);
console.log(dataPath); console.log(dataPath);
console.log(`Writing: ${value}`); console.log(`Writing: ${value} (${typeof value})`);
if(dataPath.isArray) { if(dataPath.isArray) {
const initial = getValueAtPath(actor, dataPath.path); const initial = getValueAtPath(actor, dataPath.path);
const copy = initial.map(e => deepCopy(e)); const copy = initial.map(e => deepCopy(e));
copy[dataPath.index] = copyAndMutateAtPath(initial[dataPath.index], dataPath.subPath, value); copy[dataPath.index] = copyAndMutateAtPath(initial[dataPath.index], dataPath.subPath, value);
console.log(`Array write at index ${dataPath.index}`);
console.log(copy);
actor.update({ actor.update({
[dataPath.path]: copy, [dataPath.path]: copy,
}); });

View File

@ -50,6 +50,15 @@ export class HenchActorSheet extends ActorSheet {
updateField(this.actor, path, value); updateField(this.actor, path, value);
}); });
// text fields
html.find('.hench-text-input').on('change', (event) => {
const element = event.currentTarget;
const path = element.dataset.fieldPath;
const value = element.value;
updateField(this.actor, path, value);
});
} }
_changePlaybook(newPlaybookKeyEvent) { _changePlaybook(newPlaybookKeyEvent) {

View File

@ -4,8 +4,8 @@
<h2> Details: </h2> <h2> Details: </h2>
<div id="hench-explicit-details"> <div id="hench-explicit-details">
<p>Name: {{ actor.name }}</p> <p>Name: <input type="text" class="hench-text-input" value="{{actor.name}}" data-field-path="name" /></p>
<p>Look: {{ actor.system.look }}</p> <p>Look: <input type="text" class="hench-text-input" value="{{actor.system.look}}" data-field-path="actor.system.look" /></p>
<div> <div>
<span><b>Playbook:</b></span> <span><b>Playbook:</b></span>
<select class="hench-hench-sheet-playbook-dropdown"> <select class="hench-hench-sheet-playbook-dropdown">
@ -18,16 +18,22 @@
<div> <div>
<ul> <ul>
{{#each actor.system.details}} {{#each actor.system.details}}
<li><b>{{this.question}}</b>: {{this.answer}}</li> <li>
<b>{{this.question}}:</b>
<input type="text" class="hench-text-input" data-field-path="system.details[{{@index}}].answer" value="{{this.answer}}" />
</li>
{{/each}} {{/each}}
</ul> </ul>
</div> </div>
<h3> Inclinations </h3> <h3> Inclinations </h3>
<div> <div>
<ul> <ul>
{{#each actor.system.inclinations}} {{#each actor.system.fixedInclinations}}
<li>{{this}}</li> <li>{{this}}</li>
{{/each}} {{/each}}
<li>
<input type="text" class="hench-text-input" data-field-path="system.customInclination" value="{{actor.system.customInclination}}" />
</li>
</ul> </ul>
</div> </div>
<h3>Mission Planning</h3> <h3>Mission Planning</h3>
@ -42,9 +48,15 @@
<h3>Gear</h3> <h3>Gear</h3>
<ul> <ul>
{{#each actor.system.fixedGear}} {{#each actor.system.fixedGear}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.fixedGear[{{@index}}].marked" {{#if this.marked}}checked{{/if}}/> {{this.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.fixedGear[{{@index}}].marked" {{#if this.marked}}checked{{/if}}/>
{{this.description}}
</li>
{{/each}} {{/each}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.customGear.marked" {{#if system.customGear.marked}}checked{{/if}}/> {{system.customGear.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.customGear.marked" {{#if actor.system.customGear.marked}}checked{{/if}}/>
<input type="text" class="hench-text-input" data-field-path="system.customGear.description" value="{{actor.system.customGear.description}}" />
</li>
</ul> </ul>
<h3> Harm: </h3> <h3> Harm: </h3>
@ -52,25 +64,37 @@
<h4>Level 1:</h4> <h4>Level 1:</h4>
<ul> <ul>
{{#each actor.system.harm.levelOne}} {{#each actor.system.harm.levelOne}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelOne[{{@index}}].marked" {{#if this.marked}}checked{{/if}} /> {{this.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelOne[{{@index}}].marked" {{#if this.marked}}checked{{/if}} />
<input type="text" class="hench-text-input" data-field-path="system.harm.levelOne[{{@index}}].description" value="{{this.description}}" />
</li>
{{/each}} {{/each}}
</ul> </ul>
<h4>Level 2:</h4> <h4>Level 2:</h4>
<ul> <ul>
{{#each actor.system.harm.levelTwo}} {{#each actor.system.harm.levelTwo}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelTwo[{{@index}}].marked" {{#if this.marked}}checked{{/if}} /> {{this.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelTwo[{{@index}}].marked" {{#if this.marked}}checked{{/if}} />
<input type="text" class="hench-text-input" data-field-path="system.harm.levelTwo[{{@index}}].description" value="{{this.description}}" />
</li>
{{/each}} {{/each}}
</ul> </ul>
<h4>Level 3:</h4> <h4>Level 3:</h4>
<ul> <ul>
{{#each actor.system.harm.levelThree}} {{#each actor.system.harm.levelThree}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelThree[{{@index}}].marked" {{#if this.marked}}checked{{/if}} /> {{this.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelThree[{{@index}}].marked" {{#if this.marked}}checked{{/if}} />
<input type="text" class="hench-text-input" data-field-path="system.harm.levelThree[{{@index}}].description" value="{{this.description}}" />
</li>
{{/each}} {{/each}}
</ul> </ul>
<h4>Level 3:</h4> <h4>Level 3:</h4>
<ul> <ul>
{{#each actor.system.harm.levelFour}} {{#each actor.system.harm.levelFour}}
<li><input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelFour[{{@index}}].marked" {{#if this.marked}}checked{{/if}} /> {{this.description}}</li> <li>
<input type="checkbox" class="hench-checkbox-toggle-field" data-field-path="system.harm.levelFour[{{@index}}].marked" {{#if this.marked}}checked{{/if}} />
<input type="text" class="hench-text-input" data-field-path="system.harm.levelFour[{{@index}}].description" value="{{this.description}}" />
</li>
{{/each}} {{/each}}
</ul> </ul>
</div> </div>