Drag depuis la fenêtre de recherche

This commit is contained in:
Vincent Vandemeulebrouck 2023-01-15 23:21:19 +01:00
parent 40fdff4057
commit 948309bb4f
2 changed files with 42 additions and 29 deletions

View File

@ -59,6 +59,7 @@ export class FenetreRechercheTirage extends Application {
width: 600,
height: 600,
popOut: true,
dragDrop: [{ dragSelector: "a.content-link" }],
resizable: true
});
}
@ -83,13 +84,13 @@ export class FenetreRechercheTirage extends Application {
}
static $typeToFilter(type) { return { group: 'type', code: type, label: Misc.typeName('Item', type), check: item => item.type == type }; }
static async create(tirage = {}) {
new FenetreRechercheTirage(tirage).render(true);
static async create(options) {
new FenetreRechercheTirage(options).render(true);
}
constructor(tirage) {
super();
this.tirage = tirage;
constructor(options) {
super(options);
this.tirage = {};
this.compendiums = [
SystemCompendiums.getCompendium('faune-flore-mineraux'),
SystemCompendiums.getCompendium('equipement')
@ -131,6 +132,12 @@ export class FenetreRechercheTirage extends Application {
}
}
_canDragStart() {
return true;
}
_onDragStart(event) {
console.log('_onDragStart', event)
}
activateListeners(html) {
super.activateListeners(html);
@ -150,10 +157,7 @@ export class FenetreRechercheTirage extends Application {
this.html.find("a.supprimer-filtres").click(async event => this.html.find('input.activate-filter:checked').prop("checked", false))
this.html.find("a.recherche-filtres").click(async event => {
const table = await this.buildTable();
this.html.find('div.liste-resultats').html(await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats.hbs`, { resultats: table }));
})
this.html.find("a.recherche-filtres").click(async event => await this.recherche())
this.html.find("a.tirage-filtres").click(async event => {
const table = await this.buildTable();
@ -162,6 +166,13 @@ export class FenetreRechercheTirage extends Application {
})
}
async recherche() {
const table = await this.buildTable();
const htmlResultats = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats.hbs`, { resultats: table });
this.html.find('div.liste-resultats').html(htmlResultats);
this._dragDrop.forEach(dragDropHandler => dragDropHandler.bind(this.element[0]))
}
async buildTable() {
const filter = this.getSelectedItemsFilter();
const equipementCompendiumTable = new CompendiumTable('equipement', 'Item');

View File

@ -1,3 +1,4 @@
<span draggable="true">
{{#if pack}}
{{!-- draggable="true" --}}
<a class="content-link"
@ -18,3 +19,4 @@
<i class="fas fa-suitcase"></i>
{{/if}}
{{name}}</a>
</span>