Finish getting the main item sheet completed and fully functional

This commit is contained in:
Oliver 2026-03-13 21:31:03 -06:00
parent 2518c7cf05
commit 94b3ec923b
4 changed files with 103 additions and 14 deletions

View file

@ -2,6 +2,7 @@ import { __ID__, filePath } from "../consts.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api; const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ItemSheetV2 } = foundry.applications.sheets; const { ItemSheetV2 } = foundry.applications.sheets;
const { setProperty } = foundry.utils;
export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) { export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) {
// #region Options // #region Options
@ -34,12 +35,38 @@ export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) {
// #endregion Instance Data // #endregion Instance Data
// #region Lifecycle // #region Lifecycle
async _prepareContext(partID) { async _prepareContext() {
return { return {
meta: {
idp: this.id,
editable: this.isEditable,
limited: this.isLimited
},
item: this.item, item: this.item,
system: this.item.system, system: this.item.system,
}; };
}; };
async _preparePartContext(partID, ctx) {
switch (partID) {
case `content`: {
await this._prepareContentContext(ctx);
break;
};
};
return ctx;
};
async _prepareContentContext(ctx) {
const TextEditor = foundry.applications.ux.TextEditor.implementation;
setProperty(
ctx,
`enriched.system.description`,
await TextEditor.enrichHTML(this.item.system.description),
);
};
// #endregion Lifecycle // #endregion Lifecycle
// #region Actions // #region Actions

View file

@ -15,4 +15,38 @@
border-radius: 4px; border-radius: 4px;
} }
} }
.content {
display: contents;
}
.property {
display: grid;
grid-template-columns: 1fr 100px;
align-items: center;
gap: 8px;
input[type="checkbox"] {
justify-self: end;
}
}
.description {
flex-grow: 1;
overflow: hidden;
--table-row-color-odd: var(--table-header-bg-color);
&:not(:has(> prose-mirror)) {
padding: 0.5rem;
}
}
prose-mirror {
height: 100%;
menu {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
} }

View file

@ -1,13 +1,38 @@
<div> <div class="content">
<label> <div class="property">
Equipped <label for="">
<input type="checkbox" name="system.equipped"> Weight
</label> </label>
<label> <input
Weight type="number"
<input type="number" name="system.weight"> name="system.weight"
</label> value="{{system.weight}}"
<prose-mirror {{disabled (not meta.editable)}}
name="system.description" >
></prose-mirror> </div>
<div class="property">
<label for="">
Equipped
</label>
<input
type="checkbox"
name="system.equipped"
{{checked system.equipped}}
{{disabled (not meta.editable)}}
>
</div>
<div class="bordered description">
{{#if meta.editable}}
<prose-mirror
name="system.description"
value="{{system.description}}"
collaborate="true"
data-document-uuid="{{item.uuid}}"
>
{{{ enriched.system.description }}}
</prose-mirror>
{{else}}
{{{ enriched.system.description }}}
{{/if}}
</div>
</div> </div>

View file

@ -9,9 +9,11 @@
> >
<input <input
type="text" type="text"
name="name"
class="large" class="large"
name="name"
value="{{item.name}}" value="{{item.name}}"
title="{{item.name}}"
{{disabled (not meta.editable)}}
placeholder="{{localize "Name"}}" placeholder="{{localize "Name"}}"
> >
<span aria-hidden="true">x</span> <span aria-hidden="true">x</span>
@ -19,6 +21,7 @@
type="number" type="number"
name="system.quantity" name="system.quantity"
value="{{system.quantity}}" value="{{system.quantity}}"
{{disabled (not meta.editable)}}
data-tooltip data-tooltip
aria-label="Quantity" aria-label="Quantity"
> >