nodebb-plugin-onekite-calendar 2.0.48 → 2.0.49
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/lib/api.js +16 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/public/client.js +15 -2
package/lib/api.js
CHANGED
|
@@ -924,7 +924,9 @@ api.getCapabilities = async function (req, res) {
|
|
|
924
924
|
canModerate: canMod,
|
|
925
925
|
canCreateSpecial: uid ? await canCreateSpecial(uid, settings) : false,
|
|
926
926
|
canDeleteSpecial: uid ? await canDeleteSpecial(uid, settings) : false,
|
|
927
|
+
// Outings share the same rights as reservations/locations.
|
|
927
928
|
canCreateOuting: uid ? await canRequest(uid, settings, Date.now()) : false,
|
|
929
|
+
canCreateReservation: uid ? await canRequest(uid, settings, Date.now()) : false,
|
|
928
930
|
});
|
|
929
931
|
};
|
|
930
932
|
|
|
@@ -1055,7 +1057,13 @@ api.createOuting = async function (req, res) {
|
|
|
1055
1057
|
// not on the outing date, so members can plan future outings without
|
|
1056
1058
|
// requiring next-year group membership.
|
|
1057
1059
|
const ok = await canRequest(req.uid, settings, Date.now());
|
|
1058
|
-
if (!ok)
|
|
1060
|
+
if (!ok) {
|
|
1061
|
+
return res.status(403).json({
|
|
1062
|
+
error: 'not-allowed',
|
|
1063
|
+
code: 'NOT_MEMBER',
|
|
1064
|
+
message: 'Vous devez être adhérent Onekite',
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1059
1067
|
|
|
1060
1068
|
const title = String((req.body && req.body.title) || '').trim() || 'Sortie';
|
|
1061
1069
|
const endTs = toTs(req.body && req.body.end);
|
|
@@ -1186,7 +1194,13 @@ api.createReservation = async function (req, res) {
|
|
|
1186
1194
|
const settings = await meta.settings.get('calendar-onekite');
|
|
1187
1195
|
const startPreview = toTs(req.body.start);
|
|
1188
1196
|
const ok = await canRequest(uid, settings, startPreview);
|
|
1189
|
-
if (!ok)
|
|
1197
|
+
if (!ok) {
|
|
1198
|
+
return res.status(403).json({
|
|
1199
|
+
error: 'not-allowed',
|
|
1200
|
+
code: 'NOT_MEMBER',
|
|
1201
|
+
message: 'Vous devez être adhérent Onekite',
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1190
1204
|
|
|
1191
1205
|
const isValidator = await canValidate(uid, settings);
|
|
1192
1206
|
|
package/package.json
CHANGED
package/plugin.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1203,6 +1203,8 @@ function toDatetimeLocalValue(date) {
|
|
|
1203
1203
|
const caps = await loadCapabilities().catch(() => ({}));
|
|
1204
1204
|
const canCreateSpecial = !!caps.canCreateSpecial;
|
|
1205
1205
|
const canDeleteSpecial = !!caps.canDeleteSpecial;
|
|
1206
|
+
const canCreateOuting = !!caps.canCreateOuting;
|
|
1207
|
+
const canCreateReservation = !!caps.canCreateReservation;
|
|
1206
1208
|
|
|
1207
1209
|
// Creation chooser: Location / Prévision de sortie / Évènement (si autorisé).
|
|
1208
1210
|
|
|
@@ -1281,6 +1283,17 @@ function toDatetimeLocalValue(date) {
|
|
|
1281
1283
|
if (isDialogOpen) return;
|
|
1282
1284
|
if (!lockAction('create', 900)) return;
|
|
1283
1285
|
|
|
1286
|
+
// If the user is not an Onekite member (or not logged in), do not open
|
|
1287
|
+
// the creation chooser at all. This avoids a confusing "not-allowed"
|
|
1288
|
+
// error after the user fills the form.
|
|
1289
|
+
try {
|
|
1290
|
+
if (!canCreateReservation && !canCreateOuting && !canCreateSpecial) {
|
|
1291
|
+
showAlert('error', 'Vous devez être adhérent Onekite');
|
|
1292
|
+
try { calendar.unselect(); } catch (e) {}
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
} catch (e) {}
|
|
1296
|
+
|
|
1284
1297
|
// Business rule: nothing can be created in the past.
|
|
1285
1298
|
try {
|
|
1286
1299
|
const startDateCheck = toLocalYmd(info.start);
|
|
@@ -1325,7 +1338,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1325
1338
|
// Buttons order matters for UX: put "Annuler" at bottom-right (last).
|
|
1326
1339
|
const buttons = {};
|
|
1327
1340
|
|
|
1328
|
-
buttons.location = {
|
|
1341
|
+
if (canCreateReservation) buttons.location = {
|
|
1329
1342
|
label: 'Location',
|
|
1330
1343
|
className: 'btn-onekite-location',
|
|
1331
1344
|
callback: async () => {
|
|
@@ -1364,7 +1377,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1364
1377
|
},
|
|
1365
1378
|
};
|
|
1366
1379
|
|
|
1367
|
-
buttons.outing = {
|
|
1380
|
+
if (canCreateOuting) buttons.outing = {
|
|
1368
1381
|
label: 'Prévision de sortie',
|
|
1369
1382
|
className: 'btn-onekite-outing',
|
|
1370
1383
|
callback: async () => {
|