nodebb-plugin-calendar-onekite 11.2.26 → 11.2.27

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/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
+ # Changelog
1
2
 
2
- ## 1.0.1
3
- - Correctif : après validation d'une réservation depuis l’ACP, le lien HelloAsso (paymentUrl) est maintenant bien enregistré et transmis au calendrier (bouton **Payer maintenant** visible dans la modale).
3
+ ## 1.0.2
4
+ - Calendrier : compatibilité thèmes/legacy expose `window.$` / `window.jQuery` si absents (dependency AMD `jquery`) pour éviter l’erreur **`$ is not defined`**.
5
+ - Calendrier : compatibilité NodeBB — shim minimal pour `app.alert(...)` (redirige vers le module `alerts`) afin d’éviter l’erreur **`app.alert is not a function`**.
6
+ - Calendrier : évite la double initialisation (hook `action:ajaxify.end` + tick initial) qui pouvait provoquer un clignotement au chargement.
7
+ - ACP : suppression du `require(...)` inline dans le template ACP (l’ACP script est déjà chargé via `acpScripts`) et auto-init via `ajaxify`.
4
8
 
5
- # Changelog
9
+ ## 1.0.1
10
+ - Correctif : après validation d’une réservation depuis l’ACP, le lien HelloAsso (`paymentUrl`) est maintenant bien enregistré et transmis au calendrier (bouton **Payer maintenant** visible dans la modale).
6
11
 
7
12
  ## 1.0.0
8
13
 
@@ -15,7 +20,7 @@
15
20
  - Évènements : alignement de l’horloge identique aux icônes des réservations (rendu sans colonne de temps FullCalendar).
16
21
  - Création d’évènement : clic sur un jour = valeur par défaut **07:00 → 07:00** (gestion robuste de l’`end` exclusif FullCalendar).
17
22
  - Modales : correction d’un cas où, après annulation (ESC/clic extérieur), les modales ne réapparaissaient plus.
18
- - **Nouveau** : conservation du dernier mode sélectionné (**Location** / **Évènement**) même après création/annulation/refetch (persisté par utilisateur via `localStorage`).
23
+ - Nouveau : conservation du dernier mode sélectionné (**Location** / **Évènement**) même après création/annulation/refetch (persisté par utilisateur via `localStorage`).
19
24
 
20
25
  ### Emails
21
26
  - Template relance : ajout du même bloc de paiement que dans pending (bouton + lien de secours).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-calendar-onekite",
3
- "version": "11.2.26",
3
+ "version": "11.2.27",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "acpScripts": [
32
32
  "public/admin.js"
33
33
  ],
34
- "version": "1.0.1"
34
+ "version": "1.0.2"
35
35
  }
package/public/admin.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts, bootbox) {
2
+ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alerts, bootbox, hooks) {
3
3
  'use strict';
4
4
 
5
5
  // Cache of pending reservations keyed by rid so delegated click handlers
@@ -782,5 +782,23 @@ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts
782
782
  }
783
783
  }
784
784
 
785
+ // Auto-init when the ACP page is rendered (ajaxify navigation).
786
+ function autoInit(data) {
787
+ try {
788
+ const tpl = data && data.template ? data.template.name : (window.ajaxify && window.ajaxify.data && window.ajaxify.data.template ? window.ajaxify.data.template.name : '');
789
+ if (tpl === 'admin/plugins/calendar-onekite') {
790
+ init();
791
+ }
792
+ } catch (e) {}
793
+ }
794
+
795
+ try {
796
+ if (hooks && typeof hooks.on === 'function') {
797
+ hooks.on('action:ajaxify.end', autoInit);
798
+ }
799
+ // Initial load fallback
800
+ setTimeout(() => autoInit({ template: (window.ajaxify && window.ajaxify.data && window.ajaxify.data.template) || { name: '' } }), 0);
801
+ } catch (e) {}
802
+
785
803
  return { init };
786
804
  });
package/public/client.js CHANGED
@@ -1,8 +1,34 @@
1
1
  /* global FullCalendar, ajaxify */
2
2
 
3
- define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alerts, bootbox, hooks) {
3
+ define('forum/calendar-onekite', ['jquery', 'alerts', 'bootbox', 'hooks'], function ($, alerts, bootbox, hooks) {
4
4
  'use strict';
5
5
 
6
+ // Some themes or legacy scripts still expect a global jQuery ($).
7
+ // Provide a safe global alias when missing.
8
+ try {
9
+ if (typeof window.$ === 'undefined' && $) window.$ = $;
10
+ if (typeof window.jQuery === 'undefined' && $) window.jQuery = $;
11
+ } catch (e) {}
12
+
13
+ // NodeBB core evolved from app.alert(...) to the alerts module.
14
+ // Provide a tiny compatibility shim to prevent console errors from legacy code.
15
+ try {
16
+ if (typeof window.app !== 'undefined' && window.app && typeof window.app.alert !== 'function') {
17
+ window.app.alert = function (data) {
18
+ try {
19
+ const type = (data && data.type) ? String(data.type) : 'info';
20
+ const msg = (data && (data.message || data.text)) ? String(data.message || data.text) : '';
21
+ if (!msg) return;
22
+ if (alerts && typeof alerts[type] === 'function') {
23
+ alerts[type](msg);
24
+ } else if (alerts && typeof alerts.alert === 'function') {
25
+ alerts.alert({ type, message: msg });
26
+ }
27
+ } catch (e) {}
28
+ };
29
+ }
30
+ } catch (e) {}
31
+
6
32
  // Ensure small UI tweaks are applied even when themes override bootstrap defaults.
7
33
  (function ensureOneKiteStyles() {
8
34
  try {
@@ -828,6 +854,17 @@ function toDatetimeLocalValue(date) {
828
854
  return;
829
855
  }
830
856
 
857
+ // Prevent double initialisation (ajaxify.end + initial-load tick) which can
858
+ // cause a visible "double refresh" flicker.
859
+ try {
860
+ if (el.dataset && el.dataset.onekiteInit === '1') {
861
+ return;
862
+ }
863
+ if (el.dataset) {
864
+ el.dataset.onekiteInit = '1';
865
+ }
866
+ } catch (e) {}
867
+
831
868
  if (typeof FullCalendar === 'undefined') {
832
869
  showAlert('error', 'FullCalendar non chargé');
833
870
  return;
@@ -1633,10 +1670,19 @@ function toDatetimeLocalValue(date) {
1633
1670
  }
1634
1671
 
1635
1672
  // Auto-init on /calendar when ajaxify finishes rendering.
1673
+ // Prevent double initialisation (ajaxify.end + initial tick) which causes a visible flicker.
1674
+ let didInit = false;
1675
+
1636
1676
  function autoInit(data) {
1637
1677
  try {
1638
1678
  const tpl = data && data.template ? data.template.name : (ajaxify && ajaxify.data && ajaxify.data.template ? ajaxify.data.template.name : '');
1639
1679
  if (tpl === 'calendar-onekite') {
1680
+ const el = document.querySelector('#onekite-calendar');
1681
+ if (!el) return;
1682
+ if (el.dataset && el.dataset.onekiteInit === '1') return;
1683
+ if (didInit) return;
1684
+ didInit = true;
1685
+ try { if (el.dataset) el.dataset.onekiteInit = '1'; } catch (e) {}
1640
1686
  init('#onekite-calendar');
1641
1687
  }
1642
1688
  } catch (e) {}
@@ -179,12 +179,10 @@
179
179
  </div>
180
180
  </div>
181
181
 
182
- <script>
183
- require(['admin/plugins/calendar-onekite'], function (mod) {
184
- if (mod && mod.init) {
185
- mod.init();
186
- }
187
- });
188
- </script>
182
+ <!--
183
+ No inline require() here.
184
+ NodeBB loads this plugin's ACP script via plugin.json (acpScripts).
185
+ The admin module auto-initialises on ajaxify.
186
+ -->
189
187
 
190
188
  <!-- IMPORT admin/partials/settings/footer.tpl -->