nodebb-plugin-onekite-calendar 2.0.23 → 2.0.25
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/CHANGELOG.md +3 -0
- package/lib/api.js +2 -1
- package/lib/widgets.js +35 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog – calendar-onekite
|
|
2
2
|
|
|
3
|
+
## 1.3.19
|
|
4
|
+
- Annulation : un validateur/gestionnaire peut désormais annuler **même sa propre** réservation après paiement (la restriction `cannot-cancel-paid` ne s'applique plus aux validateurs).
|
|
5
|
+
|
|
3
6
|
## 1.3.18
|
|
4
7
|
- Fix HelloAsso webhook : suppression d'une double déclaration `realtime` qui empêchait le plugin de se charger (SyntaxError).
|
|
5
8
|
|
package/lib/api.js
CHANGED
|
@@ -1315,7 +1315,8 @@ api.cancelReservation = async function (req, res) {
|
|
|
1315
1315
|
if (!isOwner && !canMod) return res.status(403).json({ error: 'not-allowed' });
|
|
1316
1316
|
|
|
1317
1317
|
const isPaid = String(r.status) === 'paid';
|
|
1318
|
-
|
|
1318
|
+
// Owners cannot cancel a paid reservation unless they also have validator rights.
|
|
1319
|
+
if (isOwner && isPaid && !canMod) return res.status(400).json({ error: 'cannot-cancel-paid' });
|
|
1319
1320
|
|
|
1320
1321
|
if (r.status === 'cancelled') return res.json({ ok: true, status: 'cancelled' });
|
|
1321
1322
|
|
package/lib/widgets.js
CHANGED
|
@@ -370,6 +370,41 @@ dateClick: function() { window.location.href = calUrl; },
|
|
|
370
370
|
|
|
371
371
|
calendar.render();
|
|
372
372
|
|
|
373
|
+
// Real-time refresh for the widget (same server events as the main calendar)
|
|
374
|
+
try {
|
|
375
|
+
// Debounce per widget instance
|
|
376
|
+
let tRefetch = null;
|
|
377
|
+
const refetch = function () {
|
|
378
|
+
try {
|
|
379
|
+
if (tRefetch) return;
|
|
380
|
+
tRefetch = setTimeout(() => {
|
|
381
|
+
tRefetch = null;
|
|
382
|
+
try {
|
|
383
|
+
calendar.refetchEvents();
|
|
384
|
+
} catch (e) {}
|
|
385
|
+
}, 200);
|
|
386
|
+
} catch (e) {}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// Register refetcher and bind socket listeners once per page
|
|
390
|
+
window.__oneKiteWidgetRefetchers = window.__oneKiteWidgetRefetchers || [];
|
|
391
|
+
window.__oneKiteWidgetRefetchers.push(refetch);
|
|
392
|
+
|
|
393
|
+
if (!window.__oneKiteWidgetSocketBound && typeof socket !== 'undefined' && socket && typeof socket.on === 'function') {
|
|
394
|
+
window.__oneKiteWidgetSocketBound = true;
|
|
395
|
+
const triggerAll = function () {
|
|
396
|
+
try {
|
|
397
|
+
const list = window.__oneKiteWidgetRefetchers || [];
|
|
398
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
399
|
+
try { list[i](); } catch (e) {}
|
|
400
|
+
}
|
|
401
|
+
} catch (e) {}
|
|
402
|
+
};
|
|
403
|
+
socket.on('event:calendar-onekite.calendarUpdated', triggerAll);
|
|
404
|
+
socket.on('event:calendar-onekite.reservationUpdated', triggerAll);
|
|
405
|
+
}
|
|
406
|
+
} catch (e) {}
|
|
407
|
+
|
|
373
408
|
// Mobile swipe (left/right) to navigate weeks
|
|
374
409
|
try {
|
|
375
410
|
let touchStartX = null;
|
package/package.json
CHANGED
package/plugin.json
CHANGED