nodebb-plugin-calendar-onekite 2.1.0 → 2.1.2
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 +1 -1
- package/plugin.json +3 -2
- package/static/js/admin-planning.bundle.js +26 -0
- package/static/js/admin.bundle.js +26 -0
- package/static/js/calendar.bundle.js +63 -0
- package/static/js/my-reservations.bundle.js +42 -0
- package/templates/admin/calendar-planning.tpl +3 -5
- package/templates/admin/plugins/calendar-onekite.tpl +2 -3
- package/templates/calendar-my-reservations.tpl +2 -0
- package/templates/calendar.tpl +1 -5
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
"name": "Calendar Onekite",
|
|
4
4
|
"description": "Calendrier + réservation matériel + validation admin + paiement HelloAsso pour NodeBB v4 (no-jQuery UI)",
|
|
5
5
|
"url": "",
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.2",
|
|
7
7
|
"library": "./library.js",
|
|
8
8
|
"staticDirs": {
|
|
9
9
|
"static": "static"
|
|
10
10
|
},
|
|
11
11
|
"acpScripts": [
|
|
12
|
-
"static/js/admin.js"
|
|
12
|
+
"static/js/admin.bundle.js",
|
|
13
|
+
"static/js/admin-planning.bundle.js"
|
|
13
14
|
],
|
|
14
15
|
"hooks": [
|
|
15
16
|
{
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
function ready(fn){
|
|
5
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
|
|
6
|
+
else fn();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function boot(){
|
|
10
|
+
if (!document.querySelector('#planning-calendar')) return;
|
|
11
|
+
|
|
12
|
+
if (typeof window.require !== 'function') {
|
|
13
|
+
console.warn('[calendar-onekite] require is not defined (planning)');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
window.require([
|
|
18
|
+
'plugins/nodebb-plugin-calendar-onekite/static/js/admin-planning'
|
|
19
|
+
], function (Mod) {
|
|
20
|
+
try { Mod && Mod.init && Mod.init(); } catch (e) { console.error(e); }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ready(boot);
|
|
25
|
+
document.addEventListener('action:ajaxify.end', boot);
|
|
26
|
+
})();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
function ready(fn){
|
|
5
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
|
|
6
|
+
else fn();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function boot(){
|
|
10
|
+
if (!document.querySelector('#calendar-onekite-admin') && !document.querySelector('#calendar-planning')) return;
|
|
11
|
+
|
|
12
|
+
if (typeof window.require !== 'function') {
|
|
13
|
+
console.warn('[calendar-onekite] require is not defined (ACP)');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
window.require([
|
|
18
|
+
'plugins/nodebb-plugin-calendar-onekite/static/js/admin'
|
|
19
|
+
], function (Admin) {
|
|
20
|
+
try { Admin && Admin.init && Admin.init(); } catch (e) { console.error(e); }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ready(boot);
|
|
25
|
+
document.addEventListener('action:ajaxify.end', boot);
|
|
26
|
+
})();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
function log(...a){ try{ console.log('[calendar-onekite]', ...a);}catch{} }
|
|
5
|
+
function warn(...a){ try{ console.warn('[calendar-onekite]', ...a);}catch{} }
|
|
6
|
+
|
|
7
|
+
function ready(fn){
|
|
8
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
|
|
9
|
+
else fn();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function runWithModules(mods, cb){
|
|
13
|
+
if (typeof window.require === 'function') {
|
|
14
|
+
window.require(mods, function(){ cb.apply(null, arguments); });
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function fetchJson(path, method='GET', body){
|
|
21
|
+
const url = path.startsWith('/api/') || path.startsWith('/api/v3/') ? path : ('/api/v3' + path);
|
|
22
|
+
const headers = { 'Content-Type':'application/json' };
|
|
23
|
+
const csrf = (window.ajaxify && window.ajaxify.data && window.ajaxify.data.csrf_token) || null;
|
|
24
|
+
if (csrf) headers['x-csrf-token'] = csrf;
|
|
25
|
+
const res = await fetch(url, { method, headers, credentials:'same-origin', body: body ? JSON.stringify(body): undefined });
|
|
26
|
+
if (!res.ok) {
|
|
27
|
+
let msg = res.statusText;
|
|
28
|
+
try { const j = await res.json(); msg = j.error || j.message || msg; } catch {}
|
|
29
|
+
const e = new Error(msg); e.status=res.status; throw e;
|
|
30
|
+
}
|
|
31
|
+
return res.json();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function initCalendar(api, alerts){
|
|
35
|
+
// use the existing calendar module (AMD) if present; else minimal inline init
|
|
36
|
+
if (runWithModules(['plugins/nodebb-plugin-calendar-onekite/static/js/calendar'], function(Calendar){
|
|
37
|
+
if (Calendar && Calendar.init) Calendar.init();
|
|
38
|
+
})) return;
|
|
39
|
+
|
|
40
|
+
// Fallback: we don't have AMD loader, do nothing but tell why
|
|
41
|
+
warn('AMD require introuvable, impossible d\'initialiser le calendrier.');
|
|
42
|
+
if (alerts && alerts.error) alerts.error('Calendrier: require introuvable (scripts NodeBB non chargés)');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function boot(){
|
|
46
|
+
if (!document.querySelector('#calendar')) return;
|
|
47
|
+
// Ensure FullCalendar loaded
|
|
48
|
+
if (!window.FullCalendar) {
|
|
49
|
+
warn('FullCalendar non chargé (CDN bloqué ?).');
|
|
50
|
+
}
|
|
51
|
+
runWithModules(['api', 'alerts'], function(api, alerts){
|
|
52
|
+
initCalendar(api, alerts);
|
|
53
|
+
}) || initCalendar(null, null);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ready(boot);
|
|
57
|
+
|
|
58
|
+
// NodeBB ajaxify navigation
|
|
59
|
+
if (window.socket && window.socket.on) {
|
|
60
|
+
// do nothing
|
|
61
|
+
}
|
|
62
|
+
document.addEventListener('action:ajaxify.end', boot);
|
|
63
|
+
})();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
'use strict';
|
|
3
|
+
if (window.__onekiteMyResLoaded) return;
|
|
4
|
+
window.__onekiteMyResLoaded=true;
|
|
5
|
+
|
|
6
|
+
function qs(sel, root){ return (root||document).querySelector(sel); }
|
|
7
|
+
function escapeHtml(s){
|
|
8
|
+
return String(s ?? '').replaceAll('&','&').replaceAll('<','<').replaceAll('>','>')
|
|
9
|
+
.replaceAll('"','"').replaceAll("'","'");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function boot(api, alerts){
|
|
13
|
+
async function load(){
|
|
14
|
+
const tbody=qs('#my-reservations-body');
|
|
15
|
+
if (!tbody) return;
|
|
16
|
+
try{
|
|
17
|
+
const rows=await api.get('/calendar/my-reservations');
|
|
18
|
+
if (!rows || !rows.length){
|
|
19
|
+
tbody.innerHTML='<tr><td colspan="7">Aucune réservation.</td></tr>'; return;
|
|
20
|
+
}
|
|
21
|
+
tbody.innerHTML = rows.map(r=>`
|
|
22
|
+
<tr>
|
|
23
|
+
<td>${escapeHtml(r.eventTitle)}</td>
|
|
24
|
+
<td>${escapeHtml(r.itemName)}</td>
|
|
25
|
+
<td>${escapeHtml(r.pickupLocation || '')}</td>
|
|
26
|
+
<td>${escapeHtml(r.dateStart)}</td>
|
|
27
|
+
<td>${escapeHtml(r.dateEnd)}</td>
|
|
28
|
+
<td>${escapeHtml(r.days || '')}</td>
|
|
29
|
+
<td>${escapeHtml(r.status)}</td>
|
|
30
|
+
</tr>
|
|
31
|
+
`).join('');
|
|
32
|
+
} catch(e){ console.error(e); alerts.error(e?.message||e); }
|
|
33
|
+
}
|
|
34
|
+
async function init(){ if (!qs('#calendar-my-reservations')) return; await load(); }
|
|
35
|
+
document.addEventListener('action:ajaxify.end', init);
|
|
36
|
+
init();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof require === 'function'){
|
|
40
|
+
require(['api','alerts'], function(api, alerts){ boot(api, alerts); });
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
30
|
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.15/index.global.min.js"></script>
|
|
31
|
-
<script>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
</script>
|
|
31
|
+
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/admin.bundle.js"></script>
|
|
32
|
+
|
|
33
|
+
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/admin-planning.bundle.js"></script>
|
|
@@ -74,6 +74,5 @@
|
|
|
74
74
|
<button id="calendar-onekite-save" class="btn btn-primary">Enregistrer</button>
|
|
75
75
|
</div>
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</script>
|
|
77
|
+
|
|
78
|
+
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/admin.bundle.js"></script>
|
package/templates/calendar.tpl
CHANGED
|
@@ -99,10 +99,6 @@
|
|
|
99
99
|
|
|
100
100
|
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.15/index.global.min.js"></script>
|
|
101
101
|
|
|
102
|
-
<script>
|
|
103
|
-
require(['plugins/nodebb-plugin-calendar-onekite/static/js/calendar'], function (Calendar) {
|
|
104
|
-
Calendar.init && Calendar.init();
|
|
105
|
-
});
|
|
106
|
-
</script>
|
|
102
|
+
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/calendar.bundle.js"></script>
|
|
107
103
|
|
|
108
104
|
<!-- IMPORT partials/footer.tpl -->
|