Remove recipe/post toggle — auto-detect type from category selection

When user selects Reseptit category, recipe fields (time, servings,
ingredients, steps) appear automatically. All other categories show
the post body field instead. Removed the manual toggle buttons and
cleaned up related CSS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 09:33:22 +02:00
parent 844e5c338b
commit 7bb5924cf6
3 changed files with 4 additions and 36 deletions

View File

@@ -88,11 +88,6 @@
<button class="modal-close" onclick="closeSubmitModal()"></button>
<h2>✏️ Lisää julkaisu</h2>
<div class="type-toggle">
<button class="type-btn active" id="sub-typeRecipeBtn" onclick="setSubmitType('recipe')">🍳 Resepti</button>
<button class="type-btn" id="sub-typePostBtn" onclick="setSubmitType('post')">📝 Julkaisu</button>
</div>
<div class="form-group">
<label>Otsikko *</label>
<input type="text" id="sub-title" placeholder="esim. Mummon mustikkapiirakka" maxlength="100" />

View File

@@ -400,8 +400,6 @@ function setSubmitType(type) {
submitType = type;
document.getElementById('sub-recipeFields').style.display = type === 'recipe' ? '' : 'none';
document.getElementById('sub-postFields').style.display = type === 'post' ? '' : 'none';
document.getElementById('sub-typeRecipeBtn').classList.toggle('active', type === 'recipe');
document.getElementById('sub-typePostBtn').classList.toggle('active', type === 'post');
}
function updateSubcategoryPicker() {
@@ -418,14 +416,15 @@ function updateSubcategoryPicker() {
subs.map(s => `<option value="${s.id}">${s.fi}</option>`).join('');
group.style.display = '';
}
// Näytä reseptikentät jos kategoria on Reseptit, muuten julkaisukentät
setSubmitType(catId === 'recipes' ? 'recipe' : 'post');
}
function openSubmitModal() {
const cats = APP.categories;
const sel = document.getElementById('sub-category');
sel.innerHTML = cats.map(c => `<option value="${c.id}">${c.emoji || ''} ${c.fi}</option>`).join('');
updateSubcategoryPicker();
setSubmitType('recipe');
updateSubcategoryPicker(); // asettaa myös oikean tyypin kategorian mukaan
document.getElementById('submitOverlay').classList.add('open');
document.body.style.overflow = 'hidden';
generateSubmitCaptcha();

View File

@@ -472,32 +472,6 @@ footer {
gap: 12px;
}
.type-toggle {
display: flex;
gap: 10px;
margin-bottom: 14px;
}
.type-btn {
flex: 1;
padding: 10px;
border: 2px solid var(--border);
border-radius: 8px;
background: #fff;
color: var(--text-light);
font-family: 'Arial', sans-serif;
font-size: 0.88rem;
font-weight: bold;
cursor: pointer;
transition: all 0.2s;
text-align: center;
}
.type-btn.active {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.submit-btn {
width: 100%;