implemented dynamic headers of item lists

This commit is contained in:
Gesina Schwalbe 2021-01-09 01:11:55 +01:00
parent 9d58388c5f
commit dc2d099565
2 changed files with 54 additions and 0 deletions

View file

@ -6,6 +6,22 @@
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
{{!--
!-- Render the given partial block only if the given itemsArray has length > 0,
!-- else only an add button.
!--
!-- @param itemsArray: the array with the items to check the length of
!-- @param dataType: the string type of the item
--}}
{{#*inline "ifHasItemOfType"}}
{{#if (and (ne itemsArray undefined) (gt itemsArray.length 0))}}
{{> @partial-block}}
{{else}}
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }}
{{/if}}
{{/inline}}
{{!-- {{!--
!-- Render a header row for a given data type. !-- Render a header row for a given data type.
!-- It is a flexbox with a child for each column head. !-- It is a flexbox with a child for each column head.
@ -83,6 +99,8 @@
{{!-- WEAPONS --}} {{!-- WEAPONS --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeWeaponPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeWeaponPlural'}}</h4>
{{!-- {{#if (and (ne itemsByType.weapon undefined) (gt itemsByType.weapon.length 0)) }} --}}
{{#> ifHasItemOfType itemsArray=itemsByType.weapon dataType='weapon' }}
<ol class="items-list"> <ol class="items-list">
{{#> itemListHeader dataType='weapon'}} {{#> itemListHeader dataType='weapon'}}
<div class="flex05 item-image" title="{{localize 'DS4.AttackType'}}">{{localize 'DS4.AttackTypeAbbr'}}</div> <div class="flex05 item-image" title="{{localize 'DS4.AttackType'}}">{{localize 'DS4.AttackTypeAbbr'}}</div>
@ -104,9 +122,13 @@
{{/itemListEntry}} {{/itemListEntry}}
{{/each}} {{/each}}
</ol> </ol>
{{!-- {{else}}
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='weapon' }} --}}
{{/ifHasItemOfType}}
{{!-- ARMOR --}} {{!-- ARMOR --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeArmorPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeArmorPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.armor dataType='armor' }}
<ol class="items-list"> <ol class="items-list">
{{#> itemListHeader dataType='armor'}} {{#> itemListHeader dataType='armor'}}
<div title="{{localize 'DS4.ArmorMaterialType'}}">{{localize 'DS4.ArmorMaterialTypeAbbr'}}</div> <div title="{{localize 'DS4.ArmorMaterialType'}}">{{localize 'DS4.ArmorMaterialTypeAbbr'}}</div>
@ -127,10 +149,12 @@
{{/itemListEntry}} {{/itemListEntry}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
{{!-- SHIELD --}} {{!-- SHIELD --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeShieldPlural'}}</h4> {{!-- SPECIFIC --}} <h4 class="items-list-title">{{localize 'DS4.ItemTypeShieldPlural'}}</h4> {{!-- SPECIFIC --}}
{{#> ifHasItemOfType itemsArray=itemsByType.shield dataType='shield' }}
<ol class="items-list"> <ol class="items-list">
{{#> itemListHeader dataType='shield' }} {{#> itemListHeader dataType='shield' }}
<div class="flex05 item-num-val" title="{{localize 'DS4.ArmorValue'}}"> <div class="flex05 item-num-val" title="{{localize 'DS4.ArmorValue'}}">
@ -143,9 +167,11 @@
{{/itemListEntry}} {{/itemListEntry}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
{{!-- TRINKET --}} {{!-- TRINKET --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeTrinketPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeTrinketPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.trinket dataType='trinket' }}
<ol class="items-list"> <ol class="items-list">
{{#> itemListHeader dataType='trinket'}} {{#> itemListHeader dataType='trinket'}}
<div class="flex2">{{localize 'DS4.StorageLocation'}}</div> <div class="flex2">{{localize 'DS4.StorageLocation'}}</div>
@ -157,9 +183,11 @@
{{/itemListEntry}} {{/itemListEntry}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
{{!-- EQUIPMENT --}} {{!-- EQUIPMENT --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeEquipmentPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeEquipmentPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.equipment dataType='equipment' }}
<ol class="items-list"> <ol class="items-list">
{{#> itemListHeader dataType='equipment'}} {{#> itemListHeader dataType='equipment'}}
<div class="flex2">{{localize 'DS4.StorageLocation'}}</div> <div class="flex2">{{localize 'DS4.StorageLocation'}}</div>
@ -171,4 +199,5 @@
{{/itemListEntry}} {{/itemListEntry}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
</div> </div>

View file

@ -4,6 +4,23 @@
{{!-- TODO: remove duplicate add and delete button definition --}} {{!-- TODO: remove duplicate add and delete button definition --}}
{{!--
!-- Render the given partial block only if the given itemsArray has length > 0,
!-- else only an add button.
!--
!-- @param itemsArray: the array with the items to check the length of
!-- @param dataType: the string type of the item
--}}
{{#*inline "ifHasItemOfType"}}
{{#if (and (ne itemsArray undefined) (gt itemsArray.length 0))}}
{{> @partial-block}}
{{else}}
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }}
{{/if}}
{{/inline}}
{{!-- {{!--
!-- Render an input element for a rank value property of an item. !-- Render an input element for a rank value property of an item.
!-- !--
@ -105,6 +122,7 @@
<div class="tab items" data-group="primary" data-tab="talents"> <div class="tab items" data-group="primary" data-tab="talents">
<h4 class="items-list-title">{{localize 'DS4.ItemTypeTalentPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeTalentPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.talent dataType='talent' }}
<ol class="items-list"> <ol class="items-list">
<li class="item flexrow item-header"> <li class="item flexrow item-header">
{{!-- image --}} {{!-- image --}}
@ -122,28 +140,35 @@
{{> talentListEntry item=item}} {{> talentListEntry item=item}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeRacialAbilityPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeRacialAbilityPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.racialAbility dataType='racialAbility' }}
<ol class="items-list"> <ol class="items-list">
{{> baseItemListHeader dataType='racialAbility' }} {{> baseItemListHeader dataType='racialAbility' }}
{{#each itemsByType.racialAbility as |item id|}} {{#each itemsByType.racialAbility as |item id|}}
{{> baseItemListEntry item=item}} {{> baseItemListEntry item=item}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeLanguagePlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeLanguagePlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.language dataType='language' }}
<ol class="items-list"> <ol class="items-list">
{{> baseItemListHeader dataType='language' }} {{> baseItemListHeader dataType='language' }}
{{#each itemsByType.language as |item id|}} {{#each itemsByType.language as |item id|}}
{{> baseItemListEntry item=item}} {{> baseItemListEntry item=item}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeAlphabetPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeAlphabetPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.alphabet dataType='alphabet' }}
<ol class="items-list"> <ol class="items-list">
{{> baseItemListHeader dataType='alphabet' }} {{> baseItemListHeader dataType='alphabet' }}
{{#each itemsByType.alphabet as |item id|}} {{#each itemsByType.alphabet as |item id|}}
{{> baseItemListEntry item=item}} {{> baseItemListEntry item=item}}
{{/each}} {{/each}}
</ol> </ol>
{{/ifHasItemOfType}}
</div> </div>