Add an option to execute actions when clicking on sidebar items #290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a new property in order items
This pull request adds a new feature to make it possible to execute actions when clicking on sidebar items. With
custom-sidebar
it is possible to add anhref
property to each sidebar item making them redirect to an internal dashboard or to an external URL. From now on, it is also possible to execute certain actions when clicking on sidebar items. These actions can be executed at the same time that you are navigating to a dashboard or an external URL or can be exclusively executed if one omits thehref
property on new items or change it to#
in existing ones.Order items properties
onClick
property of the sidebar item.It allows two types of actions,
ServiceCallAction
or
JavaScriptAction
. Take into account that setting this propertywill not stop the
href
option for working. If you want to avoidnavigating to a page, you should set the
href
optionas
#
(in new items you can just omit it)Service call actions
This action allows you to call a service clicking on an item of the sidebar
JavaScript actions
This action allows you to execute a
JavaScript
code (you don't need to wrap the code block between three square brackets)Use reactive variables in the templates
With this release, after the update of the home-assistant-javascript-templates package, it is also possible to make use of reactive variables in
JavaScript
templates. This will make your templates be reactive to variables only in the device in which you are working. For example, let's show or hide an item of the sidebar clicking on another item:Reactive variables can also be declared in the
js_variables
property giving them an initial value. Let's refactor the previous code to declare the reactive variablehide
in thejs_variables
property giving it an initial value there instead of giving the initial value in the itemhide
template:IMPORTANT