Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
albaintor committed Sep 23, 2024
1 parent d4a4425 commit c31a1e8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/app/activity-editor/command-editor/command-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,22 @@ export class CommandEditorComponent implements OnInit {
this.selectedEntity = this.activityEntities?.find(entity => entity.entity_id ==
this.uiCommand?.media_player_id);
else if (command?.entity_id && this.remote)
{
this.server.getRemotetEntity(this.remote, command.entity_id).subscribe(entity => {
this.selectedEntity = entity;
this.activityEntities = this.activityEntities.map(activityEntity =>
activityEntity.entity_id === entity.entity_id ? entity : activityEntity);
console.log("Extracted entity", entity);
this.updateSelection();
})
}
this.loadEntity(command.entity_id);
this.updateSelection();
}

loadEntity(entity_id: string)
{
if (!this.remote) return;
this.server.getRemotetEntity(this.remote, entity_id).subscribe(entity => {
this.selectedEntity = entity;
this.activityEntities = this.activityEntities.map(activityEntity =>
activityEntity.entity_id === entity.entity_id ? entity : activityEntity);
console.log("Extracted entity", entity);
this.updateSelection();
})
}

getSelectionItems(parameter: EntityCommandParameter)
{
const source = parameter.items?.source;
Expand All @@ -181,11 +185,14 @@ export class CommandEditorComponent implements OnInit {
let command = this.getCommand();

if (this.selectedEntity?.entity_id) {

const selectedEntity = this.entities.find(entity => entity.entity_id == this.selectedEntity?.entity_id);
this.entityCommands = this.configEntityCommands.filter(command =>
command.id.startsWith(this.selectedEntity?.entity_type!)).sort((a, b) =>
Helper.getEntityName(a)!.localeCompare(Helper.getEntityName(b)!));
const entity = this.entities.find(entity => entity.entity_id === this.selectedEntity?.entity_id);


if (this.featuresMap?.length > 0 && entity)
{
const features = this.featuresMap.find(featuresMap => featuresMap.entity_type === entity.entity_type);
Expand Down Expand Up @@ -240,6 +247,8 @@ export class CommandEditorComponent implements OnInit {
}

entitySelected($event: any) {
if (this.selectedEntity?.entity_id)
this.loadEntity(this.selectedEntity.entity_id);
this.updateSelection();
}

Expand Down

0 comments on commit c31a1e8

Please sign in to comment.