nodebb-plugin-discord-onekite 1.1.20 → 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 +6 -7
- package/package.json +1 -1
- package/plugin.json +4 -1
- package/static/lib/admin.js +31 -5
- package/templates/admin/plugins/discord-onekite.tpl +13 -6
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
# nodebb-plugin-discord-onekite v1.1.4.
|
|
1
|
+
# nodebb-plugin-discord-onekite v1.1.4.13
|
|
2
2
|
|
|
3
|
-
Fixes ACP
|
|
4
|
-
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
- Message: "Paramètres enregistrés"
|
|
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
package/plugin.json
CHANGED
package/static/lib/admin.js
CHANGED
|
@@ -4,18 +4,44 @@
|
|
|
4
4
|
define('admin/plugins/discord-onekite', ['settings'], function (settings) {
|
|
5
5
|
const ACP = {};
|
|
6
6
|
|
|
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(',');
|
|
13
|
+
}
|
|
14
|
+
function setSelectedCids(cids) {
|
|
15
|
+
const set = new Set((cids || []).map(String));
|
|
16
|
+
$('#cidsMulti option').each(function () {
|
|
17
|
+
$(this).prop('selected', set.has(String($(this).val())));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function getSelectedCids() {
|
|
21
|
+
return $('#cidsMulti option:selected').map(function () { return String($(this).val()); }).get();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function toastSuccess() {
|
|
25
|
+
if (window.app && typeof app.alert === 'function') {
|
|
26
|
+
app.alert({ type: 'success', title: 'Succès', message: 'Paramètres enregistrés' });
|
|
27
|
+
} else if (window.app && typeof app.alertSuccess === 'function') {
|
|
28
|
+
app.alertSuccess('Succès: Paramètres enregistrés');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
7
32
|
ACP.init = function () {
|
|
8
33
|
const $form = $('.discord-onekite-settings');
|
|
9
34
|
if (!$form.length) return;
|
|
10
35
|
|
|
11
|
-
settings.sync('discord-onekite', $form)
|
|
36
|
+
settings.sync('discord-onekite', $form, function () {
|
|
37
|
+
setSelectedCids(parseCsv($('#cids').val()));
|
|
38
|
+
});
|
|
12
39
|
|
|
13
|
-
$('#save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
|
|
40
|
+
$('#onekite-save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
|
|
14
41
|
e.preventDefault();
|
|
42
|
+
$('#cids').val(toCsv(getSelectedCids()));
|
|
15
43
|
settings.persist('discord-onekite', $form, function () {
|
|
16
|
-
|
|
17
|
-
if (typeof app.alert === 'function') { app.alert({ type: 'success', title: 'Succès', message: 'Paramètres enregistrés' }); } else { app.alertSuccess('Paramètres enregistrés'); }
|
|
18
|
-
}
|
|
44
|
+
toastSuccess();
|
|
19
45
|
});
|
|
20
46
|
});
|
|
21
47
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<div class="acp-page-container">
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<div class="d-flex justify-content-between align-items-start mb-3">
|
|
3
|
+
<div>
|
|
4
|
+
<h4 class="mb-1">Discord Onekite</h4>
|
|
5
|
+
<p class="text-muted mb-0">Notifications Discord via webhook.</p>
|
|
6
|
+
</div>
|
|
7
|
+
<button id="onekite-save" type="button" class="btn btn-primary">Enregistrer les paramètres</button>
|
|
8
|
+
</div>
|
|
4
9
|
|
|
5
10
|
<form role="form" class="discord-onekite-settings">
|
|
6
11
|
<div class="mb-3">
|
|
@@ -16,17 +21,19 @@
|
|
|
16
21
|
</div>
|
|
17
22
|
|
|
18
23
|
<div class="mb-3">
|
|
19
|
-
<label class="form-label" for="
|
|
20
|
-
|
|
24
|
+
<label class="form-label" for="cidsMulti">Catégories à notifier</label>
|
|
25
|
+
|
|
26
|
+
<select class="form-select" id="cidsMulti" multiple size="12">
|
|
21
27
|
<!-- BEGIN categories -->
|
|
22
28
|
<option value="{categories.cid}" <!-- IF categories.selected -->selected<!-- ENDIF categories.selected -->>{categories.name}</option>
|
|
23
29
|
<!-- END categories -->
|
|
24
30
|
</select>
|
|
31
|
+
|
|
32
|
+
<input type="hidden" id="cids" data-field="cids" value="{settings.cids}" />
|
|
33
|
+
|
|
25
34
|
<p class="form-text text-muted">
|
|
26
35
|
Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
|
|
27
36
|
</p>
|
|
28
37
|
</div>
|
|
29
|
-
|
|
30
|
-
<!-- IMPORT admin/partials/save_button.tpl -->
|
|
31
38
|
</form>
|
|
32
39
|
</div>
|