feat: add basic templates for data list items

This commit is contained in:
Jovan Krunić
2019-03-22 14:26:53 +01:00
parent 9850cf77c2
commit 3e697b17b4
47 changed files with 31480 additions and 95 deletions

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Injectable} from '@angular/core';
import {SCBackendAggregationConfiguration, SCFacet, SCThing} from '@openstapps/core';
import {SCBackendAggregationConfiguration, SCFacet, SCThing, SCFacetBucket} from '@openstapps/core';
@Injectable()
export class DataFacetsProvider {
@@ -45,14 +45,10 @@ export class DataFacetsProvider {
*
* @param buckets Buckets from a facet
*/
bucketsToMap(buckets: Array<{[key: string]: number}>): {[key: string]: number} {
bucketsToMap(buckets: SCFacetBucket[]): {[key: string]: number} {
const bucketsMap: {[key: string]: number} = {};
buckets.forEach((bucket) => {
for (const key in bucket) {
if (bucket.hasOwnProperty(key)) {
bucketsMap[key] = bucket[key];
}
}
bucketsMap[bucket.key] = bucket.count;
});
return bucketsMap;
}
@@ -62,12 +58,11 @@ export class DataFacetsProvider {
*
* @param bucketsMap A map from a buckets array
*/
mapToBuckets(bucketsMap: {[key: string]: number}): Array<{[key: string]: number}> {
const buckets: Array<{[key: string]: number}> = [];
mapToBuckets(bucketsMap: {[key: string]: number}): SCFacetBucket[] {
const buckets: SCFacetBucket[] = [];
for (const key in bucketsMap) {
if (bucketsMap.hasOwnProperty(key)) {
const bucket: {[key: string]: number} = {};
bucket[key] = bucketsMap[key];
const bucket: SCFacetBucket = {key: key, count: bucketsMap[key]};
buckets.push(bucket);
}
}