nodebb-plugin-discord-onekite 1.1.19 → 1.1.21
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 +8 -6
- package/package.json +1 -1
- package/static/lib/admin.js +52 -6
- package/templates/admin/plugins/discord-onekite.tpl +18 -6
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# nodebb-plugin-discord-onekite v1.1.4.
|
|
1
|
+
# nodebb-plugin-discord-onekite v1.1.4.12
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
-
|
|
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.
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
- Message: "Paramètres enregistrés"
|
|
9
|
+
Discord:
|
|
10
|
+
- Same as v1.1.4.10 line (embed only, message in embed description).
|
package/package.json
CHANGED
package/static/lib/admin.js
CHANGED
|
@@ -4,19 +4,65 @@
|
|
|
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();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function setSelectedCids(cids) {
|
|
12
|
+
const set = new Set((cids || []).map(String));
|
|
13
|
+
$('#cidsMulti option').each(function () {
|
|
14
|
+
$(this).prop('selected', set.has(String($(this).val())));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
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(',');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function toastSuccess() {
|
|
29
|
+
if (window.app && typeof app.alert === 'function') {
|
|
30
|
+
app.alert({ type: 'success', title: 'Succès', message: 'Paramètres enregistrés' });
|
|
31
|
+
} else if (window.app && typeof app.alertSuccess === 'function') {
|
|
32
|
+
app.alertSuccess('Paramètres enregistrés');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
7
36
|
ACP.init = function () {
|
|
8
37
|
const $form = $('.discord-onekite-settings');
|
|
9
38
|
if (!$form.length) return;
|
|
10
39
|
|
|
11
|
-
settings
|
|
40
|
+
// Sync settings into form fields (data-field)
|
|
41
|
+
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));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
function persist() {
|
|
48
|
+
// Before persist, copy UI multiselect to hidden CSV field
|
|
49
|
+
$('#cids').val(toCsv(getSelectedCids()));
|
|
12
50
|
|
|
13
|
-
$('#save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
|
|
14
|
-
e.preventDefault();
|
|
15
51
|
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
|
-
}
|
|
52
|
+
toastSuccess();
|
|
19
53
|
});
|
|
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();
|
|
20
66
|
});
|
|
21
67
|
};
|
|
22
68
|
|
|
@@ -1,32 +1,44 @@
|
|
|
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="save-top" 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">
|
|
7
12
|
<label class="form-label" for="webhookUrl">Discord Webhook URL</label>
|
|
8
|
-
<input type="text" class="form-control" id="webhookUrl" data-field="webhookUrl" value="{settings.webhookUrl}" placeholder="https://discord.com/api/webhooks/..." />
|
|
13
|
+
<input type="text" class="form-control" id="webhookUrl" name="webhookUrl" data-field="webhookUrl" value="{settings.webhookUrl}" placeholder="https://discord.com/api/webhooks/..." />
|
|
9
14
|
</div>
|
|
10
15
|
|
|
11
16
|
<div class="form-check mb-3">
|
|
12
|
-
<input class="form-check-input" type="checkbox" id="notifyReplies" data-field="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
|
|
17
|
+
<input class="form-check-input" type="checkbox" id="notifyReplies" name="notifyReplies" data-field="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
|
|
13
18
|
<label class="form-check-label" for="notifyReplies">
|
|
14
19
|
Notifier aussi les réponses (si décoché : uniquement les nouveaux sujets)
|
|
15
20
|
</label>
|
|
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
|
+
<!-- UI multi-select (not directly persisted) -->
|
|
27
|
+
<select class="form-select" id="cidsMulti" multiple size="12">
|
|
21
28
|
<!-- BEGIN categories -->
|
|
22
29
|
<option value="{categories.cid}" <!-- IF categories.selected -->selected<!-- ENDIF categories.selected -->>{categories.name}</option>
|
|
23
30
|
<!-- END categories -->
|
|
24
31
|
</select>
|
|
32
|
+
|
|
33
|
+
<!-- Persisted field: comma-separated list of cids -->
|
|
34
|
+
<input type="hidden" id="cids" name="cids" data-field="cids" value="{settings.cids}" />
|
|
35
|
+
|
|
25
36
|
<p class="form-text text-muted">
|
|
26
37
|
Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
|
|
27
38
|
</p>
|
|
28
39
|
</div>
|
|
29
40
|
|
|
41
|
+
<!-- Bottom-right official save button -->
|
|
30
42
|
<!-- IMPORT admin/partials/save_button.tpl -->
|
|
31
43
|
</form>
|
|
32
44
|
</div>
|