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,20 +1,22 @@
{{#if pack}}
{{!-- draggable="true" --}}
<a class="content-link"
data-uuid="Compendium.{{pack}}.{{id}}"
data-pack="{{pack}}"
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
data-id="{{id}}"
>
{{else}}
<a class="rdd-world-content-link"
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
data-id="{{id}}"
>
{{/if}}
{{#if img}}
<img class="in-text-img" src="{{img}}" alt="{{name}}" />
{{else}}
<i class="fas fa-suitcase"></i>
{{/if}}
{{name}}</a>
<span draggable="true">
{{#if pack}}
{{!-- draggable="true" --}}
<a class="content-link"
data-uuid="Compendium.{{pack}}.{{id}}"
data-pack="{{pack}}"
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
data-id="{{id}}"
>
{{else}}
<a class="rdd-world-content-link"
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
data-id="{{id}}"
>
{{/if}}
{{#if img}}
<img class="in-text-img" src="{{img}}" alt="{{name}}" />
{{else}}
<i class="fas fa-suitcase"></i>
{{/if}}
{{name}}</a>
</span>