Ajout confirmation pour vider les conteneurs

This commit is contained in:
Vincent Vandemeulebrouck 2022-10-04 01:53:18 +02:00
parent d25c6b7f1c
commit efdc676776
4 changed files with 35 additions and 27 deletions

View File

@ -234,7 +234,7 @@ export class RdDActorSheet extends ActorSheet {
html.find('.creer-une-oeuvre').click(async event => { html.find('.creer-une-oeuvre').click(async event => {
RdDUtility.selectTypeOeuvre(this); RdDUtility.selectTypeOeuvre(this);
}); });
html.find('#nettoyer-conteneurs').click(async event => { html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs(); this.actor.nettoyerConteneurs();
}); });

View File

@ -125,7 +125,7 @@ export class RdDActorVehiculeSheet extends ActorSheet {
html.find('.creer-un-objet').click(async event => { html.find('.creer-un-objet').click(async event => {
RdDUtility.selectObjetType(this); RdDUtility.selectObjetType(this);
}); });
html.find('#nettoyer-conteneurs').click(async event => { html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs(); this.actor.nettoyerConteneurs();
}); });

View File

@ -1163,6 +1163,11 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
/** Fonction de remise à plat de l'équipement (ie vide les champs 'contenu') */ /** Fonction de remise à plat de l'équipement (ie vide les champs 'contenu') */
async nettoyerConteneurs() { async nettoyerConteneurs() {
RdDUtility.confirmer({
content: `<p>Etes vous certain de vouloir vider tous les conteneurs ?</p>`,
title: 'Vider les conteneurs',
buttonLabel: 'Vider',
onAction: async () => {
const corrections = []; const corrections = [];
for (let item of this.items) { for (let item of this.items) {
if (item.estContenu) { if (item.estContenu) {
@ -1176,6 +1181,8 @@ export class RdDActor extends Actor {
await this.updateEmbeddedDocuments('Item', corrections); await this.updateEmbeddedDocuments('Item', corrections);
} }
} }
});
}
async processDropItem(params) { async processDropItem(params) {
const targetActorId = this.id; const targetActorId = this.id;

View File

@ -855,17 +855,16 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static confirmerSuppression(sheet, htmlToDelete, options) { static confirmer(options) {
const d = new Dialog({ const d = new Dialog({
title: options.title ?? 'Confirmer la suppression', title: options.title,
content: `<p>Etes vous certain de vouloir supprimer ${options.supprimer ?? 'cet objet'} ?</p>`, content: options.content,
buttons: { buttons: {
delete: { action: {
icon: '<i class="fas fa-check"></i>', icon: '<i class="fas fa-check"></i>',
label: options.deleteLabel ?? 'Supprimer', label: options.buttonLabel,
callback: () => { callback: () => {
options.onDelete(); options.onAction();
RdDUtility.slideOnDelete(sheet, htmlToDelete);
} }
}, },
cancel: { cancel: {
@ -880,12 +879,14 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete) { static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete) {
RdDUtility.confirmerSuppression(sheet, htmlToDelete,{ RdDUtility.confirmer({
supprimer: "le lien vers le véhicule/monture/suivant : " + subActor.name, content: `<p>Etes vous certain de vouloir supprimer le lien vers le véhicule/monture/suivant : ${subActor.name} ?</p>`,
deleteLabel: "Supprimer le lien", title: 'Confirmer la suppression',
onDelete: () => { buttonLabel: 'Supprimer le lien',
console.log("Delete : ", subActor.id); onAction: () => {
console.log('Delete : ', subActor.id);
sheet.actor.removeSubacteur(subActor.id); sheet.actor.removeSubacteur(subActor.id);
RdDUtility.slideOnDelete(sheet, htmlToDelete);
} }
}) })
} }
@ -898,13 +899,13 @@ export class RdDUtility {
return; return;
} }
let msgTxt = "<p>Etes vous certain de vouloir supprimer cet objet ?"; let msgTxt = '<p>Etes vous certain de vouloir supprimer cet objet ?';
let buttons = { let buttons = {
delete: { delete: {
icon: '<i class="fas fa-check"></i>', icon: '<i class="fas fa-check"></i>',
label: "Supprimer l'objet", label: "Supprimer l'objet",
callback: () => { callback: () => {
console.log("Delete : ", itemId); console.log('Delete : ', itemId);
sheet.actor.deleteEmbeddedDocuments('Item', [itemId], { renderSheet: false }); sheet.actor.deleteEmbeddedDocuments('Item', [itemId], { renderSheet: false });
RdDUtility.slideOnDelete(sheet, htmlToDelete); RdDUtility.slideOnDelete(sheet, htmlToDelete);
} }