+
+
+
+
+
+ ` : ''}
`;
}
@@ -2045,7 +2074,19 @@ export function createBubbleCardEditor() {
}
_ActionChanged(ev,array,index) {
- ev.stopPropagation();
+ var hasDefaultEntity = false;
+ try{if(ev.detail.value[ev.currentTarget.__schema[0].name]['target']['entity_id'][0] === 'entity') hasDefaultEntity = true;}
+ catch{}
+ try{if(ev.detail.value[ev.currentTarget.__schema[0].name]['target']['entity_id'] === 'entity') hasDefaultEntity = true;}
+ catch{}
+ if(hasDefaultEntity){
+ ev.detail.value[ev.currentTarget.__schema[0].name]['action'] = 'call-service';
+ if(ev.detail.value[ev.currentTarget.__schema[0].name]['perform_action']!= undefined){
+ ev.detail.value[ev.currentTarget.__schema[0].name]['service'] = ""+ev.detail.value[ev.currentTarget.__schema[0].name]['perform_action'] ;
+ delete ev.detail.value[ev.currentTarget.__schema[0].name]['perform_action'];
+ }
+ }
+
if( array === 'button_action'){
var configExist= this._config[array] ? true : false;
var valueWasChanged = ev.detail.value[ev.currentTarget.__schema[0].name] != null
@@ -2062,6 +2103,29 @@ export function createBubbleCardEditor() {
fireEvent(this, "config-changed", { config: this._config});
}
+ _updateActionsEntity(ev){
+ let obj = JSON.parse(JSON.stringify(this._config)); //get rid of the referencing
+ const configKeys = ev.target.configValue.split('.');
+ let i = 0
+ for (i = 0; i < configKeys.length - 2; i++) {
+ obj = obj[configKeys[i]] ? obj[configKeys[i]] : {};
+ }
+
+ if (!ev.target.checked){
+ if(obj[configKeys[i]].target?.entity_id ==='entity'){
+ obj[configKeys[i]]['target']={};
+ }
+ }else{
+ obj[configKeys[i]]['target']={'entity_id':'entity'};
+ }
+
+ var detail ={'value':obj};
+ var currentTarget = {'__schema':[{'name':configKeys[configKeys.length - 2]}]};
+ var newev = {...ev,detail ,currentTarget};
+
+ this._ActionChanged(newev,configKeys.length >2 ? configKeys[0] : null,configKeys.length >3 ? configKeys[1] : null);
+ }
+
_computeLabelCallback = (schema) => {
switch (schema.name) {
case "theme": return "Theme"