Merge pull request 'Recherche dans l'inventaire' (#623) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10
Reviewed-on: #623
This commit is contained in:
commit
c6c0dd43fd
@ -66,9 +66,9 @@ export class RdDActorSheet extends RdDBaseActorSheet {
|
|||||||
formData.calc.fatigue = RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max);
|
formData.calc.fatigue = RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max);
|
||||||
|
|
||||||
formData.competences.forEach(item => {
|
formData.competences.forEach(item => {
|
||||||
item.system.isVisible = this.options.recherche
|
item.system.isHidden = this.options.recherche
|
||||||
? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
|
? !item.isNomLike(this.options.recherche.text)
|
||||||
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
|
: (this.options.showCompNiveauBase && RdDItemCompetence.isNiveauBase(item));
|
||||||
RdDItemCompetence.levelUp(item, formData.system.compteurs.experience.value);
|
RdDItemCompetence.levelUp(item, formData.system.compteurs.experience.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -354,29 +354,6 @@ export class RdDActorSheet extends RdDBaseActorSheet {
|
|||||||
this.render(true);
|
this.render(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
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)
|
|
||||||
);
|
|
||||||
this.html.find('.vue-detaillee').click(async event => {
|
this.html.find('.vue-detaillee').click(async event => {
|
||||||
this.options.vueDetaillee = !this.options.vueDetaillee;
|
this.options.vueDetaillee = !this.options.vueDetaillee;
|
||||||
this.render(true);
|
this.render(true);
|
||||||
@ -486,16 +463,6 @@ export class RdDActorSheet extends RdDBaseActorSheet {
|
|||||||
async createEmptyTache() {
|
async createEmptyTache() {
|
||||||
await this.actor.createItem('tache', 'Nouvelle tache');
|
await this.actor.createItem('tache', 'Nouvelle tache');
|
||||||
}
|
}
|
||||||
_optionRecherche(target) {
|
|
||||||
if (!target.value?.length) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
text: target.value,
|
|
||||||
start: target.selectionStart,
|
|
||||||
end: target.selectionEnd,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
_getEventArmeCombat(event) {
|
_getEventArmeCombat(event) {
|
||||||
const li = this.html.find(event.currentTarget)?.parents(".item");
|
const li = this.html.find(event.currentTarget)?.parents(".item");
|
||||||
|
@ -52,10 +52,30 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||||
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
||||||
|
this._appliquerRechercheObjets(formData.objets, formData.conteneurs, this.options.recherche);
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_appliquerRechercheObjets(objets, conteneurs, recherche) {
|
||||||
|
if (recherche) {
|
||||||
|
this._setConteneursVisibles(objets, conteneurs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_setConteneursVisibles(objets, conteneurs) {
|
||||||
|
const recherche = this.options.recherche;
|
||||||
|
const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id);
|
||||||
|
let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id)
|
||||||
|
do {
|
||||||
|
allVisible.push(...addVisible)
|
||||||
|
const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id)
|
||||||
|
addVisible = parentsIds.filter(id => !allVisible.includes(id))
|
||||||
|
}
|
||||||
|
while (addVisible.length > 0)
|
||||||
|
objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||||
|
conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static filterItemsPerTypeForSheet(formData, itemTypes) {
|
static filterItemsPerTypeForSheet(formData, itemTypes) {
|
||||||
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
|
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
|
||||||
@ -140,6 +160,38 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
this.html.find('.monnaie-moins').click(async event => {
|
this.html.find('.monnaie-moins').click(async event => {
|
||||||
this.actor.monnaieIncDec(this.getItemId(event), -1);
|
this.actor.monnaieIncDec(this.getItemId(event), -1);
|
||||||
});
|
});
|
||||||
|
this.html.find('.recherche')
|
||||||
|
.each((index, field) => {
|
||||||
|
this._rechercheSelectArea(field);
|
||||||
|
})
|
||||||
|
.keyup(async event => {
|
||||||
|
this._rechercherKeyup(event);
|
||||||
|
})
|
||||||
|
.change(async event =>
|
||||||
|
this.options.recherche = this._optionRecherche(event.currentTarget)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rechercherKeyup(event) {
|
||||||
|
const currentTarget = event.currentTarget;
|
||||||
|
const nouvelleRecherche = this._optionRecherche(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_rechercheSelectArea(field) {
|
||||||
|
if (this.options.recherche) {
|
||||||
|
field.focus();
|
||||||
|
field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemId(event) {
|
getItemId(event) {
|
||||||
@ -150,6 +202,16 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
return RdDSheetUtility.getItem(event, this.actor);
|
return RdDSheetUtility.getItem(event, this.actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_optionRecherche(target) {
|
||||||
|
if (!target.value?.length) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
text: target.value,
|
||||||
|
start: target.selectionStart,
|
||||||
|
end: target.selectionEnd,
|
||||||
|
};
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_getHeaderButtons() {
|
_getHeaderButtons() {
|
||||||
let buttons = super._getHeaderButtons();
|
let buttons = super._getHeaderButtons();
|
||||||
|
@ -190,15 +190,6 @@ export class RdDItemCompetence extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static isVisible(item) {
|
|
||||||
return Number(item.system.niveau) != RdDItemCompetence.getNiveauBase(item.system.categorie);
|
|
||||||
}
|
|
||||||
|
|
||||||
static nomContientTexte(item, texte) {
|
|
||||||
return Grammar.toLowerCaseNoAccent(item.name).includes(Grammar.toLowerCaseNoAccent(texte))
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static isNiveauBase(item) {
|
static isNiveauBase(item) {
|
||||||
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie);
|
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie);
|
||||||
@ -279,7 +270,7 @@ export class RdDItemCompetence extends Item {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static triVisible(competences) {
|
static triVisible(competences) {
|
||||||
return competences.filter(it => it.system.isVisible)
|
return competences.filter(it => !it.system.isHidden)
|
||||||
.sort((a, b) => RdDItemCompetence.compare(a, b))
|
.sort((a, b) => RdDItemCompetence.compare(a, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +304,13 @@ export class RdDItem extends Item {
|
|||||||
return this.parent?.type == 'commerce';
|
return this.parent?.type == 'commerce';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isNomLike(texte) {
|
||||||
|
return Grammar.includesLowerCaseNoAccent(this.name, texte)
|
||||||
|
}
|
||||||
|
isNomTypeLike(texte) {
|
||||||
|
return this.isNomLike(texte) || Grammar.includesLowerCaseNoAccent(Misc.typeName(this.type, 'Item'), texte)
|
||||||
|
}
|
||||||
|
|
||||||
getQuantite() {
|
getQuantite() {
|
||||||
return this.isService() ? undefined : Math.round(this.system.quantite ?? 0)
|
return this.isService() ? undefined : Math.round(this.system.quantite ?? 0)
|
||||||
}
|
}
|
||||||
|
@ -1005,6 +1005,10 @@ ul, li {
|
|||||||
max-height: 1.2rem;
|
max-height: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.embed-inline {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|
||||||
.alterne-list > .list-item:hover {
|
.alterne-list > .list-item:hover {
|
||||||
background: rgba(100, 100, 50, 0.25);
|
background: rgba(100, 100, 50, 0.25);
|
||||||
}
|
}
|
||||||
|
@ -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.11",
|
"version": "10.6.12",
|
||||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.11.zip",
|
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.12.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",
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<i class="fa-regular fa-filter"></i> Filtrer
|
<i class="fa-regular fa-filter"></i> Filtrer
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</a></span>
|
</a></span>
|
||||||
<span>
|
<span class="embed-inline">
|
||||||
<input class="recherche flex-grow" type="text" value="{{options.recherche.text}}" name="recherche" size="8" data-dtype="String" placeholder=""/>
|
<input class="recherche flex-grow" type="text" value="{{options.recherche.text}}" name="recherche" size="8" data-dtype="String" placeholder=""/>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{{#if system.isVisible}}
|
{{#unless system.isHidden}}
|
||||||
<li class="item flexrow list-item {{#if system.isLevelUp}}xp-level-up tooltip{{/if}}" data-item-id="{{_id}}">
|
<li class="item flexrow list-item {{#if system.isLevelUp}}xp-level-up tooltip{{/if}}" data-item-id="{{_id}}">
|
||||||
<a class="competence-label" name="{{name}}">
|
<a class="competence-label" name="{{name}}">
|
||||||
<img class="sheet-competence-img" src="{{img}}"/>
|
<img class="sheet-competence-img" src="{{img}}"/>
|
||||||
@ -49,4 +49,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/unless}}
|
@ -1,3 +1,4 @@
|
|||||||
|
{{#unless item.system.isHidden}}
|
||||||
{{#if (or options.isObserver (ne item.type 'monnaie'))}}
|
{{#if (or options.isObserver (ne item.type 'monnaie'))}}
|
||||||
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
|
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
|
||||||
<span class="equipement-nom {{#if (eq item.type 'conteneur')}}conteneur-name{{/if}} ">
|
<span class="equipement-nom {{#if (eq item.type 'conteneur')}}conteneur-name{{/if}} ">
|
||||||
@ -43,3 +44,4 @@
|
|||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/unless}}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<h4>Equipement</h4>
|
<h4>Equipement</h4>
|
||||||
<span class="item-name">
|
<span class="item-name">
|
||||||
{{#if options.isOwned}}
|
{{#if options.isOwner}}
|
||||||
<a class="chat-card-button creer-un-objet">Nouvel objet</a>
|
<a class="chat-card-button creer-un-objet">Nouvel objet</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if options.isGM}}
|
{{#if options.isGM}}
|
||||||
<a class="chat-card-button nettoyer-conteneurs">Tout vider</a>
|
<a class="chat-card-button nettoyer-conteneurs">Tout vider</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
<span class="embed-inline">
|
||||||
|
<input class="recherche flex-grow" type="text" value="{{options.recherche.text}}" name="recherche" size="8" data-dtype="String" placeholder=""/>
|
||||||
|
</span>
|
||||||
{{#if calc.surEncombrementMessage}}<b>{{calc.surEncombrementMessage}}</b> ‐{{/if}}
|
{{#if calc.surEncombrementMessage}}<b>{{calc.surEncombrementMessage}}</b> ‐{{/if}}
|
||||||
Encombrement: {{numberFormat calc.encTotal decimals=2}} (max: {{system.attributs.encombrement.value}})
|
Encombrement: {{numberFormat calc.encTotal decimals=2}} (max: {{system.attributs.encombrement.value}})
|
||||||
{{#if (regle-optionnelle 'afficher-prix-joueurs')}}
|
{{#if (regle-optionnelle 'afficher-prix-joueurs')}}
|
||||||
|
Loading…
Reference in New Issue
Block a user