Call a hook to get all of the sidebar controls

This commit is contained in:
Oliver-Akins 2025-05-01 21:09:48 -06:00
parent eac23400a8
commit 8c9fd1930a
2 changed files with 29 additions and 15 deletions

View file

@ -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;
};

View file

@ -19,19 +19,13 @@
</section>
<section>
<h4 class="divider">Apps</h4>
<h4 class="divider">Controls</h4>
{{#each controls as | btn |}}
<button
type="button"
data-action="openStats"
data-action="{{ btn.action }}"
>
View Statistics
{{ btn.label }}
</button>
<button
type="button"
data-action="createTable"
>
Create New Table
</button>
<button type="button">Manage Tables</button>
<button type="button">Manage Rows</button>
{{/each}}
</section>