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 { 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
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,38 @@
|
||||||
<div>
|
<div class="content">
|
||||||
<label>
|
<div class="property">
|
||||||
Equipped
|
<label for="">
|
||||||
<input type="checkbox" name="system.equipped">
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Weight
|
Weight
|
||||||
<input type="number" name="system.weight">
|
|
||||||
</label>
|
</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
|
<prose-mirror
|
||||||
name="system.description"
|
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>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue