-
Notifications
You must be signed in to change notification settings - Fork 278
refactor(CLIMATE): create separate directive #706
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ export default function () { | |
return { | ||
restrict: 'AE', | ||
replace: false, | ||
scope: true, | ||
scope: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we needed to create extra scope for each tile. Maybe we did since we are doing stuff like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this influence, if generic function from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
template, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { App } from '../../app'; | ||
import tileClimate from './tileClimate'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here: Can we generically include all tile types? Alternatively: We could add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing all tile files at once might not be doable with ES imports since imports are hoisted and run before any code so we can't read files from disk and then import based on that. But we could do some preprocessing with rollup to generate files with everything imported, maybe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's of lesser importance and we should solve the html part first. (Maybe with said automatic/dynamic directives you mentioned.) |
||
|
||
App.directive('tileClimate', tileClimate); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div> | ||
<div | ||
class="item-button -center-right" | ||
ng-if="ctrl.entity.attributes.temperature && ctrl.entity.state !== 'off'" | ||
ng-click="ctrl.increaseClimateTemp($event)" | ||
> | ||
<i class="mdi mdi-plus"></i> | ||
</div> | ||
<div | ||
class="item-button -bottom-right" | ||
ng-if="ctrl.entity.attributes.temperature && ctrl.entity.state !== 'off'" | ||
ng-click="ctrl.decreaseClimateTemp($event)" | ||
> | ||
<i class="mdi mdi-minus"></i> | ||
</div> | ||
</div> | ||
<div class="item-climate"> | ||
<div class="item-climate--target"> | ||
<span>{{ ctrl.climateTarget() }}</span> | ||
<span ng-if="(_unit = ctrl.rootCtrl.entityUnit(ctrl.item, ctrl.entity))" class="item-climate--target--unit" | ||
>{{ _unit }}</span | ||
> | ||
<i class="item-climate--icon mdi" ng-class="ctrl.rootCtrl.entityIcon(ctrl.item, ctrl.entity)"></i> | ||
</div> | ||
<div | ||
class="item-climate--mode" | ||
ng-if="(_options = ctrl.getClimateOptions())" | ||
ng-click="ctrl.rootCtrl.openSelect(ctrl.item)" | ||
> | ||
<span>{{ ctrl.getClimateCurrentOption() }}</span> | ||
</div> | ||
</div> | ||
<div | ||
ng-if="ctrl.rootCtrl.selectOpened(ctrl.item)" | ||
class="item-select" | ||
ng-style="ctrl.rootCtrl.itemSelectStyles(ctrl.entity, Object.keys(_options))" | ||
> | ||
<div | ||
class="item-select--option" | ||
ng-repeat="option in _options track by $index" | ||
ng-class="{'-active': option === ctrl.lookupClimateOption(ctrl.entity.state)}" | ||
ng-click="ctrl.setClimateOption($event, option)" | ||
> | ||
<span>{{ option }}</span> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we get rid of those specialized code sections completely in
tile.html
? Kind ofinclude all tile templates from directory ...
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also thought that would look weird once all tiles are converted to have these repetitive elements here.
I think it could be solved with some directive that would dynamically insert a relevant directive based on the type. My angularjs is a bit rusty but it should be doable, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good idea. This would also pave the way to completely custom tile types user can create themselves and share if they want.