make equip icon for items clickable in item list in character sheet

This commit is contained in:
Johannes Loher 2020-12-31 12:10:59 +01:00
parent cba20e47e5
commit 6fac2c597f
3 changed files with 18 additions and 11 deletions

View file

@ -1,4 +1,4 @@
import { DS4ItemDataType } from "../item/item-data";
import { DS4ItemDataType, DS4ItemEquipable } from "../item/item-data";
import { DS4Actor } from "./actor";
import { DS4ActorDataType } from "./actor-data";
@ -62,6 +62,13 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
li.slideUp(200, () => this.render(false));
});
html.find(".item-equip").on("click", (ev) => {
const id = $(ev.currentTarget).parents(".item").data("itemId");
const item = duplicate(this.actor.getEmbeddedEntity("OwnedItem", id));
setProperty(item, "data.equipped", !getProperty(item, "data.equipped"));
this.actor.updateOwnedItem(item);
});
// Rollable abilities.
html.find(".rollable").click(this._onRoll.bind(this));
}

View file

@ -30,7 +30,7 @@ interface DS4ItemPhysical {
storageLocation: string;
}
interface DS4ItemEquipable {
export interface DS4ItemEquipable {
equipped: boolean;
}

View file

@ -5,7 +5,7 @@
{{!-- WEAPONS --}}
<h4 class="items-list-title">{{localize 'DS4.ItemTypeWeapon'}}</h4> {{!-- SPECIFIC --}}
<ol class="items-list">
<li class="item flexrow item-header">
<li class="item flexrow item-header"">
<div class="flexrow flex15">
<div title="{{localize 'DS4.ItemEquipped'}}">E</div> {{!-- equipped --}} {{!-- SPECIFIC --}}
<div class="item-image"></div>
@ -32,8 +32,8 @@
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="flexrow flex15">
{{!-- equipped? --}}
{{#if itemData.equipped}}<i class="fas fa-check-square"></i>
{{else}}<i class="far fa-square"></i>
{{#if itemData.equipped}}<i class="fas fa-check-square item-equip"></i>
{{else}}<i class="far fa-square item-equip"></i>
{{/if}} {{!--SPECIFIC --}}
{{!-- image --}}
<div class="item-image">
@ -94,8 +94,8 @@
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="flexrow flex15">
{{!-- equipped? --}}
{{#if itemData.equipped}}<i class="fas fa-check-square"></i>
{{else}}<i class="far fa-square"></i>
{{#if itemData.equipped}}<i class="fas fa-check-square item-equip"></i>
{{else}}<i class="far fa-square item-equip"></i>
{{/if}} {{!--SPECIFIC --}}
{{!-- image --}}
<div class="item-image">
@ -152,8 +152,8 @@
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="flexrow flex15">
{{!-- equipped? --}}
{{#if itemData.equipped}}<i class="fas fa-check-square"></i>
{{else}}<i class="far fa-square"></i>
{{#if itemData.equipped}}<i class="fas fa-check-square item-equip"></i>
{{else}}<i class="far fa-square item-equip"></i>
{{/if}} {{!--SPECIFIC --}}
{{!-- image --}}
<div class="item-image">
@ -202,8 +202,8 @@
<li class="item flexrow" data-item-id="{{item._id}}">
<div class="flexrow flex15">
{{!-- equipped? --}}
{{#if itemData.equipped}}<i class="fas fa-check-square"></i>
{{else}}<i class="far fa-square"></i>
{{#if itemData.equipped}}<i class="fas fa-check-square item-equip"></i>
{{else}}<i class="far fa-square item-equip"></i>
{{/if}} {{!--SPECIFIC --}}
{{!-- image --}}
<div class="item-image">