From 177de1a486674157c402183fb38f395badddf8d8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 16:29:02 +0100 Subject: [PATCH] extracted item control buttons to own templates - removed code duplication of inline button templates for item and talent overview --- src/module/ds4.ts | 2 ++ .../actor/partials/items-overview.hbs | 27 ++------------- .../actor/partials/overview-add-button.hbs | 11 ++++++ .../partials/overview-control-buttons.hbs | 8 +++++ .../actor/partials/talents-overview.hbs | 34 ++++++------------- 5 files changed, 33 insertions(+), 49 deletions(-) create mode 100644 src/templates/actor/partials/overview-add-button.hbs create mode 100644 src/templates/actor/partials/overview-control-buttons.hbs diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 4bcf2223..f8d88667 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -38,6 +38,8 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", "systems/ds4/templates/actor/partials/talents-overview.hbs", + "systems/ds4/templates/actor/partials/overview-add-button.hbs", + "systems/ds4/templates/actor/partials/overview-control-buttons.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index f3e5415d..da54d2e8 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -5,29 +5,6 @@ {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} -{{!-- -!-- Render an "add" button for a given data type. -!-- -!-- @param datType: hand over the dataType to the partial as hash parameter ---}} -{{#*inline "addItemButton"}} -
- - - {{localize 'DS4.UserInteractionAddItem'}} -
-{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
- - -
-{{/inline}} - {{!-- !-- Render a header row for a given data type. @@ -57,7 +34,7 @@ {{!-- description --}}
{{localize 'DS4.HeadingDescription'}}
{{!-- add button --}} - {{> addItemButton dataType=dataType }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -94,7 +71,7 @@ {{!-- description --}}
{{{item.data.data.description}}}
{{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} diff --git a/src/templates/actor/partials/overview-add-button.hbs b/src/templates/actor/partials/overview-add-button.hbs new file mode 100644 index 00000000..86e5d774 --- /dev/null +++ b/src/templates/actor/partials/overview-add-button.hbs @@ -0,0 +1,11 @@ +{{! +!-- Render an "add" button for adding an item of given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +}} +
+ + + {{localize "DS4.UserInteractionAddItem"}} + +
\ No newline at end of file diff --git a/src/templates/actor/partials/overview-control-buttons.hbs b/src/templates/actor/partials/overview-control-buttons.hbs new file mode 100644 index 00000000..d10dbc3f --- /dev/null +++ b/src/templates/actor/partials/overview-control-buttons.hbs @@ -0,0 +1,8 @@ +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +
+ + +
diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index af259410..3c2cfeac 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -3,30 +3,15 @@ {{!-- ======================================================================== --}} {{!-- TODO: remove duplicate add and delete button definition --}} -{{!-- -!-- Render an "add" button for a given data type. + +{{!-- +!-- Render an input element for a rank value property of an item. !-- -!-- @param datType: hand over the dataType to the partial as hash parameter +!-- @param item: the item +!-- @param property: the key of the property in item.data.data (if 'base', the max value is set automatically) +!-- @param disabled: if given, is placed plainly into the input as HTML property; +!-- meant to be set to "disabled" to disable the input element --}} -{{#*inline "addItemButton"}} -
- - - {{localize 'DS4.UserInteractionAddItem'}} -
-{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
- - -
-{{/inline}} - - {{#*inline "talentRankValue"}} {{/inline}} + {{!-- !-- Render a talent list row from a given item. !-- It is a flexbox with a child for each item value of interest. @@ -68,7 +54,7 @@ {{!-- description --}}
{{{item.data.data.description}}}
{{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} @@ -88,7 +74,7 @@ {{!-- description --}}
{{localize 'DS4.HeadingDescription'}}
{{!-- add button --}} - {{> addItemButton dataType='talent' }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }} {{#each itemsByType.talent as |item id|}} {{> talentListEntry item=item}}