removed code duplication of item body from talent
- added isPhysical boolean to getData output of item-sheet.ts - added isPhysical checks for displays of physical-only information in templates
This commit is contained in:
parent
5bdfdd410b
commit
e6b51c66a6
5 changed files with 32 additions and 51 deletions
|
@ -39,6 +39,10 @@ interface DS4ItemPhysical {
|
||||||
storageLocation: string;
|
storageLocation: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean {
|
||||||
|
return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input;
|
||||||
|
}
|
||||||
|
|
||||||
interface DS4ItemEquipable {
|
interface DS4ItemEquipable {
|
||||||
equipped: boolean;
|
equipped: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DS4Item } from "./item";
|
import { DS4Item } from "./item";
|
||||||
import { DS4ItemDataType } from "./item-data";
|
import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the basic ItemSheet with some very simple modifications
|
* Extend the basic ItemSheet with some very simple modifications
|
||||||
|
@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
|
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
|
||||||
const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor };
|
const data = {
|
||||||
|
...super.getData(),
|
||||||
|
config: CONFIG.DS4,
|
||||||
|
isOwned: this.item.isOwned,
|
||||||
|
actor: this.item.actor,
|
||||||
|
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),
|
||||||
|
};
|
||||||
console.log(data);
|
console.log(data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
<nav class="sheet-tabs tabs" data-group="primary">
|
<nav class="sheet-tabs tabs" data-group="primary">
|
||||||
<a class="item" data-tab="description">{{localize "DS4.HeadingDescription"}}</a>
|
<a class="item" data-tab="description">{{localize "DS4.HeadingDescription"}}</a>
|
||||||
<a class="item" data-tab="effects">{{localize "DS4.HeadingEffects"}}</a>
|
<a class="item" data-tab="effects">{{localize "DS4.HeadingEffects"}}</a>
|
||||||
|
{{#if isPhysical}}
|
||||||
<a class="item" data-tab="details">{{localize "DS4.HeadingDetails"}}</a>
|
<a class="item" data-tab="details">{{localize "DS4.HeadingDetails"}}</a>
|
||||||
|
{{/if}}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{{!-- Sheet Body --}}
|
{{!-- Sheet Body --}}
|
||||||
|
@ -13,10 +15,12 @@
|
||||||
{{!-- Description Tab --}}
|
{{!-- Description Tab --}}
|
||||||
{{> systems/ds4/templates/item/partials/description.hbs}}
|
{{> systems/ds4/templates/item/partials/description.hbs}}
|
||||||
|
|
||||||
{{!-- Details Tab --}}
|
|
||||||
{{> systems/ds4/templates/item/partials/details.hbs}}
|
|
||||||
|
|
||||||
{{!-- Effects Tab --}}
|
{{!-- Effects Tab --}}
|
||||||
{{> systems/ds4/templates/item/partials/effects.hbs}}
|
{{> systems/ds4/templates/item/partials/effects.hbs}}
|
||||||
|
|
||||||
|
{{#if isPhysical}}
|
||||||
|
{{!-- Details Tab --}}
|
||||||
|
{{> systems/ds4/templates/item/partials/details.hbs}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
</section>
|
</section>
|
|
@ -11,14 +11,16 @@
|
||||||
<a class="entity-link" draggable="true" data-entity="Actor" data-id="{{actor._id}}"><i
|
<a class="entity-link" draggable="true" data-entity="Actor" data-id="{{actor._id}}"><i
|
||||||
class="fas fa-user"></i>{{actor.name}}</a>
|
class="fas fa-user"></i>{{actor.name}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="side-property">
|
{{#if isPhysical}}
|
||||||
<label for="data.quantity">{{localize 'DS4.Quantity'}}</label>
|
<div class="side-property">
|
||||||
<input type="number" min="0" step="1" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
|
<label for="data.quantity">{{localize 'DS4.Quantity'}}</label>
|
||||||
</div>
|
<input type="number" min="0" step="1" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
|
||||||
<div class="side-property">
|
</div>
|
||||||
<label for="data.storageLocation">{{localize 'DS4.StorageLocation'}}</label>
|
<div class="side-property">
|
||||||
<input type="text" data-dtype="String" name="data.storageLocation" value="{{data.storageLocation}}" />
|
<label for="data.storageLocation">{{localize 'DS4.StorageLocation'}}</label>
|
||||||
</div>
|
<input type="text" data-dtype="String" name="data.storageLocation" value="{{data.storageLocation}}" />
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<span>{{localize "DS4.NotOwned"}}</span>
|
<span>{{localize "DS4.NotOwned"}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -31,42 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{{!-- Sheet Tab Navigation --}}
|
{{!-- Common Item body --}}
|
||||||
<nav class="sheet-tabs tabs" data-group="primary">
|
{{> systems/ds4/templates/item/partials/body.hbs}}
|
||||||
<a class="item" data-tab="description">{{localize "DS4.HeadingDescription"}}</a>
|
|
||||||
<a class="item" data-tab="effects">{{localize "DS4.HeadingEffects"}}</a>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
{{!-- Sheet Body --}}
|
|
||||||
<section class="sheet-body">
|
|
||||||
{{!-- The item tab for details. --}}
|
|
||||||
<div class="tab flexrow" data-group="primary" data-tab="description">
|
|
||||||
{{!-- As you add new fields, add them in here! --}}
|
|
||||||
<div class="side-properties">
|
|
||||||
{{!-- TODO: remove duplication of isOwned section here and in description.hbs--}}
|
|
||||||
{{#if isOwned}}
|
|
||||||
{{#if (ne data.equipped undefined)}}<div class="side-property">
|
|
||||||
<label for="data.equipped">{{localize 'DS4.ItemEquipped'}}</label>
|
|
||||||
<input type="checkbox" name="data.equipped" data-dtype="Boolean" {{checked data.equipped}} title="{{localize 'DS4.ItemEquipped'}}">
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
<div class="side-property">
|
|
||||||
<label for="data.actor">{{localize 'DS4.ItemOwner'}}</label>
|
|
||||||
<a class="entity-link" draggable="true" data-entity="Actor" data-id="{{actor._id}}"><i
|
|
||||||
class="fas fa-user"></i>{{actor.name}}</a>
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
<span>{{localize "DS4.NotOwned"}}</span>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
<div class="description" title="{{localize 'DS4.HeadingDescription'}}">
|
|
||||||
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{!-- Effects Tab --}}
|
|
||||||
{{> systems/ds4/templates/item/partials/effects.hbs }}
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue