nodebb-plugin-onekite-calendar 1.0.4 → 1.0.5
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 +2 -27
- package/lib/admin.js +155 -15
- package/lib/api.js +103 -158
- package/lib/controllers.js +2 -2
- package/lib/db.js +5 -5
- package/lib/discord.js +5 -6
- package/lib/helloasso.js +3 -4
- package/lib/helloassoWebhook.js +7 -8
- package/lib/scheduler.js +11 -8
- package/lib/widgets.js +8 -128
- package/library.js +63 -39
- package/package.json +1 -1
- package/plugin.json +11 -5
- package/public/admin.js +91 -19
- package/public/client.js +23 -23
- package/templates/admin/plugins/{onekite-calendar.tpl → calendar-onekite.tpl} +23 -4
- package/templates/{onekite-calendar.tpl → calendar-onekite.tpl} +0 -11
- package/lib/constants.js +0 -7
- package/lib/email.js +0 -26
- package/lib/log.js +0 -29
- /package/templates/emails/{onekite-calendar_approved.tpl → calendar-onekite_approved.tpl} +0 -0
- /package/templates/emails/{onekite-calendar_expired.tpl → calendar-onekite_expired.tpl} +0 -0
- /package/templates/emails/{onekite-calendar_paid.tpl → calendar-onekite_paid.tpl} +0 -0
- /package/templates/emails/{onekite-calendar_pending.tpl → calendar-onekite_pending.tpl} +0 -0
- /package/templates/emails/{onekite-calendar_refused.tpl → calendar-onekite_refused.tpl} +0 -0
- /package/templates/emails/{onekite-calendar_reminder.tpl → calendar-onekite_reminder.tpl} +0 -0
package/public/admin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
define('admin/plugins/onekite
|
|
2
|
+
define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts, bootbox) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
// Cache of pending reservations keyed by rid so delegated click handlers
|
|
@@ -11,11 +11,11 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
11
11
|
// by NodeBB ACP save buttons/hooks across ajaxify navigations.
|
|
12
12
|
try {
|
|
13
13
|
const now = Date.now();
|
|
14
|
-
const last = window.
|
|
14
|
+
const last = window.oneKiteCalendarLastAlert;
|
|
15
15
|
if (last && last.type === type && last.msg === msg && (now - last.ts) < 1200) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
window.
|
|
18
|
+
window.oneKiteCalendarLastAlert = { type, msg, ts: now };
|
|
19
19
|
} catch (e) {}
|
|
20
20
|
try {
|
|
21
21
|
if (alerts && typeof alerts[type] === 'function') {
|
|
@@ -46,7 +46,30 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
if (!res.ok) {
|
|
49
|
-
|
|
49
|
+
// NodeBB versions differ: some expose admin APIs under /api/admin instead of /api/v3/admin
|
|
50
|
+
if (res.status === 404 && typeof url === 'string' && url.includes('/api/v3/admin/')) {
|
|
51
|
+
const altUrl = url.replace('/api/v3/admin/', '/api/admin/');
|
|
52
|
+
const res2 = await fetch(altUrl, {
|
|
53
|
+
credentials: 'same-origin',
|
|
54
|
+
headers: (() => {
|
|
55
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
56
|
+
const token =
|
|
57
|
+
(window.config && (window.config.csrf_token || window.config.csrfToken)) ||
|
|
58
|
+
(window.ajaxify && window.ajaxify.data && window.ajaxify.data.csrf_token) ||
|
|
59
|
+
(document.querySelector('meta[name="csrf-token"]') && document.querySelector('meta[name="csrf-token"]').getAttribute('content')) ||
|
|
60
|
+
(document.querySelector('meta[name="csrf_token"]') && document.querySelector('meta[name="csrf_token"]').getAttribute('content')) ||
|
|
61
|
+
(typeof app !== 'undefined' && app && app.csrfToken) ||
|
|
62
|
+
null;
|
|
63
|
+
if (token) headers['x-csrf-token'] = token;
|
|
64
|
+
return headers;
|
|
65
|
+
})(),
|
|
66
|
+
...opts,
|
|
67
|
+
});
|
|
68
|
+
if (res2.ok) {
|
|
69
|
+
return await res2.json();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const text = await res.text().catch(() => '');
|
|
50
73
|
throw new Error(`${res.status} ${text}`);
|
|
51
74
|
}
|
|
52
75
|
return await res.json();
|
|
@@ -244,36 +267,36 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
244
267
|
}
|
|
245
268
|
|
|
246
269
|
async function loadSettings() {
|
|
247
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
270
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/settings');
|
|
248
271
|
}
|
|
249
272
|
|
|
250
273
|
async function saveSettings(payload) {
|
|
251
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
274
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/settings', {
|
|
252
275
|
method: 'PUT',
|
|
253
276
|
body: JSON.stringify(payload),
|
|
254
277
|
});
|
|
255
278
|
}
|
|
256
279
|
|
|
257
280
|
async function loadPending() {
|
|
258
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
281
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/pending');
|
|
259
282
|
}
|
|
260
283
|
|
|
261
284
|
async function approve(rid, payload) {
|
|
262
|
-
return await fetchJson(`/api/v3/admin/plugins/onekite
|
|
285
|
+
return await fetchJson(`/api/v3/admin/plugins/calendar-onekite/reservations/${rid}/approve`, {
|
|
263
286
|
method: 'PUT',
|
|
264
287
|
body: JSON.stringify(payload || {}),
|
|
265
288
|
});
|
|
266
289
|
}
|
|
267
290
|
|
|
268
291
|
async function refuse(rid, payload) {
|
|
269
|
-
return await fetchJson(`/api/v3/admin/plugins/onekite
|
|
292
|
+
return await fetchJson(`/api/v3/admin/plugins/calendar-onekite/reservations/${rid}/refuse`, {
|
|
270
293
|
method: 'PUT',
|
|
271
294
|
body: JSON.stringify(payload || {}),
|
|
272
295
|
});
|
|
273
296
|
}
|
|
274
297
|
|
|
275
298
|
async function purge(year) {
|
|
276
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
299
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/purge', {
|
|
277
300
|
method: 'POST',
|
|
278
301
|
body: JSON.stringify({ year }),
|
|
279
302
|
});
|
|
@@ -281,30 +304,55 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
281
304
|
|
|
282
305
|
async function purgeSpecialEvents(year) {
|
|
283
306
|
try {
|
|
284
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
307
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/special-events/purge', {
|
|
285
308
|
method: 'POST',
|
|
286
309
|
body: JSON.stringify({ year }),
|
|
287
310
|
});
|
|
288
311
|
} catch (e) {
|
|
289
|
-
return await fetchJson('/api/v3/admin/plugins/onekite
|
|
312
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/special-events/purge', {
|
|
290
313
|
method: 'POST',
|
|
291
314
|
body: JSON.stringify({ year }),
|
|
292
315
|
});
|
|
293
316
|
}
|
|
294
317
|
}
|
|
295
318
|
|
|
319
|
+
async function debugHelloAsso() {
|
|
320
|
+
try {
|
|
321
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/debug');
|
|
322
|
+
} catch (e) {
|
|
323
|
+
return await fetchJson('/api/v3/admin/plugins/calendar-onekite/debug');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
296
327
|
async function loadAccounting(from, to) {
|
|
297
328
|
const params = new URLSearchParams();
|
|
298
329
|
if (from) params.set('from', from);
|
|
299
330
|
if (to) params.set('to', to);
|
|
300
331
|
const qs = params.toString();
|
|
301
|
-
return await fetchJson(`/api/v3/admin/plugins/onekite
|
|
332
|
+
return await fetchJson(`/api/v3/admin/plugins/calendar-onekite/accounting${qs ? `?${qs}` : ''}`);
|
|
302
333
|
}
|
|
303
334
|
|
|
304
335
|
async function init() {
|
|
305
336
|
const form = document.getElementById('onekite-settings-form');
|
|
306
337
|
if (!form) return;
|
|
307
338
|
|
|
339
|
+
// Make the HelloAsso debug output readable in both light and dark ACP themes.
|
|
340
|
+
// NodeBB 4.x uses Bootstrap variables, so we can rely on CSS variables here.
|
|
341
|
+
(function injectAdminCss() {
|
|
342
|
+
const id = 'onekite-admin-css';
|
|
343
|
+
if (document.getElementById(id)) return;
|
|
344
|
+
const style = document.createElement('style');
|
|
345
|
+
style.id = id;
|
|
346
|
+
style.textContent = `
|
|
347
|
+
#onekite-debug-output.onekite-debug-output {
|
|
348
|
+
background: var(--bs-body-bg) !important;
|
|
349
|
+
color: var(--bs-body-color) !important;
|
|
350
|
+
border: 1px solid var(--bs-border-color) !important;
|
|
351
|
+
}
|
|
352
|
+
`;
|
|
353
|
+
document.head.appendChild(style);
|
|
354
|
+
})();
|
|
355
|
+
|
|
308
356
|
// Load settings
|
|
309
357
|
try {
|
|
310
358
|
const s = await loadSettings();
|
|
@@ -361,19 +409,19 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
361
409
|
|
|
362
410
|
// Expose the latest save handler so the global delegated listener (bound once)
|
|
363
411
|
// can always call the current instance tied to the current form.
|
|
364
|
-
window.
|
|
412
|
+
window.oneKiteCalendarAdminDoSave = doSave;
|
|
365
413
|
|
|
366
414
|
// Save buttons (NodeBB header/footer "Enregistrer" + floppy icon)
|
|
367
415
|
// Bind a SINGLE delegated listener for the entire admin session.
|
|
368
416
|
const SAVE_SELECTOR = '#save, .save, [data-action="save"], .settings-save, .floating-save, .btn[data-action="save"]';
|
|
369
|
-
if (!window.
|
|
370
|
-
window.
|
|
417
|
+
if (!window.oneKiteCalendarAdminBound) {
|
|
418
|
+
window.oneKiteCalendarAdminBound = true;
|
|
371
419
|
document.addEventListener('click', (ev) => {
|
|
372
420
|
const btn = ev.target && ev.target.closest && ev.target.closest(SAVE_SELECTOR);
|
|
373
421
|
if (!btn) return;
|
|
374
422
|
// Only handle clicks while we're on this plugin page
|
|
375
423
|
if (!document.getElementById('onekite-settings-form')) return;
|
|
376
|
-
const fn = window.
|
|
424
|
+
const fn = window.oneKiteCalendarAdminDoSave;
|
|
377
425
|
if (typeof fn === 'function') fn(ev);
|
|
378
426
|
});
|
|
379
427
|
}
|
|
@@ -626,6 +674,30 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
626
674
|
});
|
|
627
675
|
}
|
|
628
676
|
|
|
677
|
+
// Debug
|
|
678
|
+
const debugBtn = document.getElementById('onekite-debug-run');
|
|
679
|
+
if (debugBtn) {
|
|
680
|
+
debugBtn.addEventListener('click', async () => {
|
|
681
|
+
const out = document.getElementById('onekite-debug-output');
|
|
682
|
+
if (out) out.textContent = 'Chargement...';
|
|
683
|
+
try {
|
|
684
|
+
const result = await debugHelloAsso();
|
|
685
|
+
if (out) out.textContent = JSON.stringify(result, null, 2);
|
|
686
|
+
const catalogCount = result && result.catalog ? parseInt(result.catalog.count, 10) || 0 : 0;
|
|
687
|
+
const catalogOk = !!(result && result.catalog && result.catalog.ok);
|
|
688
|
+
// Accept "count > 0" even if ok flag is false (some proxies can strip fields, etc.)
|
|
689
|
+
if (catalogOk || catalogCount > 0) {
|
|
690
|
+
showAlert('success', `Catalogue HelloAsso: ${catalogCount} item(s)`);
|
|
691
|
+
} else {
|
|
692
|
+
showAlert('error', 'HelloAsso: impossible de récupérer le catalogue.');
|
|
693
|
+
}
|
|
694
|
+
} catch (e) {
|
|
695
|
+
if (out) out.textContent = String(e && e.message ? e.message : e);
|
|
696
|
+
showAlert('error', 'Debug impossible.');
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
|
|
629
701
|
// Accounting (paid reservations)
|
|
630
702
|
const accFrom = document.getElementById('onekite-acc-from');
|
|
631
703
|
const accTo = document.getElementById('onekite-acc-to');
|
|
@@ -697,7 +769,7 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
697
769
|
if (accFrom && accFrom.value) params.set('from', accFrom.value);
|
|
698
770
|
if (accTo && accTo.value) params.set('to', accTo.value);
|
|
699
771
|
const qs = params.toString();
|
|
700
|
-
const url = `/api/v3/admin/plugins/onekite
|
|
772
|
+
const url = `/api/v3/admin/plugins/calendar-onekite/accounting.csv${qs ? `?${qs}` : ''}`;
|
|
701
773
|
window.open(url, '_blank');
|
|
702
774
|
});
|
|
703
775
|
|
|
@@ -710,7 +782,7 @@ define('admin/plugins/onekite-calendar', ['alerts', 'bootbox'], function (alerts
|
|
|
710
782
|
if (accFrom && accFrom.value) params.set('from', accFrom.value);
|
|
711
783
|
if (accTo && accTo.value) params.set('to', accTo.value);
|
|
712
784
|
const qs = params.toString();
|
|
713
|
-
const url = `/api/v3/admin/plugins/onekite
|
|
785
|
+
const url = `/api/v3/admin/plugins/calendar-onekite/accounting/purge${qs ? `?${qs}` : ''}`;
|
|
714
786
|
const res = await fetchJson(url, { method: 'POST' });
|
|
715
787
|
if (res && res.ok) {
|
|
716
788
|
showAlert('success', `Compta purgée : ${res.purged || 0} réservation(s).`);
|
package/public/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* global FullCalendar, ajaxify */
|
|
2
2
|
|
|
3
|
-
define('forum/onekite
|
|
3
|
+
define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alerts, bootbox, hooks) {
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
// Ensure small UI tweaks are applied even when themes override bootstrap defaults.
|
|
7
|
-
(function
|
|
7
|
+
(function ensureOneKiteStyles() {
|
|
8
8
|
try {
|
|
9
9
|
if (document.getElementById('onekite-inline-styles')) return;
|
|
10
10
|
const style = document.createElement('style');
|
|
@@ -498,7 +498,7 @@ define('forum/onekite-calendar', ['alerts', 'bootbox', 'hooks'], function (alert
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
async function loadCapabilities() {
|
|
501
|
-
return await fetchJson('/api/v3/plugins/onekite
|
|
501
|
+
return await fetchJson('/api/v3/plugins/calendar-onekite/capabilities');
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
// Leaflet (OpenStreetMap) helpers - loaded lazily only when needed.
|
|
@@ -706,34 +706,34 @@ function attachAddressAutocomplete(inputEl, onPick) {
|
|
|
706
706
|
|
|
707
707
|
async function loadItems() {
|
|
708
708
|
try {
|
|
709
|
-
return await fetchJson('/api/v3/plugins/onekite
|
|
709
|
+
return await fetchJson('/api/v3/plugins/calendar-onekite/items');
|
|
710
710
|
} catch (e) {
|
|
711
711
|
return [];
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
async function requestReservation(payload) {
|
|
716
|
-
return await fetchJson('/api/v3/plugins/onekite
|
|
716
|
+
return await fetchJson('/api/v3/plugins/calendar-onekite/reservations', {
|
|
717
717
|
method: 'POST',
|
|
718
718
|
body: JSON.stringify(payload),
|
|
719
719
|
});
|
|
720
720
|
}
|
|
721
721
|
|
|
722
722
|
async function approveReservation(rid, payload) {
|
|
723
|
-
return await fetchJson(`/api/v3/plugins/onekite
|
|
723
|
+
return await fetchJson(`/api/v3/plugins/calendar-onekite/reservations/${rid}/approve`, {
|
|
724
724
|
method: 'PUT',
|
|
725
725
|
body: JSON.stringify(payload || {}),
|
|
726
726
|
});
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
async function cancelReservation(rid) {
|
|
730
|
-
return await fetchJson(`/api/v3/plugins/onekite
|
|
730
|
+
return await fetchJson(`/api/v3/plugins/calendar-onekite/reservations/${rid}/cancel`, {
|
|
731
731
|
method: 'PUT',
|
|
732
732
|
});
|
|
733
733
|
}
|
|
734
734
|
|
|
735
735
|
async function refuseReservation(rid, payload) {
|
|
736
|
-
return await fetchJson(`/api/v3/plugins/onekite
|
|
736
|
+
return await fetchJson(`/api/v3/plugins/calendar-onekite/reservations/${rid}/refuse`, {
|
|
737
737
|
method: 'PUT',
|
|
738
738
|
body: JSON.stringify(payload || {}),
|
|
739
739
|
});
|
|
@@ -783,7 +783,7 @@ function toDatetimeLocalValue(date) {
|
|
|
783
783
|
let blocked = new Set();
|
|
784
784
|
try {
|
|
785
785
|
const qs = new URLSearchParams({ start: selectionInfo.startStr, end: selectionInfo.endStr });
|
|
786
|
-
const evs = await fetchJson(`/api/v3/plugins/onekite
|
|
786
|
+
const evs = await fetchJson(`/api/v3/plugins/calendar-onekite/events?${qs.toString()}`);
|
|
787
787
|
(evs || []).forEach((ev) => {
|
|
788
788
|
const st = (ev.extendedProps && ev.extendedProps.status) || '';
|
|
789
789
|
if (!['pending', 'awaiting_payment', 'approved', 'paid'].includes(st)) return;
|
|
@@ -1094,7 +1094,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1094
1094
|
window.__onekiteEventsAbort = abort;
|
|
1095
1095
|
|
|
1096
1096
|
const qs = new URLSearchParams({ start: info.startStr, end: info.endStr });
|
|
1097
|
-
const url = `/api/v3/plugins/onekite
|
|
1097
|
+
const url = `/api/v3/plugins/calendar-onekite/events?${qs.toString()}`;
|
|
1098
1098
|
const data = await fetchJsonCached(url, { signal: abort.signal });
|
|
1099
1099
|
|
|
1100
1100
|
// Prefetch adjacent range (previous/next) for snappier navigation.
|
|
@@ -1108,8 +1108,8 @@ function toDatetimeLocalValue(date) {
|
|
|
1108
1108
|
const toStr = (d) => new Date(d.getTime()).toISOString();
|
|
1109
1109
|
const qPrev = new URLSearchParams({ start: toStr(prevStart), end: toStr(prevEnd) });
|
|
1110
1110
|
const qNext = new URLSearchParams({ start: toStr(nextStart), end: toStr(nextEnd) });
|
|
1111
|
-
fetchJsonCached(`/api/v3/plugins/onekite
|
|
1112
|
-
fetchJsonCached(`/api/v3/plugins/onekite
|
|
1111
|
+
fetchJsonCached(`/api/v3/plugins/calendar-onekite/events?${qPrev.toString()}`).catch(() => {});
|
|
1112
|
+
fetchJsonCached(`/api/v3/plugins/calendar-onekite/events?${qNext.toString()}`).catch(() => {});
|
|
1113
1113
|
}
|
|
1114
1114
|
} catch (e) {}
|
|
1115
1115
|
|
|
@@ -1171,11 +1171,11 @@ function toDatetimeLocalValue(date) {
|
|
|
1171
1171
|
isDialogOpen = false;
|
|
1172
1172
|
return;
|
|
1173
1173
|
}
|
|
1174
|
-
await fetchJson('/api/v3/plugins/onekite
|
|
1174
|
+
await fetchJson('/api/v3/plugins/calendar-onekite/special-events', {
|
|
1175
1175
|
method: 'POST',
|
|
1176
1176
|
body: JSON.stringify(payload),
|
|
1177
1177
|
}).catch(async () => {
|
|
1178
|
-
return await fetchJson('/api/v3/plugins/onekite
|
|
1178
|
+
return await fetchJson('/api/v3/plugins/calendar-onekite/special-events', {
|
|
1179
1179
|
method: 'POST',
|
|
1180
1180
|
body: JSON.stringify(payload),
|
|
1181
1181
|
});
|
|
@@ -1265,11 +1265,11 @@ function toDatetimeLocalValue(date) {
|
|
|
1265
1265
|
isDialogOpen = false;
|
|
1266
1266
|
return;
|
|
1267
1267
|
}
|
|
1268
|
-
await fetchJson('/api/v3/plugins/onekite
|
|
1268
|
+
await fetchJson('/api/v3/plugins/calendar-onekite/special-events', {
|
|
1269
1269
|
method: 'POST',
|
|
1270
1270
|
body: JSON.stringify(payload),
|
|
1271
1271
|
}).catch(async () => {
|
|
1272
|
-
return await fetchJson('/api/v3/plugins/onekite
|
|
1272
|
+
return await fetchJson('/api/v3/plugins/calendar-onekite/special-events', {
|
|
1273
1273
|
method: 'POST',
|
|
1274
1274
|
body: JSON.stringify(payload),
|
|
1275
1275
|
});
|
|
@@ -1296,10 +1296,10 @@ function toDatetimeLocalValue(date) {
|
|
|
1296
1296
|
let p = p0;
|
|
1297
1297
|
try {
|
|
1298
1298
|
if (p0.type === 'reservation' && p0.rid) {
|
|
1299
|
-
const details = await fetchJson(`/api/v3/plugins/onekite
|
|
1299
|
+
const details = await fetchJson(`/api/v3/plugins/calendar-onekite/reservations/${encodeURIComponent(String(p0.rid))}`);
|
|
1300
1300
|
p = Object.assign({}, p0, details);
|
|
1301
1301
|
} else if (p0.type === 'special' && p0.eid) {
|
|
1302
|
-
const details = await fetchJson(`/api/v3/plugins/onekite
|
|
1302
|
+
const details = await fetchJson(`/api/v3/plugins/calendar-onekite/special-events/${encodeURIComponent(String(p0.eid))}`);
|
|
1303
1303
|
p = Object.assign({}, p0, details, {
|
|
1304
1304
|
// keep backward compat with older field names used by templates below
|
|
1305
1305
|
pickupAddress: details.address || details.pickupAddress || p0.pickupAddress,
|
|
@@ -1348,7 +1348,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1348
1348
|
callback: async () => {
|
|
1349
1349
|
try {
|
|
1350
1350
|
const eid = String(p.eid || ev.id).replace(/^special:/, '');
|
|
1351
|
-
await fetchJson(`/api/v3/plugins/onekite
|
|
1351
|
+
await fetchJson(`/api/v3/plugins/calendar-onekite/special-events/${encodeURIComponent(eid)}`, { method: 'DELETE' });
|
|
1352
1352
|
showAlert('success', 'Évènement supprimé.');
|
|
1353
1353
|
calendar.refetchEvents();
|
|
1354
1354
|
} catch (e) {
|
|
@@ -1667,7 +1667,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1667
1667
|
});
|
|
1668
1668
|
|
|
1669
1669
|
// Expose for live updates
|
|
1670
|
-
try { window.
|
|
1670
|
+
try { window.oneKiteCalendar = calendar; } catch (e) {}
|
|
1671
1671
|
|
|
1672
1672
|
calendar.render();
|
|
1673
1673
|
|
|
@@ -1766,7 +1766,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1766
1766
|
function autoInit(data) {
|
|
1767
1767
|
try {
|
|
1768
1768
|
const tpl = data && data.template ? data.template.name : (ajaxify && ajaxify.data && ajaxify.data.template ? ajaxify.data.template.name : '');
|
|
1769
|
-
if (tpl === 'onekite
|
|
1769
|
+
if (tpl === 'calendar-onekite') {
|
|
1770
1770
|
init('#onekite-calendar');
|
|
1771
1771
|
}
|
|
1772
1772
|
} catch (e) {}
|
|
@@ -1786,9 +1786,9 @@ function toDatetimeLocalValue(date) {
|
|
|
1786
1786
|
try {
|
|
1787
1787
|
if (!window.__oneKiteSocketBound && typeof socket !== 'undefined' && socket && typeof socket.on === 'function') {
|
|
1788
1788
|
window.__oneKiteSocketBound = true;
|
|
1789
|
-
socket.on('event:onekite
|
|
1789
|
+
socket.on('event:calendar-onekite.reservationUpdated', function () {
|
|
1790
1790
|
try {
|
|
1791
|
-
const cal = window.
|
|
1791
|
+
const cal = window.oneKiteCalendar;
|
|
1792
1792
|
scheduleRefetch(cal);
|
|
1793
1793
|
} catch (e) {}
|
|
1794
1794
|
});
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
<div class="row">
|
|
4
4
|
<div class="col-lg-9">
|
|
5
|
-
<h1>Calendar
|
|
5
|
+
<h1>Calendar OneKite</h1>
|
|
6
6
|
|
|
7
7
|
<ul class="nav nav-tabs mt-3" role="tablist">
|
|
8
|
-
<li class="nav-item" role="presentation">
|
|
8
|
+
<li class="nav-item" role="presentation">
|
|
9
|
+
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#onekite-tab-settings" type="button" role="tab">Locations</button>
|
|
10
|
+
</li>
|
|
11
|
+
<li class="nav-item" role="presentation">
|
|
12
|
+
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#onekite-tab-events" type="button" role="tab">Évènements</button>
|
|
13
|
+
</li>
|
|
14
|
+
<li class="nav-item" role="presentation">
|
|
15
|
+
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#onekite-tab-pending" type="button" role="tab">Demandes en attente</button>
|
|
16
|
+
</li>
|
|
17
|
+
<li class="nav-item" role="presentation">
|
|
18
|
+
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#onekite-tab-debug" type="button" role="tab">Debug HelloAsso</button>
|
|
19
|
+
</li>
|
|
20
|
+
<li class="nav-item" role="presentation">
|
|
9
21
|
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#onekite-tab-accounting" type="button" role="tab">Comptabilisation</button>
|
|
10
22
|
</li>
|
|
11
23
|
</ul>
|
|
@@ -142,7 +154,14 @@
|
|
|
142
154
|
<h4>Demandes en attente</h4>
|
|
143
155
|
<div id="onekite-pending" class="list-group"></div>
|
|
144
156
|
</div>
|
|
145
|
-
|
|
157
|
+
|
|
158
|
+
<div class="tab-pane fade" id="onekite-tab-debug" role="tabpanel">
|
|
159
|
+
<p class="text-muted">Teste la récupération du token et la liste du matériel (catalogue).</p>
|
|
160
|
+
<button type="button" class="btn btn-secondary me-2" id="onekite-debug-run">Tester le chargement du matériel</button>
|
|
161
|
+
<pre id="onekite-debug-output" class="mt-3 p-3 border rounded onekite-debug-output" style="max-height: 360px; overflow: auto;"></pre>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div class="tab-pane fade" id="onekite-tab-accounting" role="tabpanel">
|
|
146
165
|
<h4>Comptabilisation des locations (payées)</h4>
|
|
147
166
|
<div class="d-flex flex-wrap gap-2 align-items-end mb-3">
|
|
148
167
|
<div>
|
|
@@ -186,7 +205,7 @@
|
|
|
186
205
|
</div>
|
|
187
206
|
|
|
188
207
|
<script>
|
|
189
|
-
require(['admin/plugins/onekite
|
|
208
|
+
require(['admin/plugins/calendar-onekite'], function (mod) {
|
|
190
209
|
if (mod && mod.init) {
|
|
191
210
|
mod.init();
|
|
192
211
|
}
|
|
@@ -21,17 +21,6 @@
|
|
|
21
21
|
The plugin's forum script auto-initialises on the calendar page via ajaxify.
|
|
22
22
|
-->
|
|
23
23
|
|
|
24
|
-
<script>
|
|
25
|
-
// Ultra-perf: load the forum JS only on the calendar page.
|
|
26
|
-
require(['forum/onekite-calendar'], function (mod) {
|
|
27
|
-
try {
|
|
28
|
-
if (mod && typeof mod.init === 'function') {
|
|
29
|
-
mod.init('#onekite-calendar');
|
|
30
|
-
}
|
|
31
|
-
} catch (e) {}
|
|
32
|
-
});
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
24
|
|
|
36
25
|
<style>
|
|
37
26
|
/* Make the custom "Évènement" button distinct from view buttons */
|
package/lib/constants.js
DELETED
package/lib/email.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const meta = require.main.require('./src/meta');
|
|
4
|
-
const emailer = require.main.require('./src/emailer');
|
|
5
|
-
|
|
6
|
-
function defaultLanguage() {
|
|
7
|
-
return (meta && meta.config && (meta.config.defaultLang || meta.config.defaultLanguage)) || 'fr';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Send a transactional email using NodeBB's emailer (NodeBB 4.x).
|
|
12
|
-
*/
|
|
13
|
-
async function sendEmail(template, toEmail, subject, data) {
|
|
14
|
-
if (!toEmail) return;
|
|
15
|
-
if (!emailer || typeof emailer.sendToEmail !== 'function') {
|
|
16
|
-
throw new Error('Emailer not available (sendToEmail missing)');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const language = defaultLanguage();
|
|
20
|
-
const params = Object.assign({}, data || {}, subject ? { subject } : {});
|
|
21
|
-
await emailer.sendToEmail(template, toEmail, language, params);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
sendEmail,
|
|
26
|
-
};
|
package/lib/log.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Minimal, opt-in logging.
|
|
4
|
-
// Enable by setting ONEKITE_CALENDAR_DEBUG=1 in the NodeBB process env.
|
|
5
|
-
|
|
6
|
-
let logger;
|
|
7
|
-
try {
|
|
8
|
-
logger = require.main.require('./src/logger');
|
|
9
|
-
} catch (e) {
|
|
10
|
-
logger = null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const enabled = () => !!process.env.ONEKITE_CALENDAR_DEBUG;
|
|
14
|
-
|
|
15
|
-
function warn(msg, meta) {
|
|
16
|
-
if (!enabled()) return;
|
|
17
|
-
if (logger && typeof logger.warn === 'function') {
|
|
18
|
-
logger.warn(`[onekite-calendar] ${msg}`, meta || '');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function error(msg, meta) {
|
|
23
|
-
if (!enabled()) return;
|
|
24
|
-
if (logger && typeof logger.error === 'function') {
|
|
25
|
-
logger.error(`[onekite-calendar] ${msg}`, meta || '');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = { warn, error };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|