mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-28 03:42:11 +00:00
feat: add basic templates for data list items
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user