Arrêter d'utiliser le jQuery $(selector) qui cause des effets de bord si plusieurs élements de la page (ie: foundry) correspondent au selector. Stocker le html dans les Sheet/Dialogs lors de l'appel activateListeners afin de pouvoir s'y référer ensuite. Utiliser this.html.find pour chercher dans le html de la fenêtre courante. Eliminer les référence par id html car l'id est unique (donc ne marche pas en multi-fenêtres)
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 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 }
 | |
|     super(dialogConf, dialogOptions)
 | |
| 
 | |
|     this.calendrier = calendrier;
 | |
|     this.calendrierData = calendrierData;
 | |
|   }
 | |
| 
 | |
|   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);
 | |
|     this.html.find("select[name='minutesRelative']").val(calendrierData.minutesRelative);
 | |
|     this.html.find("select[name='annee']").val(this.calendrierData.annee);
 | |
|   }
 | |
| 
 | |
|   /* -------------------------------------------- */
 | |
|   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)
 | |
|   }
 | |
| 
 | |
|   /* -------------------------------------------- */
 | |
|   updateData(calendrierData) {
 | |
|     this.calendrierData = duplicate(calendrierData);
 | |
|   }
 | |
| 
 | |
| }
 |