RC-97 | Add Context Menu for embedded weapons
This commit is contained in:
parent
fe90172656
commit
bd92e6928a
7 changed files with 77 additions and 6 deletions
|
|
@ -1,2 +1,5 @@
|
||||||
Soetarman Atmodjo:
|
Soetarman Atmodjo:
|
||||||
- icons/roll.svg : Rights Purchased.
|
- icons/roll.svg (https://thenounproject.com/icon/dice-5195278/) : Rights Purchased.
|
||||||
|
|
||||||
|
SuperNdre:
|
||||||
|
- icons/edit.svg (https://thenounproject.com/icon/edit-5208207/) : Rights Purchased
|
||||||
4
assets/icons/edit.svg
Normal file
4
assets/icons/edit.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m8.332 12.5c0-2.3008 1.8672-4.168 4.168-4.168h37.5v8.3359h-33.332v66.664h66.664v-33.332h8.3359v37.5c0 2.3008-1.8672 4.168-4.168 4.168h-75c-2.3008 0-4.168-1.8672-4.168-4.168z" fill-rule="evenodd"/>
|
||||||
|
<path d="m75.305 8.332c1.1055 0 2.1641 0.44141 2.9453 1.2227l12.195 12.195c1.6289 1.625 1.6289 4.2656 0 5.8906l-36.586 36.586c-0.6875 0.6875-1.5977 1.1133-2.5664 1.2031l-13.414 1.2188c-1.2344 0.11328-2.4492-0.32813-3.3242-1.2031s-1.3164-2.0898-1.2031-3.3242l1.2188-13.414c0.089844-0.96875 0.51563-1.8789 1.2031-2.5664l36.586-36.586c0.78125-0.78125 1.8398-1.2227 2.9453-1.2227zm-5.082 15.145 6.3008 6.3008 5.0859-5.082-6.3047-6.3047zm0.41016 12.195-6.3047-6.3047-21.594 21.598-0.63281 6.9336 6.9336-0.63281z" fill-rule="evenodd"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 822 B |
|
|
@ -1,4 +1,4 @@
|
||||||
<svg width="83" height="95" viewBox="0 0 83 95" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
<svg viewBox="0 0 83 95" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||||
<g>
|
<g>
|
||||||
<path id="svg_1" d="m77.95688,69.37862c0,-1.375 1.1133,-2.4883 2.4883,-2.4883s2.4883,1.1133 2.4883,2.4883l0,0.53516c0,1.375 -1.1133,2.4883 -2.4883,2.4883s-2.4883,-1.1133 -2.4883,-2.4883l0,-0.53516zm-49.355,-34.766c1.4609,-1.4648 3.832,-1.4648 5.2969,0c1.4609,1.4609 1.4609,3.832 0,5.2969c-1.4648,1.4609 -3.832,1.4609 -5.2969,0c-1.4648,-1.4648 -1.4648,-3.832 0,-5.2969zm20.453,20.453c1.4648,-1.4609 3.832,-1.4609 5.2969,0c1.4648,1.4648 1.4648,3.832 0,5.2969c-1.4609,1.4648 -3.832,1.4648 -5.2969,0c-1.4609,-1.4609 -1.4609,-3.832 0,-5.2969zm-10.227,-10.227c1.4609,-1.4648 3.832,-1.4648 5.293,0c1.4648,1.4609 1.4648,3.832 0,5.293c-1.4609,1.4648 -3.832,1.4648 -5.293,0c-1.4648,-1.4609 -1.4648,-3.832 0,-5.293zm-9.8594,-20.359l25.016,0c2.8828,0 5.5039,1.1797 7.4062,3.082l0.00781,0.00781c1.9023,1.9023 3.082,4.5273 3.082,7.4062l0,25.016c0,2.8828 -1.1797,5.5039 -3.082,7.4062l-0.00781,0.00782c-1.9023,1.90229 -4.5273,3.08199 -7.4062,3.08199l-25.016,0c-2.8828,0 -5.5039,-1.1797 -7.4062,-3.08199l-0.00781,-0.00782c-1.9023,-1.9023 -3.082,-4.5273 -3.082,-7.4062l0,-25.016c0,-2.8828 1.1797,-5.5039 3.082,-7.4062l0.00781,-0.00781c1.9023,-1.9023 4.5273,-3.082 7.4062,-3.082zm25.016,5l-25.016,0c-1.5156,0 -2.8906,0.61719 -3.8867,1.6094c-0.99219,0.99609 -1.6094,2.375 -1.6094,3.8867l0,25.016c0,1.5156 0.61719,2.8906 1.6094,3.8867c0.99609,0.99219 2.375,1.6094 3.8867,1.6094l25.016,0c1.5156,0 2.8906,-0.61719 3.8867,-1.6094c0.99219,-0.99609 1.6094,-2.375 1.6094,-3.8867l0,-25.016c0,-1.5156 -0.61719,-2.8906 -1.6094,-3.8867c-0.99609,-0.99219 -2.375,-1.6094 -3.8867,-1.6094zm18.355,42.309c1.1914,-0.69141 2.7188,-0.28516 3.4062,0.91016c0.69141,1.1914 0.28516,2.7188 -0.91016,3.4062l-32.113,18.539c-0.84766,0.49219 -1.8672,0.42578 -2.6328,-0.08203l-38.828,-22.418c-0.80078,-0.46094 -1.25,-1.2969 -1.25,-2.1562l-0.01172,-45c0,-1.0117 0.60156,-1.8867 1.4688,-2.2773l38.766,-22.379c0.80859,-0.46484 1.7695,-0.42578 2.5195,0.02344l38.934,22.477c0.80078,0.46094 1.25,1.2969 1.25,2.1562l0,36.395c0,1.375 -1.1133,2.4883 -2.4883,2.4883s-2.4883,-1.1133 -2.4883,-2.4883l0,-34.961l-36.48,-21.062l-36.473,21.059l0,42.141l36.469,21.055l30.867,-17.82l-0.00522,-0.00647z"/>
|
<path id="svg_1" d="m77.95688,69.37862c0,-1.375 1.1133,-2.4883 2.4883,-2.4883s2.4883,1.1133 2.4883,2.4883l0,0.53516c0,1.375 -1.1133,2.4883 -2.4883,2.4883s-2.4883,-1.1133 -2.4883,-2.4883l0,-0.53516zm-49.355,-34.766c1.4609,-1.4648 3.832,-1.4648 5.2969,0c1.4609,1.4609 1.4609,3.832 0,5.2969c-1.4648,1.4609 -3.832,1.4609 -5.2969,0c-1.4648,-1.4648 -1.4648,-3.832 0,-5.2969zm20.453,20.453c1.4648,-1.4609 3.832,-1.4609 5.2969,0c1.4648,1.4648 1.4648,3.832 0,5.2969c-1.4609,1.4648 -3.832,1.4648 -5.2969,0c-1.4609,-1.4609 -1.4609,-3.832 0,-5.2969zm-10.227,-10.227c1.4609,-1.4648 3.832,-1.4648 5.293,0c1.4648,1.4609 1.4648,3.832 0,5.293c-1.4609,1.4648 -3.832,1.4648 -5.293,0c-1.4648,-1.4609 -1.4648,-3.832 0,-5.293zm-9.8594,-20.359l25.016,0c2.8828,0 5.5039,1.1797 7.4062,3.082l0.00781,0.00781c1.9023,1.9023 3.082,4.5273 3.082,7.4062l0,25.016c0,2.8828 -1.1797,5.5039 -3.082,7.4062l-0.00781,0.00782c-1.9023,1.90229 -4.5273,3.08199 -7.4062,3.08199l-25.016,0c-2.8828,0 -5.5039,-1.1797 -7.4062,-3.08199l-0.00781,-0.00782c-1.9023,-1.9023 -3.082,-4.5273 -3.082,-7.4062l0,-25.016c0,-2.8828 1.1797,-5.5039 3.082,-7.4062l0.00781,-0.00781c1.9023,-1.9023 4.5273,-3.082 7.4062,-3.082zm25.016,5l-25.016,0c-1.5156,0 -2.8906,0.61719 -3.8867,1.6094c-0.99219,0.99609 -1.6094,2.375 -1.6094,3.8867l0,25.016c0,1.5156 0.61719,2.8906 1.6094,3.8867c0.99609,0.99219 2.375,1.6094 3.8867,1.6094l25.016,0c1.5156,0 2.8906,-0.61719 3.8867,-1.6094c0.99219,-0.99609 1.6094,-2.375 1.6094,-3.8867l0,-25.016c0,-1.5156 -0.61719,-2.8906 -1.6094,-3.8867c-0.99609,-0.99219 -2.375,-1.6094 -3.8867,-1.6094zm18.355,42.309c1.1914,-0.69141 2.7188,-0.28516 3.4062,0.91016c0.69141,1.1914 0.28516,2.7188 -0.91016,3.4062l-32.113,18.539c-0.84766,0.49219 -1.8672,0.42578 -2.6328,-0.08203l-38.828,-22.418c-0.80078,-0.46094 -1.25,-1.2969 -1.25,-2.1562l-0.01172,-45c0,-1.0117 0.60156,-1.8867 1.4688,-2.2773l38.766,-22.379c0.80859,-0.46484 1.7695,-0.42578 2.5195,0.02344l38.934,22.477c0.80078,0.46094 1.25,1.2969 1.25,2.1562l0,36.395c0,1.375 -1.1133,2.4883 -2.4883,2.4883s-2.4883,-1.1133 -2.4883,-2.4883l0,-34.961l-36.48,-21.062l-36.473,21.059l0,42.141l36.469,21.055l30.867,-17.82l-0.00522,-0.00647z"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
|
@ -6,6 +6,7 @@ import { Logger } from "../../utils/Logger.mjs";
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||||
|
const { ContextMenu } = foundry.applications.ui;
|
||||||
|
|
||||||
export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2)) {
|
export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2)) {
|
||||||
|
|
||||||
|
|
@ -22,7 +23,9 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
||||||
window: {
|
window: {
|
||||||
resizable: false,
|
resizable: false,
|
||||||
},
|
},
|
||||||
actions: {},
|
actions: {
|
||||||
|
editItem: (_event, target) => this._editItem(target),
|
||||||
|
},
|
||||||
form: {
|
form: {
|
||||||
submitOnChange: true,
|
submitOnChange: true,
|
||||||
closeOnSubmit: false,
|
closeOnSubmit: false,
|
||||||
|
|
@ -37,6 +40,32 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Lifecycle
|
// #region Lifecycle
|
||||||
|
async _onRender(context, options) {
|
||||||
|
await super._onRender(context, options);
|
||||||
|
|
||||||
|
const itemMenuOptions = [
|
||||||
|
{
|
||||||
|
name: `Edit`,
|
||||||
|
condition: () => this.isEditable,
|
||||||
|
callback: HeroSummaryCardV1._editItem,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `Delete`,
|
||||||
|
condition: () => this.isEditable,
|
||||||
|
callback: async (el) => {
|
||||||
|
const itemEl = el.closest(`[data-item-id]`);
|
||||||
|
if (!itemEl) { return };
|
||||||
|
const itemId = itemEl.dataset.itemId;
|
||||||
|
const item = await fromUuid(itemId);
|
||||||
|
await item.delete();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if (itemMenuOptions.length) {
|
||||||
|
new ContextMenu(this.element, `.weapon-ctx-menu`, itemMenuOptions, { jQuery: false, fixed: true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async _preparePartContext(partId, ctx, opts) {
|
async _preparePartContext(partId, ctx, opts) {
|
||||||
ctx = await super._preparePartContext(partId, ctx, opts);
|
ctx = await super._preparePartContext(partId, ctx, opts);
|
||||||
ctx.actor = this.document;
|
ctx.actor = this.document;
|
||||||
|
|
@ -135,5 +164,13 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Actions
|
// #region Actions
|
||||||
|
static async _editItem(target) {
|
||||||
|
const itemEl = target.closest(`[data-item-id]`);
|
||||||
|
if (!itemEl) { return };
|
||||||
|
const itemId = itemEl.dataset.itemId;
|
||||||
|
if (!itemId) { return };
|
||||||
|
const item = await fromUuid(itemId);
|
||||||
|
item.sheet.render({ force: true });
|
||||||
|
};
|
||||||
// #endregion
|
// #endregion
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -181,8 +181,23 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr data-row="{{slot.index}}" class="{{slot.class}}">
|
<tr
|
||||||
<td>{{ slot.data.name }}</td>
|
data-row="{{ slot.index }}"
|
||||||
|
class="{{slot.class}}"
|
||||||
|
data-item-id="{{ slot.data.uuid }}"
|
||||||
|
>
|
||||||
|
<td>
|
||||||
|
<rc-icon
|
||||||
|
class="weapon-ctx-menu"
|
||||||
|
var:size="1rem"
|
||||||
|
var:fill="var(--accent-3)"
|
||||||
|
name="icons/edit"
|
||||||
|
data-action="editItem"
|
||||||
|
></rc-icon>
|
||||||
|
<span class="ellipses">
|
||||||
|
{{ slot.data.name }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{#if slot.data.system.traitString}}
|
{{#if slot.data.system.traitString}}
|
||||||
<span class="traits">{{ slot.data.system.traitString }}</span>
|
<span class="traits">{{ slot.data.system.traitString }}</span>
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,18 @@
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: subgrid;
|
grid-template-columns: subgrid;
|
||||||
grid-template-rows: subgrid;
|
grid-template-rows: subgrid;
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
thead,
|
thead,
|
||||||
tbody,
|
tbody,
|
||||||
tr {
|
tr {
|
||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
|
td {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
.row-alt > * {
|
.row-alt > * {
|
||||||
background: inherit;
|
background: inherit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
font-size: var(--font-size-10)
|
font-size: var(--font-size-10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.ellipses {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Makes it so that spans are never less than the font size */
|
||||||
&:empty::before {
|
&:empty::before {
|
||||||
content: "\200b";
|
content: "\200b";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue