From 8c9fd1930a590d8a1b07e4eb55b4f8efb62685cd Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 1 May 2025 21:09:48 -0600 Subject: [PATCH] Call a hook to get all of the sidebar controls --- module/Apps/StatSidebar.mjs | 20 ++++++++++++++++++ public/templates/Apps/StatSidebar/main.hbs | 24 ++++++++-------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/module/Apps/StatSidebar.mjs b/module/Apps/StatSidebar.mjs index ce8f0eb..de61e02 100644 --- a/module/Apps/StatSidebar.mjs +++ b/module/Apps/StatSidebar.mjs @@ -38,6 +38,26 @@ export class StatSidebar extends HandlebarsApplicationMixin(AbstractSidebarTab) ctx.tableCount = db.getTables().length; + const controls = { + openStats: { label: `View Stats`, action: `openStats` }, + createTable: { label: `Create New Table`, action: `createTable` }, + manageTables: { label: `Manage Tables`, action: `` }, + manageData: { label: `Manage Data`, action: `` }, + }; + + if (!game.user.isGM) { + delete controls.createTable; + delete controls.manageTables; + }; + + const canManageTheirOwnData = false; + if (!game.user.isGM && !canManageTheirOwnData) { + delete controls.manageData; + }; + + Hooks.callAll(`${__ID__}.getStatsSidebarControls`, controls); + ctx.controls = Object.values(controls); + return ctx; }; diff --git a/public/templates/Apps/StatSidebar/main.hbs b/public/templates/Apps/StatSidebar/main.hbs index 4487cd9..deab811 100644 --- a/public/templates/Apps/StatSidebar/main.hbs +++ b/public/templates/Apps/StatSidebar/main.hbs @@ -19,19 +19,13 @@
-

Apps

- - - - +

Controls

+ {{#each controls as | btn |}} + + {{/each}}