change Bewaffnung.system.schild.groesse to be choices based and use DSA41_input

This commit is contained in:
Sven Balzer 2025-05-04 12:08:27 +02:00
parent e7f6e91516
commit 6eb2b88046
2 changed files with 11 additions and 7 deletions

View File

@ -81,11 +81,7 @@
<div class="tab {{#if (eq tabGroups.primary 'tab3')}}active{{/if}}" data-group="primary" data-tab="tab3">
<span>{{localize "DSA41.bewaffnung.schild.groesse.label"}}</span>
<select name="system.schild.groesse">
<option value="klein" {{#if (eq item.system.schild.groesse "klein")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.klein"}}</option>
<option value="gross" {{#if (eq item.system.schild.groesse "gross")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.gross"}}</option>
<option value="sehr_gross" {{#if (eq item.system.schild.groesse "sehr_gross")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.sehr_gross"}}</option>
</select>
{{DSA41_input "system.schild.groesse"}}
<span>{{localize "DSA41.bewaffnung.schild.modifikator"}}</span>
<div class="grid2">
{{>editable-input type="number" name="system.schild.modifikator_attacke" value=item.system.schild.modifikator_attacke placeholder=(localize "DSA41.bewaffnung.schild.attacke")}}

View File

@ -101,7 +101,7 @@ Hooks.once("init", async function() {
Handlebars.registerHelper({
DSA41_input: (field_name, options) => {
let fields = field_name.startsWith("system.") ? options.data.root.document.system.schema.fields : options.data.root.document.schema.fields;
let field = fields[field_name.replace(/^(system\.)/, "")];
let field = foundry.utils.getProperty(fields, field_name.replace(/^(system\.)/, "").replace(".", ".fields."));
if (!field) {
console.error("Non-existent data field provided to {{DSA4_input}} handlebars helper.");
@ -738,7 +738,15 @@ class DSA41_BewaffnungData extends TypeDataModel {
schild: new SchemaField({
aktiv: new BooleanField({ initial: false }),
groesse: new StringField({ initial: "klein" }),
groesse: new StringField({
required: true,
choices: {
"klein": "DSA41.bewaffnung.schild.groesse.klein",
"gross": "DSA41.bewaffnung.schild.groesse.gross",
"sehr_gross": "DSA41.bewaffnung.schild.groesse.sehr_gross",
},
initial: "klein",
}),
modifikator_attacke: new NumberField({ integer: true, initial: 0 }),
modifikator_parade: new NumberField({ integer: true, initial: 0 }),