Skip to content
Permalink
Browse files

Refactor feature-filter module

refs #217
  • Loading branch information...
raitisbe authored and SLeitgeb committed Jul 17, 2019
1 parent 33285a5 commit 035cd7d2a4fb3f230304ed4901313efff5fff18f
@@ -0,0 +1,42 @@
export default ['config', '$compile', function (config, $compile) {
// console.log($state);
return {
// templateUrl: `${config.hsl_path}components/feature-filter/partials/${$state.type}${config.design || ''}.html`,
template: '<ng-include src="getTemplateUrl()"/>',
scope: {
filter: "="
},
// link: function(scope, element, attrs) {
// element.html(`${hsl_path}components/feature-filter/partials/${scope.filter.type}${config.design || ''}.html`).show();
// $compile(element.contents())(scope);
// },
controller: function ($scope) {
$scope.getTemplateUrl = function () {
if (config.design == 'md') {
switch ($scope.filter.type) {
case 'fieldset':
return `components/feature-filter/partials/fieldsetmd.html`;
case 'slider':
return `components/feature-filter/partials/slidermd.html`;
}

} else {
switch ($scope.filter.type) {
case 'fieldset':
return `components/feature-filter/partials/fieldset.html`;
case 'slider':
return `components/feature-filter/partials/slider.html`;
}
}

};
},
// templateUrl: function(el, attrs) {
// return `${config.hsl_path}components/feature-filter/partials/${attrs.filter.type}md.html`
// },
// link: function(scope, element, attrs) {
// scope.filter = scope.$eval(attrs.filter);
// },
// template: require('components/feature-filter/partials/{{filter.type}}md.html'),
};
}]
@@ -0,0 +1,60 @@
export default ['$scope', 'hs.map.service', 'Core', 'hs.featureFilter.service', 'hs.layermanager.service', 'config',
function ($scope, OlMap, Core, service, LayMan, config) {
var map = OlMap.map;

$scope.map = OlMap.map;
$scope.LayMan = LayMan;

$scope.applyFilters = service.applyFilters;

$scope.allSelected = function (filter) {
return filter.selected ? filter.selected.length === filter.values.length : false;
};

$scope.isIndeterminate = function (filter) {
return filter.selected ? (filter.selected.length !== 0 && filter.selected.length !== filter.values.length) : false;
};

$scope.exists = function (item, list) {
return list.indexOf(item) > -1;
};

$scope.toggle = function (value, selected) {
var idx = selected.indexOf(value);
if (idx > -1) {
selected.splice(idx, 1);
} else {
selected.push(value);
}
};

$scope.toggleAll = function (filter) {
if (filter.selected.length === filter.values.length) {
filter.selected = [];
} else {
filter.selected = filter.values.slice(0);
}
};

$scope.$emit('scope_loaded', "featureFilter");



// $rootScope.$on('layermanager.layer_added', function (e, layer) {
// service.prepLayerFilter(layer);

// if (layer.layer instanceof VectorLayer) {
// var source = layer.layer.getSource();
// console.log(source.getState());
// var listenerKey = source.on('change', function (e) {
// if (source.getState() === 'ready') {
// console.log(source.getState());
// Observable.unByKey(listenerKey);
// service.prepLayerFilter(layer);
// $scope.applyFilters(layer);
// }
// });
// }
// });
}
]
@@ -0,0 +1,8 @@
export default ['config', function (config) {
return {
template: require(`components/feature-filter/partials/feature-filter-md.html`),
link: function (scope, element) {

}
};
}]

0 comments on commit 035cd7d

Please sign in to comment.
You can’t perform that action at this time.