Skip to content

Commit

Permalink
219 setting an entity alongside any type of tap action is ignored (#234)
Browse files Browse the repository at this point in the history
* Fix entity alongside any type of tap_action

* Updated info.md

* Fixed Navigation header url not working

* Updated libs
  • Loading branch information
marcokreeft87 committed May 17, 2023
1 parent 407fe18 commit 05f72e9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
4 changes: 4 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% if installed %}

### Features
{% if version_installed.replace("v", "").replace(".","") | int < 10722 %}
- Fixed `Navigation header url not working`
{% endif %}

{% if version_installed.replace("v", "").replace(".","") | int < 10721 %}
- Fixed `entity alongside any type of tap_actions`
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "room-card",
"version": "1.07.21",
"version": "1.07.22",
"description": "Show entities in Home Assistant's Lovelace UI",
"keywords": [
"home-assistant",
Expand Down
6 changes: 3 additions & 3 deletions room-card.js

Large diffs are not rendered by default.

Binary file modified room-card.js.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ export const clickHandler = (element: LitElement, hass: HomeAssistant, entity: R

export const generateActions = (config: RoomCardConfig, entity: RoomCardEntity) => {
return {
tap_action: generateAction(config.tap_action, entity),
double_tap_action: generateAction(config.double_tap_action, entity),
hold_action: generateAction(config.hold_action, entity),
tap_action: checkAction(config.tap_action, entity?.tap_action),
double_tap_action: checkAction(config.double_tap_action, entity?.double_tap_action),
hold_action: checkAction(config.hold_action, entity?.hold_action),
} as RoomCardEntity
}

export const generateAction = (action: ActionConfig, entity: RoomCardEntity) => {
return entity && action?.action !== undefined && action.action !== "more-info" ? entity : action;
export const checkAction = (action: ActionConfig, entityAction: ActionConfig) => {
return entityAction ?? action;
}

export const renderTitle = (config: RoomCardConfig, hass: HomeAssistant, element: LitElement, entity?: RoomCardEntity, ) : HTMLTemplateResult => {
export const renderTitle = (config: RoomCardConfig, hass: HomeAssistant, element: LitElement, entity?: RoomCardEntity) : HTMLTemplateResult => {
if(config.hide_title === true)
return null;

Expand Down
3 changes: 2 additions & 1 deletion tests/entity/renderTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ describe('Testing entity file function renderValue', () => {
const entity: RoomCardEntity = {
stateObj: stateObj,
show_icon: true,
icon: 'mdi:table'
icon: 'mdi:table',
tap_action: { action: 'navigate' } as NavigateActionConfig
};

stateObj.attributes['title'] = "Test title";
Expand Down

0 comments on commit 05f72e9

Please sign in to comment.