mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-04-30 10:41:40 -04:00
Remove usage of fromEntries
This commit is contained in:
parent
fc8331c13c
commit
96b677434b
2 changed files with 19 additions and 17 deletions
|
@ -118,12 +118,12 @@ export class SimpleActorSheet extends ActorSheet {
|
||||||
|
|
||||||
// Handle the free-form attributes list
|
// Handle the free-form attributes list
|
||||||
const formAttrs = expandObject(formData).data.attributes || {};
|
const formAttrs = expandObject(formData).data.attributes || {};
|
||||||
const attributes = Object.fromEntries(Object.entries(formAttrs).map(attr => {
|
const attributes = Object.values(formAttrs).reduce((obj, v) => {
|
||||||
let [k, v] = attr;
|
let k = v["key"].trim();
|
||||||
k = v["key"].trim();
|
|
||||||
delete v["key"];
|
delete v["key"];
|
||||||
return [k, v];
|
obj[k] = v;
|
||||||
}));
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
// Remove attributes which are no longer used
|
// Remove attributes which are no longer used
|
||||||
for ( let k of Object.keys(this.object.data.data.attributes) ) {
|
for ( let k of Object.keys(this.object.data.data.attributes) ) {
|
||||||
|
@ -131,9 +131,10 @@ export class SimpleActorSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-combine formData
|
// Re-combine formData
|
||||||
formData = Object.fromEntries(Object.entries(formData).filter(a => !a[0].startsWith("data.attributes")));
|
formData = Object.entries(formData).filter(e => !e[0].startsWith("data.attributes")).reduce((obj, e) => {
|
||||||
formData["_id"] = this.object._id;
|
obj[e[0]] = e[1];
|
||||||
formData["data.attributes"] = attributes;
|
return obj;
|
||||||
|
}, {_id: this.object._id, "data.attributes": attributes});
|
||||||
|
|
||||||
// Update the Actor
|
// Update the Actor
|
||||||
return this.object.update(formData);
|
return this.object.update(formData);
|
||||||
|
|
|
@ -102,12 +102,12 @@ export class SimpleItemSheet extends ItemSheet {
|
||||||
|
|
||||||
// Handle the free-form attributes list
|
// Handle the free-form attributes list
|
||||||
const formAttrs = expandObject(formData).data.attributes || {};
|
const formAttrs = expandObject(formData).data.attributes || {};
|
||||||
const attributes = Object.fromEntries(Object.entries(formAttrs).map(attr => {
|
const attributes = Object.values(formAttrs).reduce((obj, v) => {
|
||||||
let [k, v] = attr;
|
let k = v["key"].trim();
|
||||||
k = v["key"].trim();
|
|
||||||
delete v["key"];
|
delete v["key"];
|
||||||
return [k, v];
|
obj[k] = v;
|
||||||
}));
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
// Remove attributes which are no longer used
|
// Remove attributes which are no longer used
|
||||||
for ( let k of Object.keys(this.object.data.data.attributes) ) {
|
for ( let k of Object.keys(this.object.data.data.attributes) ) {
|
||||||
|
@ -115,9 +115,10 @@ export class SimpleItemSheet extends ItemSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-combine formData
|
// Re-combine formData
|
||||||
formData = Object.fromEntries(Object.entries(formData).filter(a => !a[0].startsWith("data.attributes")));
|
formData = Object.entries(formData).filter(e => !e[0].startsWith("data.attributes")).reduce((obj, e) => {
|
||||||
formData["_id"] = this.object._id;
|
obj[e[0]] = e[1];
|
||||||
formData["data.attributes"] = attributes;
|
return obj;
|
||||||
|
}, {_id: this.object._id, "data.attributes": attributes});
|
||||||
|
|
||||||
// Update the Item
|
// Update the Item
|
||||||
return this.object.update(formData);
|
return this.object.update(formData);
|
||||||
|
|
Loading…
Add table
Reference in a new issue