nodebb-plugin-equipment-calendar 0.2.9 → 0.3.1

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/library.js CHANGED
@@ -311,8 +311,8 @@ plugin.init = async function (params) {
311
311
 
312
312
  // Admin (ACP) routes
313
313
  if (mid && mid.admin) {
314
- router.get('/admin/plugins/equipment-calendar', mid.admin.buildHeader, renderAdminPage);
315
- router.get('/api/admin/plugins/equipment-calendar', renderAdminPage);
314
+ router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
315
+ router.get('/api/admin/plugins/equipment-calendar', middleware.applyCSRF, renderAdminPage);
316
316
  router.post('/admin/plugins/equipment-calendar/save', middleware.applyCSRF, handleAdminSave);
317
317
  }
318
318
 
@@ -393,8 +393,8 @@ plugin.addAdminNavigation = async function (header) {
393
393
  // --- Admin page routes (ACP) ---
394
394
  plugin.addAdminRoutes = async function (params) {
395
395
  const { router, middleware: mid } = params;
396
- router.get('/admin/plugins/equipment-calendar', mid.admin.buildHeader, renderAdminPage);
397
- router.get('/api/admin/plugins/equipment-calendar', renderAdminPage);
396
+ router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
397
+ router.get('/api/admin/plugins/equipment-calendar', middleware.applyCSRF, renderAdminPage);
398
398
  };
399
399
 
400
400
  async function renderAdminPage(req, res) {
@@ -402,6 +402,7 @@ async function renderAdminPage(req, res) {
402
402
  res.render('admin/plugins/equipment-calendar', {
403
403
  title: 'Equipment Calendar',
404
404
  settings,
405
+ saved: req.query && String(req.query.saved || '') === '1',
405
406
  view_dayGridMonth: (settings.defaultView || 'dayGridMonth') === 'dayGridMonth',
406
407
  view_timeGridWeek: (settings.defaultView || '') === 'timeGridWeek',
407
408
  view_timeGridDay: (settings.defaultView || '') === 'timeGridDay',
@@ -488,7 +489,6 @@ async function renderCalendarPage(req, res) {
488
489
  eventsB64: Buffer.from(JSON.stringify(events), 'utf8').toString('base64'),
489
490
  blocksB64: Buffer.from(JSON.stringify(blocks), 'utf8').toString('base64'),
490
491
  itemsB64: Buffer.from(JSON.stringify(items.map(i => ({ id: i.id, name: i.name, location: i.location }))), 'utf8').toString('base64'),
491
- csrf: req.csrfToken,
492
492
  });
493
493
  }
494
494
 
@@ -538,7 +538,6 @@ async function renderApprovalsPage(req, res) {
538
538
  title: 'Validation des réservations',
539
539
  rows,
540
540
  hasRows: Array.isArray(rows) && rows.length > 0,
541
- csrf: req.csrfToken,
542
541
  });
543
542
  }
544
543
 
@@ -710,7 +709,7 @@ async function handleAdminSave(req, res) {
710
709
  };
711
710
 
712
711
  await meta.settings.set(SETTINGS_KEY, values);
713
- return res.redirect('/admin/plugins/equipment-calendar');
712
+ return res.redirect('/admin/plugins/equipment-calendar?saved=1');
714
713
  } catch (e) {
715
714
  return res.status(500).send(e.message || 'error');
716
715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-equipment-calendar",
3
- "version": "0.2.9",
3
+ "version": "0.3.1",
4
4
  "description": "Equipment reservation calendar for NodeBB (FullCalendar, approvals, HelloAsso payments)",
5
5
  "main": "library.js",
6
6
  "scripts": {
package/plugin.json CHANGED
@@ -26,6 +26,6 @@
26
26
  "scripts": [
27
27
  "public/js/client.js"
28
28
  ],
29
- "version": "0.2.1",
29
+ "version": "0.2.4",
30
30
  "minver": "4.7.1"
31
31
  }
@@ -75,8 +75,17 @@
75
75
  // show modal
76
76
  const modalEl = document.getElementById('ecReserveModal');
77
77
  if (!modalEl) return;
78
- const modal = bootstrap ? bootstrap.Modal.getOrCreateInstance(modalEl) : null;
79
- if (modal) modal.show();
78
+ if (typeof bootstrap !== 'undefined' && bootstrap.Modal) {
79
+ const modal = bootstrap.Modal.getOrCreateInstance(modalEl);
80
+ modal.show();
81
+ } else {
82
+ // Fallback: no bootstrap JS available, just submit directly if there is an available item
83
+ if (hasAny) {
84
+ if (confirm('Envoyer la demande de réservation pour cette plage ?')) {
85
+ form.submit();
86
+ }
87
+ }
88
+ }
80
89
  }
81
90
 
82
91
  function initCalendar() {
@@ -1,8 +1,22 @@
1
1
  <div class="acp-page-container">
2
2
  <h1>Equipment Calendar</h1>
3
3
 
4
- <form method="post" action="/admin/plugins/equipment-calendar/save" class="mb-3">
5
- <input type="hidden" name="_csrf" value="{csrf}">
4
+ {{{ if saved }}}
5
+ <div class="alert alert-success">Paramètres enregistrés.</div>
6
+ <script>
7
+ (function () {
8
+ try {
9
+ if (window.app && window.app.alertSuccess) {
10
+ window.app.alertSuccess('Paramètres enregistrés');
11
+ }
12
+ } catch (e) {}
13
+ }());
14
+ </script>
15
+ {{{ end }}}
16
+
17
+
18
+ <form id="ec-admin-form" method="post" action="/admin/plugins/equipment-calendar/save" class="mb-3">
19
+ <input type="hidden" name="_csrf" value="{config.csrf_token}">
6
20
 
7
21
  <div class="alert alert-warning">
8
22
  Le champ "Matériel" doit être un JSON valide (array). Exemple :
@@ -60,6 +74,25 @@
60
74
  <div class="mb-3"><label class="form-label">Timezone</label><input name="timezone" class="form-control" value="{settings.timezone}"></div>
61
75
  </div>
62
76
 
63
- <button class="btn btn-primary" type="submit">Sauvegarder</button>
77
+ <button id="ec-save" class="btn btn-primary" type="button">Sauvegarder</button>
64
78
  </form>
65
79
  </div>
80
+
81
+ <script>
82
+ (function () {
83
+ function ready(fn){ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn); else fn(); }
84
+ ready(function () {
85
+ var btn = document.getElementById('ec-save');
86
+ var form = document.getElementById('ec-admin-form');
87
+ if (!btn || !form) { return; }
88
+ btn.addEventListener('click', function () {
89
+ try {
90
+ form.submit();
91
+ } catch (e) {
92
+ console.error(e);
93
+ alert('Erreur lors de la soumission du formulaire (voir console).');
94
+ }
95
+ });
96
+ });
97
+ }());
98
+ </script>
@@ -24,7 +24,7 @@
24
24
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
25
25
  </div>
26
26
  <div class="modal-body">
27
- <input type="hidden" name="_csrf" value="{csrf}">
27
+ <input type="hidden" name="_csrf" value="{config.csrf_token}">
28
28
  <input type="hidden" name="start" value="">
29
29
  <input type="hidden" name="end" value="">
30
30
 
@@ -61,7 +61,7 @@
61
61
  </div>
62
62
  </div>
63
63
 
64
- <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/6.1.19/index.global.min.js"></script>
64
+ <script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.19/index.global.min.js"></script>
65
65
  <script src="/plugins/nodebb-plugin-equipment-calendar/js/client.js"></script>
66
66
 
67
67
  <script>