Add foundation of the application and templates
This commit is contained in:
parent
a014bb8e6c
commit
60034dcee2
8 changed files with 165 additions and 0 deletions
72
module/apps/SidebarTabRearranger.mjs
Normal file
72
module/apps/SidebarTabRearranger.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { __ID__, filePath } from "../consts.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
const { getDocumentClass } = foundry.utils;
|
||||
|
||||
export class SidebarTabRearranger extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
// #region Options
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: `form`,
|
||||
classes: [
|
||||
__ID__,
|
||||
`SidebarTabRearranger`,
|
||||
],
|
||||
window: {
|
||||
title: `OFT.apps.SidebarTabRearranger.title`,
|
||||
},
|
||||
position: {},
|
||||
form: {
|
||||
handler: this.#onSubmit,
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
},
|
||||
actions: {},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
list: { template: filePath(`templates/SidebarTabRearranger/list.hbs`) },
|
||||
footer: { template: filePath(`templates/SidebarTabRearranger/footer.hbs`) },
|
||||
};
|
||||
// #endregion Options
|
||||
|
||||
// #region Instance Data
|
||||
// #endregion Instance Data
|
||||
|
||||
// #region Lifecycle
|
||||
/** @this {SidebarTabRearranger} */
|
||||
static async #onSubmit() {};
|
||||
// #endregion Lifecycle
|
||||
|
||||
// #region Data Prep
|
||||
async _prepareContext() {
|
||||
const ctx = {
|
||||
meta: {
|
||||
idp: this.id,
|
||||
},
|
||||
};
|
||||
|
||||
const tabs = ui.sidebar.constructor.TABS;
|
||||
ctx.tabs = [];
|
||||
for (const [id, tab] of Object.entries(tabs)) {
|
||||
let { documentName, gmOnly, tooltip, icon } = tab;
|
||||
if (gmOnly && !game.user.isGM) { continue };
|
||||
|
||||
if (documentName) {
|
||||
tooltip ??= getDocumentClass(documentName).metadata.labelPlural;
|
||||
icon ??= CONFIG[documentName]?.sidebarIcon;
|
||||
};
|
||||
|
||||
ctx.tabs.push({
|
||||
id,
|
||||
name: game.i18n.localize(tooltip),
|
||||
icon,
|
||||
});
|
||||
};
|
||||
|
||||
return ctx;
|
||||
};
|
||||
// #endregion Data Prep
|
||||
|
||||
// #region Actions
|
||||
// #endregion Actions
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue