diff --git a/app-profiles/research-dashboard/dashboard.config.js b/app-profiles/research-dashboard/dashboard.config.js index b9279c8bf..961029559 100644 --- a/app-profiles/research-dashboard/dashboard.config.js +++ b/app-profiles/research-dashboard/dashboard.config.js @@ -9,6 +9,7 @@ * migrated bundle behaves identically. */ import { lbl } from './src/composables/useDashboardAggregations.js' +import { readLanguageFamily } from '@map/composables/legends/useLanguageFamilyLegendData.js' // same numeric coercion the DataTable uses for its num columns const num = (v) => { if (typeof v === 'number') return v; const n = parseFloat(String(v ?? '').replace(/[^0-9.\-]/g, '')); return isNaN(n) ? null : n } @@ -41,7 +42,11 @@ export default { wagf_block: { label: 'Block', get: (r) => lbl(r.wagf_block) }, country_code: { label: 'Country', get: (r) => lbl(r.country_code), geoIso: (r) => r.country_code && r.country_code.value }, engagement_status: { label: 'Status', get: (r) => lbl(r.engagement_status) }, - language_family: { label: 'Language Family', get: (r) => lbl(r.imb_language_family) }, + // The API fills imb_language_family for only a few dozen rows, so the family is resolved + // the way the research map's legend buckets it: the API family when present, else derived + // from the primary-language label. The same accessor drives the counts and the row-click + // filter, so a family row narrows every linked panel. + language_family: { label: 'Language Family', get: (r) => readLanguageFamily({ languageFamily: r.imb_language_family, primary_language: r.primary_language }) }, primary_language: { label: 'Language', get: (r) => lbl(r.primary_language) }, // People tier accessors — key by CODE (DashboardFacetRail resolves code→human name via // useAffinityBlockLegendData). Mirrors research-map's affinity-block → cluster → PG hierarchy. diff --git a/library/composables/legends/useLanguageFamilyLegendData.js b/library/composables/legends/useLanguageFamilyLegendData.js index e75a67b08..68968dcc5 100644 --- a/library/composables/legends/useLanguageFamilyLegendData.js +++ b/library/composables/legends/useLanguageFamilyLegendData.js @@ -132,6 +132,11 @@ function readFamily(p) { } return 'Unknown' } +// Per-row family accessor for surfaces that aggregate RAW API rows (the research +// dashboard's facet rail). Same precedence as the legend buckets above: the API +// family when present, else derived from the primary-language label. Feed it +// { languageFamily, primary_language } (or any shape readFamily reads). +export const readLanguageFamily = readFamily function readLanguage(p) { // Read from _raw first (returns original API comma-inverted label like "Arabic, Sudanese"). // p.language may have been overwritten to the unwrapped value form by useMapData.