Update Weapon context menu to also work for the Armour/Shield
This commit is contained in:
parent
5a7cc44014
commit
9a3b82ef6a
2 changed files with 53 additions and 26 deletions
|
|
@ -46,15 +46,24 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
};
|
||||
|
||||
static async _onRender() {
|
||||
const itemMenuOptions = [
|
||||
new ContextMenu(
|
||||
this.element,
|
||||
`[data-ctx-menu="weapon"],[data-ctx-menu="armour"]`,
|
||||
[
|
||||
{
|
||||
name: `Edit`,
|
||||
condition: () => this.isEditable,
|
||||
condition: (el) => {
|
||||
const itemId = el.dataset.itemId;
|
||||
return this.isEditable && itemId !== ``;
|
||||
},
|
||||
callback: HeroSummaryCardV1._editItem,
|
||||
},
|
||||
{
|
||||
name: `Delete`,
|
||||
condition: () => this.isEditable,
|
||||
condition: (el) => {
|
||||
const itemId = el.dataset.itemId;
|
||||
return this.isEditable && itemId !== ``;
|
||||
},
|
||||
callback: async (el) => {
|
||||
const itemEl = el.closest(`[data-item-id]`);
|
||||
if (!itemEl) { return };
|
||||
|
|
@ -63,10 +72,9 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
await item.delete();
|
||||
},
|
||||
},
|
||||
];
|
||||
if (itemMenuOptions.length) {
|
||||
new ContextMenu(this.element, `.weapon-ctx-menu`, itemMenuOptions, { jQuery: false, fixed: true });
|
||||
};
|
||||
],
|
||||
{ jQuery: false, fixed: true },
|
||||
);
|
||||
};
|
||||
|
||||
async _preparePartContext(partId, ctx, opts) {
|
||||
|
|
|
|||
|
|
@ -55,23 +55,41 @@
|
|||
{{/each}}
|
||||
</div>
|
||||
<ul class="armour-items">
|
||||
<li class="row-alt">
|
||||
<li
|
||||
class="row-alt"
|
||||
data-ctx-menu="armour"
|
||||
data-item-id="{{armours.head.uuid}}"
|
||||
>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.head" }}</span>
|
||||
<span class="value ellipses">{{ armours.head.name }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<li
|
||||
data-ctx-menu="armour"
|
||||
data-item-id="{{armours.body.uuid}}"
|
||||
>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.body" }}</span>
|
||||
<span class="value ellipses">{{ armours.body.name }}</span>
|
||||
</li>
|
||||
<li class="row-alt">
|
||||
<li
|
||||
class="row-alt"
|
||||
data-ctx-menu="armour"
|
||||
data-item-id="{{armours.arms.uuid}}"
|
||||
>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.arms" }}</span>
|
||||
<span class="value ellipses">{{ armours.arms.name }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<li
|
||||
data-ctx-menu="armour"
|
||||
data-item-id="{{armours.legs.uuid}}"
|
||||
>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.legs" }}</span>
|
||||
<span class="value ellipses">{{ armours.legs.name }}</span>
|
||||
</li>
|
||||
<li class="row-alt">
|
||||
<li
|
||||
class="row-alt"
|
||||
data-ctx-menu="armour"
|
||||
data-item-id="{{shield.uuid}}"
|
||||
>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.shield" }}</span>
|
||||
<span class="value ellipses">{{ shield.name }}</span>
|
||||
</li>
|
||||
|
|
@ -199,7 +217,8 @@
|
|||
{{else}}
|
||||
<tr
|
||||
data-row="{{ slot.index }}"
|
||||
class="{{slot.class}} weapon-ctx-menu"
|
||||
class="{{slot.class}}"
|
||||
data-ctx-menu="weapon"
|
||||
data-item-id="{{ slot.data.uuid }}"
|
||||
>
|
||||
<td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue