21 lines
800 B
JavaScript
21 lines
800 B
JavaScript
export default class BaseItem extends foundry.abstract.TypeDataModel {
|
|
|
|
/** @inheritDoc */
|
|
async importFromCompendium(pack, id, updateData={}, options={}) {
|
|
console.log(`called ${pack} ${id} `);
|
|
const created = await super.importFromCompendium(pack, id, updateData, options);
|
|
|
|
const item = await pack.getDocument(id);
|
|
const contents = await item.system.contents;
|
|
if ( contents ) {
|
|
const fromOptions = foundry.utils.mergeObject({ clearSort: false }, options);
|
|
const toCreate = await BaseItem.createWithContents(contents, {
|
|
container: created, keepId: options.keepId, transformAll: item => this.fromCompendium(item, fromOptions)
|
|
});
|
|
await BaseItem.createDocuments(toCreate, {fromCompendium: true, keepId: true});
|
|
}
|
|
|
|
return created;
|
|
}
|
|
|
|
} |