Skip to content

Commit

Permalink
[#4319] Disabled find item buttons on compendium locked actor sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Sep 18, 2024
1 parent 629ac43 commit ce13307
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion less/v2/character.less
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@
&:hover:not(:has(a:hover)) { box-shadow: 0 0 12px var(--dnd5e-color-gold); }
}

&.empty {
&.empty:not(.disabled) {
cursor: pointer;
transition: opacity 250ms ease;
&:hover { opacity: .5; }
Expand Down
5 changes: 5 additions & 0 deletions module/applications/actor/character-sheet-2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ export default class ActorSheet5eCharacter2 extends ActorSheetV2Mixin(ActorSheet
if ( this._mode === this.constructor.MODES.EDIT ) {
html.find(".tab.details .item-action").on("click", this._onItemAction.bind(this));
}

if ( !this.isEditable ) {
html[0].querySelectorAll('[data-action="findItem"]').forEach(el => el.classList.add("disabled"));
}
}

/* -------------------------------------------- */
Expand Down Expand Up @@ -481,6 +485,7 @@ export default class ActorSheet5eCharacter2 extends ActorSheetV2Mixin(ActorSheet
* @protected
*/
async _onFindItem(type, { classIdentifier }={}) {
if ( !this.isEditable ) return;
const filters = { locked: { types: new Set([type]) } };
if ( classIdentifier ) filters.locked.additional = { class: { [classIdentifier]: 1 } };
const result = await CompendiumBrowser.selectOne({ filters });
Expand Down

0 comments on commit ce13307

Please sign in to comment.