extract item-list-entry to commonly used partial

This commit is contained in:
Johannes Loher 2021-02-26 01:08:55 +01:00
parent 0d486647a2
commit b3ac3cde84
7 changed files with 164 additions and 213 deletions

View file

@ -65,6 +65,7 @@ async function registerHandlebarsPartials() {
"systems/ds4/templates/actor/partials/creature-inventory.hbs", "systems/ds4/templates/actor/partials/creature-inventory.hbs",
"systems/ds4/templates/actor/partials/talent-rank-equation.hbs", "systems/ds4/templates/actor/partials/talent-rank-equation.hbs",
"systems/ds4/templates/actor/partials/item-list-header.hbs", "systems/ds4/templates/actor/partials/item-list-header.hbs",
"systems/ds4/templates/actor/partials/item-list-entry.hbs",
]; ];
return loadTemplates(templatePaths); return loadTemplates(templatePaths);
} }

View file

@ -0,0 +1,46 @@
{{!--
!-- Render an item list entry row.
!-- If the partial is called with a partial block, the partial block
!-- content is inserted before the description.
!-- @param itemData: The data of the item.
!-- @param isEquipable: A flag to enable the equipped column.
!-- @param hasQuantity: A flag to enable the quantity column.
!-- @param hideDescription: A flag to disable the description column.
!-- @param @partial-block: Custom column headers can be passed using the partial block.
--}}
<li class="ds4-item-list__row item" data-item-id="{{itemData._id}}">
{{!-- equipped --}}
{{#if isEquipable}}
<input class="ds4-item-list__editable ds4-item-list__editable--checkbox item-change" type="checkbox" {{checked
itemData.data.equipped}} data-dtype="Boolean" data-property="data.equipped"
title="{{localize 'DS4.ItemEquipped'}}">
{{/if}}
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{itemData.img}}')" title="{{itemData.name}}"></div>
{{!-- amount --}}
{{#if hasQuantity}}
<input class="ds4-item-list__editable item-change" type="number" min="0" step="1" value="{{itemData.data.quantity}}"
data-dtype="Number" data-property="data.quantity" title="{{localize 'DS4.Quantity'}}" />
{{/if}}
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{itemData.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText itemData.data.description}}" />
{{!-- item type specifics --}}
{{#if @partial-block }}
{{> @partial-block}}
{{/if}}
{{!-- description --}}
{{#unless hideDescription}}
<div class="ds4-item-list__description" title="{{htmlToPlainText itemData.data.description}}">
{{{itemData.data.description}}}</div>
{{/unless}}
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>

View file

@ -13,22 +13,28 @@
{{#if isEquipable}} {{#if isEquipable}}
<div title="{{localize 'DS4.ItemEquipped'}}">{{localize 'DS4.ItemEquippedAbbr'}}</div> <div title="{{localize 'DS4.ItemEquipped'}}">{{localize 'DS4.ItemEquippedAbbr'}}</div>
{{/if}} {{/if}}
{{!-- image --}} {{!-- image --}}
<div></div> <div></div>
{{!-- amount --}} {{!-- amount --}}
{{#if hasQuantity}} {{#if hasQuantity}}
<div title="{{localize 'DS4.Quantity'}}">#</div> <div title="{{localize 'DS4.Quantity'}}">#</div>
{{/if}} {{/if}}
{{!-- name --}} {{!-- name --}}
<div>{{localize 'DS4.ItemName'}}</div> <div>{{localize 'DS4.ItemName'}}</div>
{{!-- item type specifics --}} {{!-- item type specifics --}}
{{#if @partial-block }} {{#if @partial-block }}
{{> @partial-block }} {{> @partial-block }}
{{/if}} {{/if}}
{{!-- description --}} {{!-- description --}}
{{#unless hideDescription}} {{#unless hideDescription}}
<div>{{localize 'DS4.Description'}}</div> <div>{{localize 'DS4.Description'}}</div>
{{/unless}} {{/unless}}
{{!-- control buttons placeholder --}} {{!-- control buttons placeholder --}}
<div></div> <div></div>
</li> </li>

View file

@ -19,42 +19,6 @@
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }}
{{/inline}} {{/inline}}
{{!--
!-- Render a list row from a given item.
!-- An equipped checkbox is rendered except for the case item.data.type==='loot'.
!-- The partial assumes a variable item to be given in the context.
!-- If the partial is called with a partial block, the partial block
!-- content is inserted before the description.
!-- @param item: hand over the item to the partial as hash parameter
!-- @param partial-block: hand over custom children in the partial block.
--}}
{{#*inline "itemListEntry"}}
<li class="ds4-item-list__row item" data-item-id="{{item._id}}">
{{!-- equipped --}}
{{#if (ne item.type 'loot')}}
<input class="ds4-item-list__editable ds4-item-list__editable--checkbox item-change" type="checkbox" {{checked
item.data.equipped}} data-dtype="Boolean" data-property="data.equipped" title="{{localize 'DS4.ItemEquipped'}}">
{{/if}}
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{item.img}}')" title="{{item.name}}"></div>
{{!-- amount --}}
<input class="ds4-item-list__editable item-change" type="number" min="0" step="1" value="{{item.data.quantity}}"
data-dtype="Number" data-property="data.quantity" title="{{localize 'DS4.Quantity'}}" />
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText item.data.description}}" />
{{!-- item type specifics --}}
{{> @partial-block}}
{{!-- description --}}
<div class="ds4-item-list__description" title="{{htmlToPlainText item.data.description}}">
{{{item.data.description}}}</div>
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/inline}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
{{!-- WEAPONS --}} {{!-- WEAPONS --}}
@ -62,23 +26,34 @@
{{#> ifHasItemOfType itemsArray=itemsByType.weapon dataType='weapon' }} {{#> ifHasItemOfType itemsArray=itemsByType.weapon dataType='weapon' }}
<ol class="ds4-item-list ds4-item-list--weapon item-list"> <ol class="ds4-item-list ds4-item-list--weapon item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}}
{{!-- attack type --}}
<div class="ds4-item-list__image" title="{{localize 'DS4.AttackType'}}">{{localize 'DS4.AttackTypeAbbr'}}</div> <div class="ds4-item-list__image" title="{{localize 'DS4.AttackType'}}">{{localize 'DS4.AttackTypeAbbr'}}</div>
{{!-- weapon bonus --}}
<div title="{{localize 'DS4.WeaponBonus'}}"> <div title="{{localize 'DS4.WeaponBonus'}}">
{{localize 'DS4.WeaponBonusAbbr'}} {{localize 'DS4.WeaponBonusAbbr'}}
</div> </div>
{{!-- opponent defense --}}
<div title="{{localize 'DS4.OpponentDefense'}}"> <div title="{{localize 'DS4.OpponentDefense'}}">
{{localize 'DS4.OpponentDefenseAbbr'}} {{localize 'DS4.OpponentDefenseAbbr'}}
</div> </div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.weapon as |item id|}}
{{#> itemListEntry item=item}} {{#each itemsByType.weapon as |itemData id|}}
{{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true hasQuantity=true}}
{{!-- attack type --}}
<div class="ds4-item-list__image" <div class="ds4-item-list__image"
style="background-image: url('{{lookup ../../config.icons.attackTypes item.data.attackType}}')" style="background-image: url('{{lookup ../../config.icons.attackTypes itemData.data.attackType}}')"
title="{{lookup ../../config.i18n.attackTypes item.data.attackType}}"> title="{{lookup ../../config.i18n.attackTypes itemData.data.attackType}}">
</div> </div>
<div>{{ item.data.weaponBonus}}</div>
<div>{{ item.data.opponentDefense}}</div> {{!-- weapon bonus --}}
{{/itemListEntry}} <div>{{ itemData.data.weaponBonus}}</div>
{{!-- opponent defense --}}
<div>{{ itemData.data.opponentDefense}}</div>
{{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -88,22 +63,33 @@
{{#> ifHasItemOfType itemsArray=itemsByType.armor dataType='armor' }} {{#> ifHasItemOfType itemsArray=itemsByType.armor dataType='armor' }}
<ol class="ds4-item-list ds4-item-list--armor item-list"> <ol class="ds4-item-list ds4-item-list--armor item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}}
{{!-- armor material type --}}
<div title="{{localize 'DS4.ArmorMaterialType'}}">{{localize 'DS4.ArmorMaterialTypeAbbr'}}</div> <div title="{{localize 'DS4.ArmorMaterialType'}}">{{localize 'DS4.ArmorMaterialTypeAbbr'}}</div>
{{!-- armor type --}}
<div title="{{localize 'DS4.ArmorType'}}">{{localize 'DS4.ArmorTypeAbbr'}}</div> <div title="{{localize 'DS4.ArmorType'}}">{{localize 'DS4.ArmorTypeAbbr'}}</div>
{{!-- armor value --}}
<div title="{{localize 'DS4.ArmorValue'}}"> <div title="{{localize 'DS4.ArmorValue'}}">
{{localize 'DS4.ArmorValueAbbr'}} {{localize 'DS4.ArmorValueAbbr'}}
</div> </div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.armor as |item id|}}
{{#> itemListEntry item=item }} {{#each itemsByType.armor as |itemData id|}}
<div title="{{lookup ../../config.i18n.armorMaterialTypes item.data.armorMaterialType}}"> {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true hasQuantity=true}}
{{lookup ../../config.i18n.armorMaterialTypesAbbr item.data.armorMaterialType}} {{!-- armor material type --}}
<div title="{{lookup ../../config.i18n.armorMaterialTypes itemData.data.armorMaterialType}}">
{{lookup ../../config.i18n.armorMaterialTypesAbbr itemData.data.armorMaterialType}}
</div> </div>
<div title="{{lookup ../../config.i18n.armorTypes item.data.armorType}}">
{{lookup ../../config.i18n.armorTypesAbbr item.data.armorType}} {{!-- armor type --}}
<div title="{{lookup ../../config.i18n.armorTypes itemData.dataData.armorType}}">
{{lookup ../../config.i18n.armorTypesAbbr itemData.dataData.armorType}}
</div> </div>
<div>{{ item.data.armorValue}}</div>
{{/itemListEntry}} {{!-- armor value --}}
<div>{{ itemData.data.armorValue}}</div>
{{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -114,31 +100,34 @@
{{#> ifHasItemOfType itemsArray=itemsByType.shield dataType='shield' }} {{#> ifHasItemOfType itemsArray=itemsByType.shield dataType='shield' }}
<ol class="ds4-item-list ds4-item-list--shield item-list"> <ol class="ds4-item-list ds4-item-list--shield item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}}
{{!-- armor value --}}
<div title="{{localize 'DS4.ArmorValue'}}"> <div title="{{localize 'DS4.ArmorValue'}}">
{{localize 'DS4.ArmorValueAbbr'}} {{localize 'DS4.ArmorValueAbbr'}}
</div> </div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.shield as |item id|}} {{#each itemsByType.shield as |itemData id|}}
{{#> itemListEntry item=item }} {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true hasQuantity=true}}
<div>{{item.data.armorValue}}</div> {{!-- armor value --}}
{{/itemListEntry}} <div>{{itemData.data.armorValue}}</div>
{{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
{{!-- EQUIPMENT --}} {{!-- EQUIPMENT --}}
<h4 class="ds4-item-list-title">{{localize 'DS4.ItemTypeEquipmentPlural'}}</h4> <h4 class="ds4-item-list-title">{{localize 'DS4.ItemTypeEquipmentPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.equipment dataType='equipment' }} {{#> ifHasItemOfType itemsArray=itemsByType.equipment dataType='equipment' }}
<ol class="ds4-item-list ds4-item-list--equipment item-list"> <ol class="ds4-item-list ds4-item-list--equipment item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hasQuantity=true}}
{{!-- storage location --}}
<div>{{localize 'DS4.StorageLocation'}}</div> <div>{{localize 'DS4.StorageLocation'}}</div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.equipment as |item id|}} {{#each itemsByType.equipment as |itemData id|}}
{{#> itemListEntry item=item }} {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true hasQuantity=true}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.data.storageLocation}}" {{!-- storage location --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{itemData.data.storageLocation}}"
data-dtype="String" data-property="data.storageLocation" title="{{localize 'DS4.StorageLocation'}}"> data-dtype="String" data-property="data.storageLocation" title="{{localize 'DS4.StorageLocation'}}">
{{/itemListEntry}} {{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -148,13 +137,15 @@
{{#> ifHasItemOfType itemsArray=itemsByType.loot dataType='loot' }} {{#> ifHasItemOfType itemsArray=itemsByType.loot dataType='loot' }}
<ol class="ds4-item-list ds4-item-list--loot item-list"> <ol class="ds4-item-list ds4-item-list--loot item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs hasQuantity=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs hasQuantity=true}}
{{!-- storage location --}}
<div>{{localize 'DS4.StorageLocation'}}</div> <div>{{localize 'DS4.StorageLocation'}}</div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.loot as |item id|}} {{#each itemsByType.loot as |itemData id|}}
{{#> itemListEntry item=item }} {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData hasQuantity=true}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.data.storageLocation}}" {{!-- storage location --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{itemData.data.storageLocation}}"
data-dtype="String" data-property="data.storageLocation" title="{{localize 'DS4.StorageLocation'}}"> data-dtype="String" data-property="data.storageLocation" title="{{localize 'DS4.StorageLocation'}}">
{{/itemListEntry}} {{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}

View file

@ -1,39 +1,8 @@
{{!-- TODO: Refactor to avoid code duplication with items-overview and talents-overview --}}
{{!-- ======================================================================== --}}
{{!-- INLINE PARTIAL DEFINITIONS --}}
{{!-- ======================================================================== --}}
{{!--
!-- Render a list row for a base item from a given item.
!-- Base item means it just has an image, a description, and a name (and effects).
!-- It is a flexbox with a child for each item value of interest.
!-- The partial assumes a variable item to be given in the context.
!--
!-- @param item: hand over the item to the partial as hash parameter
--}}
{{#*inline "itemListEntry"}}
<li class="ds4-item-list__row item " data-item-id="{{item._id}}">
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{item.img}}')" title="{{item.name}}"></div>
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText item.data.description}}" />
{{!-- description --}}
<div class="ds4-item-list__description" title="{{htmlToPlainText item.data.description}}">
{{{item.data.description}}}</div>
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/inline}}
{{!-- ======================================================================== --}}
<div class="tab special-creature-abilities" data-group="primary" data-tab="special-creature-abilities"> <div class="tab special-creature-abilities" data-group="primary" data-tab="special-creature-abilities">
<ol class="ds4-item-list ds4-item-list--special-creature-ability item-list"> <ol class="ds4-item-list ds4-item-list--special-creature-ability item-list">
{{> systems/ds4/templates/actor/partials/item-list-header.hbs }} {{> systems/ds4/templates/actor/partials/item-list-header.hbs }}
{{#each itemsByType.specialCreatureAbility as |item id|}} {{#each itemsByType.specialCreatureAbility as |itemData id|}}
{{> itemListEntry item=item}} {{> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData}}
{{/each}} {{/each}}
</ol> </ol>
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='specialCreatureAbility' }} {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='specialCreatureAbility' }}

View file

@ -5,30 +5,32 @@
{{!-- {{!--
!-- Base template to display a value with unit. !-- Base template to display a value with unit.
!-- @param unitDatum: the object to display; must have a value and a unit attribute !-- @param unitDatum: the object to display; must have a value and a unit attribute
!-- @param localizationString !-- @param titleKey: The key of the localized title to use.
!-- @param unitNames: mapping of allowed unitDatum.unit values to localized unit name !-- @param unitNames: mapping of allowed unitDatum.unit values to localized unit name
!-- @param unitAbbrs: mapping of allowed unitDatum.unit values to unit abbreviation !-- @param unitAbbrs: mapping of allowed unitDatum.unit values to unit abbreviation
--}} --}}
{{#*inline "unit"}} {{#*inline "unit"}}
<div title="{{localize localizationString}} [{{lookup unitNames unitDatum.unit}}]"> <div title="{{localize titleKey}} [{{lookup unitNames unitDatum.unit}}]">
{{#if unitDatum.value }} {{#if unitDatum.value }}
{{unitDatum.value}}&thinsp;{{lookup unitAbbrs unitDatum.unit}} {{unitDatum.value}}&thinsp;{{lookup unitAbbrs unitDatum.unit}}
{{else}}-{{/if}} {{else}}-{{/if}}
</div> </div>
{{/inline}} {{/inline}}
{{!-- {{!--
!-- Two templates based on the "unit" template for displaying values with unit. !-- Two templates based on the "unit" template for displaying values with unit.
!-- Both accept a `config` object holding the unitNames and unitAbbr instead of !-- Both accept a `config` object holding the unitNames and unitAbbr instead of
!-- directly handing over the latter two. !-- directly handing over the latter two.
!-- @param titleKey: The key of the localized title to use.
--}} --}}
{{#*inline "temporalUnit"}} {{#*inline "temporalUnit"}}
{{> unit unitNames=config.i18n.temporalUnits unitAbbrs=config.i18n.temporalUnitsAbbr unitDatum=unitDatum {{> unit unitNames=config.i18n.temporalUnits unitAbbrs=config.i18n.temporalUnitsAbbr unitDatum=unitDatum
localizationString=localizationString}} titleKey=titleKey}}
{{/inline}} {{/inline}}
{{#*inline "distanceUnit"}} {{#*inline "distanceUnit"}}
{{> unit unitNames=config.i18n.distanceUnits unitAbbrs=config.i18n.distanceUnitsAbbr unitDatum=unitDatum {{> unit unitNames=config.i18n.distanceUnits unitAbbrs=config.i18n.distanceUnitsAbbr unitDatum=unitDatum
localizationString=localizationString}} titleKey=titleKey}}
{{/inline}} {{/inline}}
@ -40,44 +42,43 @@ localizationString=localizationString}}
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hideDescription=true}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hideDescription=true}}
{{!-- spell type --}} {{!-- spell type --}}
<div title="{{localize 'DS4.SpellType'}}">{{localize 'DS4.SpellTypeAbbr'}}</div> <div title="{{localize 'DS4.SpellType'}}">{{localize 'DS4.SpellTypeAbbr'}}</div>
{{!-- spell bonus --}} {{!-- spell bonus --}}
<div title="{{localize 'DS4.SpellBonus'}}">{{localize 'DS4.SpellBonusAbbr'}}</div> <div title="{{localize 'DS4.SpellBonus'}}">{{localize 'DS4.SpellBonusAbbr'}}</div>
{{!-- max. distance --}} {{!-- max. distance --}}
<div title="{{localize 'DS4.SpellMaxDistance'}}"><i class="fas fa-ruler"></i></div> <div title="{{localize 'DS4.SpellMaxDistance'}}"><i class="fas fa-ruler"></i></div>
{{!-- duration --}} {{!-- duration --}}
<div title="{{localize 'DS4.SpellDuration'}}"><i class="far fa-clock"></i></div> <div title="{{localize 'DS4.SpellDuration'}}"><i class="far fa-clock"></i></div>
{{!-- cooldown duration --}} {{!-- cooldown duration --}}
<div title="{{localize 'DS4.SpellCooldownDuration'}}"><i class="fas fa-hourglass-half"></i></div> <div title="{{localize 'DS4.SpellCooldownDuration'}}"><i class="fas fa-hourglass-half"></i></div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.spell as |item id|}} {{#each itemsByType.spell as |itemData id|}}
<li class="ds4-item-list__row item" data-item-id="{{item._id}}"> {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true
<input class="ds4-item-list__editable ds4-item-list__editable--checkbox item-change" type="checkbox" hideDescription=true}}
{{checked item.data.data.equipped}} data-dtype="Boolean" data-property="data.equipped"
title="{{localize 'DS4.ItemEquipped'}}">
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{item.img}}')" title="{{item.name}}"></div>
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText item.data.data.description}}" />
{{!-- spell type --}} {{!-- spell type --}}
<div class="ds4-item-list__image" <div class="ds4-item-list__image"
style="background-image: url('{{lookup ../config.icons.spellTypes item.data.data.spellType}}')" style="background-image: url('{{lookup ../../config.icons.spellTypes itemData.data.spellType}}')"
title="{{lookup ../config.i18n.spellTypes item.data.data.spellType}}"> title="{{lookup ../../config.i18n.spellTypes itemData.data.spellType}}">
</div> </div>
{{!-- spell bonus --}} {{!-- spell bonus --}}
<input class="ds4-item-list__editable item-change" type="text" data-dtype="String" <input class="ds4-item-list__editable item-change" type="text" data-dtype="String" data-property="data.bonus"
data-property="data.bonus" value="{{item.data.data.bonus}}" title="{{localize 'DS4.SpellBonus'}}" /> value="{{itemData.data.bonus}}" title="{{localize 'DS4.SpellBonus'}}" />
{{!-- max. distance --}} {{!-- max. distance --}}
{{> distanceUnit localizationString='DS4.SpellMaxDistance' unitDatum=item.data.data.maxDistance {{> distanceUnit titleKey='DS4.SpellMaxDistance' unitDatum=itemData.data.maxDistance
config=../config}} config=../../config}}
{{!-- duration --}} {{!-- duration --}}
{{> temporalUnit localizationString='DS4.SpellDuration' unitDatum=item.data.data.duration config=../config}} {{> temporalUnit titleKey='DS4.SpellDuration' unitDatum=itemData.data.duration config=../../config}}
{{!-- cooldown duration --}} {{!-- cooldown duration --}}
{{> temporalUnit localizationString='DS4.SpellCooldownDuration' unitDatum=item.data.data.cooldownDuration {{> temporalUnit titleKey='DS4.SpellCooldownDuration' unitDatum=itemData.data.cooldownDuration
config=../config}} config=../../config}}
{{!-- control buttons --}} {{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/each}} {{/each}}
</ol> </ol>
{{!-- add button --}} {{!-- add button --}}

View file

@ -19,72 +19,6 @@
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }}
{{/inline}} {{/inline}}
{{!--
!-- Render a talent list row from a given item.
!-- It is a flexbox with a child for each item value of interest.
!-- The partial assumes a variable item to be given in the context.
!--
!-- @param item: hand over the item to the partial as hash parameter
--}}
{{#*inline "talentListEntry"}}
<li class="ds4-item-list__row item" data-item-id="{{item._id}}">
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{item.img}}')" title="{{item.name}}"></div>
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText item.data.description}}">
{{!-- talent tank equation --}}
{{> systems/ds4/templates/actor/partials/talent-rank-equation.hbs talentRank=item.data.rank}}
{{!-- description --}}
<div class="ds4-item-list__description" title="{{htmlToPlainText item.data.description}}">
{{{item.data.description}}}</div>
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/inline}}
{{!--
!-- Render a list header for a base item list entry from a given item.
!-- The partial assumes a variable dataType to be given in the context.
--}}
{{#*inline "talentListHeader"}}
<li class="ds4-item-list__row ds4-item-list__row--header">
{{!-- image --}}
<div></div>
{{!-- name --}}
<div>{{localize 'DS4.ItemName'}}</div>
{{!-- description --}}
<div>{{localize 'DS4.Description'}}</div>
{{!-- control buttons placeholder --}}
<div></div>
</li>
{{/inline}}
{{!--
!-- Render a list row for a base item from a given item.
!-- Base item means it just has an image, a description, and a name (and effects).
!-- It is a flexbox with a child for each item value of interest.
!-- The partial assumes a variable item to be given in the context.
!--
!-- @param item: hand over the item to the partial as hash parameter
--}}
{{#*inline "baseItemListEntry"}}
<li class="ds4-item-list__row item" data-item-id="{{item._id}}">
{{!-- image --}}
<div class="ds4-item-list__image" style="background-image: url('{{item.img}}')" title="{{item.name}}"></div>
{{!-- name --}}
<input class="ds4-item-list__editable item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{htmlToPlainText item.data.description}}">
{{!-- description --}}
<div class="ds4-item-list__description" title="{{htmlToPlainText item.data.description}}">
{{{item.data.description}}}</div>
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/inline}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
<div class="tab talents-abilities" data-group="primary" data-tab="talents-abilities"> <div class="tab talents-abilities" data-group="primary" data-tab="talents-abilities">
@ -92,11 +26,14 @@
{{#> ifHasItemOfType itemsArray=itemsByType.talent dataType='talent'}} {{#> ifHasItemOfType itemsArray=itemsByType.talent dataType='talent'}}
<ol class="ds4-item-list ds4-item-list--talent item-list"> <ol class="ds4-item-list ds4-item-list--talent item-list">
{{#> systems/ds4/templates/actor/partials/item-list-header.hbs}} {{#> systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{!-- rank info --}} {{!-- rank --}}
<div>{{localize 'DS4.TalentRank'}}</div> <div>{{localize 'DS4.TalentRank'}}</div>
{{/systems/ds4/templates/actor/partials/item-list-header.hbs}} {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.talent as |item id|}} {{#each itemsByType.talent as |itemData id|}}
{{> talentListEntry item=item}} {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData}}
{{!-- rank --}}
{{> systems/ds4/templates/actor/partials/talent-rank-equation.hbs talentRank=itemData.data.rank}}
{{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -105,8 +42,8 @@
{{#> ifHasItemOfType itemsArray=itemsByType.racialAbility dataType='racialAbility'}} {{#> ifHasItemOfType itemsArray=itemsByType.racialAbility dataType='racialAbility'}}
<ol class="ds4-item-list ds4-item-list--racial-ability item-list"> <ol class="ds4-item-list ds4-item-list--racial-ability item-list">
{{> systems/ds4/templates/actor/partials/item-list-header.hbs}} {{> systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.racialAbility as |item id|}} {{#each itemsByType.racialAbility as |itemData id|}}
{{> baseItemListEntry item=item}} {{> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -115,8 +52,8 @@
{{#> ifHasItemOfType itemsArray=itemsByType.language dataType='language'}} {{#> ifHasItemOfType itemsArray=itemsByType.language dataType='language'}}
<ol class="ds4-item-list ds4-item-list--language item-list"> <ol class="ds4-item-list ds4-item-list--language item-list">
{{> systems/ds4/templates/actor/partials/item-list-header.hbs}} {{> systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.language as |item id|}} {{#each itemsByType.language as |itemData id|}}
{{> baseItemListEntry item=item}} {{> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}
@ -125,8 +62,8 @@
{{#> ifHasItemOfType itemsArray=itemsByType.alphabet dataType='alphabet'}} {{#> ifHasItemOfType itemsArray=itemsByType.alphabet dataType='alphabet'}}
<ol class="ds4-item-list ds4-item-list--alphabet item-list"> <ol class="ds4-item-list ds4-item-list--alphabet item-list">
{{> systems/ds4/templates/actor/partials/item-list-header.hbs}} {{> systems/ds4/templates/actor/partials/item-list-header.hbs}}
{{#each itemsByType.alphabet as |item id|}} {{#each itemsByType.alphabet as |itemData id|}}
{{> baseItemListEntry item=item}} {{> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}} {{/ifHasItemOfType}}