This commit is contained in:
Dapoolp 2025-08-06 16:29:03 +02:00
parent c1a1e74bc4
commit 0e74ce0476
7 changed files with 99 additions and 69 deletions

View file

@ -43,6 +43,8 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
}; };
this._dragDrop = this._createDragDropHandlers(); this._dragDrop = this._createDragDropHandlers();
this.itemBrowser = null;
} }
get title() { 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 }, '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) { static async viewItem(_, target) {
@ -617,6 +619,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
} }
}); });
if(this.itemBrowser) this.itemBrowser.close();
this.close(); this.close();
} }

View file

@ -13,6 +13,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
this._dragDrop = this._createDragDropHandlers(); this._dragDrop = this._createDragDropHandlers();
this.tabGroups.primary = 'advancements'; this.tabGroups.primary = 'advancements';
this.itemBrowser = null;
} }
get title() { get title() {
@ -537,13 +539,20 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
} }
}; };
// if(type == "domains") if(type == "domains") {
// presets.filter = { const domains = this.actor.system.domains,
// 'level.max': { key: 'level.max', value: 1 }, multiclassDomain = this.levelup.classUpgradeChoices?.multiclass?.domain;
// 'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null }, 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) { static async selectPreview(_, button) {
@ -644,6 +653,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
}, {}); }, {});
await this.actor.levelUp(levelupData); await this.actor.levelUp(levelupData);
if(this.itemBrowser) this.itemBrowser.close();
this.close(); this.close();
} }
} }

View file

@ -17,7 +17,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
this.config = CONFIG.DH.ITEMBROWSER.compendiumConfig; this.config = CONFIG.DH.ITEMBROWSER.compendiumConfig;
this.presets = options.presets; 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); 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 sortList: this.sortList
}, },
position: { position: {
top: 70, top: 330,
left: 120, left: 120,
width: 800, width: 800,
height: 600 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 */ /** @inheritDoc */
async _onRender(context, options) { async _onRender(context, options) {
await super._onRender(context, options); await super._onRender(context, options);
@ -94,6 +111,15 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
this._createFilterInputs(); this._createFilterInputs();
this._createDragProcess(); 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) { if(this.presets?.filter) {
Object.entries(this.presets.filter).forEach(([k,v]) => this.fieldFilter.find(c => c.name === k).value = v.value); Object.entries(this.presets.filter).forEach(([k,v]) => this.fieldFilter.find(c => c.name === k).value = v.value);
await this._onInputFilterBrowser(); await this._onInputFilterBrowser();
@ -129,11 +155,9 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
folder.folders = c.folders folder.folders = c.folders
? ItemBrowser.sortBy(this.getCompendiumFolders(c.folders, folder, depth + 2), 'label') ? ItemBrowser.sortBy(this.getCompendiumFolders(c.folders, folder, depth + 2), 'label')
: []; : [];
// sortBy(Object.values(c.folders), 'label')
folders.push(folder); folders.push(folder);
}); });
// console.log(folders)
return folders; return folders;
} }
@ -197,8 +221,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
f.choices = f.choices(); f.choices = f.choices();
} }
f.name ??= f.key; f.name ??= f.key;
f.value = this.presets.filter?.[f.name]?.value ?? null; f.value = this.presets?.filter?.[f.name]?.value ?? null;
// filters.push(f);
}); });
return filters; return filters;
} }
@ -248,8 +271,6 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
container: '[data-application-part="list"] .filter-content .wrapper', container: '[data-application-part="list"] .filter-content .wrapper',
content: '[data-application-part="list"] .item-list', content: '[data-application-part="list"] .item-list',
callback: this._onInputFilterBrowser.bind(this) 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); if (matchesSearch) this.#filteredItems.browser.search.add(item.id);
const { input } = this.#filteredItems.browser; const { input } = this.#filteredItems.browser;
li.hidden = !(input.has(item.id) && matchesSearch); 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; const { search } = this.#filteredItems.browser;
li.hidden = !(search.has(item.id) && matchesMenu); 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); 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() { _createDragProcess() {
new foundry.applications.ux.DragDrop.implementation({ new foundry.applications.ux.DragDrop.implementation({
dragSelector: '.item-container', dragSelector: '.item-container',
// dropSelector: ".directory-list",
permissions: { permissions: {
dragstart: this._canDragStart.bind(this) dragstart: this._canDragStart.bind(this)
// drop: this._canDragDrop.bind(this)
}, },
callbacks: { callbacks: {
// dragover: this._onDragOver.bind(this),
dragstart: this._onDragStart.bind(this) dragstart: this._onDragStart.bind(this)
// drop: this._onDrop.bind(this)
} }
}).bind(this.element); }).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) { async _onDragStart(event) {
// console.log(event)
// ui.context?.close({ animate: false });
const { itemUuid } = event.target.closest('[data-item-uuid]').dataset, const { itemUuid } = event.target.closest('[data-item-uuid]').dataset,
item = await foundry.utils.fromUuid(itemUuid), item = await foundry.utils.fromUuid(itemUuid),
dragData = item.toDragData(); dragData = item.toDragData();
// console.log(dragData)
// const dragData = { UUID: itemUuid };
event.dataTransfer.setData('text/plain', JSON.stringify(dragData)); event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
} }

View file

@ -242,6 +242,10 @@
border-radius: 6px; border-radius: 6px;
min-height: 30px; min-height: 30px;
> * {
white-space: nowrap;
}
div[data-sort-key] { div[data-sort-key] {
&:after { &:after {
font-family: "Font Awesome 6 Pro"; font-family: "Font Awesome 6 Pro";
@ -272,6 +276,8 @@
.item-desc .wrapper { .item-desc .wrapper {
padding: 0 10px; padding: 0 10px;
display: flex; display: flex;
flex-direction: column;
gap: 5px;
} }
img { img {
@ -328,6 +334,7 @@
.title { .title {
font-family: @font-subtitle; font-family: @font-subtitle;
margin: 0; margin: 0;
text-align: center;
} }
.hint { .hint {
font-family: @font-body; font-family: @font-body;
@ -339,4 +346,24 @@
pointer-events: none; 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;
}
}
}
} }

View file

@ -26,7 +26,7 @@ Parameters:
<legend> <legend>
{{localize title}} {{localize title}}
{{#if canCreate}} {{#if canCreate}}
<a data-action="addNewItem" data-document-class="{{ifThen (eq type 'effect') 'ActiveEffect' 'Item' }}" <a data-action="{{ifThen (or (eq type 'effect') (eq type 'feature')) 'createDoc' 'addNewItem' }}" data-document-class="{{ifThen (eq type 'effect') 'ActiveEffect' 'Item' }}"
data-type="{{ifThen (eq type 'effect') 'base' type}}" data-type="{{ifThen (eq type 'effect') 'base' type}}"
{{#if inVault}}data-in-vault="{{inVault}}"{{/if}} {{#if inVault}}data-in-vault="{{inVault}}"{{/if}}
{{#if disabled}} data-disabled="{{disabled}}"{{/if}} {{#if disabled}} data-disabled="{{disabled}}"{{/if}}

View file

@ -1,6 +1,5 @@
<div class="compendium-results"> <div class="compendium-results">
{{#if menu.data }} {{#if menu.data }}
{{#unless (or presets.render.lite presets.render.noFolder)}}
<div class="menu-path"> <div class="menu-path">
{{#each menu.path}} {{#each menu.path}}
{{#if (eq this "folders")}} {{#if (eq this "folders")}}
@ -12,9 +11,7 @@
{{/if}} {{/if}}
{{/each}} {{/each}}
</div> </div>
{{/unless}}
<div class="item-filter"> <div class="item-filter">
{{#unless presets.render.lite}}
<div class="filter-header"> <div class="filter-header">
<div class="search-bar"> <div class="search-bar">
<div class="icon"> <div class="icon">
@ -22,12 +19,11 @@
</div> </div>
<input type="search" name="search" class="search-input" placeholder="Search..."> <input type="search" name="search" class="search-input" placeholder="Search...">
</div> </div>
{{#if (and fieldFilter (not presets.render.noFilter))}} {{#if fieldFilter.length}}
<a data-tooltip="Filters" data-action="expandContent"><i class="fa-solid fa-filter"></i></a> <a data-tooltip="Filters" data-action="expandContent"><i class="fa-solid fa-filter"></i></a>
{{/if}} {{/if}}
<a data-tooltip="Erase" data-action="resetFilters"><i class="fa-solid fa-eraser"></i></a> <a data-tooltip="Erase" data-action="resetFilters"><i class="fa-solid fa-eraser"></i></a>
</div> </div>
{{/unless}}
<div class="filter-content extensible"> <div class="filter-content extensible">
<div class="wrapper"> <div class="wrapper">
{{#each fieldFilter}} {{#each fieldFilter}}

View file

@ -1,4 +1,4 @@
<div class="compendium-sidebar" {{#if (or presets.render.lite presets.render.noFolder)}}style="display: none;"{{/if}}> <div class="compendium-sidebar">
{{#each compendiums}} {{#each compendiums}}
<details class="compendium-container" data-compendium-id="{{id}}" open> <details class="compendium-container" data-compendium-id="{{id}}" open>
<summary> <summary>