Skip to content

Commit

Permalink
Merge pull request #1750 from StarWarsFoundryVTT/handlebars_1632
Browse files Browse the repository at this point in the history
fix(template): stop using deprecated function
  • Loading branch information
wrycu authored Dec 27, 2024
2 parents 671cab2 + 1d661dd commit 64a5359
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* Allow weapon status check for dice roll also for shipweapon
* Blind GM rolls are now properly hidden from players ([#1712](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1712))
* Properly use Genesys story points when the theme is set to Genesys ([#1711](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1711))
* Stop using deprecated `select` Handlebars helper ([#1632](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1632))
* Note that the same _code_ is in use, it is just no longer using the built-in (and deprecated) version

`1.903`
* Features:
Expand Down
10 changes: 10 additions & 0 deletions modules/swffg-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ Hooks.once("init", async function () {
// Add utilities to the global scope, this can be useful for macro makers
window.DicePoolFFG = DicePoolFFG;

// add back in the select helper (under a new name, so we don't get warnings)
Handlebars.registerHelper({
selectFfg: function (selected, options) {
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
const html = options.fn(this);
return html.replace(rgx, "$& selected");
}
});

// Register Handlebars utilities
Handlebars.registerHelper("json", JSON.stringify);

Expand Down
4 changes: 2 additions & 2 deletions templates/dialogs/ffg-sheet-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<input type="text" name="flags.starwarsffg.config.{{id}}" id="{{id}}" data-dtype="String" value="{{localize option.value}}" />
{{/if}} {{#if (eq option.type "Array")}}
<select name="flags.starwarsffg.config.{{id}}" id="{{id}}">
{{#select option.value }}{{#each option.options as |optionvalue id| }}
{{#selectFfg option.value }}{{#each option.options as |optionvalue id| }}
<option value="{{id}}">{{optionvalue}}</option>
{{/each}}{{/select}}
{{/each}}{{/selectFfg}}
</select>
{{/if}}
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/group-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="initiative">
<h1>{{localize "SWFFG.InitiativeMode"}}</h1>
<select class="initiative-mode" name="initiative-mode" id="initiative-mode">
{{#select initiative}}
{{#selectFfg initiative}}
<option value="Vigilance">{{localize "SWFFG.SkillsNameVigilance"}}</option>
<option value="Cool">{{localize "SWFFG.SkillsNameCool"}}</option>
{{/select}}
{{/selectFfg}}
</select>
</div>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions templates/parts/shared/ffg-block.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
{{/if}} {{#if (eq type "Dropdown")}}
<select style="text-align: center;" name="{{name}}">
{{#if (eq name "data.characteristic.value")}}<option value="">None</option>{{/if}}
{{#select value}} {{#each options as |t|}}
{{#selectFfg value}} {{#each options as |t|}}
<option value="{{#if (eq t.value undefined) }}{{t._id}}{{else}}{{t.value}}{{/if}}">{{localize t.label}}{{t.name}}</option>
{{/each}} {{/select}}
{{/each}} {{/selectFfg}}
</select>
{{/if}} {{#if (eq type "Multicheckbox")}}
<div class="grid grid-2col firing-arcs">
Expand Down
8 changes: 4 additions & 4 deletions templates/parts/shared/ffg-modifiers.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<li class="attribute flexrow" data-attribute="{{key}}">
<input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}" style="display: none;" />
<select class="attribute-modtype" name="data.attributes.{{key}}.modtype">
{{#select attr.modtype}}
{{#selectFfg attr.modtype}}
{{#if (or (eq ../item.type "criticaldamage") (eq ../item.type "shipattachment") (eq ../item.type "shipweapon") )}}
{{#each ../this.FFG.vehicle_mod_types as |t|}}
<option value="{{t.value}}">{{localize t.label}}</option>
Expand Down Expand Up @@ -47,10 +47,10 @@
{{/if}}
{{/each}}
{{/if}}
{{/select}}
{{/selectFfg}}
</select>
<select class="attribute-mod" name="data.attributes.{{key}}.mod">
{{#select attr.mod}}
{{#selectFfg attr.mod}}
{{#if (and (eq attr.modtype "Stat") (or (eq ../item.type "criticaldamage") (eq ../item.type "shipattachment") (eq ../item.type "shipweapon"))) }}
{{#each ../this.FFG.vehicle_stats as |t|}}
<option value="{{t.value}}">{{localize t.label}}</option>
Expand Down Expand Up @@ -102,7 +102,7 @@
<option value="{{t.value}}">{{localize t.label}}</option>
{{/each}}
{{/if}}
{{/select}}
{{/selectFfg}}
</select>
{{#if (or (eq attr.modtype "Career Skill") (eq attr.modtype "Force Boost") )}}
<input class="attribute-value" type="checkbox" name="data.attributes.{{key}}.value" data-dtype="Boolean" {{#if (or (eq attr.value "0") (eq attr.value false)) }}{{else}}checked{{/if}} />
Expand Down

0 comments on commit 64a5359

Please sign in to comment.