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> <button class="modal-close" onclick="closeSubmitModal()"></button>
<h2>✏️ Lisää julkaisu</h2> <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"> <div class="form-group">
<label>Otsikko *</label> <label>Otsikko *</label>
<input type="text" id="sub-title" placeholder="esim. Mummon mustikkapiirakka" maxlength="100" /> <input type="text" id="sub-title" placeholder="esim. Mummon mustikkapiirakka" maxlength="100" />

View File

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

View File

@@ -472,32 +472,6 @@ footer {
gap: 12px; 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 { .submit-btn {
width: 100%; width: 100%;