added number conversion in HTML value retrieval
Changes: - number input fields now return numbers - range elements removed since they are untested Additions: - added min and step specifiers to input fields associated to item number properties - added a color hint for invalidity of item number input fields in actor sheet
This commit is contained in:
parent
ec404624c7
commit
61beda7734
5 changed files with 18 additions and 7 deletions
|
@ -131,7 +131,7 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
|
||||||
* The value is parsed to:
|
* The value is parsed to:
|
||||||
* - Checkbox: boolean
|
* - Checkbox: boolean
|
||||||
* - Text input: string
|
* - Text input: string
|
||||||
* - Number, range input: trimmed string
|
* - Number: number
|
||||||
* @param el the input element to collect the value of
|
* @param el the input element to collect the value of
|
||||||
*/
|
*/
|
||||||
private getValue(el: HTMLFormElement): boolean | string | number {
|
private getValue(el: HTMLFormElement): boolean | string | number {
|
||||||
|
@ -148,12 +148,18 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Numbers and ranges:
|
// Numbers:
|
||||||
else if (["number", "range"].includes(el.type)) {
|
else if (el.type === "number") {
|
||||||
const value: string = el.value.trim();
|
const value = Number(el.value.trim());
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // Ranges:
|
||||||
|
// else if (el.type === "range") {
|
||||||
|
// const value: string = el.value.trim();
|
||||||
|
// return value;
|
||||||
|
// }
|
||||||
|
|
||||||
// // Radio Checkboxes (untested, cf. FormDataExtended.process)
|
// // Radio Checkboxes (untested, cf. FormDataExtended.process)
|
||||||
// else if (el.type === "radio") {
|
// else if (el.type === "radio") {
|
||||||
// const chosen: HTMLFormElement = el.find((r: HTMLFormElement) => r["checked"]);
|
// const chosen: HTMLFormElement = el.find((r: HTMLFormElement) => r["checked"]);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
@use "sass:color";
|
||||||
|
|
||||||
.items-list {
|
.items-list {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 7px 0;
|
margin: 7px 0;
|
||||||
|
@ -52,6 +54,9 @@
|
||||||
width: 2.5em;
|
width: 2.5em;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
.item-num-val:invalid {
|
||||||
|
background-color: color.mix(lightcoral, $c-light-grey, 25%);
|
||||||
|
}
|
||||||
|
|
||||||
.item-description {
|
.item-description {
|
||||||
font-size: 75%;
|
font-size: 75%;
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<img src="{{item.img}}" title="{{item.name}}" width="24" height="24" />
|
<img src="{{item.img}}" title="{{item.name}}" width="24" height="24" />
|
||||||
</div>
|
</div>
|
||||||
{{!-- amount --}}
|
{{!-- amount --}}
|
||||||
<input class="flex05 item-num-val item-change" type="number" value="{{item.data.data.quantity}}" data-dtype="Number"
|
<input class="flex05 item-num-val item-change" type="number" min="0" step="1" value="{{item.data.data.quantity}}" data-dtype="Number"
|
||||||
data-property="data.quantity" title="{{localize 'DS4.Quantity'}}">
|
data-property="data.quantity" title="{{localize 'DS4.Quantity'}}">
|
||||||
{{!-- name --}}
|
{{!-- name --}}
|
||||||
<input class="flex3 item-name item-change" type="text" value="{{item.name}}" data-dtype="String"
|
<input class="flex3 item-name item-change" type="text" value="{{item.name}}" data-dtype="String"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="side-property">
|
<div class="side-property">
|
||||||
<label for="data.quantity">{{localize 'DS4.Quantity'}}</label>
|
<label for="data.quantity">{{localize 'DS4.Quantity'}}</label>
|
||||||
<input type="number" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
|
<input type="number" min="0" step="1" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="side-property">
|
<div class="side-property">
|
||||||
<label for="data.storageLocation">{{localize 'DS4.StorageLocation'}}</label>
|
<label for="data.storageLocation">{{localize 'DS4.StorageLocation'}}</label>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="side-properties">
|
<div class="side-properties">
|
||||||
<div class="side-property">
|
<div class="side-property">
|
||||||
<label for="data.price">{{localize "DS4.PriceGold"}}</label>
|
<label for="data.price">{{localize "DS4.PriceGold"}}</label>
|
||||||
<input type="number" data-dtype="Number" name="data.price" value="{{data.price}}" />
|
<input type="number" min="0" data-dtype="Number" name="data.price" value="{{data.price}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="side-property">
|
<div class="side-property">
|
||||||
<label for="data.availability">{{localize "DS4.ItemAvailability"}}</label>
|
<label for="data.availability">{{localize "DS4.ItemAvailability"}}</label>
|
||||||
|
|
Loading…
Reference in a new issue