nodebb-plugin-onekite-calendar 2.0.43 → 2.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-calendar",
3
- "version": "2.0.43",
3
+ "version": "2.0.44",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "acpScripts": [
40
40
  "public/admin.js"
41
41
  ],
42
- "version": "2.0.43"
42
+ "version": "2.0.44"
43
43
  }
package/public/client.js CHANGED
@@ -110,6 +110,11 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
110
110
  // Current FullCalendar instance (for refresh after actions)
111
111
  let currentCalendar = null;
112
112
 
113
+ // The creation chooser handler is created inside init() (it needs the
114
+ // calendar instance and capability flags). The mobile FAB is mounted outside
115
+ // init(), so we store the handler here.
116
+ let createFromSelectionHandler = null;
117
+
113
118
  // Mobile FAB (mounted only on the calendar page)
114
119
  let fabEl = null;
115
120
  let fabHandler = null;
@@ -208,7 +213,8 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
208
213
  return opts.join('');
209
214
  }
210
215
 
211
- async function openSpecialEventDialog(selectionInfo) {
216
+ async function openSpecialEventDialog(selectionInfo, opts) {
217
+ const kind = (opts && opts.kind) ? String(opts.kind) : 'special';
212
218
  const start = selectionInfo.start;
213
219
  // FullCalendar can omit `end` for certain interactions. Also, for all-day
214
220
  // selections, `end` is exclusive (next day at 00:00). We normalise below
@@ -259,10 +265,13 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
259
265
 
260
266
  const seStartTime = timeString(seStart);
261
267
  const seEndTime = timeString(seEnd);
268
+ const defaultTitlePlaceholder = kind === 'outing' ? 'Prévision de sortie' : 'Ex: ...';
269
+ const defaultTitleValue = kind === 'outing' ? 'Prévision de sortie' : '';
270
+
262
271
  const html = `
263
272
  <div class="mb-3">
264
273
  <label class="form-label">Titre</label>
265
- <input type="text" class="form-control" id="onekite-se-title" placeholder="Ex: ..." />
274
+ <input type="text" class="form-control" id="onekite-se-title" value="${escapeHtml(defaultTitleValue)}" placeholder="${escapeHtml(defaultTitlePlaceholder)}" />
266
275
  </div>
267
276
  <div class="row g-2">
268
277
  <div class="col-12 col-md-6">
@@ -307,7 +316,7 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
307
316
  return await new Promise((resolve) => {
308
317
  let resolved = false;
309
318
  const dialog = bootbox.dialog({
310
- title: 'Créer un évènement',
319
+ title: kind === 'outing' ? 'Créer une prévision de sortie' : 'Créer un évènement',
311
320
  message: html,
312
321
  buttons: {
313
322
  cancel: {
@@ -430,8 +439,9 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
430
439
 
431
440
 
432
441
  async function openOutingDialog(selectionInfo) {
433
- // Same UI as special events, but saved as "Sorties" (prévisions).
434
- const payload = await openSpecialEventDialog(selectionInfo);
442
+ // Same UI as special events, but saved as "Sorties" (prévisions) and with
443
+ // a different title.
444
+ const payload = await openSpecialEventDialog(selectionInfo, { kind: 'outing' });
435
445
  if (!payload) return null;
436
446
  // Default title if empty
437
447
  if (!payload.title) payload.title = 'Prévision de sortie';
@@ -1391,6 +1401,9 @@ function toDatetimeLocalValue(date) {
1391
1401
  });
1392
1402
  }
1393
1403
 
1404
+ // Expose to the mobile FAB (mounted outside init).
1405
+ createFromSelectionHandler = handleCreateFromSelection;
1406
+
1394
1407
  calendar = new FullCalendar.Calendar(el, {
1395
1408
  initialView: 'dayGridMonth',
1396
1409
  height: 'auto',
@@ -2368,7 +2381,12 @@ function parseYmdDate(ymdStr) {
2368
2381
  fabEl.setAttribute('aria-label', 'Nouvelle réservation');
2369
2382
  fabEl.innerHTML = '<i class="fa fa-plus"></i>';
2370
2383
 
2371
- fabHandler = () => openFabDatePicker(handleCreateFromSelection);
2384
+ fabHandler = () => {
2385
+ // init() sets createFromSelectionHandler. If the calendar has not
2386
+ // finished initialising, do nothing.
2387
+ if (typeof createFromSelectionHandler !== 'function') return;
2388
+ openFabDatePicker(createFromSelectionHandler);
2389
+ };
2372
2390
  fabEl.addEventListener('click', fabHandler);
2373
2391
 
2374
2392
  document.body.appendChild(fabEl);