mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-04 13:47:10 -04:00
Ensure worldbuilding changes are working on legacy worldbuilding world and adjust attribute form styling
This commit is contained in:
parent
977fb4b76b
commit
8a2ba78203
4 changed files with 47 additions and 37 deletions
|
@ -36,17 +36,16 @@ export class SimpleActorSheet extends ActorSheet {
|
|||
data.data.ungroupedAttributes = {};
|
||||
|
||||
// Build an array of sorted group keys.
|
||||
let groupKeys = Object.keys(data.data.groups).sort((a, b) => {
|
||||
// Attempt to sort by the label, but fall back to the key.
|
||||
let aSort = data.data.groups[a].label ? data.data.groups[a].label : a;
|
||||
let bSort = data.data.groups[b].label ? data.data.groups[b].label : b;
|
||||
const groups = data.data.groups || {};
|
||||
let groupKeys = Object.keys(groups).sort((a, b) => {
|
||||
let aSort = groups[a].label ?? a;
|
||||
let bSort = groups[b].label ?? b;
|
||||
return aSort.localeCompare(bSort);
|
||||
});
|
||||
|
||||
// Iterate over the sorted groups to add their attributes..
|
||||
groupKeys.forEach(key => {
|
||||
// Retrieve the group.
|
||||
let group = data.data.attributes[key];
|
||||
// Iterate over the sorted groups to add their attributes.
|
||||
for ( let key of groupKeys ) {
|
||||
let group = data.data.attributes[key] || {};
|
||||
|
||||
// Initialize the attributes container for this group.
|
||||
if ( !data.data.groups[key]['attributes'] ) data.data.groups[key]['attributes'] = {};
|
||||
|
@ -58,7 +57,7 @@ export class SimpleActorSheet extends ActorSheet {
|
|||
group[attr]['isResource'] = group[attr]['dtype'] === 'Resource';
|
||||
data.data.groups[key]['attributes'][attr] = group[attr];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Sort the remaining attributes attributes.
|
||||
Object.keys(data.data.attributes).filter(a => !groupKeys.includes(a)).sort((a, b) => a.localeCompare(b)).forEach(key => {
|
||||
|
|
|
@ -4,6 +4,15 @@
|
|||
*/
|
||||
export class SimpleActor extends Actor {
|
||||
|
||||
/** @override */
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
this.data.data.groups = this.data.data.groups || {};
|
||||
this.data.data.attributes = this.data.data.attributes || {};
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
getRollData() {
|
||||
const data = super.getRollData();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue