nodebb-plugin-equipment-calendar 0.1.0 → 0.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/library.js CHANGED
@@ -350,6 +350,7 @@ plugin.init = async function (params) {
350
350
  title: 'Paiement',
351
351
  rid: req.query.rid || '',
352
352
  status: req.query.status || 'ok',
353
+ statusError: String(req.query.status || '') === 'error',
353
354
  });
354
355
  });
355
356
 
@@ -389,6 +390,10 @@ async function renderAdminPage(req, res) {
389
390
  res.render('admin/plugins/equipment-calendar', {
390
391
  title: 'Equipment Calendar',
391
392
  settings,
393
+ view_dayGridMonth: (settings.defaultView || 'dayGridMonth') === 'dayGridMonth',
394
+ view_timeGridWeek: (settings.defaultView || '') === 'timeGridWeek',
395
+ view_timeGridDay: (settings.defaultView || '') === 'timeGridDay',
396
+ view_showRequesterToAll: String(settings.showRequesterToAll || '0') === '1',
392
397
  });
393
398
  }
394
399
 
@@ -397,10 +402,13 @@ async function renderCalendarPage(req, res) {
397
402
  const settings = await getSettings();
398
403
  const items = parseItems(settings.itemsJson).filter(i => i.active);
399
404
 
405
+ const rawItems = items;
406
+
400
407
  const tz = settings.timezone || 'Europe/Paris';
401
408
 
402
- const itemId = String(req.query.itemId || (items[0]?.id || '')).trim();
403
- const chosenItem = items.find(i => i.id === itemId) || items[0] || null;
409
+ const itemId = String(req.query.itemId || (rawItems[0]?.id || '')).trim();
410
+ const chosenItem = rawItems.find(i => i.id === itemId) || rawItems[0] || null;
411
+ const itemsView = rawItems.map(it => ({ ...it, selected: chosenItem ? it.id === chosenItem.id : false }));
404
412
 
405
413
  // Determine range to render
406
414
  const now = DateTime.now().setZone(tz);
@@ -437,7 +445,7 @@ async function renderCalendarPage(req, res) {
437
445
 
438
446
  res.render('equipment-calendar/calendar', {
439
447
  title: 'Réservation de matériel',
440
- items,
448
+ items: itemsView,
441
449
  chosenItemId: chosenItem ? chosenItem.id : '',
442
450
  chosenItemName: chosenItem ? chosenItem.name : '',
443
451
  chosenItemPriceCents: chosenItem ? chosenItem.priceCents : 0,
@@ -499,6 +507,7 @@ async function renderApprovalsPage(req, res) {
499
507
  res.render('equipment-calendar/approvals', {
500
508
  title: 'Validation des réservations',
501
509
  rows,
510
+ hasRows: Array.isArray(rows) && rows.length > 0,
502
511
  csrf: req.csrfToken,
503
512
  });
504
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-equipment-calendar",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Equipment reservation calendar for NodeBB (FullCalendar, approvals, HelloAsso payments)",
5
5
  "main": "library.js",
6
6
  "scripts": {
@@ -26,7 +26,7 @@
26
26
  <input id="notifyGroup" class="form-control" value="{{settings.notifyGroup}}">
27
27
  </div>
28
28
  <div class="form-check">
29
- <input class="form-check-input" type="checkbox" id="showRequesterToAll" {{#if (eq settings.showRequesterToAll "1")}}checked{{/if}}>
29
+ <input class="form-check-input" type="checkbox" id="showRequesterToAll" {{#if view_showRequesterToAll}}checked{{/if}}>
30
30
  <label class="form-check-label" for="showRequesterToAll">Afficher le demandeur à tout le monde</label>
31
31
  </div>
32
32
  </div>
@@ -49,9 +49,9 @@
49
49
  <h5>Calendrier</h5>
50
50
  <div class="mb-3"><label class="form-label">Vue par défaut</label>
51
51
  <select id="defaultView" class="form-select">
52
- <option value="dayGridMonth" {{#if (eq settings.defaultView "dayGridMonth")}}selected{{/if}}>Mois</option>
53
- <option value="timeGridWeek" {{#if (eq settings.defaultView "timeGridWeek")}}selected{{/if}}>Semaine</option>
54
- <option value="timeGridDay" {{#if (eq settings.defaultView "timeGridDay")}}selected{{/if}}>Jour</option>
52
+ <option value="dayGridMonth" {{#if view_dayGridMonth}}selected{{/if}}>Mois</option>
53
+ <option value="timeGridWeek" {{#if view_timeGridWeek}}selected{{/if}}>Semaine</option>
54
+ <option value="timeGridDay" {{#if view_timeGridDay}}selected{{/if}}>Jour</option>
55
55
  </select>
56
56
  </div>
57
57
  <div class="mb-3"><label class="form-label">Timezone</label><input id="timezone" class="form-control" value="{{settings.timezone}}"></div>
@@ -1,7 +1,7 @@
1
1
  <div class="equipment-approvals-page">
2
2
  <h1>Validation des réservations</h1>
3
3
 
4
- {{#if rows.length}}
4
+ {{#if hasRows}}
5
5
  <div class="table-responsive">
6
6
  <table class="table table-striped align-middle">
7
7
  <thead>
@@ -16,7 +16,7 @@
16
16
  </tr>
17
17
  </thead>
18
18
  <tbody>
19
- {{#rows}}
19
+ {{#each rows}}
20
20
  <tr>
21
21
  <td>{{itemName}}</td>
22
22
  <td>{{requester}}</td>
@@ -41,7 +41,7 @@
41
41
  </form>
42
42
  </td>
43
43
  </tr>
44
- {{/rows}}
44
+ {{/each}}
45
45
  </tbody>
46
46
  </table>
47
47
  </div>
@@ -6,9 +6,9 @@
6
6
  <div>
7
7
  <label class="form-label">Matériel</label>
8
8
  <select name="itemId" class="form-select" onchange="this.form.submit()">
9
- {{#items}}
10
- <option value="{{id}}" {{#if (eq ../chosenItemId id)}}selected{{/if}}>{{name}} — {{location}}</option>
11
- {{/items}}
9
+ {{#each items}}
10
+ <option value="{{id}}" {{#if selected}}selected{{/if}}>{{name}} — {{location}}</option>
11
+ {{/each}}
12
12
  </select>
13
13
  </div>
14
14
  <div class="text-muted small">
@@ -55,13 +55,16 @@
55
55
  <script src="/plugins/nodebb-plugin-equipment-calendar/lib/client.js"></script>
56
56
 
57
57
  <script>
58
- window.EC_EVENTS = {{{eventsJson}}};
58
+ // eventsJson is already JSON, we output it unescaped by using data attribute trick
59
+ window.EC_EVENTS = JSON.parse(document.getElementById('ec-events-json').textContent);
59
60
  window.EC_INITIAL_DATE = "{{initialDateISO}}";
60
61
  window.EC_INITIAL_VIEW = "{{view}}";
61
62
  window.EC_TZ = "{{tz}}";
62
63
  window.EC_CAN_CREATE = {{#if canCreate}}true{{else}}false{{/if}};
63
64
  </script>
64
65
 
66
+ <script type="application/json" id="ec-events-json">{{{eventsJson}}}</script>
67
+
65
68
  <style>
66
69
  .ec-status-pending .fc-event-title { font-weight: 600; }
67
70
  .ec-status-valid .fc-event-title { font-weight: 700; }
@@ -1,6 +1,6 @@
1
1
  <div class="equipment-payment-return">
2
2
  <h1>Paiement</h1>
3
- {{#if (eq status "error")}}
3
+ {{#if statusError}}
4
4
  <div class="alert alert-danger">Le paiement semble avoir échoué. Référence réservation: <code>{{rid}}</code></div>
5
5
  {{else}}
6
6
  <div class="alert alert-info">Merci. Si le paiement est confirmé, la réservation passera en "validée". Référence: <code>{{rid}}</code></div>