nodebb-plugin-discord-onekite 1.1.21 → 1.1.22

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/README.md CHANGED
@@ -1,10 +1,7 @@
1
- # nodebb-plugin-discord-onekite v1.1.4.12
1
+ # nodebb-plugin-discord-onekite v1.1.4.13
2
2
 
3
- ACP:
4
- - Uses official `settings.sync()` + `settings.persist()`
5
- - Toast title: "Succès" / message: "Paramètres enregistrés"
6
- - Adds a top button "Enregistrer les paramètres" (also keeps the standard bottom-right save button)
7
- - Categories multi-select is persisted as CSV via hidden `data-field="cids"` input for reliability.
8
-
9
- Discord:
10
- - Same as v1.1.4.10 line (embed only, message in embed description).
3
+ Fixes ACP not applying JS / not persisting:
4
+ - Uses `acpScripts` + modules key `admin/plugins/discord-onekite.js` to ensure admin script loads.
5
+ - Removes bottom-right save button partial; uses only the top "Enregistrer les paramètres" button.
6
+ - Persists categories via hidden CSV field `data-field="cids"`.
7
+ - Toast uses title "Succès" and message "Paramètres enregistrés".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -22,7 +22,10 @@
22
22
  }
23
23
  ],
24
24
  "templates": "templates",
25
+ "acpScripts": [
26
+ "static/lib/admin.js"
27
+ ],
25
28
  "modules": {
26
- "../admin/plugins/discord-onekite.js": "static/lib/admin.js"
29
+ "admin/plugins/discord-onekite.js": "static/lib/admin.js"
27
30
  }
28
31
  }
@@ -4,32 +4,28 @@
4
4
  define('admin/plugins/discord-onekite', ['settings'], function (settings) {
5
5
  const ACP = {};
6
6
 
7
- function getSelectedCids() {
8
- return $('#cidsMulti option:selected').map(function () { return String($(this).val()); }).get();
7
+ function parseCsv(v) {
8
+ if (!v) return [];
9
+ return String(v).split(',').map(s => s.trim()).filter(Boolean);
10
+ }
11
+ function toCsv(arr) {
12
+ return (arr || []).map(String).filter(Boolean).join(',');
9
13
  }
10
-
11
14
  function setSelectedCids(cids) {
12
15
  const set = new Set((cids || []).map(String));
13
16
  $('#cidsMulti option').each(function () {
14
17
  $(this).prop('selected', set.has(String($(this).val())));
15
18
  });
16
19
  }
17
-
18
- function parseCsv(v) {
19
- if (!v) return [];
20
- if (Array.isArray(v)) return v.map(String).filter(Boolean);
21
- return String(v).split(',').map(s => s.trim()).filter(Boolean);
22
- }
23
-
24
- function toCsv(arr) {
25
- return (arr || []).map(String).filter(Boolean).join(',');
20
+ function getSelectedCids() {
21
+ return $('#cidsMulti option:selected').map(function () { return String($(this).val()); }).get();
26
22
  }
27
23
 
28
24
  function toastSuccess() {
29
25
  if (window.app && typeof app.alert === 'function') {
30
26
  app.alert({ type: 'success', title: 'Succès', message: 'Paramètres enregistrés' });
31
27
  } else if (window.app && typeof app.alertSuccess === 'function') {
32
- app.alertSuccess('Paramètres enregistrés');
28
+ app.alertSuccess('Succès: Paramètres enregistrés');
33
29
  }
34
30
  }
35
31
 
@@ -37,32 +33,16 @@ define('admin/plugins/discord-onekite', ['settings'], function (settings) {
37
33
  const $form = $('.discord-onekite-settings');
38
34
  if (!$form.length) return;
39
35
 
40
- // Sync settings into form fields (data-field)
41
36
  settings.sync('discord-onekite', $form, function () {
42
- // After sync, update UI multiselect from persisted CSV value
43
- const csv = $('#cids').val();
44
- setSelectedCids(parseCsv(csv));
37
+ setSelectedCids(parseCsv($('#cids').val()));
45
38
  });
46
39
 
47
- function persist() {
48
- // Before persist, copy UI multiselect to hidden CSV field
40
+ $('#onekite-save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
41
+ e.preventDefault();
49
42
  $('#cids').val(toCsv(getSelectedCids()));
50
-
51
43
  settings.persist('discord-onekite', $form, function () {
52
44
  toastSuccess();
53
45
  });
54
- }
55
-
56
- // bottom-right save button has id #save (from partial)
57
- $('#save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
58
- e.preventDefault();
59
- persist();
60
- });
61
-
62
- // top button
63
- $('#save-top').off('click.discordOnekite').on('click.discordOnekite', function (e) {
64
- e.preventDefault();
65
- persist();
66
46
  });
67
47
  };
68
48
 
@@ -4,17 +4,17 @@
4
4
  <h4 class="mb-1">Discord Onekite</h4>
5
5
  <p class="text-muted mb-0">Notifications Discord via webhook.</p>
6
6
  </div>
7
- <button id="save-top" type="button" class="btn btn-primary">Enregistrer les paramètres</button>
7
+ <button id="onekite-save" type="button" class="btn btn-primary">Enregistrer les paramètres</button>
8
8
  </div>
9
9
 
10
10
  <form role="form" class="discord-onekite-settings">
11
11
  <div class="mb-3">
12
12
  <label class="form-label" for="webhookUrl">Discord Webhook URL</label>
13
- <input type="text" class="form-control" id="webhookUrl" name="webhookUrl" data-field="webhookUrl" value="{settings.webhookUrl}" placeholder="https://discord.com/api/webhooks/..." />
13
+ <input type="text" class="form-control" id="webhookUrl" data-field="webhookUrl" value="{settings.webhookUrl}" placeholder="https://discord.com/api/webhooks/..." />
14
14
  </div>
15
15
 
16
16
  <div class="form-check mb-3">
17
- <input class="form-check-input" type="checkbox" id="notifyReplies" name="notifyReplies" data-field="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
17
+ <input class="form-check-input" type="checkbox" id="notifyReplies" data-field="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
18
18
  <label class="form-check-label" for="notifyReplies">
19
19
  Notifier aussi les réponses (si décoché : uniquement les nouveaux sujets)
20
20
  </label>
@@ -23,22 +23,17 @@
23
23
  <div class="mb-3">
24
24
  <label class="form-label" for="cidsMulti">Catégories à notifier</label>
25
25
 
26
- <!-- UI multi-select (not directly persisted) -->
27
26
  <select class="form-select" id="cidsMulti" multiple size="12">
28
27
  <!-- BEGIN categories -->
29
28
  <option value="{categories.cid}" <!-- IF categories.selected -->selected<!-- ENDIF categories.selected -->>{categories.name}</option>
30
29
  <!-- END categories -->
31
30
  </select>
32
31
 
33
- <!-- Persisted field: comma-separated list of cids -->
34
- <input type="hidden" id="cids" name="cids" data-field="cids" value="{settings.cids}" />
32
+ <input type="hidden" id="cids" data-field="cids" value="{settings.cids}" />
35
33
 
36
34
  <p class="form-text text-muted">
37
35
  Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
38
36
  </p>
39
37
  </div>
40
-
41
- <!-- Bottom-right official save button -->
42
- <!-- IMPORT admin/partials/save_button.tpl -->
43
38
  </form>
44
39
  </div>