feat: add scene crosslinks to automation cards
Some checks failed
Lint & Test / test (push) Failing after 31s
Some checks failed
Lint & Test / test (push) Failing after 31s
Scene name and fallback scene in automation cards are now clickable, navigating to the corresponding scene preset card. Also renders the deactivation mode label which was previously set but never displayed.
This commit is contained in:
@@ -9,7 +9,7 @@ import { showToast, showConfirm, setTabRefreshing } from '../core/ui.ts';
|
||||
import { Modal } from '../core/modal.ts';
|
||||
import { CardSection } from '../core/card-sections.ts';
|
||||
import { updateTabBadge, updateSubTabHash } from './tabs.ts';
|
||||
import { ICON_SETTINGS, ICON_START, ICON_PAUSE, ICON_CLOCK, ICON_AUTOMATION, ICON_HELP, ICON_OK, ICON_TIMER, ICON_MONITOR, ICON_RADIO, ICON_SCENE, ICON_CLONE, ICON_TRASH, ICON_CIRCLE_OFF } from '../core/icons.ts';
|
||||
import { ICON_SETTINGS, ICON_START, ICON_PAUSE, ICON_CLOCK, ICON_AUTOMATION, ICON_HELP, ICON_OK, ICON_TIMER, ICON_MONITOR, ICON_RADIO, ICON_SCENE, ICON_CLONE, ICON_TRASH, ICON_CIRCLE_OFF, ICON_UNDO } from '../core/icons.ts';
|
||||
import * as P from '../core/icon-paths.ts';
|
||||
import { wrapCard } from '../core/card-colors.ts';
|
||||
import { TagInput, renderTagChips } from '../core/tag-input.ts';
|
||||
@@ -255,12 +255,17 @@ function createAutomationCard(automation: Automation, sceneMap = new Map()) {
|
||||
const sceneColor = scene ? scene.color || '#4fc3f7' : '#888';
|
||||
|
||||
// Deactivation mode label
|
||||
let deactivationLabel = '';
|
||||
let deactivationMeta = '';
|
||||
if (automation.deactivation_mode === 'revert') {
|
||||
deactivationLabel = t('automations.deactivation_mode.revert');
|
||||
deactivationMeta = `<span class="card-meta">${ICON_UNDO} ${t('automations.deactivation_mode.revert')}</span>`;
|
||||
} else if (automation.deactivation_mode === 'fallback_scene') {
|
||||
const fallback = automation.deactivation_scene_preset_id ? sceneMap.get(automation.deactivation_scene_preset_id) : null;
|
||||
deactivationLabel = fallback ? `${t('automations.deactivation_mode.fallback_scene')}: ${escapeHtml(fallback.name)}` : t('automations.deactivation_mode.fallback_scene');
|
||||
if (fallback) {
|
||||
const fbColor = fallback.color || '#4fc3f7';
|
||||
deactivationMeta = `<span class="card-meta stream-card-link" onclick="event.stopPropagation(); navigateToCard('automations',null,'scenes','data-scene-id','${automation.deactivation_scene_preset_id}')">${ICON_UNDO} <span style="color:${fbColor}">●</span> ${escapeHtml(fallback.name)}</span>`;
|
||||
} else {
|
||||
deactivationMeta = `<span class="card-meta">${ICON_UNDO} ${t('automations.deactivation_mode.fallback_scene')}</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
let lastActivityMeta = '';
|
||||
@@ -284,7 +289,8 @@ function createAutomationCard(automation: Automation, sceneMap = new Map()) {
|
||||
</div>
|
||||
<div class="card-subtitle">
|
||||
<span class="card-meta">${condPills}</span>
|
||||
<span class="card-meta">${ICON_SCENE} <span style="color:${sceneColor}">●</span> ${sceneName}</span>
|
||||
<span class="card-meta${scene ? ' stream-card-link' : ''}"${scene ? ` onclick="event.stopPropagation(); navigateToCard('automations',null,'scenes','data-scene-id','${automation.scene_preset_id}')"` : ''}>${ICON_SCENE} <span style="color:${sceneColor}">●</span> ${sceneName}</span>
|
||||
${deactivationMeta}
|
||||
</div>
|
||||
${renderTagChips(automation.tags)}`,
|
||||
actions: `
|
||||
|
||||
Reference in New Issue
Block a user