Merge branch '49-hide-units' into 'master'

Values with unit only displayed if value is specified

Closes #49

See merge request dungeonslayers/ds4!52
This commit is contained in:
Gesina Schwalbe 2021-01-17 10:29:51 +01:00
commit a395ef21e4

View file

@ -2,25 +2,32 @@
{{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- INLINE PARTIAL DEFINITIONS --}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
{{!--
{{!-- !-- Base template to display a value with unit.
!-- Two templates for displaying values 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 localizationString
!-- @param config: the config object !-- @param unitNames: mapping of allowed unitDatum.unit values to localized unit name
!-- @param unitAbbrs: mapping of allowed unitDatum.unit values to unit abbreviation
--}}
{{#*inline "unit"}}
<div class="unit-data-pair item-num-val"
title="{{localize localizationString}} [{{lookup unitNames unitDatum.unit}}]" >
{{#if unitDatum.value }}
{{unitDatum.value}}{{lookup unitAbbrs unitDatum.unit}}
{{else}}-{{/if}}
</div>
{{/inline}}
{{!--
!-- Two templates based on the "unit" template for displaying values with unit.
!-- Both accept a `config` object holding the unitNames and unitAbbr instead of
!-- directly handing over the latter two.
--}} --}}
{{#*inline "temporalUnit"}} {{#*inline "temporalUnit"}}
<div class="unit-data-pair item-num-val" {{> unit unitNames=config.temporalUnits unitAbbrs=config.temporalUnitsAbbr unitDatum=unitDatum localizationString=localizationString}}
title="{{localize localizationString}} [{{lookup config.temporalUnits unitDatum.unit}}]" >
{{unitDatum.value}}{{lookup config.temporalUnitsAbbr unitDatum.unit}}
</div>
{{/inline}} {{/inline}}
{{#*inline "distanceUnit"}} {{#*inline "distanceUnit"}}
<div class="unit-data-pair item-num-val" {{> unit unitNames=config.distanceUnits unitAbbrs=config.distanceUnitsAbbr unitDatum=unitDatum localizationString=localizationString}}
title="{{localize localizationString}} [{{lookup config.distanceUnits unitDatum.unit}}]" >
{{unitDatum.value}}{{lookup config.distanceUnitsAbbr unitDatum.unit}}
</div>
{{/inline}} {{/inline}}