feat: notes de bord et sauvegarde position calendrier
- bouton crayon sur la fenêtre calendrier (MJ) → dialogue de note - date impériale + date réelle préremplies - append au journal configuré (créé auto si inexistant) - appendJournalNote : labels passés depuis l'ouverture (pas de re-lecture) - échappement XSS via jQuery .text().html() - onSave async + await + try/catch - sauvegarde position calendrier (client scope, debounced 300ms) - restore position au constructeur - close() async avec await settings.set - boutons note et config groupés dans .mgt2-cal-actions (flex row)
This commit is contained in:
+35
-2
@@ -22,10 +22,16 @@ export class CalendarApp extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
},
|
||||
};
|
||||
|
||||
constructor({ onConfig, onClose } = {}) {
|
||||
constructor({ onConfig, onClose, onNote } = {}) {
|
||||
super();
|
||||
const saved = game.settings?.get(MODULE_ID, 'calendarPosition');
|
||||
if (saved?.left != null && saved?.top != null) {
|
||||
this.position.left = saved.left;
|
||||
this.position.top = saved.top;
|
||||
}
|
||||
this._onConfig = onConfig;
|
||||
this._onClose = onClose;
|
||||
this._onNote = onNote;
|
||||
this._data = { year: 1116, day: 1, hour: 12, minute: 0, planet: '' };
|
||||
}
|
||||
|
||||
@@ -46,6 +52,26 @@ export class CalendarApp extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
html.find('.mgt2-cal-config-btn').on('click', () => {
|
||||
this._onConfig?.();
|
||||
});
|
||||
html.find('.mgt2-cal-note-btn').on('click', () => {
|
||||
this._onNote?.();
|
||||
});
|
||||
}
|
||||
|
||||
setPosition(position) {
|
||||
const result = super.setPosition(position);
|
||||
this._debouncedSavePos();
|
||||
return result;
|
||||
}
|
||||
|
||||
_debouncedSavePos() {
|
||||
if (this._savePosTimeout) clearTimeout(this._savePosTimeout);
|
||||
this._savePosTimeout = setTimeout(() => {
|
||||
game.settings?.set(MODULE_ID, 'calendarPosition', {
|
||||
left: this.position.left,
|
||||
top: this.position.top,
|
||||
});
|
||||
this._savePosTimeout = null;
|
||||
}, 300);
|
||||
}
|
||||
|
||||
updateDisplay(data) {
|
||||
@@ -53,8 +79,15 @@ export class CalendarApp extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
this.render();
|
||||
}
|
||||
|
||||
close() {
|
||||
async close() {
|
||||
if (game.settings) {
|
||||
await game.settings.set(MODULE_ID, 'calendarPosition', {
|
||||
left: this.position.left,
|
||||
top: this.position.top,
|
||||
});
|
||||
}
|
||||
this._onConfig = null;
|
||||
this._onNote = null;
|
||||
this._onClose?.();
|
||||
this._onClose = null;
|
||||
return super.close();
|
||||
|
||||
Reference in New Issue
Block a user