diff --git a/module/applications/characterCreation/characterCreation.mjs b/module/applications/characterCreation/characterCreation.mjs index 8c07fb9e..e44f82fa 100644 --- a/module/applications/characterCreation/characterCreation.mjs +++ b/module/applications/characterCreation/characterCreation.mjs @@ -43,6 +43,8 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl }; this._dragDrop = this._createDragDropHandlers(); + + this.itemBrowser = null; } get title() { @@ -503,7 +505,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl 'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null }, }; - return new ItemBrowser({ presets }).render({ force: true }); + return this.itemBrowser = await new ItemBrowser({ presets }).render({ force: true }); } static async viewItem(_, target) { @@ -617,6 +619,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl } }); + if(this.itemBrowser) this.itemBrowser.close(); this.close(); } diff --git a/module/applications/levelup/levelup.mjs b/module/applications/levelup/levelup.mjs index 3160a938..4ec690e4 100644 --- a/module/applications/levelup/levelup.mjs +++ b/module/applications/levelup/levelup.mjs @@ -13,6 +13,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2) this._dragDrop = this._createDragDropHandlers(); this.tabGroups.primary = 'advancements'; + + this.itemBrowser = null; } get title() { @@ -537,13 +539,20 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2) } }; - // if(type == "domains") - // presets.filter = { - // 'level.max': { key: 'level.max', value: 1 }, - // 'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null }, - // }; + if(type == "domains") { + const domains = this.actor.system.domains, + multiclassDomain = this.levelup.classUpgradeChoices?.multiclass?.domain; + if (multiclassDomain) { + if (!domains.includes(x => x === multiclassDomain)) + domains.push(multiclassDomain); + } + presets.filter = { + 'level.max': { key: 'level.max', value: this.levelup.currentLevel }, + 'system.domain': { key: 'system.domain', value: domains }, + }; + } - return new ItemBrowser({ presets }).render({ force: true }); + return this.itemBrowser = await new ItemBrowser({ presets }).render({ force: true }); } static async selectPreview(_, button) { @@ -644,6 +653,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2) }, {}); await this.actor.levelUp(levelupData); + if(this.itemBrowser) this.itemBrowser.close(); this.close(); } } diff --git a/module/applications/ui/itemBrowser.mjs b/module/applications/ui/itemBrowser.mjs index ffc1b77b..69de5249 100644 --- a/module/applications/ui/itemBrowser.mjs +++ b/module/applications/ui/itemBrowser.mjs @@ -17,7 +17,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { this.config = CONFIG.DH.ITEMBROWSER.compendiumConfig; this.presets = options.presets; - if(this.presets?.folder) + if(this.presets?.compendium && this.presets?.folder) ItemBrowser.selectFolder.call(this, null, null, this.presets.compendium, this.presets.folder); } @@ -41,7 +41,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { sortList: this.sortList }, position: { - top: 70, + top: 330, left: 120, width: 800, height: 600 @@ -86,6 +86,23 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { } }; + /** @inheritDoc */ + async _preFirstRender(context, options) { + if(context.presets?.render?.noFolder || context.presets?.render?.lite) + options.position.width = 600; + + await super._preFirstRender(context, options); + } + + /** @inheritDoc */ + async _preRender(context, options) { + + if(context.presets?.render?.noFolder || context.presets?.render?.lite) + options.parts.splice(options.parts.indexOf('sidebar'), 1); + + await super._preRender(context, options); + } + /** @inheritDoc */ async _onRender(context, options) { await super._onRender(context, options); @@ -93,6 +110,15 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { this._createSearchFilter(); this._createFilterInputs(); this._createDragProcess(); + + if(context.presets?.render?.lite) + this.element.classList.add('lite'); + + if(context.presets?.render?.noFolder) + this.element.classList.add('no-folder'); + + if(context.presets?.render?.noFilter) + this.element.classList.add('no-filter'); if(this.presets?.filter) { Object.entries(this.presets.filter).forEach(([k,v]) => this.fieldFilter.find(c => c.name === k).value = v.value); @@ -129,11 +155,9 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { folder.folders = c.folders ? ItemBrowser.sortBy(this.getCompendiumFolders(c.folders, folder, depth + 2), 'label') : []; - // sortBy(Object.values(c.folders), 'label') folders.push(folder); }); - // console.log(folders) return folders; } @@ -197,8 +221,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { f.choices = f.choices(); } f.name ??= f.key; - f.value = this.presets.filter?.[f.name]?.value ?? null; - // filters.push(f); + f.value = this.presets?.filter?.[f.name]?.value ?? null; }); return filters; } @@ -248,8 +271,6 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { container: '[data-application-part="list"] .filter-content .wrapper', content: '[data-application-part="list"] .item-list', callback: this._onInputFilterBrowser.bind(this) - // target: '.filter-button', - // filters: FilterMenu.invetoryFilters } ]; @@ -283,7 +304,6 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { if (matchesSearch) this.#filteredItems.browser.search.add(item.id); const { input } = this.#filteredItems.browser; li.hidden = !(input.has(item.id) && matchesSearch); - // li.hidden = !(matchesSearch); } } @@ -313,10 +333,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { const { search } = this.#filteredItems.browser; li.hidden = !(search.has(item.id) && matchesMenu); - // li.hidden = !(matchesMenu); } - - console.log(this.fieldFilter) } /** @@ -383,45 +400,22 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { itemListContainer.replaceChildren(...newOrder); } - /** - * Serialize salient information about this Document when dragging it. - * @returns {object} An object of drag data. - */ - // toDragData() { - // const dragData = {type: this.documentName}; - // if ( this.id ) dragData.uuid = this.uuid; - // else dragData.data = this.toObject(); - // return dragData; - // } - _createDragProcess() { new foundry.applications.ux.DragDrop.implementation({ dragSelector: '.item-container', - // dropSelector: ".directory-list", permissions: { dragstart: this._canDragStart.bind(this) - // drop: this._canDragDrop.bind(this) }, callbacks: { - // dragover: this._onDragOver.bind(this), dragstart: this._onDragStart.bind(this) - // drop: this._onDrop.bind(this) } }).bind(this.element); - // this.element.querySelectorAll(".directory-item.folder").forEach(folder => { - // folder.addEventListener("dragenter", this._onDragHighlight.bind(this)); - // folder.addEventListener("dragleave", this._onDragHighlight.bind(this)); - // }); } async _onDragStart(event) { - // console.log(event) - // ui.context?.close({ animate: false }); const { itemUuid } = event.target.closest('[data-item-uuid]').dataset, item = await foundry.utils.fromUuid(itemUuid), dragData = item.toDragData(); - // console.log(dragData) - // const dragData = { UUID: itemUuid }; event.dataTransfer.setData('text/plain', JSON.stringify(dragData)); } diff --git a/styles/less/ui/item-browser/item-browser.less b/styles/less/ui/item-browser/item-browser.less index 9dd453ec..63ebe233 100644 --- a/styles/less/ui/item-browser/item-browser.less +++ b/styles/less/ui/item-browser/item-browser.less @@ -242,6 +242,10 @@ border-radius: 6px; min-height: 30px; + > * { + white-space: nowrap; + } + div[data-sort-key] { &:after { font-family: "Font Awesome 6 Pro"; @@ -272,6 +276,8 @@ .item-desc .wrapper { padding: 0 10px; display: flex; + flex-direction: column; + gap: 5px; } img { @@ -328,6 +334,7 @@ .title { font-family: @font-subtitle; margin: 0; + text-align: center; } .hint { font-family: @font-body; @@ -339,4 +346,24 @@ pointer-events: none; } } + + &.lite, &.no-folder { + .menu-path { + display: none; + } + } + + &.lite { + .filter-header { + display: none; + } + } + + &.no-filter { + .filter-header { + a[data-action="expandContent"] { + display: none; + } + } + } } diff --git a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs index c5ef4c69..8fbd5800 100644 --- a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs +++ b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs @@ -26,7 +26,7 @@ Parameters: {{localize title}} {{#if canCreate}} - {{#if menu.data }} - {{#unless (or presets.render.lite presets.render.noFolder)}} - - {{/unless}} +
- {{#unless presets.render.lite}} -
-