allow toggling sort from manual to alphabetical and back for items
This commit is contained in:
@@ -161,17 +161,59 @@ export default class DeltaGreenActorSheet extends ActorSheet {
|
||||
}
|
||||
}
|
||||
|
||||
armor.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
if (actorData.system.sorting.armorSortAlphabetical) {
|
||||
armor.sort(function (a, b) {
|
||||
let x = a.name.toLowerCase();
|
||||
let y = b.name.toLowerCase();
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (x > y) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
armor.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
}
|
||||
|
||||
weapons.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
if (actorData.system.sorting.weaponSortAlphabetical) {
|
||||
weapons.sort(function (a, b) {
|
||||
let x = a.name.toLowerCase();
|
||||
let y = b.name.toLowerCase();
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (x > y) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
weapons.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
}
|
||||
|
||||
gear.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
if (actorData.system.sorting.gearSortAlphabetical) {
|
||||
gear.sort(function (a, b) {
|
||||
let x = a.name.toLowerCase();
|
||||
let y = b.name.toLowerCase();
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (x > y) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
gear.sort(function (a, b) {
|
||||
return a.sort - b.sort;
|
||||
});
|
||||
}
|
||||
|
||||
// Assign and return
|
||||
actorData.armor = armor;
|
||||
@@ -502,6 +544,30 @@ export default class DeltaGreenActorSheet extends ActorSheet {
|
||||
html.find(".clear-all-bond-damage-checks").click((ev) => {
|
||||
this._updateBondsRemoveAllDamagedCheckmarks();
|
||||
});
|
||||
|
||||
// item sorting toggles
|
||||
html.find(".toggle-item-sorting-style").click((event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const itemType = event.currentTarget.getAttribute("data-gear-type");
|
||||
|
||||
if (itemType === "weapon") {
|
||||
this.actor.update({
|
||||
"system.sorting.weaponSortAlphabetical":
|
||||
!this.actor.system.sorting.weaponSortAlphabetical,
|
||||
});
|
||||
} else if (itemType === "armor") {
|
||||
this.actor.update({
|
||||
"system.sorting.armorSortAlphabetical":
|
||||
!this.actor.system.sorting.armorSortAlphabetical,
|
||||
});
|
||||
} else if (itemType === "gear") {
|
||||
this.actor.update({
|
||||
"system.sorting.gearSortAlphabetical":
|
||||
!this.actor.system.sorting.gearSortAlphabetical,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// trigger an update on all bonds that have had their damaged flag checked off
|
||||
|
||||
+11
-3
@@ -40,6 +40,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"item-sorting": {
|
||||
"sorting": {
|
||||
"weaponSortAlphabetical": false,
|
||||
"armorSortAlphabetical": false,
|
||||
"gearSortAlphabetical": false
|
||||
}
|
||||
},
|
||||
"human_skills": {
|
||||
"skills": {
|
||||
"accounting": {
|
||||
@@ -429,7 +436,7 @@
|
||||
}
|
||||
},
|
||||
"unnatural": {
|
||||
"templates": ["base", "unnatural_skills"],
|
||||
"templates": ["base", "unnatural_skills", "item-sorting"],
|
||||
"sanity": {
|
||||
"notes": "",
|
||||
"failedLoss": "1D4",
|
||||
@@ -441,7 +448,7 @@
|
||||
"showUntrainedSkills": true
|
||||
},
|
||||
"npc": {
|
||||
"templates": ["base", "human_skills"],
|
||||
"templates": ["base", "human_skills", "item-sorting"],
|
||||
"schemaVersion": 1.0,
|
||||
"sanity": {
|
||||
"value": 100,
|
||||
@@ -452,6 +459,7 @@
|
||||
"showUntrainedSkills": true
|
||||
},
|
||||
"vehicle": {
|
||||
"templates": ["item-sorting"],
|
||||
"name": "",
|
||||
"description": "",
|
||||
"shortDescription": "",
|
||||
@@ -465,7 +473,7 @@
|
||||
"passengers": []
|
||||
},
|
||||
"agent": {
|
||||
"templates": ["base", "human_skills"],
|
||||
"templates": ["base", "human_skills", "item-sorting"],
|
||||
"schemaVersion": 1.0,
|
||||
"sanity": {
|
||||
"value": 100,
|
||||
|
||||
@@ -9,9 +9,15 @@
|
||||
<ol class="items-list">
|
||||
|
||||
<li class="item flexrow item-header">
|
||||
<div class="item-image"></div>
|
||||
<div class="item-image">
|
||||
{{#if actor.system.sorting.weaponSortAlphabetical}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-solid fa-arrow-down-a-z" data-gear-type="weapon"></i></a>
|
||||
{{else}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-arrow-down-short-wide" data-gear-type="weapon"></i></a>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<span class="">
|
||||
<a><i class="fa-solid fa-arrow-down-a-z"></i></a>
|
||||
{{localize 'DG.Gear.Name'}}
|
||||
<a><i class="weapon-browse fas fa-search"></i></a>
|
||||
</span>
|
||||
@@ -100,7 +106,13 @@
|
||||
|
||||
<li class="item flexrow item-header">
|
||||
|
||||
<div class="item-image"></div>
|
||||
<div class="item-image">
|
||||
{{#if actor.system.sorting.armorSortAlphabetical}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-solid fa-arrow-down-a-z" data-gear-type="armor"></i></a>
|
||||
{{else}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-arrow-down-short-wide" data-gear-type="armor"></i></a>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="item-name"><span>{{localize 'DG.Gear.Name'}} <a><i class="armor-browse fas fa-search"></i></a></span></div>
|
||||
<span class="centered-item-property">{{localize 'DG.Gear.ArmorRating'}}</span>
|
||||
<span class="centered-item-property">{{localize 'DG.Gear.Equipped'}}</span>
|
||||
@@ -152,7 +164,13 @@
|
||||
|
||||
<li class="item flexrow item-header">
|
||||
|
||||
<div class="item-image"></div>
|
||||
<div class="item-image">
|
||||
{{#if actor.system.sorting.gearSortAlphabetical}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-solid fa-arrow-down-a-z" data-gear-type="gear"></i></a>
|
||||
{{else}}
|
||||
<a><i class="toggle-item-sorting-style fa-solid fa-arrow-down-short-wide" data-gear-type="gear"></i></a>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div style="min-width: 55%;" class="item-name">{{localize 'DG.Gear.Name'}}</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user