Prevent creating a Trait when it's on a non-geist Actor

This commit is contained in:
Eldritch-Oliver 2025-10-10 21:49:32 -06:00
parent 0e0f9d3831
commit 4d0f29d7f0
2 changed files with 21 additions and 2 deletions

View file

@ -1,11 +1,29 @@
import { localizer } from "../../utils/Localizer.mjs";
const { fields } = foundry.data;
export class TraitData extends foundry.abstract.TypeDataModel {
// #region Schema
static defineSchema() {
return {
description: fields.HTMLField({ blank: true, nullable: false, trim: true }),
description: new fields.HTMLField({ blank: true, nullable: false, trim: true }),
};
};
// #endregion Schema
// #region Lifecycle
async _preCreate() {
if (this.parent.isEmbedded && this.parent.parent.type !== `geist`) {
ui.notifications.error(localizer(
`RipCrypt.notifs.error.invalid-parent-document`,
{ itemType: `trait`, parentType: this.parent.parent.type },
));
return false;
};
};
// #endregion
async getFormFields() {
return [];
};
};