Fix for advancements fail to add new items ("_id" readonly error. see #42)

This commit is contained in:
Vlyan
2022-09-08 09:44:32 +02:00
parent 49fee9a5dd
commit 3a674fd0f4
3 changed files with 9 additions and 2 deletions

View File

@@ -216,8 +216,11 @@ export class ItemL5r5e extends Item {
}
// New id
if (newId) {
item._id = foundry.utils.randomID();
if (newId || !item._id) {
// Bypass the readonly for "_id"
const tmpData = item.toJSON();
tmpData._id = foundry.utils.randomID();
item = new ItemL5r5e(tmpData);
}
// Copy the parent permission to the sub item