Add customizable tags and categories with UI management

- Introduced settings for tags and categories in `settings.js`:
  - Added `tags` and `categories` settings with default values and support for customization.
  - Registered a new settings menu for managing tags and categories dynamically.
- Enhanced `main.js` to use the customizable tags and categories in templates.
  - Adjusted `AscAssetManager.TEMPLATES` to include a new `SETTINGS_TAGS_AND_CATEGORIES` template.
  - Updated the `renderUploadForm` hook to fetch tags and categories dynamically from settings.
- Added a new Handlebars template `settings-tags-and-categories.hbs`:
  - Provides a user interface for managing tags and categories.
  - Includes functionality to add, reset, and delete rows dynamically.

These updates allow users to define and manage tags and categories via the module's settings menu, improving flexibility and user experience.
This commit is contained in:
2025-01-23 10:24:54 -06:00
parent 4cd01570f7
commit 3fdaadf7e0
3 changed files with 231 additions and 3 deletions

View File

@@ -8,7 +8,8 @@ export class AscAssetManager {
static TEMPLATES = {
UPLOAD_CHOOSE:`modules/${this.ID}/templates/upload-choose.hbs`,
UPLOAD_FORM:`modules/${this.ID}/templates/upload-form.hbs`,
SETTINGS_MENU_MACRO:`modules/${this.ID}/templates/settings-menu-macro.hbs`
SETTINGS_MENU_MACRO:`modules/${this.ID}/templates/settings-menu-macro.hbs`,
SETTINGS_TAGS_AND_CATEGORIES:`modules/${this.ID}/templates/settings-tags-and-categories.hbs`
}
static getDirectory () {
@@ -148,7 +149,11 @@ Hooks.on("renderHotbar", ({macros}, html) => {
});
Hooks.on("ascAssetManager.renderUploadForm", (data={})=>{
const templateData = {moduleId: AscAssetManager.ID, fileCategories: AscAssetManager.fileCategories, fileTags: AscAssetManager.fileTags}
const templateData = {
moduleId: AscAssetManager.ID,
fileCategories: game.settings.get(AscAssetManager.ID, "categories"),
fileTags: game.settings.get(AscAssetManager.ID, "tags")
}
renderTemplate(AscAssetManager.TEMPLATES.UPLOAD_FORM, templateData).then(content => {
let {file} = data
const dialog = new Dialog({