From 7cce58d895f4b1d7afdb7cbdc1c0294c58391c1b Mon Sep 17 00:00:00 2001 From: sladecraven Date: Thu, 10 Dec 2020 20:14:35 +0100 Subject: [PATCH] #52 : Debut gestion astrologie --- module/rdd-astrologie-editeur.js | 45 +++++++++++++++++++++ module/rdd-calendrier.js | 30 +++++++++++++- styles/simple.css | 2 + templates/calendar-astrologie-template.html | 22 ++++++++++ templates/calendar-template.html | 1 + 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 module/rdd-astrologie-editeur.js create mode 100644 templates/calendar-astrologie-template.html diff --git a/module/rdd-astrologie-editeur.js b/module/rdd-astrologie-editeur.js new file mode 100644 index 00000000..6451ba9e --- /dev/null +++ b/module/rdd-astrologie-editeur.js @@ -0,0 +1,45 @@ +import { Misc } from "./misc.js"; + +/** + * Extend the base Dialog entity by defining a custom window to perform roll. + * @extends {Dialog} + */ +export class RdDAstrologieEditeur extends Dialog { + + /* -------------------------------------------- */ + constructor(html, calendrier, calendrierData) { + + let myButtons = { + saveButton: { label: "Enregistrer", callback: html => this.fillData() } + }; + + // Common conf + let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" }; + let dialogOptions = { classes: ["rdddialog"], width: 800, height: 300, 'z-index': 99999 } + super(dialogConf, dialogOptions) + + this.calendrier = calendrier; + this.updateData( calendrierData ); + } + + /* -------------------------------------------- */ + fillData( ) { + } + + /* -------------------------------------------- */ + updateData( calendrierData ) { + this.calendrierData = duplicate(calendrierData); + } + + /* -------------------------------------------- */ + activateListeners(html) { + super.activateListeners(html); + + let astrologieData = this.astrologieData; + + $(function () { + }); + + } + +} diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index c2fe6656..11e1e5a5 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -1,5 +1,6 @@ /* -------------------------------------------- */ import { RdDCalendrierEditeur } from "./rdd-calendrier-editeur.js"; +import { RdDAstrologieEditeur } from "./rdd-astrologie-editeur.js"; /* -------------------------------------------- */ const heuresList = [ "vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant" ]; @@ -69,6 +70,13 @@ export class RdDCalendrier extends Application { return options; } + /* -------------------------------------------- */ + getDateFromIndex( index ) { + let month = Math.ceil(index / 28); + let day = index - (month*28); + return day+"/"+heuresList[month]; + } + /* -------------------------------------------- */ getCurrentDayIndex( ) { return (this.calendrier.moisRdD * 28) + this.calendrier.jour; @@ -241,7 +249,7 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async showCalendarEditor() { + async showCalendarEditor() { let calendrierData = duplicate( this.fillCalendrierData( ) ); if ( this.editeur == undefined ) { calendrierData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index); @@ -254,6 +262,22 @@ export class RdDCalendrier extends Application { this.editeur.render(true); } + /* -------------------------------------------- */ + async showAstrologieEditor() { + let calendrierData = duplicate( this.fillCalendrierData( ) ); + calendrierData.astrologieData = duplicate( this.listeNombreAstral ); + for (let index in calendrierData.astrologieData ) { + let astralData = calendrierData.astrologieData[index]; + astralData.humanDate = this.getDateFromIndex( index ); + } + if ( this.astrologieEditeur == undefined ) { + let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-astrologie-template.html', calendrierData ); + this.astrologieEditeur = new RdDAstrologieEditeur(html, this, calendrierData ) + } + this.astrologieEditeur.updateData( calendrierData ); + this.astrologieEditeur.render(true); + } + /* -------------------------------------------- */ /** @override */ activateListeners(html) { @@ -305,6 +329,10 @@ export class RdDCalendrier extends Application { ev.preventDefault(); this.showCalendarEditor(); }); + html.find('#astrologie-btn-edit').click(ev => { + ev.preventDefault(); + this.showAstrologieEditor(); + }); html.find('#calendar--move-handle').mousedown(ev => { ev.preventDefault(); diff --git a/styles/simple.css b/styles/simple.css index 41d119e7..1a0ae392 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -978,12 +978,14 @@ ul, li { margin: 2px; grid-row-gap: 3px; } +#astrologie-btn-edit, #calendar-btn-edit{ grid-row: 1; grid-column: 1; margin: auto; color: rgba(0, 0, 0, 0.5); } +#astrologie-btn-edit:hover, #calendar-btn-edit:hover { color: #FFF; border: 0px solid #000; diff --git a/templates/calendar-astrologie-template.html b/templates/calendar-astrologie-template.html new file mode 100644 index 00000000..40c35459 --- /dev/null +++ b/templates/calendar-astrologie-template.html @@ -0,0 +1,22 @@ +
+
+
+

Astrologie

+
+
+ + {{!-- Sheet Body --}} +
+
+ + + + {{#each astrologieData as |nombreData key|}} + + {{/each}} + +
{{nombreData.humanDate}} - {{nombreData.nombreAstral}}
+
+
+ +
diff --git a/templates/calendar-template.html b/templates/calendar-template.html index 269c5e06..a5feef09 100644 --- a/templates/calendar-template.html +++ b/templates/calendar-template.html @@ -1,6 +1,7 @@
+

Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})