diff --git a/public/app.js b/public/app.js index d3609ec..8dbe2a0 100644 --- a/public/app.js +++ b/public/app.js @@ -3002,10 +3002,6 @@ const initApp = () => { // Fields const cFormId = document.getElementById('childFormId'); - const cFormTurma = document.getElementById('childFormTurma'); - const cFormSala = document.getElementById('childFormSala'); - const cFormPeriodo = document.getElementById('childFormPeriodo'); - const cFormAuxiliares = document.getElementById('childFormAuxiliares'); const cFormNome = document.getElementById('childFormNome'); const cFormApelido = document.getElementById('childFormApelido'); const cFormDataNasc = document.getElementById('childFormDataNasc'); @@ -3015,6 +3011,47 @@ const initApp = () => { const cFormPais = document.getElementById('childFormPais'); const cFormAutorizados = document.getElementById('childFormAutorizados'); + // Fields Turma Config + const tabTurmaConfig = document.getElementById('tabTurmaConfig'); + const tabTurmaAlunos = document.getElementById('tabTurmaAlunos'); + const turmaConfigSection = document.getElementById('turmaConfigSection'); + const turmaAlunosSection = document.getElementById('turmaAlunosSection'); + + const configTurmaNome = document.getElementById('configTurmaNome'); + const configTurmaSala = document.getElementById('configTurmaSala'); + const configTurmaPeriodo = document.getElementById('configTurmaPeriodo'); + const configTurmaProfTitular = document.getElementById('configTurmaProfTitular'); + const configTurmaProfAux1 = document.getElementById('configTurmaProfAux1'); + const configTurmaProfAux2 = document.getElementById('configTurmaProfAux2'); + const configTurmaCuidadora = document.getElementById('configTurmaCuidadora'); + const btnSaveTurmaConfig = document.getElementById('btnSaveTurmaConfig'); + + // Tab Logic + if (tabTurmaConfig) { + tabTurmaConfig.addEventListener('click', () => { + tabTurmaConfig.classList.add('active'); + tabTurmaConfig.style.borderBottomColor = 'var(--brand-green)'; + tabTurmaConfig.style.color = 'var(--brand-green)'; + tabTurmaAlunos.classList.remove('active'); + tabTurmaAlunos.style.borderBottomColor = 'transparent'; + tabTurmaAlunos.style.color = 'var(--text-secondary)'; + turmaConfigSection.style.display = 'flex'; + turmaAlunosSection.style.display = 'none'; + }); + } + if (tabTurmaAlunos) { + tabTurmaAlunos.addEventListener('click', () => { + tabTurmaAlunos.classList.add('active'); + tabTurmaAlunos.style.borderBottomColor = 'var(--brand-green)'; + tabTurmaAlunos.style.color = 'var(--brand-green)'; + tabTurmaConfig.classList.remove('active'); + tabTurmaConfig.style.borderBottomColor = 'transparent'; + tabTurmaConfig.style.color = 'var(--text-secondary)'; + turmaAlunosSection.style.display = 'flex'; + turmaConfigSection.style.display = 'none'; + }); + } + // Toggle Especial Fields if (cFormEspecial) { cFormEspecial.addEventListener('change', () => { @@ -3034,6 +3071,40 @@ const initApp = () => { localStorage.setItem('camila_turma', JSON.stringify(turma)); }; + const loadTurmaConfig = () => { + return JSON.parse(localStorage.getItem('camila_config_turma') || '{}'); + }; + + const saveTurmaConfig = (cfg) => { + localStorage.setItem('camila_config_turma', JSON.stringify(cfg)); + showCustomAlert('Sucesso', 'Configurações da turma salvas com sucesso!'); + }; + + if (btnSaveTurmaConfig) { + btnSaveTurmaConfig.addEventListener('click', () => { + saveTurmaConfig({ + nome: configTurmaNome.value, + sala: configTurmaSala.value, + periodo: configTurmaPeriodo.value, + profTitular: configTurmaProfTitular.value, + profAux1: configTurmaProfAux1.value, + profAux2: configTurmaProfAux2.value, + cuidadora: configTurmaCuidadora.value + }); + }); + } + + const populateTurmaConfig = () => { + const cfg = loadTurmaConfig(); + if(configTurmaNome) configTurmaNome.value = cfg.nome || ''; + if(configTurmaSala) configTurmaSala.value = cfg.sala || ''; + if(configTurmaPeriodo) configTurmaPeriodo.value = cfg.periodo || 'Integral'; + if(configTurmaProfTitular) configTurmaProfTitular.value = cfg.profTitular || ''; + if(configTurmaProfAux1) configTurmaProfAux1.value = cfg.profAux1 || ''; + if(configTurmaProfAux2) configTurmaProfAux2.value = cfg.profAux2 || ''; + if(configTurmaCuidadora) configTurmaCuidadora.value = cfg.cuidadora || ''; + }; + const renderTurmaList = () => { if (!childrenList) return; const turma = loadTurma(); @@ -3049,7 +3120,7 @@ const initApp = () => {