Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

fix(SLIDER): update value in real-time on change #652

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,20 @@ App.controller('Main', function ($scope, $timeout, $location, Api, tmhDynamicLoc
return initSliderConf(item, entity, { }, DEFAULT_VOLUME_SLIDER_OPTIONS);
};

$scope.getSliderValue = function (item, entity, conf) {
let value = conf.value;

if (item.slider.formatValue) {
value = item.slider.formatValue(conf);
}

if (typeof item.filter === 'function') {
return callFunction(item.filter, [value, item, entity]);
}

return value;
};

$scope.getLightSliderValue = function (slider, conf) {
if (slider.formatValue) {
return slider.formatValue(conf);
Expand Down
6 changes: 3 additions & 3 deletions scripts/directives/tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,17 @@
</div>
</div>

<div ng-if="item.type === TYPES.SLIDER"
<div ng-if="item.type === TYPES.SLIDER && (_c = getSliderConf(item, entity))"
class="item-entity-container" ng-class="{'-slider-bottom': item.bottom}">

<div class="item-entity">
<span ng-bind="entityValue(item, entity)"
<span ng-bind="getSliderValue(item, entity, _c)"
class="item-entity--value"></span>
<span ng-if="(_unit = entityUnit(item, entity))"
class="item-entity--unit" ng-bind="_unit"></span>
</div>

<div class="item-slider" ng-if="(_c = getSliderConf(item, entity))">
<div class="item-slider">
<input type="range"
ng-model="_c.getSetValue"
ng-model-options="{ getterSetter: true }"
Expand Down