Add channel/role autocomplete dropdowns via datalist + /api/guild/resources endpoint
Some checks failed
Deploy Discord Bot / deploy (push) Has been cancelled
Some checks failed
Deploy Discord Bot / deploy (push) Has been cancelled
This commit is contained in:
@@ -105,6 +105,9 @@ router.get('/', (req, res) => {
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<datalist id="channelList"></datalist>
|
||||
<datalist id="roleList"></datalist>
|
||||
<datalist id="categoryList"></datalist>
|
||||
<script>
|
||||
${baseScript}
|
||||
async function ensureAuth() {
|
||||
@@ -1090,6 +1093,9 @@ router.get('/', (req, res) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<datalist id="channelList"></datalist>
|
||||
<datalist id="roleList"></datalist>
|
||||
<datalist id="categoryList"></datalist>
|
||||
<div id="toast" class="toast"></div>
|
||||
<script>
|
||||
${baseScript}
|
||||
@@ -1708,6 +1714,56 @@ router.get('/', (req, res) => {
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
async function loadResources(guildId) {
|
||||
if (!guildId) return;
|
||||
const res = await fetch('/api/guild/resources?guildId=' + encodeURIComponent(guildId));
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
const channelList = document.getElementById('channelList');
|
||||
const roleList = document.getElementById('roleList');
|
||||
const categoryList = document.getElementById('categoryList');
|
||||
if (channelList) {
|
||||
channelList.innerHTML = '';
|
||||
(data.channels || []).forEach((c) => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = '#' + c.name + ' (' + c.id + ')';
|
||||
channelList.appendChild(opt);
|
||||
});
|
||||
}
|
||||
if (roleList) {
|
||||
roleList.innerHTML = '';
|
||||
(data.roles || []).forEach((r) => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = r.id;
|
||||
opt.textContent = '@' + r.name + ' (' + r.id + ')';
|
||||
roleList.appendChild(opt);
|
||||
});
|
||||
}
|
||||
if (categoryList) {
|
||||
categoryList.innerHTML = '';
|
||||
(data.categories || []).forEach((c) => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = c.name + ' (' + c.id + ')';
|
||||
categoryList.appendChild(opt);
|
||||
});
|
||||
}
|
||||
document.querySelectorAll('input[placeholder*="123456"]').forEach((el) => {
|
||||
if (!el.hasAttribute('list')) el.setAttribute('list', 'channelList');
|
||||
});
|
||||
['automationActionValue', 'eventRole', 'statuspageChannel'].forEach((id) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el && !el.hasAttribute('list')) el.setAttribute('list', 'roleList');
|
||||
});
|
||||
document.querySelectorAll('input[name="supportRoleId"], input[name="logChannelId"]').forEach((el) => {
|
||||
if (!el.hasAttribute('list')) el.setAttribute('list', 'channelList');
|
||||
});
|
||||
document.querySelectorAll('textarea[id$="Role"], textarea[id*="Role"]').forEach((el) => {
|
||||
if (!el.hasAttribute('list')) el.setAttribute('list', 'roleList');
|
||||
});
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) return '-';
|
||||
const dt = new Date(value);
|
||||
@@ -1814,6 +1870,7 @@ router.get('/', (req, res) => {
|
||||
if (data.guilds?.length) {
|
||||
currentGuild = currentGuild || guildSelect.value || data.guilds[0].id;
|
||||
guildSelect.value = currentGuild;
|
||||
await loadResources(currentGuild);
|
||||
await loadSettings(currentGuild);
|
||||
await loadModules();
|
||||
await loadOverview();
|
||||
@@ -2727,6 +2784,7 @@ router.get('/', (req, res) => {
|
||||
|
||||
guildSelect.addEventListener('change', async (e) => {
|
||||
currentGuild = e.target.value;
|
||||
await loadResources(currentGuild);
|
||||
await loadSettings(currentGuild);
|
||||
await loadOverview();
|
||||
await loadTickets();
|
||||
|
||||
Reference in New Issue
Block a user