Ver Fonte

✨ only show schema classes with >2 datasets

jmacura há 4 anos atrás
pai
commit
d21e0e4bda
1 ficheiros alterados com 12 adições e 1 exclusões
  1. 12 1
      src/adjuster/adjuster.service.ts

+ 12 - 1
src/adjuster/adjuster.service.ts

@@ -93,8 +93,12 @@ export class AdjusterService {
 
     /* Listen to schema changes so the factors can be re-arranged in the view */
     this.adjusterPresetsService.schemaChanges.subscribe((newSchema) => {
-      //TODO: i18n this!
+      const orphanedDatasets = [];
       this.factors = newSchema.groups.map((group) => {
+        const datasets = this.adjusterPresetsService.getGroupDatasets(group.id);
+        if (datasets.length < 3) {
+          orphanedDatasets.push(...datasets);
+        }
         return {
           id: group.id,
           labels: group.labels,
@@ -102,6 +106,13 @@ export class AdjusterService {
           datasets: this.adjusterPresetsService.getGroupDatasets(group.id)
         }
       });
+      this.factors = this.factors.filter((factor) => factor.datasets.length >= 3);
+      this.factors.push({
+        id: 'others',
+        labels: [{'@value': 'Ostatní', '@language': 'cs'}, {'@value': 'Others', '@language': 'en'}],
+        weight: this.resetFactorWeights('others'),
+        datasets: orphanedDatasets
+      })
     });
 
     /* Listen to problem changes so the datasets can be turned on/off */