Skip to content

Commit 5befb1e

Browse files
authored
Update fast-search-card.js
1 parent b10ebd4 commit 5befb1e

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

dist/fast-search-card.js

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8017,25 +8017,22 @@ class FastSearchCard extends HTMLElement {
80178017

80188018
const leftPaneHTML = this.getDetailLeftPaneHTML(item);
80198019
const rightPaneHTML = this.getDetailRightPaneHTML(item);
8020-
80218020
detailPanel.innerHTML = `
80228021
<div class="detail-content">
80238022
<div class="detail-left">${leftPaneHTML}</div>
80248023
<div class="detail-divider"></div>
80258024
<div class="detail-right">${rightPaneHTML}</div>
80268025
</div>
80278026
`;
8028-
80298027
this.shadowRoot.querySelector('.back-button').addEventListener('click', (e) => {
80308028
e.stopPropagation();
80318029
this.handleBackClick();
80328030
});
8033-
80348031
this.setupDetailTabs(item);
8035-
8032+
80368033
// NEU: Favorite Button Event Listener
80378034
const favoriteButton = this.shadowRoot.querySelector('.favorite-button');
8038-
if (favoriteButton) {
8035+
if (favoriteButton && item.id) { // ← Null-Check hinzugefügt
80398036
favoriteButton.addEventListener('click', (e) => {
80408037
const entityId = e.currentTarget.dataset.entityId;
80418038
this.toggleStarLabel(entityId);
@@ -8048,7 +8045,6 @@ class FastSearchCard extends HTMLElement {
80488045
const iconBackground = detailPanel.querySelector('.icon-background');
80498046
const titleArea = detailPanel.querySelector('.detail-title-area');
80508047
const infoRow = detailPanel.querySelector('.detail-info-row');
8051-
80528048
if(iconBackground) this.animateElementIn(iconBackground, { opacity: [0, 1] }, { duration: 600 });
80538049
if(titleArea) this.animateElementIn(titleArea, { opacity: [0, 1], transform: ['translateY(10px)', 'translateY(0)'] }, { delay: 300 });
80548050
if(infoRow) this.animateElementIn(infoRow, { opacity: [0, 1], transform: ['translateY(10px)', 'translateY(0)'] }, { delay: 500 });
@@ -11275,17 +11271,20 @@ class FastSearchCard extends HTMLElement {
1127511271

1127611272
// Toggle: Hinzufügen oder entfernen
1127711273
const isFavorite = userFavorites.includes(entityId);
11274+
let newIsStarred;
1127811275

1127911276
if (isFavorite) {
1128011277
userFavorites = userFavorites.filter(id => id !== entityId);
11278+
newIsStarred = false;
1128111279
console.log(`➖ Entferne ${entityId} von Favoriten`);
1128211280
} else {
1128311281
userFavorites = [...userFavorites, entityId];
11282+
newIsStarred = true;
1128411283
console.log(`➕ Füge ${entityId} zu Favoriten hinzu`);
1128511284
}
1128611285

11287-
// ✅ SOFORT visuell aktualisieren (vor dem Speichern)
11288-
this.updateStarButtonState(entityId);
11286+
// ✅ SOFORT visuell aktualisieren mit dem NEUEN Zustand
11287+
this.updateStarButtonStateImmediate(entityId, newIsStarred);
1128911288
this.renderResults(); // Suchergebnisse sofort aktualisieren
1129011289

1129111290
// User-Favoriten in Gesamt-Struktur zurückschreiben
@@ -11306,6 +11305,35 @@ class FastSearchCard extends HTMLElement {
1130611305
this.updateStarButtonState(entityId);
1130711306
}
1130811307
}
11308+
11309+
updateStarButtonStateImmediate(entityId, isStarred) {
11310+
const favoriteButton = this.shadowRoot.querySelector('.favorite-button');
11311+
if (!favoriteButton) return;
11312+
11313+
try {
11314+
// ✅ SOFORTIGE Animation für besseres Feedback
11315+
favoriteButton.animate([
11316+
{ transform: 'scale(1)' },
11317+
{ transform: 'scale(1.2)' },
11318+
{ transform: 'scale(1)' }
11319+
], {
11320+
duration: 200,
11321+
easing: 'ease-out'
11322+
});
11323+
11324+
// CSS-Klasse und SVG fill mit dem übergebenen Zustand ändern
11325+
favoriteButton.classList.toggle('active', isStarred);
11326+
const svg = favoriteButton.querySelector('svg');
11327+
if (svg) {
11328+
svg.setAttribute('fill', isStarred ? '#ff4757' : 'none');
11329+
}
11330+
11331+
favoriteButton.title = isStarred ? 'Favorit entfernen' : 'Als Favorit markieren';
11332+
11333+
} catch (error) {
11334+
console.error('❌ Fehler beim sofortigen Update des Favorite-Button:', error);
11335+
}
11336+
}
1130911337

1131011338
updateStarButtonState(entityId) {
1131111339
const favoriteButton = this.shadowRoot.querySelector('.favorite-button');
@@ -11328,17 +11356,7 @@ class FastSearchCard extends HTMLElement {
1132811356
const userStars = allUserStars[userId] || [];
1132911357
const isStarred = userStars.includes(entityId);
1133011358

11331-
// ✅ SOFORTIGE Animation für besseres Feedback
11332-
favoriteButton.animate([
11333-
{ transform: 'scale(1)' },
11334-
{ transform: 'scale(1.2)' },
11335-
{ transform: 'scale(1)' }
11336-
], {
11337-
duration: 200,
11338-
easing: 'ease-out'
11339-
});
11340-
11341-
// CSS-Klasse und SVG fill ändern
11359+
// CSS-Klasse und SVG fill ändern (OHNE Animation)
1134211360
favoriteButton.classList.toggle('active', isStarred);
1134311361
const svg = favoriteButton.querySelector('svg');
1134411362
if (svg) {

0 commit comments

Comments
 (0)