-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div style="margin-top: 20px;"> | ||
<div class="row" style="margin: 5px;"> | ||
<h4 class="col-md-12"> | ||
{{'MCA.NAME' | translate}} | ||
</h4> | ||
</div> | ||
<div data-ng-repeat="mca in data.availableMcas" class="row" style="margin: 5px;"> | ||
<div class="col-md-12"> | ||
{{mca.title}} | ||
<div class="fa fa-paint-brush makeNarrow" ng-click="vm.setMcaAsStyle($index)" style="float:right; cursor:pointer" popover="{{'MCA.SET_STYLE' | translate}}" popover-placement="right" popover-trigger="mouseenter" popover-append-to-body="true" /> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module MCAWidget { | ||
/** | ||
* Config | ||
*/ | ||
var moduleName = 'csComp'; | ||
|
||
/** | ||
* Module | ||
*/ | ||
export var myModule; | ||
try { | ||
myModule = angular.module(moduleName); | ||
} catch (err) { | ||
// named module does not exist, so create one | ||
myModule = angular.module(moduleName, []); | ||
} | ||
|
||
/** | ||
* Directive to display the available map layers. | ||
*/ | ||
myModule.directive('mcawidget', [function() : ng.IDirective { | ||
return { | ||
restrict : 'E', // E = elements, other options are A=attributes and C=classes | ||
scope : { | ||
}, // isolated scope, separated from parent. Is however empty, as this directive is self contained by using the messagebus. | ||
templateUrl: 'directives/Widgets/MCAWidget/MCAWidget.tpl.html', | ||
replace : true, // Remove the directive from the DOM | ||
transclude : false, // Add elements and attributes to the template | ||
controller : MCAWidget.MCAWidgetCtrl | ||
} | ||
} | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
module MCAWidget { | ||
export class MCAWidgetData { | ||
title: string; | ||
/** | ||
* If provided, indicates the layer that needs to be enabled in order to show the widget. | ||
*/ | ||
layerId: string; | ||
/** | ||
* The available mca's | ||
*/ | ||
availableMcas: Mca.Models.Mca[]; | ||
} | ||
|
||
export interface IMCAWidgetScope extends ng.IScope { | ||
vm: MCAWidgetCtrl; | ||
data: MCAWidgetData; | ||
} | ||
|
||
export class MCAWidgetCtrl { | ||
private scope: IMCAWidgetScope; | ||
private widget: csComp.Services.IWidget; | ||
private parentWidget: JQuery; | ||
private mcaScope: Mca.IMcaScope; | ||
|
||
public static $inject = [ | ||
'$scope', | ||
'$timeout', | ||
'$controller', | ||
'layerService', | ||
'messageBusService', | ||
'mapService' | ||
]; | ||
|
||
constructor( | ||
private $scope: IMCAWidgetScope, | ||
private $timeout: ng.ITimeoutService, | ||
private $controller: ng.IControllerService, | ||
private $layerService: csComp.Services.LayerService, | ||
private $messageBus: csComp.Services.MessageBusService, | ||
private $mapService: csComp.Services.MapService | ||
) { | ||
$scope.vm = this; | ||
var par = <any>$scope.$parent; | ||
this.widget = par.widget; | ||
|
||
$scope.data = <MCAWidgetData>this.widget.data; | ||
|
||
if (typeof $scope.data.layerId !== 'undefined') { | ||
// Hide widget | ||
this.parentWidget = $("#" + this.widget.elementId).parent(); | ||
this.parentWidget.hide(); | ||
this.$messageBus.subscribe('layer', (action: string, layer: csComp.Services.ProjectLayer) => { | ||
switch (action) { | ||
case 'activated': | ||
case 'deactivate': | ||
this.activateLayer(layer); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private activateLayer(layer: csComp.Services.ProjectLayer) { | ||
this.mcaScope = this.getMcaScope(); | ||
if (!this.mcaScope) return; | ||
|
||
if (layer.id !== this.$scope.data.layerId || (layer.id === this.$scope.data.layerId && !layer.enabled)) { | ||
this.parentWidget.hide(); | ||
return; | ||
} | ||
this.$timeout(() => { | ||
this.parentWidget.show(); | ||
}, 0); | ||
} | ||
|
||
private getMcaScope() { | ||
var mcaElm = angular.element('div[id="mca"]'); | ||
if (!mcaElm) { | ||
console.log('Mca element not found.'); | ||
return; | ||
} | ||
var mcaScope = <Mca.IMcaScope>mcaElm.scope(); | ||
if (!mcaScope) { | ||
console.log('Mca controller scope not found.'); | ||
return; | ||
} else { | ||
this.$scope.data.availableMcas = mcaScope.vm.availableMcas; | ||
return mcaScope; | ||
} | ||
} | ||
|
||
private setMcaAsStyle(mcaNr: number) { | ||
if (!this.mcaScope || !this.mcaScope.vm.mca) { | ||
console.log('Mca controller scope not found.'); | ||
return; | ||
} else { | ||
var vm = this.mcaScope.vm; | ||
if (!vm.showFeature) { | ||
this.$messageBus.notifyWithTranslation('SELECT_A_FEATURE', 'SELECT_FEATURE_FOR_STYLE'); | ||
return; | ||
} | ||
if (vm.properties.length > 0) { | ||
var availableMcas = vm.availableMcas.length; | ||
if (mcaNr <= availableMcas) { | ||
vm.mca = vm.availableMcas[mcaNr]; | ||
vm.updateMca(); | ||
} | ||
console.log('Set mca style.'); | ||
vm.setStyle(vm.properties[0]); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters