From 29d34daa9a9c8a6015c99cc2330e5e38f556d9b0 Mon Sep 17 00:00:00 2001
From: Gesina Schwalbe <gesina.schwalbe@pheerai.de>
Date: Wed, 30 Dec 2020 23:50:27 +0100
Subject: [PATCH 1/3] added equipped and owner to item sheet

Additions:
- added equipped checkbox to item sheet
- added item owner to item properties list
- added some translations
- added some TODOs

Changes:
- item properties owner, equipped, quantity, storageLocation
  are only shown if item is owned by an actor
- moved item properties price and availability
  to details tab
- shortened ItemEquipped translation
- added item.actor and item.isOwned property values
  to data returned from DS4ItemSheet.getData
  (properties aren't accessible in Handlebars)
---
 src/lang/en.json                            |  3 +-
 src/module/item/item-sheet.ts               |  2 +-
 src/templates/actor/partials/items.hbs      |  4 ++-
 src/templates/item/partials/description.hbs | 36 +++++++++++----------
 src/templates/item/partials/details.hbs     | 17 +++++++++-
 5 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/src/lang/en.json b/src/lang/en.json
index 601ffc37..5abf614c 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -16,7 +16,8 @@
     "DS4.Quantity": "Quantity",
     "DS4.PriceGold": "Price (Gold)",
     "DS4.StorageLocation": "Stored at",
-    "DS4.ItemEquipped": "Item equipped?",
+    "DS4.ItemEquipped": "Equipped?",
+    "DS4.ItemOwner": "Owner",
     "DS4.ItemAvailability": "Availability",
     "DS4.ItemAvailabilityHamlet": "Hamlet",
     "DS4.ItemAvailabilityVilage": "Village",
diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts
index b060341e..ac8197aa 100644
--- a/src/module/item/item-sheet.ts
+++ b/src/module/item/item-sheet.ts
@@ -26,7 +26,7 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
 
     /** @override */
     getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
-        const data = { ...super.getData(), config: CONFIG.DS4 };
+        const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor };
         console.log(data);
         return data;
     }
diff --git a/src/templates/actor/partials/items.hbs b/src/templates/actor/partials/items.hbs
index 1c72cd46..28f8be43 100644
--- a/src/templates/actor/partials/items.hbs
+++ b/src/templates/actor/partials/items.hbs
@@ -1,4 +1,6 @@
-{{!-- TODO: Where possible use icons with complete names as hovers instead of long names --}}
+{{!-- TODO: For items list: only show header, if list is not empty --}}
+{{!-- TODO: Reduce code duplications --}}
+{{!-- TODO: Change from flex layout to grid layout --}}
 {{!-- Tab with overview and quick-actions on owned items --}}
 <div class="tab items" data-group="primary" data-tab="items">
 
diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs
index 56c8fdd2..64197ea4 100644
--- a/src/templates/item/partials/description.hbs
+++ b/src/templates/item/partials/description.hbs
@@ -1,27 +1,29 @@
 <div class="tab flexrow" data-group="primary" data-tab="description">
     <div class="side-properties">
+        {{#if isOwned}}
         <div class="side-property">
-            <label for="data.quantity">{{localize "DS4.Quantity"}}</label>
+            <label for="data.actor">{{localize 'DS4.ItemOwner'}}</label>
+            <a class="entity-link" draggable="true" data-entity="Actor" data-id="{{actor._id}}"><i
+                    class="fas fa-user"></i>{{actor.name}}</a>
+        </div>
+        {{#if (ne data.equipped undefined)}}<div class="side-property">
+            <label for="data.equipped">{{localize 'DS4.ItemEquipped'}}</label>
+            <input type="checkbox" name="data.equipped" data-dtype="Boolean" {{checked data.equipped}} title="{{localize 'DS4.ItemEquipped'}}">
+        </div>
+        {{/if}}
+        <div class="side-property">
+            <label for="data.quantity">{{localize 'DS4.Quantity'}}</label>
             <input type="number" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
         </div>
         <div class="side-property">
-            <label for="data.storageLocation">{{localize "DS4.StorageLocation"}}</label>
+            <label for="data.storageLocation">{{localize 'DS4.StorageLocation'}}</label>
             <input type="text" data-dtype="String" name="data.storageLocation" value="{{data.storageLocation}}" />
         </div>
-        <div class="side-property">
-            <label for="data.price">{{localize "DS4.PriceGold"}}</label>
-            <input type="number" data-dtype="Number" name="data.price" value="{{data.price}}" />
-        </div>
-        <div class="side-property">
-            <label for="data.availability">{{localize "DS4.ItemAvailability"}}</label>
-            <select name="data.availability" data-type="String">
-                {{#select data.availability}}
-                {{#each config.itemAvailabilities as |value key|}}
-                <option value="{{key}}">{{value}}</option>
-                {{/each}}
-                {{/select}}
-            </select>
-        </div>
+        {{else}}
+        <p>Item isn't owned.</p>
+        {{/if}}
+    </div>
+    <div class="description">
+        {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
     </div>
-    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
 </div>
\ No newline at end of file
diff --git a/src/templates/item/partials/details.hbs b/src/templates/item/partials/details.hbs
index 2d5b3f0c..0e57a780 100644
--- a/src/templates/item/partials/details.hbs
+++ b/src/templates/item/partials/details.hbs
@@ -1,5 +1,20 @@
 {{!-- The item tab for details. --}}
 <div class="tab details" data-group="primary" data-tab="details">
     {{!-- As you add new fields, add them in here! --}}
-    <p>Nothing to see yet.</p>
+    <div class="side-properties">
+        <div class="side-property">
+                <label for="data.price">{{localize "DS4.PriceGold"}}</label>
+                <input type="number" data-dtype="Number" name="data.price" value="{{data.price}}" />
+            </div>
+            <div class="side-property">
+                <label for="data.availability">{{localize "DS4.ItemAvailability"}}</label>
+                <select name="data.availability" data-type="String">
+                    {{#select data.availability}}
+                    {{#each config.itemAvailabilities as |value key|}}
+                    <option value="{{key}}">{{value}}</option>
+                    {{/each}}
+                    {{/select}}
+                </select>
+            </div>
+        </div>
 </div>
\ No newline at end of file

From 445febf4783b237fa5f4bf43f173bc2bd7ee98d1 Mon Sep 17 00:00:00 2001
From: Gesina Schwalbe <gesina.schwalbe@pheerai.de>
Date: Thu, 31 Dec 2020 01:18:50 +0100
Subject: [PATCH 2/3] localized "not owned" hint

---
 src/lang/en.json                            | 1 +
 src/templates/item/partials/description.hbs | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lang/en.json b/src/lang/en.json
index 5abf614c..e0e916f5 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -1,5 +1,6 @@
 {
     "DS4.UserInteractionAddItem": "Add item",
+    "DS4.NotOwned": "No owner",
     "DS4.Description": "Description",
     "DS4.DescriptionAbbr": "Desc",
     "DS4.Details": "Details",
diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs
index 64197ea4..fdfe6754 100644
--- a/src/templates/item/partials/description.hbs
+++ b/src/templates/item/partials/description.hbs
@@ -20,7 +20,7 @@
             <input type="text" data-dtype="String" name="data.storageLocation" value="{{data.storageLocation}}" />
         </div>
         {{else}}
-        <p>Item isn't owned.</p>
+        {{localize "DS4.NotOwned"}}
         {{/if}}
     </div>
     <div class="description">

From 80e6fd26ae2c44dd0b3cd0ab3c1d78099a674b34 Mon Sep 17 00:00:00 2001
From: Gesina Schwalbe <gesina.schwalbe@pheerai.de>
Date: Thu, 31 Dec 2020 16:35:41 +0100
Subject: [PATCH 3/3] Apply 1 suggestion(s) to 1 file(s)

---
 src/lang/en.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lang/en.json b/src/lang/en.json
index 28764b4d..de17c09b 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -17,7 +17,7 @@
     "DS4.Quantity": "Quantity",
     "DS4.PriceGold": "Price (Gold)",
     "DS4.StorageLocation": "Stored at",
-    "DS4.ItemEquipped": "Equipped?",
+    "DS4.ItemEquipped": "Equipped",
     "DS4.ItemOwner": "Owner",
     "DS4.ItemAvailability": "Availability",
     "DS4.ItemAvailabilityHamlet": "Hamlet",