Organiser la chronologie par date
This commit is contained in:
parent
f9fd8a1e24
commit
9c0d08cb6f
@ -80,8 +80,15 @@ export class DialogChronologie extends Dialog {
|
||||
await this.forceValidation();
|
||||
const { journalId, journalEntry } = this.findJournal();
|
||||
if (journalEntry?.canUserModify(game.user)) {
|
||||
const journalParameters = this.extractJournalParameters();
|
||||
|
||||
const jour = journalParameters.dateRdD.jour;
|
||||
const mois = journalParameters.dateRdD.mois.label;
|
||||
const annee = journalParameters.dateRdD.annee;
|
||||
const section = `${jour} ${mois} ${annee}`
|
||||
const content = await this.prepareChronologieEntry(journalParameters);
|
||||
// ajouter à la page ou créer une page
|
||||
this.addContentToJournal(journalEntry, await this.prepareChronologieEntry());
|
||||
this.addContentToJournal(journalEntry, section, content);
|
||||
this.storeLatestUsedJournalEntry(journalId);
|
||||
this.close();
|
||||
}
|
||||
@ -101,8 +108,8 @@ export class DialogChronologie extends Dialog {
|
||||
return { journalId, journalEntry };
|
||||
}
|
||||
|
||||
async prepareChronologieEntry() {
|
||||
return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", this.extractJournalParameters());
|
||||
async prepareChronologieEntry(journalParameters) {
|
||||
return await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/chronologie-entry.html", journalParameters);
|
||||
}
|
||||
|
||||
extractJournalParameters() {
|
||||
@ -120,19 +127,19 @@ export class DialogChronologie extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
addContentToJournal(journalEntry, content) {
|
||||
let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, 'Chronologie'));
|
||||
addContentToJournal(journalEntry, section, content) {
|
||||
let page = journalEntry.pages.find(p => p.type == 'text' && Grammar.equalsInsensitive(p.name, section));
|
||||
if (page) {
|
||||
page.update({ 'text.content': content + '\n' + page.text.content });
|
||||
page.update({ 'text.content': page.text.content + '\n' + content });
|
||||
}
|
||||
else {
|
||||
journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(content)]);
|
||||
journalEntry.createEmbeddedDocuments('JournalEntryPage', [this.newPageChronologie(section, content)]);
|
||||
}
|
||||
}
|
||||
|
||||
newPageChronologie(content) {
|
||||
newPageChronologie(section, content) {
|
||||
return new JournalEntryPage({
|
||||
name: 'Chronologie',
|
||||
name: section,
|
||||
type: 'text',
|
||||
title: { show: true, level: 1 },
|
||||
text: { content: content, format: 1 }
|
||||
|
@ -1,4 +1,4 @@
|
||||
<h2>{{dateRdD.jour}} {{dateRdD.mois.label}} {{dateRdD.annee}}, à l'heure de {{dateRdD.heure.label}}</h2>
|
||||
<h2>Heure de {{dateRdD.heure.label}}</h2>
|
||||
<p>{{information}}</p>
|
||||
<p class="poesie-reference">Par {{auteur}} ({{dateReel}})</p>
|
||||
<hr>
|
||||
|
Loading…
Reference in New Issue
Block a user