implemented step 11

- sections on website
This commit is contained in:
2026-06-14 09:06:03 +02:00
parent c11f7e4d75
commit c01eb30632
4 changed files with 260 additions and 6 deletions

View File

@ -102,6 +102,48 @@ const App = {
} else {
this.addServiceItem();
}
// Step 4
if (wd.visuals) {
this.state.selection.style = wd.visuals.style;
this.state.selection.palette = wd.visuals.palette;
this.updateStyleSelection();
this.updatePaletteSelection();
}
if (wd.assets) {
this.state.selection.logo = wd.assets.logo;
this.state.selection.gallery = wd.assets.gallery || [];
if (this.state.selection.logo) this.renderLogoPreview();
this.renderGalleryPreviews();
}
// Step 5
if (wd.modules) {
const m = wd.modules;
if (m.sections) {
m.sections.forEach(sec => {
const el = document.querySelector(`input[data-module="${sec}"]`);
if (el) el.checked = true;
});
}
if (m.contact_form) {
document.getElementById('form-enabled').checked = m.contact_form.enabled;
document.getElementById('form-config-container').classList.toggle('hidden', !m.contact_form.enabled);
if (m.contact_form.mode) {
document.querySelector(`input[name="form-mode"][value="${m.contact_form.mode}"]`).checked = true;
document.getElementById('config-local').classList.toggle('hidden', m.contact_form.mode !== 'local');
document.getElementById('config-smtp').classList.toggle('hidden', m.contact_form.mode !== 'smtp');
}
if (m.contact_form.smtp) {
document.getElementById('smtp-host').value = m.contact_form.smtp.host || '';
document.getElementById('smtp-port').value = m.contact_form.smtp.port || '';
document.getElementById('smtp-user').value = m.contact_form.smtp.user || '';
document.getElementById('smtp-recipient').value = m.contact_form.smtp.recipient || '';
}
}
}
}
},
@ -212,6 +254,18 @@ const App = {
document.getElementById('gallery-add-box').addEventListener('click', () => document.getElementById('gallery-input').click());
document.getElementById('gallery-input').addEventListener('change', (e) => this.handleFileUpload(e, 'gallery'));
// Step 5 events
document.getElementById('form-enabled').addEventListener('change', (e) => {
document.getElementById('form-config-container').classList.toggle('hidden', !e.target.checked);
});
document.querySelectorAll('input[name="form-mode"]').forEach(radio => {
radio.addEventListener('change', (e) => {
document.getElementById('config-local').classList.toggle('hidden', e.target.value !== 'local');
document.getElementById('config-smtp').classList.toggle('hidden', e.target.value !== 'smtp');
});
});
},
renderCategories() {
@ -610,6 +664,46 @@ const App = {
alert('Nepodarilo sa uložiť dáta: ' + error.message);
return;
}
} else if (this.state.currentStep === 5) {
const sections = [];
document.querySelectorAll('input[data-module]:checked').forEach(el => {
sections.push(el.getAttribute('data-module'));
});
const formEnabled = document.getElementById('form-enabled').checked;
const formMode = document.querySelector('input[name="form-mode"]:checked').value;
const modulesData = {
pages: ['home'],
sections: sections,
contact_form: {
enabled: formEnabled,
mode: formMode,
smtp: formMode === 'smtp' ? {
host: document.getElementById('smtp-host').value,
port: document.getElementById('smtp-port').value,
user: document.getElementById('smtp-user').value,
pass: document.getElementById('smtp-pass').value,
recipient: document.getElementById('smtp-recipient').value
} : null,
local_viewer: formMode === 'local' ? {
password: document.getElementById('local-password').value
} : null
}
};
try {
await this.apiCall('saveStep', {
step: 5,
data: {
modules: modulesData
}
});
} catch (error) {
console.error('Save step 5 failed:', error);
alert('Nepodarilo sa uložiť dáta: ' + error.message);
return;
}
}
if (this.state.currentStep < this.state.totalSteps) {
@ -641,6 +735,16 @@ const App = {
nextDisabled = !name || !gdpr || (!email && !phone);
} else if (this.state.currentStep === 4) {
nextDisabled = !this.state.selection.style || !this.state.selection.palette;
} else if (this.state.currentStep === 5) {
const formEnabled = document.getElementById('form-enabled').checked;
if (formEnabled) {
const mode = document.querySelector('input[name="form-mode"]:checked').value;
if (mode === 'local') {
nextDisabled = !document.getElementById('local-password').value;
} else {
nextDisabled = !document.getElementById('smtp-host').value || !document.getElementById('smtp-recipient').value;
}
}
}
btnNext.disabled = nextDisabled;