nodebb-plugin-equipment-calendar 0.2.6 → 0.2.7

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.6",
3
+ "version": "0.2.7",
4
4
  "description": "Equipment reservation calendar for NodeBB (FullCalendar, approvals, HelloAsso payments)",
5
5
  "main": "library.js",
6
6
  "scripts": {
@@ -18,7 +18,6 @@
18
18
  "dependencies": {
19
19
  "axios": "^1.7.9",
20
20
  "luxon": "^3.5.0",
21
- "uuid": "^9.0.1",
22
- "fullcalendar": "^6.1.19"
21
+ "uuid": "^9.0.1"
23
22
  }
24
23
  }
package/plugin.json CHANGED
@@ -21,8 +21,7 @@
21
21
  "templates": "./public/templates",
22
22
  "staticDirs": {
23
23
  "js": "public/js",
24
- "css": "public/css",
25
- "vendor": "node_modules/fullcalendar/dist"
24
+ "css": "public/css"
26
25
  },
27
26
  "scripts": [
28
27
  "public/js/client.js"
@@ -1,40 +1,55 @@
1
1
  'use strict';
2
- /* global socket */
2
+ /* global window, document, socket, app */
3
3
 
4
- define('admin/plugins/equipment-calendar', ['jquery'], function ($) {
5
- const EquipmentCalendar = {};
4
+ (function () {
5
+ function byId(id) { return document.getElementById(id); }
6
6
 
7
- EquipmentCalendar.init = function () {
8
- $('#save').on('click', function () {
9
- const payload = {
10
- creatorGroups: $('#creatorGroups').val(),
11
- approverGroup: $('#approverGroup').val(),
12
- notifyGroup: $('#notifyGroup').val(),
13
- itemsJson: $('#itemsJson').val(),
14
- ha_clientId: $('#ha_clientId').val(),
15
- ha_clientSecret: $('#ha_clientSecret').val(),
16
- ha_organizationSlug: $('#ha_organizationSlug').val(),
17
- ha_returnUrl: $('#ha_returnUrl').val(),
18
- ha_webhookSecret: $('#ha_webhookSecret').val(),
19
- defaultView: $('#defaultView').val(),
20
- timezone: $('#timezone').val(),
21
- showRequesterToAll: $('#showRequesterToAll').is(':checked') ? '1' : '0',
22
- };
7
+ function collect() {
8
+ return {
9
+ creatorGroups: byId('creatorGroups') ? byId('creatorGroups').value : '',
10
+ approverGroup: byId('approverGroup') ? byId('approverGroup').value : '',
11
+ notifyGroup: byId('notifyGroup') ? byId('notifyGroup').value : '',
12
+ itemsJson: byId('itemsJson') ? byId('itemsJson').value : '[]',
13
+ ha_clientId: byId('ha_clientId') ? byId('ha_clientId').value : '',
14
+ ha_clientSecret: byId('ha_clientSecret') ? byId('ha_clientSecret').value : '',
15
+ ha_organizationSlug: byId('ha_organizationSlug') ? byId('ha_organizationSlug').value : '',
16
+ ha_returnUrl: byId('ha_returnUrl') ? byId('ha_returnUrl').value : '',
17
+ ha_webhookSecret: byId('ha_webhookSecret') ? byId('ha_webhookSecret').value : '',
18
+ defaultView: byId('defaultView') ? byId('defaultView').value : 'dayGridMonth',
19
+ timezone: byId('timezone') ? byId('timezone').value : 'Europe/Paris',
20
+ showRequesterToAll: (byId('showRequesterToAll') && byId('showRequesterToAll').checked) ? '1' : '0',
21
+ };
22
+ }
23
+
24
+ function onReady(fn) {
25
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
26
+ else fn();
27
+ }
28
+
29
+ onReady(function () {
30
+ const btn = byId('save');
31
+ if (!btn) return;
32
+
33
+ btn.addEventListener('click', function () {
34
+ if (typeof socket === 'undefined' || !socket.emit) {
35
+ const msg = 'Socket NodeBB indisponible (socket.emit). Vérifie que tu es bien dans l\'ACP.';
36
+ if (window.app && window.app.alertError) window.app.alertError(msg);
37
+ else alert(msg);
38
+ return;
39
+ }
40
+
41
+ const payload = collect();
23
42
 
24
43
  socket.emit('admin.settings.save', { hash: 'equipmentCalendar', values: payload }, function (err) {
25
44
  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é');
45
+ const m = (err.message || err) + '';
46
+ if (window.app && window.app.alertError) return window.app.alertError(m);
47
+ alert(m);
48
+ return;
33
49
  }
50
+ if (window.app && window.app.alertSuccess) return window.app.alertSuccess('Sauvegardé');
34
51
  alert('Sauvegardé');
35
52
  });
36
53
  });
37
- };
38
-
39
- return EquipmentCalendar;
40
- });
54
+ });
55
+ }());
@@ -62,6 +62,3 @@
62
62
  </div>
63
63
  </div>
64
64
 
65
- <script>
66
- require(['admin/plugins/equipment-calendar'], function (m) { m.init(); });
67
- </script>
@@ -50,8 +50,7 @@
50
50
  {{{ end }}}
51
51
  </div>
52
52
 
53
- <link rel="stylesheet" href="/plugins/nodebb-plugin-equipment-calendar/vendor/index.global.min.css">
54
- <script src="/plugins/nodebb-plugin-equipment-calendar/vendor/index.global.min.js"></script>
53
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/6.1.19/index.global.min.js"></script>
55
54
  <script src="/plugins/nodebb-plugin-equipment-calendar/js/client.js"></script>
56
55
 
57
56
  <script>