nodebb-plugin-calendar-onekite 1.4.0 → 1.4.3
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 +856 -850
- package/package.json +1 -1
- package/plugin.json +4 -1
- package/static/js/admin.js +68 -59
- package/templates/admin/calendar-planning.tpl +30 -0
- package/templates/admin/plugins/calendar-onekite.tpl +4 -4
package/package.json
CHANGED
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.4.
|
|
6
|
+
"version": "1.4.3",
|
|
7
7
|
"library": "./library.js",
|
|
8
8
|
"staticDirs": {
|
|
9
9
|
"static": "static"
|
|
@@ -14,5 +14,8 @@
|
|
|
14
14
|
{ "hook": "filter:widgets.getWidgets", "method": "defineWidgets" },
|
|
15
15
|
{ "hook": "filter:widget.render:calendarUpcoming", "method": "renderUpcomingWidget" }
|
|
16
16
|
],
|
|
17
|
+
"acpScripts": [
|
|
18
|
+
"static/js/admin.js"
|
|
19
|
+
],
|
|
17
20
|
"templates": "templates"
|
|
18
21
|
}
|
package/static/js/admin.js
CHANGED
|
@@ -1,37 +1,45 @@
|
|
|
1
|
-
'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
initSettings: function () {
|
|
9
|
-
if (!$('#calendar-onekite-admin').length) return;
|
|
10
|
-
AdminCalendar.bindSettingsSave();
|
|
11
|
-
AdminCalendar.loadPending();
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
initPlanning: function () {
|
|
15
|
-
if (!$('#calendar-planning').length) return;
|
|
16
|
-
AdminCalendar.loadPlanning();
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
bindSettingsSave: function () {
|
|
20
|
-
$('#calendar-onekite-save').on('click', () => {
|
|
21
|
-
const settings = {
|
|
22
|
-
allowedGroups: $('#calendar-onekite-groups').val(),
|
|
23
|
-
allowedBookingGroups: $('#calendar-onekite-book-groups').val(),
|
|
24
|
-
limit: $('#calendar-onekite-widget-limit').val()
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
api.put('/admin/plugins/nodebb-plugin-calendar-onekite', settings)
|
|
28
|
-
.then(() => app.alertSuccess('Paramètres enregistrés'))
|
|
29
|
-
.catch(err => app.alertError(err.message || err));
|
|
30
|
-
});
|
|
31
|
-
},
|
|
1
|
+
define('plugins/nodebb-plugin-calendar-onekite/static/js/admin', [
|
|
2
|
+
'api',
|
|
3
|
+
'alerts',
|
|
4
|
+
], function (api, alerts) {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const AdminCalendar = {};
|
|
32
8
|
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
AdminCalendar.init = function () {
|
|
10
|
+
AdminCalendar.initSettings();
|
|
11
|
+
AdminCalendar.initPlanning();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
AdminCalendar.initSettings = function () {
|
|
15
|
+
if (!$('#calendar-onekite-admin').length) return;
|
|
16
|
+
AdminCalendar.bindSettingsSave();
|
|
17
|
+
AdminCalendar.loadPending();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
AdminCalendar.initPlanning = function () {
|
|
21
|
+
if (!$('#calendar-planning').length) return;
|
|
22
|
+
AdminCalendar.loadPlanning();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
AdminCalendar.bindSettingsSave = function () {
|
|
26
|
+
$('#calendar-onekite-save').off('click').on('click', function () {
|
|
27
|
+
const settings = {
|
|
28
|
+
allowedGroups: $('#calendar-onekite-groups').val(),
|
|
29
|
+
allowedBookingGroups: $('#calendar-onekite-book-groups').val(),
|
|
30
|
+
limit: $('#calendar-onekite-widget-limit').val(),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// ✅ RECOMMANDÉ: endpoint standard
|
|
34
|
+
api.put('/admin/plugins/calendar-onekite', settings)
|
|
35
|
+
.then(() => alerts.success('Paramètres enregistrés'))
|
|
36
|
+
.catch(err => alerts.error(err?.message || err));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
AdminCalendar.loadPending = function () {
|
|
41
|
+
api.get('/admin/calendar/pending')
|
|
42
|
+
.then(list => {
|
|
35
43
|
const container = $('#pending-reservations');
|
|
36
44
|
if (!container.length) return;
|
|
37
45
|
|
|
@@ -83,45 +91,47 @@ $(document).ready(function () {
|
|
|
83
91
|
|
|
84
92
|
container.append(card);
|
|
85
93
|
});
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
validateReservation: function (rid, row) {
|
|
90
|
-
$.post('/api/admin/calendar/reservation/' + rid + '/validate')
|
|
91
|
-
.then(res => {
|
|
92
|
-
row.css('background', '#d4edda');
|
|
93
|
-
row.find('.validate-btn').remove();
|
|
94
|
-
row.find('.cancel-btn').remove();
|
|
95
|
-
row.append('<p><strong>Validée.</strong> Lien de paiement envoyé.</p>');
|
|
96
|
-
})
|
|
97
|
-
.catch(err => {
|
|
98
|
-
app.alertError(err.responseJSON?.error || err.message);
|
|
99
|
-
});
|
|
100
|
-
},
|
|
94
|
+
})
|
|
95
|
+
.catch(err => alerts.error(err?.message || err));
|
|
96
|
+
};
|
|
101
97
|
|
|
102
|
-
|
|
98
|
+
AdminCalendar.validateReservation = function (rid, row) {
|
|
99
|
+
api.post('/admin/calendar/reservation/' + rid + '/validate', {})
|
|
100
|
+
.then(() => {
|
|
101
|
+
row.css('background', '#d4edda');
|
|
102
|
+
row.find('.validate-btn').remove();
|
|
103
|
+
row.find('.cancel-btn').remove();
|
|
104
|
+
row.append('<p><strong>Validée.</strong> Lien de paiement envoyé.</p>');
|
|
105
|
+
})
|
|
106
|
+
.catch(err => alerts.error(err?.message || err));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
AdminCalendar.cancelReservation = function (rid, row) {
|
|
110
|
+
require(['bootbox'], function (bootbox) {
|
|
103
111
|
bootbox.confirm('Annuler cette réservation ?', ok => {
|
|
104
112
|
if (!ok) return;
|
|
105
|
-
|
|
113
|
+
api.post('/admin/calendar/reservation/' + rid + '/cancel', {})
|
|
106
114
|
.then(() => {
|
|
107
115
|
row.css('background', '#f8d7da');
|
|
108
116
|
row.find('.validate-btn').remove();
|
|
109
117
|
row.find('.cancel-btn').remove();
|
|
110
118
|
row.append('<p><strong>Annulée.</strong></p>');
|
|
111
119
|
})
|
|
112
|
-
.catch(err =>
|
|
120
|
+
.catch(err => alerts.error(err?.message || err));
|
|
113
121
|
});
|
|
114
|
-
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
AdminCalendar.loadPlanning = function () {
|
|
126
|
+
api.get('/admin/calendar/planning')
|
|
127
|
+
.then(rows => {
|
|
118
128
|
const tbody = $('#planning-body');
|
|
119
129
|
if (!tbody.length) return;
|
|
120
130
|
|
|
121
131
|
tbody.empty();
|
|
122
132
|
|
|
123
133
|
if (!rows.length) {
|
|
124
|
-
tbody.append('<tr><td colspan="
|
|
134
|
+
tbody.append('<tr><td colspan="9">Aucune réservation future.</td></tr>');
|
|
125
135
|
return;
|
|
126
136
|
}
|
|
127
137
|
|
|
@@ -141,10 +151,9 @@ $(document).ready(function () {
|
|
|
141
151
|
`);
|
|
142
152
|
tbody.append(tr);
|
|
143
153
|
});
|
|
144
|
-
})
|
|
145
|
-
|
|
154
|
+
})
|
|
155
|
+
.catch(err => alerts.error(err?.message || err));
|
|
146
156
|
};
|
|
147
157
|
|
|
148
|
-
AdminCalendar
|
|
149
|
-
AdminCalendar.initPlanning();
|
|
158
|
+
return AdminCalendar;
|
|
150
159
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<div id="calendar-planning">
|
|
2
|
+
<h2>Planning des réservations de matériel</h2>
|
|
3
|
+
|
|
4
|
+
<p>
|
|
5
|
+
<a href="/admin/plugins/calendar-onekite" class="btn btn-default btn-sm">
|
|
6
|
+
← Retour au plugin Calendar Onekite
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<table class="table table-striped">
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<th>Événement</th>
|
|
14
|
+
<th>Matériel</th>
|
|
15
|
+
<th>Lieu de retrait</th>
|
|
16
|
+
<th>UID</th>
|
|
17
|
+
<th>Quantité</th>
|
|
18
|
+
<th>Début</th>
|
|
19
|
+
<th>Fin</th>
|
|
20
|
+
<th>Jours</th>
|
|
21
|
+
<th>Statut</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody id="planning-body">
|
|
25
|
+
<tr><td colspan="9">Chargement…</td></tr>
|
|
26
|
+
</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/admin.js"></script>
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
<small>Ex : administrators, moderators</small>
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
<div class="form-group">
|
|
19
18
|
<label>Nombre d’événements dans le widget</label>
|
|
20
19
|
<input id="calendar-onekite-widget-limit" type="number" class="form-control" value="{settings.limit}">
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="form-group">
|
|
21
23
|
<label>Groupes autorisés à réserver</label>
|
|
22
24
|
<input id="calendar-onekite-book-groups" class="form-control" value="{settings.allowedBookingGroups}">
|
|
23
25
|
<small>Ex : registered-users, membres, vip</small>
|
|
24
26
|
</div>
|
|
25
27
|
|
|
26
28
|
<button id="calendar-onekite-save" class="btn btn-primary">Enregistrer</button>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<script src="/plugins/nodebb-plugin-calendar-onekite/static/js/admin.js"></script>
|
|
29
|
+
</div>
|