mirror of
https://github.com/Alvin-Zilverstand/Challenge_15_Magazijn_App_Maken.git
synced 2026-03-06 21:29:20 +01:00
changes
This commit is contained in:
@@ -124,10 +124,16 @@ function displayItems() {
|
||||
// Apply search filter with translation support
|
||||
if (searchTerm.trim() !== '') {
|
||||
filteredItems = filteredItems.filter(item => {
|
||||
if (window.translationManager) {
|
||||
const localizedItem = window.translationManager.getLocalizedItem(item);
|
||||
const translationManager = window.ensureTranslationManager ? window.ensureTranslationManager() : null;
|
||||
if (translationManager) {
|
||||
const localizedItem = translationManager.getLocalizedItem(item);
|
||||
return localizedItem.name.toLowerCase().includes(searchTerm) ||
|
||||
(localizedItem.description && localizedItem.description.toLowerCase().includes(searchTerm));
|
||||
} else if (window.getItemDisplayText) {
|
||||
const currentLang = localStorage.getItem('language') || 'nl';
|
||||
const name = window.getItemDisplayText(item, 'name', currentLang);
|
||||
const description = window.getItemDisplayText(item, 'description', currentLang);
|
||||
return name.toLowerCase().includes(searchTerm) || description.toLowerCase().includes(searchTerm);
|
||||
} else {
|
||||
// Fallback for when translation manager isn't loaded yet (default to Dutch)
|
||||
const name = item.name?.nl || item.name?.en || item.name || '';
|
||||
@@ -151,10 +157,28 @@ function displayItems() {
|
||||
// Display items in grid view
|
||||
const gridContainer = document.getElementById('itemsGrid');
|
||||
gridContainer.innerHTML = filteredItems.map(item => {
|
||||
const localizedItem = window.translationManager ? window.translationManager.getLocalizedItem(item) : {
|
||||
name: item.name?.nl || item.name?.en || item.name || 'Onbekend Artikel',
|
||||
description: item.description?.nl || item.description?.en || item.description || ''
|
||||
};
|
||||
// Use multiple fallback strategies
|
||||
const translationManager = window.ensureTranslationManager ? window.ensureTranslationManager() : null;
|
||||
let localizedItem;
|
||||
|
||||
if (translationManager) {
|
||||
localizedItem = translationManager.getLocalizedItem(item);
|
||||
} else if (window.getItemDisplayText) {
|
||||
// Use debug helper fallback
|
||||
const currentLang = localStorage.getItem('language') || 'nl';
|
||||
localizedItem = {
|
||||
...item,
|
||||
name: window.getItemDisplayText(item, 'name', currentLang),
|
||||
description: window.getItemDisplayText(item, 'description', currentLang)
|
||||
};
|
||||
} else {
|
||||
// Final fallback
|
||||
localizedItem = {
|
||||
...item,
|
||||
name: (typeof item.name === 'object') ? (item.name?.nl || item.name?.en || 'Onbekend Artikel') : (item.name || 'Onbekend Artikel'),
|
||||
description: (typeof item.description === 'object') ? (item.description?.nl || item.description?.en || 'Geen beschrijving beschikbaar') : (item.description || 'Geen beschrijving beschikbaar')
|
||||
};
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="col-md-4 col-lg-3 mb-4">
|
||||
@@ -180,10 +204,28 @@ function displayItems() {
|
||||
// Display items in list view
|
||||
const itemsListBody = document.getElementById('itemsListBody');
|
||||
itemsListBody.innerHTML = filteredItems.map(item => {
|
||||
const localizedItem = window.translationManager ? window.translationManager.getLocalizedItem(item) : {
|
||||
name: item.name?.nl || item.name?.en || item.name || 'Onbekend Artikel',
|
||||
description: item.description?.nl || item.description?.en || item.description || ''
|
||||
};
|
||||
// Use multiple fallback strategies
|
||||
const translationManager = window.ensureTranslationManager ? window.ensureTranslationManager() : null;
|
||||
let localizedItem;
|
||||
|
||||
if (translationManager) {
|
||||
localizedItem = translationManager.getLocalizedItem(item);
|
||||
} else if (window.getItemDisplayText) {
|
||||
// Use debug helper fallback
|
||||
const currentLang = localStorage.getItem('language') || 'nl';
|
||||
localizedItem = {
|
||||
...item,
|
||||
name: window.getItemDisplayText(item, 'name', currentLang),
|
||||
description: window.getItemDisplayText(item, 'description', currentLang)
|
||||
};
|
||||
} else {
|
||||
// Final fallback
|
||||
localizedItem = {
|
||||
...item,
|
||||
name: (typeof item.name === 'object') ? (item.name?.nl || item.name?.en || 'Onbekend Artikel') : (item.name || 'Onbekend Artikel'),
|
||||
description: (typeof item.description === 'object') ? (item.description?.nl || item.description?.en || 'Geen beschrijving beschikbaar') : (item.description || 'Geen beschrijving beschikbaar')
|
||||
};
|
||||
}
|
||||
|
||||
return `
|
||||
<tr class="item-row" style="cursor: pointer" onclick="showItemDetails(${JSON.stringify(item).replace(/"/g, '"')})">
|
||||
|
||||
Reference in New Issue
Block a user