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 => {
RdDUtility.selectTypeOeuvre(this);
});
html.find('#nettoyer-conteneurs').click(async event => {
html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
});

View File

@ -125,7 +125,7 @@ export class RdDActorVehiculeSheet extends ActorSheet {
html.find('.creer-un-objet').click(async event => {
RdDUtility.selectObjetType(this);
});
html.find('#nettoyer-conteneurs').click(async event => {
html.find('.nettoyer-conteneurs').click(async event => {
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') */
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 = [];
for (let item of this.items) {
if (item.estContenu) {
@ -1176,6 +1181,8 @@ export class RdDActor extends Actor {
await this.updateEmbeddedDocuments('Item', corrections);
}
}
});
}
async processDropItem(params) {
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({
title: options.title ?? 'Confirmer la suppression',
content: `<p>Etes vous certain de vouloir supprimer ${options.supprimer ?? 'cet objet'} ?</p>`,
title: options.title,
content: options.content,
buttons: {
delete: {
action: {
icon: '<i class="fas fa-check"></i>',
label: options.deleteLabel ?? 'Supprimer',
label: options.buttonLabel,
callback: () => {
options.onDelete();
RdDUtility.slideOnDelete(sheet, htmlToDelete);
options.onAction();
}
},
cancel: {
@ -880,12 +879,14 @@ export class RdDUtility {
/* -------------------------------------------- */
static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete) {
RdDUtility.confirmerSuppression(sheet, htmlToDelete,{
supprimer: "le lien vers le véhicule/monture/suivant : " + subActor.name,
deleteLabel: "Supprimer le lien",
onDelete: () => {
console.log("Delete : ", subActor.id);
RdDUtility.confirmer({
content: `<p>Etes vous certain de vouloir supprimer le lien vers le véhicule/monture/suivant : ${subActor.name} ?</p>`,
title: 'Confirmer la suppression',
buttonLabel: 'Supprimer le lien',
onAction: () => {
console.log('Delete : ', subActor.id);
sheet.actor.removeSubacteur(subActor.id);
RdDUtility.slideOnDelete(sheet, htmlToDelete);
}
})
}
@ -898,13 +899,13 @@ export class RdDUtility {
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 = {
delete: {
icon: '<i class="fas fa-check"></i>',
label: "Supprimer l'objet",
callback: () => {
console.log("Delete : ", itemId);
console.log('Delete : ', itemId);
sheet.actor.deleteEmbeddedDocuments('Item', [itemId], { renderSheet: false });
RdDUtility.slideOnDelete(sheet, htmlToDelete);
}