Skip to content

Commit

Permalink
Fix Service Call
Browse files Browse the repository at this point in the history
  • Loading branch information
Sian-Lee-SA committed Dec 30, 2022
1 parent 352cd65 commit 3dc2033
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 171 deletions.
459 changes: 290 additions & 169 deletions honeycomb-menu.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/honeycomb-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { objectEvalTemplate, getTemplateOrValue } from "./helpers.js";

var cardTools = customElements.get('card-tools');
const _ = require('lodash');

class HoneycombMenuItem extends Polymer.Element
{
Expand Down Expand Up @@ -95,6 +96,11 @@ class HoneycombMenuItem extends Polymer.Element
pointer-events: all;
height: 100%;
}
#item > * {
height: 100%;
}
:host([disabled]) #item {
background: var(--honeycomb-menu-disabled, #9a9a9a6e);
}
Expand Down Expand Up @@ -127,6 +133,13 @@ class HoneycombMenuItem extends Polymer.Element
variables: {},
}, this.config);

if( _.isString( this.config.tap_action ) )
this.config.tap_action = {'action':this.config.tap_action};
if( _.isString( this.config.hold_action ) )
this.config.hold_action = {'action':this.config.hold_action};
if( _.isString( this.config.double_tap_action ) )
this.config.double_tap_action = {'action':this.config.double_tap_action};

if( ! this.config.active )
this.style.setProperty('--paper-item-icon-active-color', 'var(--paper-item-icon-color)');

Expand Down
8 changes: 6 additions & 2 deletions src/honeycomb-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ function traverseConfigs( _config, _buttons )
}

hass._callService = hass.callService
hass.callService = function(domain, service, data)
hass.callService = function(domain, service, data, target)
{

if( domain != 'honeycomb' )
return hass._callService(domain, service, data);
return hass._callService(domain, service, data, target);


var honeycombConfig = traverseConfigs( data );

Expand All @@ -106,6 +108,7 @@ hass.callService = function(domain, service, data)
showHoneycombMenu(honeycombConfig);
}

customElements.whenDefined('card-tools').then(() => {
class HoneycombMenu extends Polymer.Element
{
static get is()
Expand Down Expand Up @@ -511,3 +514,4 @@ class HoneycombMenu extends Polymer.Element
}
}
customElements.define(HoneycombMenu.is, HoneycombMenu);
});

0 comments on commit 3dc2033

Please sign in to comment.