diff --git a/admin.html b/admin.html
index cc4a086..f2663d6 100644
--- a/admin.html
+++ b/admin.html
@@ -281,6 +281,13 @@
+
+
+
+
+
@@ -492,6 +499,7 @@
document.getElementById('backLink').textContent = at('back');
document.getElementById('saveBtn').textContent = at('save');
populateCategorySelect();
+ populateOwnerSelect();
renderCatList();
renderPostList();
renderUserList();
@@ -676,6 +684,13 @@
updateAdminSubcategories();
}
+ function populateOwnerSelect(currentUserId = '') {
+ const sel = document.getElementById('postOwner');
+ sel.innerHTML = `` +
+ (ADMIN.users || []).map(u => ``).join('');
+ if (currentUserId) sel.value = currentUserId;
+ }
+
function updateAdminSubcategories(checked = []) {
const catId = document.getElementById('postCategory').value;
const cat = ADMIN.categories.find(c => c.id === catId);
@@ -755,6 +770,20 @@
].filter(Boolean);
const post = { title, emoji, category, subcategory, author, desc, images, type: currentType };
+ // Omistaja / submittedBy
+ const ownerId = document.getElementById('postOwner').value;
+ if (ownerId) {
+ const owner = (ADMIN.users || []).find(u => u.id === ownerId);
+ post.submittedBy = { userId: ownerId, nickname: owner?.nickname || author, validated: true };
+ if (!author && owner) post.author = owner.nickname;
+ } else {
+ // Keep existing submittedBy if editing unless explicitly cleared
+ if (editingId) {
+ const existing = ADMIN.posts.find(p => p.id === editingId);
+ if (existing?.submittedBy && !ownerId) post.submittedBy = null;
+ }
+ }
+
if (currentType === 'recipe') {
post.time = document.getElementById('postTime').value.trim();
post.servings = document.getElementById('postServings').value.trim();
@@ -795,6 +824,7 @@
document.getElementById('postTitle').value = p.title;
document.getElementById('postCategory').value = p.category;
document.getElementById('postAuthor').value = p.author || '';
+ populateOwnerSelect(p.submittedBy?.userId || '');
// Load subcategory checkboxes with existing values
const existingSubs = Array.isArray(p.subcategory) ? p.subcategory : (p.subcategory ? [p.subcategory] : []);
updateAdminSubcategories(existingSubs);
@@ -833,6 +863,7 @@
editingId = null;
document.getElementById('postTitle').value = '';
document.getElementById('postAuthor').value = '';
+ populateOwnerSelect('');
updateAdminSubcategories([]);
document.getElementById('postDesc').value = '';
document.getElementById('postTime').value = '';