blob: 66663263c3668a2a6f6dc731ae3ede6fb1faf5ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import {ComponentType} from "../utils/constants";
import {CacheService} from "../services/cache-service";
export class CategoryTypeFilter {
static $inject = ['Sdc.Services.CacheService'];
constructor(cacheService:CacheService) {
let filter = <CategoryTypeFilter>(categories:any, selectedType:Array<string>, selectedSubResourceTypes:Array<string>) => {
if (selectedType.indexOf(ComponentType.RESOURCE) === -1 && selectedSubResourceTypes.length > 0) {
selectedType = selectedType.concat([ComponentType.RESOURCE]);
}
if (!selectedType.length)
return categories;
let filteredCategories:any = [];
selectedType.forEach((type:string) => {
filteredCategories = filteredCategories.concat(cacheService.get(type.toLowerCase() + 'Categories'));
});
return _.filter(categories, function (category:any) {
return filteredCategories.indexOf(category) != -1;
});
};
return filter;
}
}
|