nodebb-plugin-calendar-onekite 1.3.5 → 1.3.7

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
@@ -99,7 +99,8 @@ async function updateEvent(eid, data) {
99
99
  allDay: data.allDay !== undefined ? (data.allDay ? 1 : 0) : existing.allDay,
100
100
  location: data.location !== undefined ? String(data.location) : existing.location,
101
101
  visibility: data.visibility !== undefined ? String(data.visibility) : existing.visibility,
102
- bookingEnabled: data.bookingEnabled !== undefined ? (data.bookingEnabled ? 1 : 0) : (existing.bookingEnabled || 0),
102
+ bookingEnabled:
103
+ data.bookingEnabled !== undefined ? (data.bookingEnabled ? 1 : 0) : (existing.bookingEnabled || 0),
103
104
  bookingItems: JSON.stringify(bookingItems),
104
105
  updatedAt: String(Date.now()),
105
106
  };
@@ -224,6 +225,23 @@ function computePrice(event, reservation) {
224
225
  return unit * reservation.quantity * days;
225
226
  }
226
227
 
228
+ /* ********* ADMIN PAGE (AJOUTÉ) ********* */
229
+
230
+ async function renderAdminPage(req, res) {
231
+ try {
232
+ const settings = (await Settings.get('calendar-onekite')) || {};
233
+ res.render('admin/plugins/calendar-onekite', {
234
+ title: 'Calendar OneKite',
235
+ settings,
236
+ });
237
+ } catch (err) {
238
+ if (req.path && req.path.startsWith('/api/')) {
239
+ return res.status(500).json({ error: err.message });
240
+ }
241
+ res.status(500).send(err.message);
242
+ }
243
+ }
244
+
227
245
  /* ********* INIT ********* */
228
246
 
229
247
  Plugin.init = async function (params) {
@@ -390,7 +408,7 @@ Plugin.init = async function (params) {
390
408
  status: 'pending_admin',
391
409
  helloAssoOrderId: null,
392
410
  createdAt: now,
393
- pickupLocation: item.pickupLocation || ''
411
+ pickupLocation: item.pickupLocation || '',
394
412
  };
395
413
 
396
414
  allRes.push(reservation);
@@ -566,7 +584,6 @@ Plugin.init = async function (params) {
566
584
  const itemIndex = items.findIndex(i => i.id === reservation.itemId);
567
585
  if (itemIndex !== -1) {
568
586
  const item = items[itemIndex];
569
- // plus de reservedTemp, la logique se base sur les réservations
570
587
  item.reserved = (item.reserved || 0) + reservation.quantity;
571
588
  items[itemIndex] = item;
572
589
  }
@@ -602,12 +619,12 @@ Plugin.init = async function (params) {
602
619
  }
603
620
  });
604
621
 
605
- /* PAGE ADMIN PLUGIN */
622
+ /* PAGE ADMIN PLUGIN (CORRIGÉ) */
606
623
 
607
- router.get('/admin/plugins/nodebb-plugin-calendar-onekite', middleware.admin.buildHeader, renderAdminPage);
608
- router.get('/api/admin/plugins/nodebb-plugin-calendar-onekite', renderAdminPage);
624
+ router.get('/admin/plugins/calendar-onekite', middleware.admin.buildHeader, renderAdminPage);
625
+ router.get('/api/admin/plugins/calendar-onekite', renderAdminPage);
609
626
 
610
- router.put('/api/admin/plugins/nodebb-plugin-calendar-onekite', middleware.admin.checkPrivileges, async (req, res) => {
627
+ router.put('/api/admin/plugins/calendar-onekite', middleware.admin.checkPrivileges, async (req, res) => {
611
628
  try {
612
629
  await Settings.set('calendar-onekite', req.body);
613
630
  res.json({ status: 'ok' });
@@ -710,7 +727,7 @@ Plugin.addAdminNavigation = function (header) {
710
727
  header.plugins.push({
711
728
  route: '/plugins/calendar-onekite',
712
729
  icon: 'fa fa-calendar',
713
- name: 'Calendar Lite',
730
+ name: 'Calendar OneKite',
714
731
  });
715
732
  return header;
716
733
  };
@@ -727,7 +744,7 @@ Plugin.defineWidgets = async function (widgets) {
727
744
 
728
745
  Plugin.renderUpcomingWidget = async function (widget, callback) {
729
746
  try {
730
- const settings = await Settings.get('calendar-onekite') || {};
747
+ const settings = (await Settings.get('calendar-onekite')) || {};
731
748
  const limit = Number(widget.data.limit || settings.limit || 5);
732
749
  const events = await getUpcomingEvents(limit);
733
750
  const html = await appRef.renderAsync('widgets/calendar-upcoming', { events });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-calendar-onekite",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
package/plugin.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "Calendar Onekite",
4
4
  "description": "Calendrier + réservation de matériel + validation admin + paiement HelloAsso pour NodeBB v4",
5
5
  "url": "",
6
- "version": "1.3.5",
6
+ "version": "1.3.7",
7
7
  "library": "./library.js",
8
8
  "staticDirs": {
9
9
  "static": "static"
@@ -84,5 +84,5 @@
84
84
  </div>
85
85
  </div>
86
86
 
87
- <link rel="stylesheet" href="/plugins/nodebb-plugin-calendar-lite/static/style.css">
88
- <script src="/plugins/nodebb-plugin-calendar-lite/static/js/calendar.js"></script>
87
+ <link rel="stylesheet" href="/plugins/nodebb-plugin-calendar-onekite/static/style.css">
88
+ <script src="/plugins/nodebb-plugin-calendar-onekite/static/js/calendar.js"></script>
@@ -0,0 +1,22 @@
1
+ <div class="calendar-upcoming-widget">
2
+ <h4>Prochains événements</h4>
3
+
4
+ <!-- IF !events.length -->
5
+ <p>Aucun événement prévu.</p>
6
+ <!-- ELSE -->
7
+ <ul class="calendar-upcoming-list">
8
+ <!-- BEGIN events -->
9
+ <li>
10
+ <strong>{events.title}</strong><br>
11
+ <small>
12
+ <!-- tu peux custom le format date via moment côté client si tu veux -->
13
+ {events.start} → {events.end}
14
+ </small>
15
+ <!-- IF events.location -->
16
+ <br><small>{events.location}</small>
17
+ <!-- ENDIF events.location -->
18
+ </li>
19
+ <!-- END events -->
20
+ </ul>
21
+ <!-- ENDIF !events.length -->
22
+ </div>