[Indicators] Support template override

Allow indicators to include their own custom templates.
WTD-608.
This commit is contained in:
Victor Woeltjen 2014-12-16 13:23:20 -08:00
parent c1ea620341
commit 1a50f50310
4 changed files with 34 additions and 23 deletions

View File

@ -11,6 +11,10 @@
{
"key": "action-button",
"templateUrl": "templates/controls/action-button.html"
},
{
"key": "indicator",
"templateUrl": "templates/indicator.html"
}
],
"controllers": [

View File

@ -1,23 +1,9 @@
<div class='abs bottom-bar ue-bottom-bar' ng-controller="BottomBarController as bar">
<div id='status' class='status-holder abs'>
<div ng-repeat="indicator in bar.getIndicators()"
class='status block'
ng-class='indicator.getClass()'>
<span class="ui-symbol status-indicator"
ng-class='indicator.getGlyphClass()'>
{{indicator.getGlyph()}}
</span>
<span class="label"
ng-class='indicator.getTextClass()'>
{{indicator.getText()}}
</span>
<a href=''
class="ui-symbol"
ng-if="indicator.configure"
ng-click="indicator.configure()">
G
</a>
</div>
<mct-include ng-repeat="indicator in bar.getIndicators()"
ng-model="indicator.ngModel"
key="indicator.template">
</mct-include>
</div>
<!--mct-include key="'app-logo'"></mct-include-->
</div>

View File

@ -0,0 +1,17 @@
<div class='status block'
ng-click='ngModel.configure()'
ng-class='ngModel.getClass()'>
<span class="ui-symbol status-indicator"
ng-class='ngModel.getGlyphClass()'>
{{ngModel.getGlyph()}}
</span>
<span class="label"
ng-class='ngModel.getTextClass()'>
{{ngModel.getText()}}
</span>
<a href=''
class="ui-symbol"
ng-if="ngModel.configure">
G
</a>
</div>

View File

@ -11,13 +11,17 @@ define(
* @constructor
*/
function BottomBarController(indicators) {
// Utility function used to instantiate indicators
// from their injected constructors.
function instantiate(Indicator) {
return new Indicator();
// Utility function used to make indicators presentable
// for display.
function present(Indicator) {
return {
template: Indicator.template || "indicator",
ngModel: typeof Indicator === 'function' ?
new Indicator() : Indicator
};
}
indicators = indicators.map(instantiate);
indicators = indicators.map(present);
return {
/**