nodebb-plugin-equipment-calendar 9.0.10 → 9.0.11

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
@@ -735,7 +735,24 @@ plugin.init = async function (params) {
735
735
 
736
736
  // Admin (ACP) routes
737
737
  if (mid && mid.admin) {
738
- router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
738
+
739
+ router.post('/admin/plugins/equipment-calendar/save', middleware.applyCSRF, async (req, res) => {
740
+ try {
741
+ const body = req.body || {};
742
+ // only keep known keys
743
+ const out = {};
744
+ Object.keys(DEFAULT_SETTINGS).forEach((k) => {
745
+ if (body[k] !== undefined) out[k] = body[k];
746
+ });
747
+ await meta.settings.set('equipmentCalendar', out);
748
+ return res.redirect(nconf.get('relative_path') + '/admin/plugins/equipment-calendar?saved=1');
749
+ } catch (e) {
750
+ winston.error('[equipment-calendar] admin save error', e);
751
+ return res.redirect(nconf.get('relative_path') + '/admin/plugins/equipment-calendar?error=1');
752
+ }
753
+ });
754
+
755
+ router.get('/admin/plugins/equipment-calendar', middleware.applyCSRF, mid.admin.buildHeader, renderAdminPage);
739
756
  router.get('/admin/plugins/equipment-calendar/reservations', middleware.applyCSRF, mid.admin.buildHeader, renderAdminReservationsPage);
740
757
  router.get('/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, mid.admin.buildHeader, handleHelloAssoTest);
741
758
  router.get('/api/admin/plugins/equipment-calendar/helloasso-test', middleware.applyCSRF, handleHelloAssoTest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-equipment-calendar",
3
- "version": "9.0.10",
3
+ "version": "9.0.11",
4
4
  "description": "Equipment reservation calendar for NodeBB (FullCalendar, approvals, HelloAsso payments)",
5
5
  "main": "library.js",
6
6
  "scripts": {
package/plugin.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "scripts": [
26
26
  "public/js/client.js"
27
27
  ],
28
- "version": "3.0.0-stable4x-official-save",
28
+ "version": "3.0.0-stable4y-save-fallback",
29
29
  "minver": "4.7.1",
30
30
  "acpScripts": [
31
31
  "public/js/admin.js"
@@ -4,7 +4,9 @@ define('admin/plugins/equipment-calendar', ['settings', 'alerts'], function (Set
4
4
  const Admin = {};
5
5
  Admin.init = function () {
6
6
  Settings.load('equipmentCalendar', $('.acp-page-container'));
7
- $('#save').on('click', function () {
7
+ $('#save').on('click', function (e) {
8
+ try { e.preventDefault(); } catch (err) {}
9
+
8
10
  Settings.save('equipmentCalendar', $('.acp-page-container'), function () {
9
11
  alerts.success('[[admin/settings:settings-saved]]');
10
12
  });
@@ -1,5 +1,7 @@
1
1
 
2
2
  <div class="acp-page-container">
3
+ <form class="equipment-calendar-form" method="post" action="{config.relative_path}/admin/plugins/equipment-calendar/save">
4
+ <input type="hidden" name="_csrf" value="{csrf_token}">
3
5
  <h1 class="mb-3">Equipment Calendar</h1>
4
6
 
5
7
  <div class="card card-body mb-3">
@@ -63,10 +65,15 @@
63
65
  </div>
64
66
 
65
67
  <button id="save" class="btn btn-primary" type="button">Enregistrer</button>
68
+ </form>
66
69
  </div>
67
70
 
68
71
  <script>
69
72
  require(['admin/plugins/equipment-calendar'], function (mod) {
70
73
  mod.init();
74
+ try {
75
+ var f = document.querySelector('.equipment-calendar-form');
76
+ if (f) f.addEventListener('submit', function (e) { e.preventDefault(); return false; });
77
+ } catch (e) {}
71
78
  });
72
79
  </script>