Alikategoria-parannukset: monivalinta, Muut-kategoria, emoji pois administa
- api.php: lisätään 'Muut'-alikategoria Resepteihin, Neulomiseen ja Vinkkeihin - api.php: getOrInitCategories() lisää puuttuvat alikategoriat automaattisesti - admin.html: poistetaan emoji-kenttä (emoji tulee kategoriasta automaattisesti) - admin.html: alikategoriat checkboxeina → voi valita useamman samanaikaisesti - script.js: subcategory tallennetaan aina taulukkona - script.js: filterPosts tukee pilkulla eroteltuja alikategorioita (postSubs.includes) - script.js: renderCards kirjoittaa subcategory-arrayn pilkulla eroteltuna data-attribuuttiin Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
10
script.js
10
script.js
@@ -177,7 +177,7 @@ function renderCards() {
|
||||
? `<div class="card-img card-has-photo"><img src="${imgSrc}" alt="${p.title}" /></div>`
|
||||
: `<div class="card-img">${p.emoji}</div>`;
|
||||
return `
|
||||
<article class="recipe-card" data-category="${p.category}" data-subcategory="${p.subcategory || ''}">
|
||||
<article class="recipe-card" data-category="${p.category}" data-subcategory="${Array.isArray(p.subcategory) ? p.subcategory.join(',') : (p.subcategory || '')}">
|
||||
${cardImgHTML}
|
||||
<div class="card-body">
|
||||
<span class="category-tag">${getCategoryLabel(p.category)}</span>
|
||||
@@ -237,8 +237,9 @@ function filterPosts() {
|
||||
const cards = document.querySelectorAll('.recipe-card');
|
||||
let visible = 0;
|
||||
cards.forEach(card => {
|
||||
const matchesCat = currentFilter === 'all' || card.dataset.category === currentFilter;
|
||||
const matchesSub = currentSubFilter === 'all' || card.dataset.subcategory === currentSubFilter;
|
||||
const matchesCat = currentFilter === 'all' || card.dataset.category === currentFilter;
|
||||
const postSubs = (card.dataset.subcategory || '').split(',').filter(Boolean);
|
||||
const matchesSub = currentSubFilter === 'all' || postSubs.includes(currentSubFilter);
|
||||
const title = (card.querySelector('h3')?.textContent || '').toLowerCase();
|
||||
const desc = (card.querySelector('p:not(.card-author)')?.textContent || '').toLowerCase();
|
||||
const subLbl = (card.dataset.subcategory || '').toLowerCase();
|
||||
@@ -526,7 +527,8 @@ async function submitPublicPost() {
|
||||
}
|
||||
|
||||
const category = document.getElementById('sub-category').value;
|
||||
const subcategory = document.getElementById('sub-subcategory')?.value || '';
|
||||
const subVal = document.getElementById('sub-subcategory')?.value || '';
|
||||
const subcategory = subVal ? [subVal] : [];
|
||||
const cat = APP.categories.find(c => c.id === category);
|
||||
const emoji = cat?.emoji || '📝';
|
||||
const author = document.getElementById('sub-author').value.trim() || 'Vieras';
|
||||
|
||||
Reference in New Issue
Block a user