From 8922bb1b72a6320ff6f240ce8913ef48f3b5f5b5 Mon Sep 17 00:00:00 2001
From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com>
Date: Fri, 2 May 2025 10:55:28 +0200
Subject: [PATCH] add the ability to reorder items in Inventory
---
src/ActorSheet.hbs | 12 ++++++------
src/main.mjs | 6 ++++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/ActorSheet.hbs b/src/ActorSheet.hbs
index 0e9341a..f455c18 100644
--- a/src/ActorSheet.hbs
+++ b/src/ActorSheet.hbs
@@ -322,8 +322,8 @@
{{localize "DSA41.list_empty"}}
{{/unless}}
- {{#each actor.itemTypes.Bewaffnung}}
-
+ {{#each (sorted actor.itemTypes.Bewaffnung)}}
+
@@ -356,8 +356,8 @@
{{localize "DSA41.list_empty"}}
{{/unless}}
- {{#each actor.itemTypes.Ruestung}}
-
+ {{#each (sorted actor.itemTypes.Ruestung)}}
+
{{this.name}}
@@ -382,8 +382,8 @@
{{localize "DSA41.list_empty"}}
{{/unless}}
- {{#each actor.itemTypes.Gegenstand}}
-
+ {{#each (sorted actor.itemTypes.Gegenstand)}}
+
{{this.name}}
diff --git a/src/main.mjs b/src/main.mjs
index 0ad30df..8b958b0 100644
--- a/src/main.mjs
+++ b/src/main.mjs
@@ -92,6 +92,12 @@ Hooks.once("init", async function() {
}
});
+ Handlebars.registerHelper({
+ sorted: (array, options) => {
+ return array.toSorted((a, b) => a.sort - b.sort);
+ }
+ });
+
await loadTemplates({
"editable-input": "systems/dsa-4th-edition/src/EditableInput.hbs",