Merge pull request 'Recherche par nom' (#618) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10

Reviewed-on: #618
This commit is contained in:
uberwald 2023-01-31 07:32:09 +01:00
commit 9f24aee1f3
6 changed files with 57 additions and 22 deletions

View File

@ -202,7 +202,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/enum-periode.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-periode.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-effet.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-effet.html',
// Partials // Partials
'systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats.hbs', 'systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats-recherche.hbs',
'systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs', 'systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs',
'systems/foundryvtt-reve-de-dragon/templates/common/periodicite.hbs', 'systems/foundryvtt-reve-de-dragon/templates/common/periodicite.hbs',
'systems/foundryvtt-reve-de-dragon/templates/common/enum-duree.hbs', 'systems/foundryvtt-reve-de-dragon/templates/common/enum-duree.hbs',

View File

@ -3,6 +3,7 @@ import { HtmlUtility } from '../html-utility.js';
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { CompendiumTableHelpers } from '../settings/system-compendiums.js'; import { CompendiumTableHelpers } from '../settings/system-compendiums.js';
import { RdDRaretes } from '../item/raretes.js'; import { RdDRaretes } from '../item/raretes.js';
import { Grammar } from '../grammar.js';
const FILTER_GROUPS = [ const FILTER_GROUPS = [
{ group: 'type', label: "Type d'objet" }, { group: 'type', label: "Type d'objet" },
@ -188,6 +189,30 @@ export class FenetreRechercheTirage extends Application {
const row = await CompendiumTableHelpers.getRandom(table, 'Item') const row = await CompendiumTableHelpers.getRandom(table, 'Item')
await CompendiumTableHelpers.tableRowToChatMessage(row, 'Item'); await CompendiumTableHelpers.tableRowToChatMessage(row, 'Item');
}) })
// this.html.find('.recherche')
// .each((index, field) => {
// if (this.options.recherche) {
// field.focus();
// field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
// }
// })
// .keyup(async event => {
// const nouvelleRecherche = this._optionRecherche(event.currentTarget);
// if (this.options.recherche?.text != nouvelleRecherche?.text) {
// this.options.recherche = nouvelleRecherche;
// if (this.timerRecherche) {
// clearTimeout(this.timerRecherche);
// }
// this.timerRecherche = setTimeout(() => {
// this.timerRecherche = undefined;
// this.render(true);
// }, 500);
// }
// })
// .change(async event =>
// this.options.recherche = this._optionRecherche(event.currentTarget)
// );
} }
showFilterGroup(groupDiv, show) { showFilterGroup(groupDiv, show) {
@ -200,14 +225,14 @@ export class FenetreRechercheTirage extends Application {
supprimerFiltres() { supprimerFiltres() {
this.html.find('input:is(.activate-filter-group,.activate-filter-milieu)').prop("checked", false); this.html.find('input:is(.activate-filter-group,.activate-filter-milieu)').prop("checked", false);
this.html.find('div.liste-resultats').html(''); this.html.find('div.liste-resultats-recherche').html('');
this.changeListeFiltresActifs(); this.html.find('.section-filters-text input.recherche').val('');
} }
async recherche() { async recherche() {
const table = await this.buildTable(); const table = await this.buildTable();
const htmlResultats = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats.hbs`, { resultats: table }); const htmlResultats = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/tirage/liste-resultats-recherche.hbs`, { resultats: table });
this.html.find('div.liste-resultats').html(htmlResultats); this.html.find('div.liste-resultats-recherche').html(htmlResultats);
this._dragDrop.forEach(dragDropHandler => dragDropHandler.bind(this.element[0])) this._dragDrop.forEach(dragDropHandler => dragDropHandler.bind(this.element[0]))
} }
@ -225,13 +250,19 @@ export class FenetreRechercheTirage extends Application {
} }
return (it, mi) => true; return (it, mi) => true;
} }
buildFilterRechercheName() {
const recherche = this.html.find('.section-filters-text input.recherche').val();
if (recherche) {
return (it, mi) => Grammar.includesLowerCaseNoAccent(it.name, recherche);
}
return (it, mi) => true;
}
buildCheckedGroupFilter(milieux) { buildCheckedGroupFilter(milieux) {
const filtersList = this.getGroupCheckedFilters() const filtersList = this.getGroupCheckedFilters()
.map(gf => this.buildOrFilter(gf.filters.map(f => f.check))); .map(gf => this.buildOrFilter(gf.filters.map(f => f.check)));
if (milieux) { filtersList.push(this.buildMilieuxFilter(milieux));
filtersList.push(this.buildMilieuxFilter(milieux)); filtersList.push(this.buildFilterRechercheName());
}
return this.buildAndFilter(filtersList) return this.buildAndFilter(filtersList)
} }

View File

@ -988,7 +988,7 @@ ul, li {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.sheet input.recherche { :is(.sheet, div.fenetre-recherche div.section-filters-text) input.recherche {
background-image: url("img/ui/icon-search.svg"); background-image: url("img/ui/icon-search.svg");
background-position: 0.1rem 0.1rem; background-position: 0.1rem 0.1rem;
background-size: 1rem; background-size: 1rem;
@ -1962,26 +1962,26 @@ div.vl {
width: 1px; width: 1px;
flex-grow: 0; flex-grow: 0;
} }
div.fenetre-recherche div.recherche { div.fenetre-recherche div.zone-recherche {
display: flex; display: flex;
} }
div.fenetre-recherche div.recherche div.filtres { div.fenetre-recherche div.zone-recherche div.filtres {
width: fit-content; width: fit-content;
min-width: 200px; min-width: 200px;
float: left; float: left;
} }
div.fenetre-recherche div.titre-fenetre-recherche { div.fenetre-recherche div.titre-resultats-recherche {
flex-basis: 0; flex-basis: 0;
max-height: fit-content; max-height: fit-content;
} }
div.fenetre-recherche div.liste-resultats { div.fenetre-recherche div.liste-resultats-recherche {
display: flex; display: flex;
flex: auto; flex: auto;
flex-flow: row wrap; flex-flow: row wrap;
flex-direction: row; flex-direction: row;
align-content: flex-start ; align-content: flex-start ;
} }
div.fenetre-recherche div.liste-resultats div.resultat { div.fenetre-recherche div.liste-resultats-recherche div.resultat {
width: fit-content; width: fit-content;
margin: 0.2rem 0.5rem; margin: 0.2rem 0.5rem;
} }

View File

@ -1,8 +1,8 @@
{ {
"id": "foundryvtt-reve-de-dragon", "id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"version": "10.6.7", "version": "10.6.8",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.7.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.8.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",

View File

@ -7,12 +7,16 @@
<span class="liste-filtres-actifs"></span> <span class="liste-filtres-actifs"></span>
</div> </div>
<hr> <hr>
<div class="recherche"> <div class="zone-recherche">
<div class="filtres"> <div class="filtres">
<div class="titre-fenetre-recherche"> <div class="titre-resultats-recherche">
<h3>Filtres</h3> <h3>Filtres</h3>
</div> </div>
<div class="section-filters-text">
<h4>
<input class="recherche flex-grow" type="text" value="{{options.recherche.text}}" name="recherche" size="8" data-dtype="String" placeholder=""/>
</h4>
</div>
<div class="section-filters-root"> <div class="section-filters-root">
<h4> <h4>
<a class="section-filters-toggle">Milieux <a class="section-filters-toggle">Milieux
@ -56,10 +60,10 @@
</div> </div>
<div class="vl"></div> <div class="vl"></div>
<div class="resultats"> <div class="resultats">
<div class="titre-fenetre-recherche"> <div class="titre-resultats-recherche">
<h3>Résultat de recherche</h3> <h3>Résultat de recherche</h3>
</div> </div>
<div class="liste-resultats"> <div class="liste-resultats-recherche">
</div> </div>
</div> </div>