Adiciona botão Duplicar nos modelos de relatório na aba de gerenciamento de templates
This commit is contained in:
+17
-1
@@ -2547,13 +2547,14 @@ const initApp = () => {
|
||||
<div style="font-weight: 600; color: var(--text-primary); font-size: 0.9rem;">${t.nome}</div>
|
||||
<div style="font-size: 0.75rem; color: var(--text-secondary);">${t.periodicidade} • ${t.finalidade || 'Sem finalidade'}</div>
|
||||
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px;">
|
||||
<button class="template-duplicate-btn" data-id="${t.id}" style="background: none; border: 1px solid var(--border-light); color: var(--text-secondary); padding: 2px 8px; border-radius: 4px; font-size: 0.72rem; cursor: pointer; transition: opacity 0.2s;">Duplicar</button>
|
||||
<button class="template-edit-btn" data-id="${t.id}" style="background: none; border: 1px solid var(--border-light); color: var(--brand-green); padding: 2px 8px; border-radius: 4px; font-size: 0.72rem; cursor: pointer;">Editar</button>
|
||||
<button class="template-delete-btn" data-id="${t.id}" style="background: none; border: 1px solid var(--border-light); color: #ff6b6b; padding: 2px 8px; border-radius: 4px; font-size: 0.72rem; cursor: pointer;">Excluir</button>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
// Eventos de clique na lista para editar/deletar
|
||||
// Eventos de clique na lista para editar/deletar/duplicar
|
||||
templatesList.querySelectorAll('.obs-item').forEach(item => {
|
||||
item.addEventListener('click', (e) => {
|
||||
if (e.target.tagName === 'BUTTON') return;
|
||||
@@ -2563,6 +2564,21 @@ const initApp = () => {
|
||||
});
|
||||
});
|
||||
|
||||
templatesList.querySelectorAll('.template-duplicate-btn').forEach(btn => {
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const id = btn.dataset.id;
|
||||
const template = allTemplates.find(t => t.id == id);
|
||||
if (template) {
|
||||
fillTemplateForm(template);
|
||||
templateFormId.value = '';
|
||||
templateFormNome.value = template.nome + ' (Cópia)';
|
||||
templateFormTitle.textContent = 'Duplicar Modelo';
|
||||
if (templateFormNome) templateFormNome.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
templatesList.querySelectorAll('.template-edit-btn').forEach(btn => {
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user