Chronologie et année

Fix jour dans chronologie
Permettre de saisir l'année
This commit is contained in:
Vincent Vandemeulebrouck 2022-11-25 03:17:07 +01:00
parent 8667d77169
commit c435bfa343
5 changed files with 42 additions and 32 deletions

View File

@ -16,13 +16,15 @@ export class DialogChronologie extends Dialog {
});
}
static async create() {
const dateRdD = game.system.rdd.calendrier.getCalendrier();
const dialogData = {
auteur: game.user.name,
isGM: game.user.isGM,
information: "",
journalId: game.settings.get(SYSTEM_RDD, LATEST_USED_JOURNAL_ID),
journaux: game.journal.filter(it => it.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)),
dateRdD: game.system.rdd.calendrier.getCalendrier(),
dateRdD: dateRdD,
jourRdD: dateRdD.jour +1,
heureRdD: game.system.rdd.calendrier.getCurrentHeure(),
dateReel: DialogChronologie.getCurrentDateTime()
};
@ -90,7 +92,7 @@ export class DialogChronologie extends Dialog {
auteur: $("form.rdddialogchrono :input[name='auteur']").val(),
information: $("form.rdddialogchrono :input[name='information']").val(),
dateRdD: {
jour: $("form.rdddialogchrono :input[name='dateRdD.jour']").val(),
jour: $("form.rdddialogchrono :input[name='jourRdD']").val(),
moisRdD: $("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(),
annee: $("form.rdddialogchrono :input[name='dateRdD.annee']").val()
},

View File

@ -12,45 +12,47 @@ export class RdDCalendrierEditeur extends Dialog {
content: html,
title: "Editeur de date/heure",
buttons: {
save: { label: "Enregistrer", callback: html => this.fillData() }
},
save: { label: "Enregistrer", callback: html => this.fillData() }
},
default: "save"
};
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 'fit-content', 'z-index': 99999 }
let dialogOptions = { classes: ["rdd-dialog-calendar-editor"], width: 400, height: 'fit-content', 'z-index': 99999 }
super(dialogConf, dialogOptions)
this.calendrier = calendrier;
this.calendrierData = calendrierData;
}
/* -------------------------------------------- */
fillData( ) {
this.calendrierData.moisKey = $("#nomMois").val();
this.calendrierData.heureKey = $("#nomHeure").val();
this.calendrierData.jourMois = $("#jourMois").val();
this.calendrierData.minutesRelative = $("#minutesRelative").val();
fillData() {
this.calendrierData.annee = $("input[name='annee']").val();
this.calendrierData.moisKey = $("select[name='nomMois']").val();
this.calendrierData.heureKey = $("select[name='nomHeure']").val();
this.calendrierData.jourMois = $("select[name='jourMois']").val();
this.calendrierData.minutesRelative = $("select[name='minutesRelative']").val();
console.log("UPDATE ", this.calendrierData);
this.calendrier.saveEditeur( this.calendrierData )
this.calendrier.saveEditeur(this.calendrierData)
}
/* -------------------------------------------- */
updateData( calendrierData ) {
updateData(calendrierData) {
this.calendrierData = duplicate(calendrierData);
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
let calendrierData = this.calendrierData;
$(function () {
console.log(calendrierData);
$("#nomMois").val(calendrierData.moisKey);
$("#nomHeure").val(calendrierData.heureKey);
$("#jourMois").val(calendrierData.jourMois);
$("#minutesRelative").val(calendrierData.minutesRelative);
$("input[name='nomMois']").val(calendrierData.moisKey);
$("select[name='nomHeure']").val(calendrierData.heureKey);
$("select[name='jourMois']").val(calendrierData.jourMois);
$("select[name='minutesRelative']").val(calendrierData.minutesRelative);
$("select[name='annee']").val(calendrierData.annee);
});
}

View File

@ -116,7 +116,7 @@ export class RdDCalendrier extends Application {
game.settings.set(SYSTEM_RDD, "calendrier", this.calendrier);
this.listeNombreAstral = this.getListeNombreAstral();
this.rebuildListeNombreAstral(false); // Ensure always up-to-date
this.rebuildListeNombreAstral(HIDE_DICE); // Ensure always up-to-date
}
console.log('RdDCalendrier.constructor()', this.calendrier, this.calendrierPos, this.listeNombreAstral);
}
@ -210,12 +210,13 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
getNombreAstral(indexDate) {
let astralData = this.getListeNombreAstral().find((nombreAstral, i) => nombreAstral.index == indexDate);
const listNombreAstral = this.getListeNombreAstral();
let astralData = listNombreAstral.find((nombreAstral, i) => nombreAstral.index == indexDate);
return astralData?.nombreAstral;
}
/* -------------------------------------------- */
async rebuildListeNombreAstral(showDice = SHOW_DICE) {
async rebuildListeNombreAstral(showDice = HIDE_DICE) {
if (Misc.isUniqueConnectedGM()) {
let jourCourant = this.getCurrentDayIndex();
let newList = [];
@ -228,9 +229,8 @@ export class RdDCalendrier extends Application {
newList[i] = await this.ajouterNombreAstral(dayIndex, showDice);
}
}
//console.log("SAVE list", newList, jourCourant);
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", newList);
this.listeNombreAstral = newList;
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
}
}
@ -323,6 +323,7 @@ export class RdDCalendrier extends Application {
formData.moisKey = mois.key;
formData.jourMois = this.calendrier.jour + 1;
formData.nomMois = mois.label; // heures et mois nommés identiques
formData.annee = this.calendrier.annee;
formData.iconMois = dossierIconesHeures + mois.icon;
formData.nomHeure = heure.label;
formData.iconHeure = dossierIconesHeures + heure.icon;
@ -471,7 +472,7 @@ export class RdDCalendrier extends Application {
updateDisplay() {
let calendrier = this.fillCalendrierData();
// Rebuild text du calendrier
let dateHTML = `Jour ${calendrier.jourMois} de ${calendrier.nomMois} (${calendrier.nomSaison})`
let dateHTML = `${calendrier.jourMois} ${calendrier.nomMois} ${calendrier.annee} (${calendrier.nomSaison})`
if (game.user.isGM) {
dateHTML = dateHTML + " - NA: " + (this.getCurrentNombreAstral() ?? "indéterminé");
}
@ -494,6 +495,7 @@ export class RdDCalendrier extends Application {
this.calendrier.minutesRelative = Number(calendrierData.minutesRelative);
this.calendrier.jour = Number(calendrierData.jourMois) - 1;
this.calendrier.moisRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.moisKey);
this.calendrier.annee = Number(calendrierData.annee);
this.calendrier.heureRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.heureKey);
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off">
<form class="rdd-dialog-calendar-editor" autocomplete="off">
<header class="sheet-header">
<div class="header-fields">
<h1 class="charname">Edition du Calendrier</h1>
@ -7,9 +7,13 @@
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
<label for="annee">Année</label>
<input type="text" name="annee" value="{{annee}}" data-dtype="Number" min="0"/>
</div>
<div class="form-group">
<label for="mois">Mois</label>
<select name="nomMois" id="nomMois" data-dtype="String">
<select name="nomMois" data-dtype="String">
{{#select nomMois}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}}
@ -17,7 +21,7 @@
</div>
<div class="form-group">
<label for="jour">Jour du mois </label>
<select name="jourMois" id="jourMois" data-dtype="String">
<select name="jourMois" data-dtype="String">
{{#select jourMois}}
{{#each jourMoisOptions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0}}</option>
@ -27,7 +31,7 @@
</div>
<div class="form-group">
<label for="heure">Heure Draconique</label>
<select name="nomHeure" id="nomHeure" data-dtype="String">
<select name="nomHeure" data-dtype="String">
{{#select nomHeure}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}}
@ -35,7 +39,7 @@
</div>
<div class="form-group">
<label for="minutesRelative">Minutes</label>
<select name="minutesRelative" id="minutesRelative" data-dtype="String">
<select name="minutesRelative" data-dtype="String">
{{#select minutesRelative}}
{{#each minutesOptions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0}}</option>

View File

@ -17,9 +17,9 @@
</select>
</div>
<div class="form-group">
<label for="dateRdD.jour">Date en jeu</label>
<label for="jourRdD">Date en jeu</label>
<span class="flexrow">
<input type="text" name="dateRdD.jour" value="{{dateRdD.jour}}" data-dtype="Number" min="1" max="28"/>
<input type="text" name="jourRdD" value="{{jourRdD}}" data-dtype="Number" min="1" max="28"/>
<select type="text" name="dateRdD.moisRdD.key" value="{{dateRdD.moisRdD.key}}" data-dtype="String" >
{{#select dateRdD.moisRdD.key}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}