v12 fixes : Fix select to selectOptions

This commit is contained in:
Vlyan
2024-05-24 18:44:24 +02:00
parent fcc2691f4b
commit 3b37859cb5
12 changed files with 87 additions and 201 deletions

View File

@@ -150,7 +150,10 @@ export class TwentyQuestionsDialog extends FormApplication {
skillsList,
skillsListStep7,
skillsListStep17,
noHonorSkillsList: ["commerce", "skulduggery", "medicine", "seafaring", "survival", "labor"],
noHonorSkillsList: CONFIG.l5r5e.noHonorSkillsList.map(id => ({
id,
label: game.i18n.localize("l5r5e.skills." + CONFIG.l5r5e.skills.get(id.toLowerCase()) + "." + id.toLowerCase())
})),
techniquesList: game.l5r5e.HelpersL5r5e.getTechniquesList({ displayInTypes: true }),
data: this.object.data,
cache: this.cache,

View File

@@ -23,6 +23,7 @@ export const L5R5E = {
skirmish: "tactics",
mass_battle: "command",
},
noHonorSkillsList: ["commerce", "skulduggery", "medicine", "seafaring", "survival", "labor"],
};
// *** Techniques ***

View File

@@ -7,7 +7,11 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
/**
* Sub Types of advancements
*/
static types = { ring: "l5r5e.rings.label", skill: "l5r5e.skills.label" }; // others have theirs own xp count
static types = [
{ id: "ring", label: "l5r5e.rings.label" },
{ id: "skill", label: "l5r5e.skills.label" },
// others have theirs own xp count
];
/** @override */
static get defaultOptions() {
@@ -43,29 +47,33 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
const currentSkill = this.object.system.skill;
html.find("#advancement_type").on("change", (event) => {
$(event.target).prop("disabled", true);
if ($(event.target).val() === "skill") {
const targetEvt = $(event.target);
targetEvt.prop("disabled", true);
if (targetEvt.val() === "skill") {
this._updateChoice({ ring: currentRing }, { skill: currentSkill }).then(
$(event.target).prop("disabled", false)
targetEvt.prop("disabled", false)
);
} else {
} else if (targetEvt.val() === "ring") {
this._updateChoice({ skill: currentSkill }, { ring: currentRing }).then(
$(event.target).prop("disabled", false)
targetEvt.prop("disabled", false)
);
}
});
html.find("#advancement_ring").on("change", (event) => {
$(event.target).prop("disabled", true);
this._updateChoice({ ring: currentRing }, { ring: $(event.target).val() }).then(
$(event.target).prop("disabled", false)
const targetEvt = $(event.target);
targetEvt.prop("disabled", true);
this._updateChoice({ ring: currentRing }, { ring: targetEvt.val() }).then(
targetEvt.prop("disabled", false)
);
});
html.find("#advancement_skill").on("change", (event) => {
$(event.target).prop("disabled", true);
this._updateChoice({ skill: currentSkill }, { skill: $(event.target).val() }).then(
$(event.target).prop("disabled", false)
const targetEvt = $(event.target);
targetEvt.prop("disabled", true);
this._updateChoice({ skill: currentSkill }, { skill: targetEvt.val() }).then(
targetEvt.prop("disabled", false)
);
});
}
@@ -141,8 +149,5 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
xp_used: xp_used,
},
});
// Re render
this.render(false);
}
}

View File

@@ -18,7 +18,10 @@ export class WeaponSheetL5r5e extends ItemSheetL5r5e {
// Martial skills only
sheetData.data.skills = Array.from(CONFIG.l5r5e.skills)
.filter(([id, cat]) => cat === "martial")
.map(([id, cat]) => id);
.map(([id, cat]) => ({
id,
label: "l5r5e.skills." + cat.toLowerCase() + "." + id.toLowerCase(),
}));
return sheetData;
}

View File

@@ -4,11 +4,7 @@
<label>{{localize 'l5r5e.clans.label'}}</label>
<div class="form-fields">
<select class="attribute-dtype" name="clan">
{{#select data.clan}}
{{#each clanList as |value|}}
<option value="{{value.id}}">{{value.label}}</option>
{{/each}}
{{/select}}
{{selectOptions clanList selected=data.clan valueAttr='id' labelAttr='label'}}
</select>
</div>
</div>
@@ -16,11 +12,7 @@
<label>{{localize 'l5r5e.social.gender.title'}}</label>
<div class="form-fields">
<select class="attribute-dtype" name="gender">
{{#select data.gender}}
{{#each genderList as |value|}}
<option value="{{value.id}}">{{value.label}}</option>
{{/each}}
{{/select}}
{{selectOptions genderList selected=data.gender valueAttr='id' labelAttr='label'}}
</select>
</div>
</div>

View File

@@ -2,11 +2,7 @@
{{!-- Npc Type (minion / adversary) --}}
<li>
<select class="attribute-dtype" name="system.type" {{^if data.editable_not_soft_locked}}disabled{{/if}}>
{{#select data.system.type}}
{{#each data.types as |t|}}
<option value="{{t.id}}">{{t.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.types selected=data.system.type valueAttr='id' labelAttr='label'}}
</select>
</li>
{{!-- Martial --}}

View File

@@ -22,11 +22,7 @@
<label>
{{localize 'l5r5e.twenty_questions.part0.type'}}
<select name="template" class="skill-select">
{{#select data.template}}
{{#each templates as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions templates selected=data.template valueAttr='id' labelAttr='label'}}
</select>
</label>
<br>
@@ -46,12 +42,8 @@
<label>
{{localize 'l5r5e.twenty_questions.increase_ring1'}}
<select name="step1.ring" class="ring-select">
{{#select data.step1.ring}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_ring'}}</option>
{{#each ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions ringsList selected=data.step1.ring valueAttr='id' labelAttr='label'}}
</select>
</label>
</td>
@@ -59,16 +51,12 @@
<label>
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step1.skill" class="skill-select">
{{#select data.step1.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step1.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
</label>
</td>
@@ -94,39 +82,27 @@
<td class="third">
{{localize 'l5r5e.twenty_questions.increase_ring1'}}
<select name="step2.ring" class="ring-select">
{{#select data.step2.ring}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_ring'}}</option>
{{#each ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions ringsList selected=data.step2.ring valueAttr='id' labelAttr='label'}}
</select>
</td>
<td class="third">
{{localize 'l5r5e.twenty_questions.increase_skill2'}}
<select name="step2.skill1" class="skill-select">
{{#select data.step2.skill1}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step2.skill1 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="step2.skill2" class="skill-select">
{{#select data.step2.skill2}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step2.skill2 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
</td>
<td class="third">
@@ -160,20 +136,12 @@
<td class="fifty">
{{localize 'l5r5e.twenty_questions.increase_ring2'}}
<select name="step3.ring1" class="ring-select">
{{#select data.step3.ring1}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_ring'}}</option>
{{#each ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions ringsList selected=data.step3.ring1 valueAttr='id' labelAttr='label'}}
</select>
<select name="step3.ring2" class="ring-select">
{{#select data.step3.ring2}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_ring'}}</option>
{{#each ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions ringsList selected=data.step3.ring2 valueAttr='id' labelAttr='label'}}
</select>
{{localize 'l5r5e.twenty_questions.part2.honor'}}
<input type="number" name="step3.social_honor" min="0" max="100" value="{{data.step3.social_honor}}" data-dtype="Number" placeholder="0" />
@@ -181,64 +149,44 @@
<td class="fifty">
{{localize 'l5r5e.twenty_questions.increase_skill3'}}
<select name="step3.skill1" class="skill-select">
{{#select data.step3.skill1}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step3.skill1 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="step3.skill2" class="skill-select">
{{#select data.step3.skill2}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step3.skill2 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="step3.skill3" class="skill-select">
{{#select data.step3.skill3}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step3.skill3 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="step3.skill4" class="skill-select">
{{#select data.step3.skill4}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step3.skill4 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="step3.skill5" class="skill-select">
{{#select data.step3.skill5}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step3.skill5 valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
</td>
</tr>
@@ -271,12 +219,8 @@
<label>
{{localize 'l5r5e.twenty_questions.increase_ring1'}}
<select name="step4.ring" class="ring-select">
{{#select data.step4.ring}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_ring'}}</option>
{{#each ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions ringsList selected=data.step4.ring valueAttr='id' labelAttr='label'}}
</select>
</label>
<button class="next" name="next" type="button">{{localize 'l5r5e.twenty_questions.bt_next'}} <i class='fas fa-arrow-right'></i></button>
@@ -304,16 +248,12 @@
<td class="third">
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step7.skill" class="skill-select">
{{#select data.step7.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsListStep7 as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step7.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/select}}
</select>
</td>
<td class="or">
@@ -332,12 +272,8 @@
<td class="third">
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step8.skill" class="skill-select" {{#ifCond data.step8.item.length '>' 0}}disabled{{/ifCond}}>
{{#select data.step8.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each noHonorSkillsList as |skillId|}}
<option value="{{skillId}}">{{localizeSkillId skillId}}</option>
{{/each}}
{{/select}}
{{selectOptions noHonorSkillsList selected=data.step8.skill valueAttr='id' labelAttr='label'}}
</select>
</td>
<td class="or">
@@ -415,18 +351,14 @@
{{localize 'l5r5e.twenty_questions.and'}}
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step13.skill" class="skill-select" {{#ifCond data.step13.advantage.length '>' 0}}disabled{{/ifCond}}>
{{#select data.step13.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#ifCond cache.step13.advantage.length '==' '0'}}
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{selectOptions skills selected=../data.step13.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
{{/ifCond}}
{{/select}}
</select>
</td>
<td class="or">
@@ -478,16 +410,12 @@
<label>
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step17.skill" class="skill-select">
{{#select data.step17.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsListStep17 as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
{{/select}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsListStep17 as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{selectOptions skills selected=../data.step17.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
</select>
</label>
{{else}}
@@ -538,16 +466,12 @@
<td>
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step18.skill" class="skill-select">
{{#select data.step18.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
{{/select}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{selectOptions skills selected=../data.step18.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
</select>
{{localize 'l5r5e.twenty_questions.part6.d10r2_drop_items'}}
{{> 'systems/l5r5e/templates/actors/character/twenty-questions-item.html' itemsList=cache.step18.heritage_item stepName='step18.heritage_item' itemType='items' hideDndAt=1}}
@@ -558,16 +482,12 @@
<label>
{{localize 'l5r5e.twenty_questions.increase_skill1'}}
<select name="step17.skill" class="skill-select">
{{#select data.step17.skill}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsListStep17 as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
{{/select}}
<option value="none">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each skillsListStep17 as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{selectOptions skills selected=../data.step17.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
</select>
</label>
{{/ifCond}}

View File

@@ -25,13 +25,11 @@
<label>{{localizeSkill data.skill.cat 'title'}}</label>
{{/if}}
<select class="attribute-dtype" name="skill">
{{#select data.skill.id}}
{{#select data.skill.cat}}
{{#each data.skill.list as |item|}}
<option value="{{item.id}}">{{item.label}}</option>
{{/each}}
{{/select}}
{{/select}}
{{#if useCategory}}
{{selectOptions data.skill.list selected=data.skill.cat valueAttr='id' labelAttr='label'}}
{{else}}
{{selectOptions data.skill.list selected=data.skill.id valueAttr='id' labelAttr='label'}}
{{/if}}
</select>
{{else}}
<label>{{localizeSkill data.skill.cat 'title'}}</label>

View File

@@ -8,36 +8,24 @@
{{!-- Attributes Tab --}}
<article class="attributes" data-group="primary" data-tab="attributes">
<select name="system.advancement_type" id="advancement_type">
{{#select data.system.advancement_type}}
{{#each data.subTypesList as |label type|}}
<option value="{{type}}">{{localize label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.subTypesList selected=data.system.advancement_type valueAttr='id' labelAttr='label' localize=true}}
</select>
{{#ifCond data.system.advancement_type '==' 'ring'}}
<select name="system.ring" id="advancement_ring">
{{#select data.system.ring}}
{{#each data.ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.ringsList selected=data.system.ring valueAttr='id' labelAttr='label'}}
</select>
{{/ifCond}}
{{#ifCond data.system.advancement_type '==' 'skill'}}
<select name="system.skill" id="advancement_skill">
<option value="">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#select data.system.skill}}
{{#each data.skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
{{/select}}
</select>
<select name="system.skill" id="advancement_skill">
<option value="">{{localize 'l5r5e.twenty_questions.choose_one_skill'}}</option>
{{#each data.skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{selectOptions skills selected=../data.system.skill valueAttr='id' labelAttr='label'}}
</optgroup>
{{/each}}
</select>
{{/ifCond}}
<label class="cursus attribute-value checkbox">
<input type="checkbox" name="system.in_curriculum" {{checked data.system.in_curriculum}} />

View File

@@ -8,18 +8,10 @@
{{!-- Attributes Tab --}}
<article class="attributes" data-group="primary" data-tab="attributes">
<select name="system.ring">
{{#select data.system.ring}}
{{#each data.ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.ringsList selected=data.system.ring valueAttr='id' labelAttr='label'}}
</select>
<select class="attribute" name="system.peculiarity_type">
{{#select data.system.peculiarity_type}}
{{#each data.subTypesList as |type|}}
<option value="{{type.id}}">{{type.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.subTypesList selected=data.system.peculiarity_type valueAttr='id' labelAttr='label'}}
</select>
<label class="cursus attribute-value checkbox">
<input type="checkbox" name="system.in_curriculum" {{checked data.system.in_curriculum}} />

View File

@@ -8,18 +8,10 @@
{{!-- Attributes Tab --}}
<article class="attributes" data-group="primary" data-tab="attributes">
<select name="system.ring">
{{#select data.system.ring}}
{{#each data.ringsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.ringsList selected=data.system.ring valueAttr='id' labelAttr='label'}}
</select>
<select name="system.technique_type">
{{#select data.system.technique_type}}
{{#each data.techniquesList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
{{/select}}
{{selectOptions data.techniquesList selected=data.system.technique_type valueAttr='id' labelAttr='label'}}
</select>
<label class="cursus attribute-value checkbox">
<input type="checkbox" name="system.in_curriculum" {{checked data.system.in_curriculum}} />

View File

@@ -23,11 +23,7 @@
<label class="skillType">
{{localize 'l5r5e.skills.label'}}
<select class="attribute-dtype" name="system.skill">
{{#select data.system.skill}}
{{#each data.skills as |id cat|}}
<option value="{{id}}">{{localizeSkillId id}}</option>
{{/each}}
{{/select}}
{{selectOptions data.skills selected=data.system.skill valueAttr='id' labelAttr='label' localize=true}}
</select>
</label>
<fieldset class="stats">