Fix the issue with ContextMenus being completely non-functional in v13 (closes #91)
This commit is contained in:
parent
9177b7cc2d
commit
b36fe27182
2 changed files with 24 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { __ID__, filePath } from "../consts.mjs";
|
||||
import { deleteItemFromElement, editItemFromElement } from "./utils.mjs";
|
||||
import { createContextMenuOption, deleteItemFromElement, editItemFromElement } from "./utils.mjs";
|
||||
import { config } from "../config.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { TAFDocumentSheetConfig } from "./TAFDocumentSheetConfig.mjs";
|
||||
|
|
@ -226,7 +226,7 @@ export class PlayerSheet extends
|
|||
this.element,
|
||||
`[data-item-uuid]`,
|
||||
[
|
||||
{
|
||||
createContextMenuOption({
|
||||
label: _loc(`taf.misc.edit`),
|
||||
condition: (el) => {
|
||||
const itemUuid = el.dataset.itemUuid;
|
||||
|
|
@ -234,8 +234,8 @@ export class PlayerSheet extends
|
|||
return this.isEditable && itemExists;
|
||||
},
|
||||
onClick: editItemFromElement,
|
||||
},
|
||||
{
|
||||
}),
|
||||
createContextMenuOption({
|
||||
label: _loc(`taf.misc.delete`),
|
||||
condition: (el) => {
|
||||
const itemUuid = el.dataset.itemUuid;
|
||||
|
|
@ -243,7 +243,7 @@ export class PlayerSheet extends
|
|||
return this.isEditable && itemExists;
|
||||
},
|
||||
onClick: deleteItemFromElement,
|
||||
},
|
||||
}),
|
||||
],
|
||||
{ jQuery: false, fixed: true },
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,25 @@ This file contains utility methods used by Applications in order to be
|
|||
DRYer
|
||||
*/
|
||||
|
||||
/**
|
||||
* A helper function that takes a v14-compatible ContextMenuEntry option
|
||||
* and adjusts it for v13 if required
|
||||
*
|
||||
* @param {ContextMenuEntry} option The v14+ compatible menu entry option
|
||||
* @returns {ContextMenuEntry} The v14+ or <v13 menu option object
|
||||
*/
|
||||
export function createContextMenuOption(option) {
|
||||
if (game.release.generation < 14) {
|
||||
return {
|
||||
name: option.label,
|
||||
visible: option.condition,
|
||||
callback: (target) => option.onClick(null, target),
|
||||
};
|
||||
};
|
||||
|
||||
return option;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Event} _event The click event
|
||||
* @param {HTMLElement} target The element to operate on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue