add PreisField and use it in Gegenstand
This commit is contained in:
parent
5e94198077
commit
32331729cc
@ -123,6 +123,15 @@ html {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .price-input {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(min-content, 1fr) max-content;
|
||||||
|
|
||||||
|
& input {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
& .placeholder {
|
& .placeholder {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
border-top: 1px solid;
|
border-top: 1px solid;
|
||||||
|
|||||||
38
src/main.mjs
38
src/main.mjs
@ -277,6 +277,42 @@ function get_minified_formula(formula, data) {
|
|||||||
return Roll.getFormula(output);
|
return Roll.getFormula(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PreisUnitField extends StringField {
|
||||||
|
constructor(options={}, context={}) {
|
||||||
|
return super({
|
||||||
|
required: true,
|
||||||
|
choices: {
|
||||||
|
"kreuzer": "DSA41.currency.kreuzer",
|
||||||
|
"heller": "DSA41.currency.heller",
|
||||||
|
"silbertaler": "DSA41.currency.silbertaler",
|
||||||
|
"dukaten": "DSA41.currency.dukaten",
|
||||||
|
},
|
||||||
|
initial: "silbertaler",
|
||||||
|
...options
|
||||||
|
}, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreisField extends SchemaField {
|
||||||
|
constructor() {
|
||||||
|
return super({
|
||||||
|
value: new NumberField({ integer: true, initial: 0, min: 0 }),
|
||||||
|
unit: new PreisUnitField(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_toInput(config) {
|
||||||
|
const value_input = this.fields["value"].toInput({ value: config.value.value, });
|
||||||
|
const unit_input = this.fields["unit"] .toInput({ value: config.value.unit, localize: true });
|
||||||
|
|
||||||
|
let outer_div = document.createElement("div");
|
||||||
|
outer_div.className = "price-input";
|
||||||
|
outer_div.replaceChildren(value_input, unit_input);
|
||||||
|
|
||||||
|
return outer_div;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class AttributeField extends SchemaField {
|
class AttributeField extends SchemaField {
|
||||||
constructor() {
|
constructor() {
|
||||||
return super({
|
return super({
|
||||||
@ -685,7 +721,7 @@ class DSA41_GegenstandData extends TypeDataModel {
|
|||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
return {
|
||||||
gewicht: new NumberField({ integer: false, initial: 0, min: 0 }),
|
gewicht: new NumberField({ integer: false, initial: 0, min: 0 }),
|
||||||
preis: new NumberField({ integer: true, initial: 0, min: 0 }),
|
preis: new PreisField(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user