GH-87 Cohort Gang Type fix
- Closes #87 - Fixes Gang Type multiple select
This commit is contained in:
parent
0a06e07d57
commit
c785f0691d
|
@ -1,3 +1,7 @@
|
|||
v2.6
|
||||
- Fixed bug with upgrade
|
||||
- Fixed bug with Gang Type (checkboxes in Foundry can not be used to pass string values so changed to multiple select)
|
||||
|
||||
v2.5
|
||||
- Updates the functionality with checkboxes and new FormDataExtended api.
|
||||
- Fixes Traumas for FVTT 0.7.2+.
|
||||
|
|
|
@ -185,6 +185,34 @@ Hooks.once("init", async function() {
|
|||
return outStr;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* Takes label from Selected option instead of just plain value.
|
||||
*/
|
||||
|
||||
Handlebars.registerHelper('selectOptionsWithLabel', function(choices, options) {
|
||||
|
||||
const localize = options.hash['localize'] ?? false;
|
||||
let selected = options.hash['selected'] ?? null;
|
||||
let blank = options.hash['blank'] || null;
|
||||
selected = selected instanceof Array ? selected.map(String) : [String(selected)];
|
||||
|
||||
// Create an option
|
||||
const option = (key, object) => {
|
||||
if ( localize ) object.label = game.i18n.localize(object.label);
|
||||
let isSelected = selected.includes(key);
|
||||
html += `<option value="${key}" ${isSelected ? "selected" : ""}>${object.label}</option>`
|
||||
};
|
||||
|
||||
// Create the options
|
||||
let html = "";
|
||||
if ( blank ) option("", blank);
|
||||
Object.entries(choices).forEach(e => option(...e));
|
||||
|
||||
return new Handlebars.SafeString(html);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,16 +29,15 @@
|
|||
</section>
|
||||
|
||||
<section id="gang-expert-type-selector" class="flex-vertical">
|
||||
{{#if (eq data.cohort.[0] "Gang")}}
|
||||
{{#if (eq data.cohort "Gang")}}
|
||||
|
||||
<div class="label-stripe">{{localize "BITD.GangType"}}</div>
|
||||
<div id="gang-type-boxes" class="flex-horizontal">
|
||||
{{#multiboxes data.gang_type}}
|
||||
{{#each data.gang_type_list as |gang_type key|}}
|
||||
<input id="gang-type-{{key}}" type="checkbox" name="data.gang_type" value="{{key}}">
|
||||
<label for="gang-type-{{key}}">{{localize gang_type.label}}</label>
|
||||
{{/each}}
|
||||
{{/multiboxes}}
|
||||
|
||||
<select name="data.gang_type" multiple>
|
||||
{{selectOptionsWithLabel data.gang_type_list selected=data.gang_type localize=true}}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div id="selected-gang-description" class="description">
|
||||
{{#each data.gang_type as |gang_type key|}}
|
||||
|
@ -50,7 +49,7 @@
|
|||
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq data.cohort.[0] "Expert")}}
|
||||
{{#if (eq data.cohort "Expert")}}
|
||||
<div class="label-stripe">{{localize "BITD.ExpertType"}}</div>
|
||||
<input type="text" name="data.expert_type" value="{{data.expert_type}}">
|
||||
{{/if}}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="cohort-block">
|
||||
<div class="label-stripe">
|
||||
<div class="item-sheet-open">{{#if (eq item.data.cohort.[0] "Gang")}}Gang of {{#each item.data.gang_type as |gang_type key|}}{{gang_type}} {{/each}}{{/if}}{{#if (eq item.data.cohort.[0] "Expert")}}{{item.data.cohort.[0]}} {{item.data.expert_type}}{{/if}} (click to edit)</div>
|
||||
<div class="item-sheet-open">{{#if (eq item.data.cohort "Gang")}}Gang of {{#each item.data.gang_type as |gang_type key|}}{{gang_type}} {{/each}}{{/if}}{{#if (eq item.data.cohort "Expert")}}{{item.data.cohort}} {{item.data.expert_type}}{{/if}} (click to edit)</div>
|
||||
<div>Q:{{item.data.quality}} S:{{item.data.scale}}</div>
|
||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
|
@ -17,7 +17,7 @@
|
|||
{{/each}}
|
||||
</div>
|
||||
|
||||
{{#if (eq item.data.cohort.[0] "Gang")}}
|
||||
{{#if (eq item.data.cohort "Gang")}}
|
||||
{{#each item.data.gang_type as |gang_type key|}}
|
||||
<div>
|
||||
{{#with (lookup ../item.data.gang_type_list gang_type)}}{{localize description}} {{/with}}
|
||||
|
|
Loading…
Reference in New Issue