Ajout bouton Item diminuer quantité

Pour diminuer la quantité des objets multiples sans avoir à éditer
This commit is contained in:
Vincent Vandemeulebrouck 2023-03-30 02:56:06 +02:00
parent 2aa62cffe9
commit de56fa909a
5 changed files with 22 additions and 14 deletions

View File

@ -152,6 +152,8 @@ export class RdDBaseActorSheet extends ActorSheet {
const item = this.getItem(event);
RdDSheetUtility.splitItem(item, this.actor);
});
this.html.find('.item-quantite-plus').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), 1));
this.html.find('.item-quantite-moins').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), -1));
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, this.getItem(event)));
this.html.find('.item-vendre').click(async event => this.vendre(this.getItem(event)));
@ -161,12 +163,6 @@ export class RdDBaseActorSheet extends ActorSheet {
this.html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
});
this.html.find('.monnaie-plus').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), 1);
});
this.html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), -1);
});
}
_rechercherKeyup(event) {

View File

@ -150,11 +150,11 @@ export class RdDBaseActor extends Actor {
}
/* -------------------------------------------- */
async monnaieIncDec(id, value) {
let monnaie = this.getMonnaie(id);
if (monnaie) {
const quantite = Math.max(0, monnaie.system.quantite + value);
await this.updateEmbeddedDocuments('Item', [{ _id: monnaie.id, 'system.quantite': quantite }]);
async itemQuantiteIncDec(id, value) {
let item = this.getItem(id);
if (item && item.isInventaire()) {
const quantite = Math.max(0, item.system.quantite + value);
await this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'system.quantite': quantite }]);
}
}

View File

@ -209,6 +209,14 @@ export class RdDItemSheet extends ItemSheet {
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => this.render(true)));
this.html.find('.item-quantite-plus').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
this.render();
});
this.html.find('.item-quantite-moins').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
this.render();
});
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: duplicate(timestamp) })

View File

@ -15,7 +15,11 @@
</a>
{{/if}}
</span>
<span class="equipement-detail">{{item.system.quantite}}
<span class="equipement-detail">
{{#if (gt item.system.quantite 1)}}
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
{{/if}}
{{item.system.quantite}}
{{#if (gt item.system.quantite 1)}}
<a class="item-split" title="Séparer"><i class="fas fa-unlink"></i></a>
{{/if}}

View File

@ -10,7 +10,7 @@
</span>
{{#if @root.options.isOwner}}
<span class="equipement-button item-controls">
<a class="monnaie-moins"><i class="fas fa-minus-square"></i></a>
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
</span>
{{/if}}
<span class="equipement-detail">
@ -18,7 +18,7 @@
</span>
{{#if @root.options.isOwner}}
<span class="equipement-button item-controls">
<a class="monnaie-plus"><i class="fas fa-plus-square"></i></a>
<a class="item-quantite-plus"><i class="fas fa-plus-square"></i></a>
</span>
{{/if}}
<span class="equipement-actions item-controls">