fix: data-action delegation + convert onclick to event listeners, sidebar+logout+modals
This commit is contained in:
@@ -28,14 +28,14 @@ const NotificationsPage = {
|
||||
|
||||
showCreate() {
|
||||
U.modal('æ·»åŠ Webhook', `
|
||||
<form id="nc-form"><div class="form-group"><label>名称 *</label><input id="nc-name" placeholder="如: Discord通知" required></div>
|
||||
<form id="nc-form"><div class="form-group"><label>å<EFBFBD><EFBFBD>ç§° *</label><input id="nc-name" placeholder="å¦? Discord通知" required></div>
|
||||
<div class="form-group"><label>类型 *</label><select id="nc-type"><option value="webhook">Webhook</option></select></div>
|
||||
<div class="form-group"><label>Webhook URL *</label><input id="nc-url" placeholder="https://discord.com/api/webhooks/..." required></div>
|
||||
<div class="form-group"><label>触å<C2A6>‘事件</label>
|
||||
<div style="display:flex;flex-wrap:wrap;gap:8px;margin-top:4px">${EventOptions('all')}</div>
|
||||
<input type="hidden" id="nc-events" value="all">
|
||||
</div>
|
||||
<div class="modal-f"><button type="button" class="btn btn-o" onclick="App.closeModal()">取消</button><button type="submit" class="btn btn-p">创建</button></div></form>
|
||||
<div class="modal-f"><button type="button" class="btn btn-o" data-action="App:closeModal">å<>–消</button><button type="submit" class="btn btn-p">创建</button></div></form>
|
||||
`);
|
||||
bindEventToggles();
|
||||
document.getElementById('nc-form').onsubmit = async e => { e.preventDefault();
|
||||
@@ -51,8 +51,8 @@ const NotificationsPage = {
|
||||
<div style="display:flex;flex-wrap:wrap;gap:8px;margin-top:4px">${EventOptions(events)}</div>
|
||||
<input type="hidden" id="ne-events" value="${events}">
|
||||
</div>
|
||||
<div class="form-group"><label>状态</label><select id="ne-active"><option value="1" ${active?'selected':''}>启用</option><option value="0" ${!active?'selected':''}>禁用</option></select></div>
|
||||
<div class="modal-f"><button type="button" class="btn btn-o" onclick="App.closeModal()">取消</button><button type="submit" class="btn btn-p">保存</button></div></form>
|
||||
<div class="form-group"><label>状æ€?/label><select id="ne-active"><option value="1" ${active?'selected':''}>å<EFBFBD>¯ç”¨</option><option value="0" ${!active?'selected':''}>ç¦<EFBFBD>用</option></select></div>
|
||||
<div class="modal-f"><button type="button" class="btn btn-o" data-action="App:closeModal">å<>–消</button><button type="submit" class="btn btn-p">ä¿<EFBFBD>å˜</button></div></form>
|
||||
`);
|
||||
bindEventToggles();
|
||||
document.getElementById('ne-form').onsubmit = async e => { e.preventDefault();
|
||||
@@ -61,7 +61,7 @@ const NotificationsPage = {
|
||||
},
|
||||
|
||||
async test(id) { try { alert((await API.post(`/notifications/${id}/test`)).message); } catch(ex){alert(ex.message);} },
|
||||
async del(id) { if(await U.confirm('确认删除此通知配置?')){ try { await API.req('DELETE',`/notifications/${id}`); this.load(); } catch(ex){alert(ex.message);} } }
|
||||
async del(id) { if(await U.confirm('ç¡®è®¤åˆ é™¤æ¤é€šçŸ¥é…<EFBFBD>ç½®ï¼?)){ try { await API.req('DELETE',`/notifications/${id}`); this.load(); } catch(ex){alert(ex.message);} } }
|
||||
};
|
||||
|
||||
function EventOptions(current) { return ['all','ticket_created','ticket_claimed','ticket_transferred','ticket_updated'].map(e=>`<label style="cursor:pointer;font-size:12px"><input type="checkbox" value="${e}" class="ev-check" ${current.split(',').map(s=>s.trim()).includes(e)?'checked':''}> ${EventsLabelSingle(e)}</label>`).join(''); }
|
||||
|
||||
Reference in New Issue
Block a user