nodebb-plugin-equipment-calendar 0.2.3 → 0.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-equipment-calendar",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Equipment reservation calendar for NodeBB (FullCalendar, approvals, HelloAsso payments)",
5
5
  "main": "library.js",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
- /* global $, app */
2
+ /* global socket */
3
3
 
4
- define('admin/plugins/equipment-calendar', function () {
4
+ define('admin/plugins/equipment-calendar', ['jquery'], function ($) {
5
5
  const EquipmentCalendar = {};
6
6
 
7
7
  EquipmentCalendar.init = function () {
@@ -22,8 +22,16 @@ define('admin/plugins/equipment-calendar', function () {
22
22
  };
23
23
 
24
24
  socket.emit('admin.settings.save', { hash: 'equipmentCalendar', values: payload }, function (err) {
25
- if (err) return app.alertError(err.message || err);
26
- app.alertSuccess('Sauvegardé');
25
+ if (err) {
26
+ if (window.app && window.app.alertError) {
27
+ return window.app.alertError(err.message || err);
28
+ }
29
+ return alert(err.message || err);
30
+ }
31
+ if (window.app && window.app.alertSuccess) {
32
+ return window.app.alertSuccess('Sauvegardé');
33
+ }
34
+ alert('Sauvegardé');
27
35
  });
28
36
  });
29
37
  };
@@ -1,18 +1,20 @@
1
1
  'use strict';
2
- /* global $, window, document, FullCalendar */
2
+ /* global window, document, FullCalendar */
3
3
 
4
4
  (function () {
5
5
  function submitCreate(startISO, endISO) {
6
6
  const form = document.getElementById('ec-create-form');
7
7
  if (!form) return;
8
- form.querySelector('input[name="start"]').value = startISO;
9
- form.querySelector('input[name="end"]').value = endISO;
8
+ const startInput = form.querySelector('input[name="start"]');
9
+ const endInput = form.querySelector('input[name="end"]');
10
+ if (startInput) startInput.value = startISO;
11
+ if (endInput) endInput.value = endISO;
10
12
  form.submit();
11
13
  }
12
14
 
13
- $(document).ready(function () {
15
+ function init() {
14
16
  const el = document.getElementById('equipment-calendar');
15
- if (!el) return;
17
+ if (!el || typeof FullCalendar === 'undefined') return;
16
18
 
17
19
  const events = window.EC_EVENTS || [];
18
20
  const initialDate = window.EC_INITIAL_DATE;
@@ -26,18 +28,13 @@
26
28
  selectMirror: true,
27
29
  events: events,
28
30
  select: function (info) {
29
- // FullCalendar provides end exclusive for all-day; for timed selections it's fine.
30
31
  submitCreate(info.startStr, info.endStr);
31
32
  },
32
33
  dateClick: function (info) {
33
- // Create 1-hour slot by default
34
34
  const start = info.date;
35
35
  const end = new Date(start.getTime() + 60 * 60 * 1000);
36
36
  submitCreate(start.toISOString(), end.toISOString());
37
37
  },
38
- eventClick: function (info) {
39
- // optionally show details
40
- },
41
38
  headerToolbar: {
42
39
  left: 'prev,next today',
43
40
  center: 'title',
@@ -46,5 +43,11 @@
46
43
  });
47
44
 
48
45
  calendar.render();
49
- });
46
+ }
47
+
48
+ if (document.readyState === 'loading') {
49
+ document.addEventListener('DOMContentLoaded', init);
50
+ } else {
51
+ init();
52
+ }
50
53
  }());
@@ -50,7 +50,6 @@
50
50
  {{/if}}
51
51
  </div>
52
52
 
53
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.19/index.global.min.css">
54
53
  <script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.19/index.global.min.js"></script>
55
54
  <script src="/plugins/nodebb-plugin-equipment-calendar/js/client.js"></script>
56
55