Poista vastauspohjat asetuksista, pidetään vain tikettipuolella
Vastauspohjien hallinta kuuluu asiakaspalvelu-osioon, ei API-asetusten alle. Poistettu tuplana ollut HTML-osio + siihen liittyvät JS-eventlistenerit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
25
index.html
25
index.html
@@ -651,31 +651,6 @@
|
||||
<pre id="test-api-result" style="margin-top:0.75rem;background:#f8f9fb;padding:1rem;border-radius:8px;font-size:0.85rem;display:none;overflow-x:auto;"></pre>
|
||||
</div>
|
||||
|
||||
<!-- Vastauspohjat -->
|
||||
<div class="table-card" style="padding:1.5rem;margin-top:1rem;">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem;">
|
||||
<h3 style="color:#0f3460;margin:0;border-bottom:none;">Vastauspohjat</h3>
|
||||
<button class="btn-primary" id="btn-add-template" style="font-size:0.85rem;">+ Uusi pohja</button>
|
||||
</div>
|
||||
<p style="color:#666;font-size:0.85rem;margin-bottom:1rem;">Nopeat vastauspohjat tiketteihin. Valittavissa vastauslomakkeen valikosta.</p>
|
||||
<div id="templates-list"></div>
|
||||
<div id="template-form" style="display:none;margin-top:1rem;padding:1rem;background:#f8f9fb;border-radius:8px;">
|
||||
<input type="hidden" id="template-edit-id">
|
||||
<div class="form-group" style="margin-bottom:0.5rem;">
|
||||
<label style="font-size:0.85rem;">Nimi</label>
|
||||
<input type="text" id="template-edit-name" placeholder="esim. Kuittaus vastaanotettu">
|
||||
</div>
|
||||
<div class="form-group" style="margin-bottom:0.5rem;">
|
||||
<label style="font-size:0.85rem;">Sisältö</label>
|
||||
<textarea id="template-edit-body" rows="4" placeholder="Kiitos viestistäsi! Olemme vastaanottaneet asiasi ja palaamme siihen mahdollisimman pian."></textarea>
|
||||
</div>
|
||||
<div style="display:flex;gap:0.5rem;">
|
||||
<button class="btn-primary" id="btn-save-template">Tallenna</button>
|
||||
<button class="btn-secondary" id="btn-cancel-template">Peruuta</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Telegram-asetukset -->
|
||||
<div class="table-card" style="padding:1.5rem;margin-top:1rem;">
|
||||
<h3 style="color:#0f3460;margin-bottom:0.5rem;border-bottom:2px solid #f0f2f5;padding-bottom:0.5rem;">Telegram-hälytykset</h3>
|
||||
|
||||
62
script.js
62
script.js
@@ -2085,70 +2085,10 @@ let replyTemplates = [];
|
||||
async function loadTemplates() {
|
||||
try {
|
||||
replyTemplates = await apiCall('reply_templates');
|
||||
renderTemplates();
|
||||
renderTplList();
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
function renderTemplates() {
|
||||
const list = document.getElementById('templates-list');
|
||||
if (!list) return;
|
||||
if (replyTemplates.length === 0) {
|
||||
list.innerHTML = '<p style="color:#aaa;font-size:0.85rem;">Ei vastauspohjia vielä.</p>';
|
||||
return;
|
||||
}
|
||||
list.innerHTML = replyTemplates.map(t =>
|
||||
`<div style="display:flex;justify-content:space-between;align-items:center;padding:0.5rem 0;border-bottom:1px solid #f0f2f5;">
|
||||
<div>
|
||||
<strong style="font-size:0.9rem;">${esc(t.nimi)}</strong>
|
||||
<div style="font-size:0.8rem;color:#888;max-width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">${esc(t.body.substring(0, 80))}</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:0.3rem;">
|
||||
<button class="btn-secondary" onclick="editTemplate('${t.id}')" style="padding:4px 8px;font-size:0.78rem;">Muokkaa</button>
|
||||
<button class="btn-danger" onclick="deleteTemplate('${t.id}')" style="padding:4px 8px;font-size:0.78rem;">Poista</button>
|
||||
</div>
|
||||
</div>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
document.getElementById('btn-add-template').addEventListener('click', () => {
|
||||
document.getElementById('template-edit-id').value = '';
|
||||
document.getElementById('template-edit-name').value = '';
|
||||
document.getElementById('template-edit-body').value = '';
|
||||
document.getElementById('template-form').style.display = 'block';
|
||||
});
|
||||
|
||||
document.getElementById('btn-cancel-template').addEventListener('click', () => {
|
||||
document.getElementById('template-form').style.display = 'none';
|
||||
});
|
||||
|
||||
document.getElementById('btn-save-template').addEventListener('click', async () => {
|
||||
const id = document.getElementById('template-edit-id').value || undefined;
|
||||
const nimi = document.getElementById('template-edit-name').value.trim();
|
||||
const body = document.getElementById('template-edit-body').value.trim();
|
||||
if (!nimi || !body) { alert('Täytä nimi ja sisältö'); return; }
|
||||
try {
|
||||
await apiCall('reply_template_save', 'POST', { id, nimi, body });
|
||||
document.getElementById('template-form').style.display = 'none';
|
||||
loadTemplates();
|
||||
} catch (e) { alert(e.message); }
|
||||
});
|
||||
|
||||
window.editTemplate = function(id) {
|
||||
const t = replyTemplates.find(x => x.id === id);
|
||||
if (!t) return;
|
||||
document.getElementById('template-edit-id').value = t.id;
|
||||
document.getElementById('template-edit-name').value = t.nimi;
|
||||
document.getElementById('template-edit-body').value = t.body;
|
||||
document.getElementById('template-form').style.display = 'block';
|
||||
};
|
||||
|
||||
window.deleteTemplate = async function(id) {
|
||||
if (!confirm('Poistetaanko vastauspohja?')) return;
|
||||
try {
|
||||
await apiCall('reply_template_delete', 'POST', { id });
|
||||
loadTemplates();
|
||||
} catch (e) { alert(e.message); }
|
||||
};
|
||||
|
||||
// ==================== TELEGRAM ====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user