Finish getting the main item sheet completed and fully functional
This commit is contained in:
parent
2518c7cf05
commit
94b3ec923b
4 changed files with 103 additions and 14 deletions
|
|
@ -2,6 +2,7 @@ import { __ID__, filePath } from "../consts.mjs";
|
|||
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
const { setProperty } = foundry.utils;
|
||||
|
||||
export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) {
|
||||
// #region Options
|
||||
|
|
@ -34,12 +35,38 @@ export class GenericItemSheet extends HandlebarsApplicationMixin(ItemSheetV2) {
|
|||
// #endregion Instance Data
|
||||
|
||||
// #region Lifecycle
|
||||
async _prepareContext(partID) {
|
||||
async _prepareContext() {
|
||||
return {
|
||||
meta: {
|
||||
idp: this.id,
|
||||
editable: this.isEditable,
|
||||
limited: this.isLimited
|
||||
},
|
||||
item: this.item,
|
||||
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
|
||||
|
||||
// #region Actions
|
||||
|
|
|
|||
|
|
@ -15,4 +15,38 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,38 @@
|
|||
<div>
|
||||
<label>
|
||||
Equipped
|
||||
<input type="checkbox" name="system.equipped">
|
||||
</label>
|
||||
<label>
|
||||
<div class="content">
|
||||
<div class="property">
|
||||
<label for="">
|
||||
Weight
|
||||
<input type="number" name="system.weight">
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="system.weight"
|
||||
value="{{system.weight}}"
|
||||
{{disabled (not meta.editable)}}
|
||||
>
|
||||
</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"
|
||||
></prose-mirror>
|
||||
value="{{system.description}}"
|
||||
collaborate="true"
|
||||
data-document-uuid="{{item.uuid}}"
|
||||
>
|
||||
{{{ enriched.system.description }}}
|
||||
</prose-mirror>
|
||||
{{else}}
|
||||
{{{ enriched.system.description }}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
>
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
class="large"
|
||||
name="name"
|
||||
value="{{item.name}}"
|
||||
title="{{item.name}}"
|
||||
{{disabled (not meta.editable)}}
|
||||
placeholder="{{localize "Name"}}"
|
||||
>
|
||||
<span aria-hidden="true">x</span>
|
||||
|
|
@ -19,6 +21,7 @@
|
|||
type="number"
|
||||
name="system.quantity"
|
||||
value="{{system.quantity}}"
|
||||
{{disabled (not meta.editable)}}
|
||||
data-tooltip
|
||||
aria-label="Quantity"
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue