foundryvtt-reve-de-dragon/module/rdd-calendrier-editeur.js

53 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-12-08 21:40:41 +01:00
import { Misc } from "./misc.js";
/**
* Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog}
*/
export class RdDCalendrierEditeur extends Dialog {
/* -------------------------------------------- */
constructor(html, calendrier, calendrierData) {
let dialogConf = {
content: html,
title: "Editeur de date/heure",
buttons: {
save: { label: "Enregistrer", callback: html => this.fillData() }
},
default: "save"
};
let dialogOptions = { classes: ["rdd-dialog-calendar-editor"], width: 400, height: 'fit-content', 'z-index': 99999 }
2020-12-08 21:40:41 +01:00
super(dialogConf, dialogOptions)
2020-12-08 21:40:41 +01:00
this.calendrier = calendrier;
this.calendrierData = calendrierData;
2020-12-08 21:40:41 +01:00
}
activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.html.find("input[name='nomMois']").val(this.calendrierData.moisKey);
this.html.find("select[name='nomHeure']").val(this.calendrierData.heureKey);
this.html.find("select[name='jourMois']").val(this.calendrierData.jourMois);
2022-12-20 00:52:32 +01:00
this.html.find("select[name='minutesRelative']").val(this.calendrierData.minutesRelative);
this.html.find("select[name='annee']").val(this.calendrierData.annee);
}
2020-12-08 21:40:41 +01:00
/* -------------------------------------------- */
fillData() {
this.calendrierData.annee = this.html.find("input[name='annee']").val();
this.calendrierData.moisKey = this.html.find("select[name='nomMois']").val();
this.calendrierData.heureKey = this.html.find("select[name='nomHeure']").val();
this.calendrierData.jourMois = this.html.find("select[name='jourMois']").val();
this.calendrierData.minutesRelative = this.html.find("select[name='minutesRelative']").val();
this.calendrier.saveEditeur(this.calendrierData)
2020-12-08 21:40:41 +01:00
}
/* -------------------------------------------- */
updateData(calendrierData) {
2020-12-08 21:40:41 +01:00
this.calendrierData = duplicate(calendrierData);
}
}