Skip to content

Commit c572187

Browse files
committed
Fix discipline filters across scope changes
1 parent 3fa7537 commit c572187

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
if (legacy === 'IT') scope = ['IT'];
1515
else if (legacy === 'INRAE') scope = ['INRAE'];
1616
else if (legacy === 'BOTH') scope = []; // legacy union → ALL
17-
else scope = ['IT']; // default
17+
else scope = []; // default: ALL
1818
}
1919
var hasIT = scope.indexOf('IT') >= 0, hasIN = scope.indexOf('INRAE') >= 0;
2020
var mode = (hasIT && hasIN) ? 'BOTH' : hasIT ? 'IT' : hasIN ? 'INRAE' : 'ALL';
2121
document.documentElement.classList.add('mode-' + mode);
22-
} catch(e) { document.documentElement.classList.add('mode-IT'); }
22+
} catch(e) { document.documentElement.classList.add('mode-ALL'); }
2323
</script>
2424
<link rel="preconnect" href="https://fonts.googleapis.com">
2525
<link href="https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,600;1,400&family=Fira+Code:wght@400;500&family=Lato:wght@300;400;700&display=swap" rel="stylesheet">
@@ -381,7 +381,7 @@
381381
<dd>Each project's EU contribution (for the active scope) is distributed evenly over its duration. A project spanning 3.5 years with €700k contribution yields ~€200k/year. Years partially covered receive a proportional share. This allows meaningful cross-year comparisons despite uneven project starts and ends.</dd>
382382

383383
<dt>Scope filter (IT / INRAE)</dt>
384-
<dd>The <strong>Scope</strong> filter in the left sidebar controls which projects are visible. <strong>IT only</strong> (default): projects where INRAE Transfert SAS is a partner. <strong>INRAE only</strong>: projects where the broader INRAE research institute participates (typically a much larger portfolio). <strong>Both checked</strong>: only projects shared by IT and INRAE (intersection). <strong>Neither checked</strong>: every project involving either entity (union of all). When both or neither are selected, budget figures are summed (IT + INRAE combined). Each project's card shows up to three budget chips: total EU budget, IT contribution, INRAE contribution — only the relevant ones are displayed.</dd>
384+
<dd>The <strong>Scope</strong> filter in the left sidebar controls which projects are visible. <strong>IT only</strong>: projects where INRAE Transfert SAS is a partner. <strong>INRAE only</strong>: projects where the broader INRAE research institute participates (typically a much larger portfolio). <strong>Both checked</strong>: only projects shared by IT and INRAE (intersection). <strong>Neither checked</strong> (default): every project involving either entity (union of all). When both or neither are selected, budget figures are summed (IT + INRAE combined). Each project's card shows up to three budget chips: total EU budget, IT contribution, INRAE contribution — only the relevant ones are displayed.</dd>
385385

386386
<dt>FP7 → funding type mapping</dt>
387387
<dd>FP7 funding scheme codes are normalised to categories equivalent to H2020/HE types to enable cross-programme budget breakdowns. Mappings include: <code>CP</code>, <code>CP-TP</code>, <code>CP-IP</code> → RIA · <code>CP-*-SICA</code> → RIA · <code>MC-*</code> (Marie Curie) → MSCA · <code>ERC-*</code> → ERC · <code>BSG-SME*</code> → EIC · <code>NoE</code> (Networks of Excellence) → CSA · <code>HORIZON-AG/PARC</code> → COFUND.</dd>

js/app.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
══════════════════════════════════════════════════════════════ */
44

55
let ALL = [], VISIBLE_PROJECTS = [], FILTERED = [];
6-
let FILTERS = { scope: new Set(['IT']), programme: new Set(), itRole: new Set(), inraeRole: new Set(), schemeGroup: new Set(), status: new Set(), country: new Set() };
6+
let FILTERS = { scope: new Set(), programme: new Set(), itRole: new Set(), inraeRole: new Set(), schemeGroup: new Set(), status: new Set(), country: new Set() };
77
let SEARCH = '', SORT = 'startDate-desc';
88
let DOMAIN_FILTERS = [], DOMAIN_OPERATOR = 'OR';
99
let REGION_FILTER = null, PARTNER_FILTER = null, PARTNER_PAGE = 0;
1010
let CHARTS = {};
11-
let VIEW_MODE = 'IT'; // derived from FILTERS.scope: 'IT' | 'INRAE' | 'BOTH' (intersection) | 'ALL' (union)
11+
let VIEW_MODE = 'ALL'; // derived from FILTERS.scope: 'IT' | 'INRAE' | 'BOTH' (intersection) | 'ALL' (union)
1212

1313
function destroyChart(id) { if (CHARTS[id]) { CHARTS[id].destroy(); delete CHARTS[id]; } }
1414

@@ -35,6 +35,10 @@ function applyViewMode({ rebuild = true } = {}) {
3535
if (rebuild) {
3636
delete window._domDescendants;
3737
delete window._domToIds;
38+
delete window._filteredPkeys;
39+
delete window._nodeFilteredCount;
40+
if (typeof _domTree !== 'undefined') _domTree = null;
41+
if (typeof _donutDrillNode !== 'undefined') _donutDrillNode = null;
3842
buildKPIs();
3943
buildSidebar();
4044
apply();
@@ -88,7 +92,7 @@ async function load() {
8892
if (legacy === 'IT') scope = ['IT'];
8993
else if (legacy === 'INRAE') scope = ['INRAE'];
9094
else if (legacy === 'BOTH') scope = []; // legacy union → ALL
91-
else scope = ['IT']; // default
95+
else scope = []; // default: ALL
9296
}
9397
FILTERS.scope = new Set(scope);
9498
} catch (e) {}
@@ -166,13 +170,16 @@ function apply() {
166170
}
167171
}
168172
if (DOMAIN_FILTERS.length) {
169-
const getDescendantIds = df => {
170-
if (window._domDescendants && window._domDescendants[df.key]) return window._domDescendants[df.key];
171-
return null;
172-
};
173173
const matchDomain = df => {
174-
const ids = getDescendantIds(df);
174+
const ids = window._domDescendants && window._domDescendants[df.key];
175175
if (ids && ids.size > 0) return ids.has(p.id + '|' + p.programme);
176+
const selectedPath = (df.path && df.path.length ? df.path : (df.key || '').split('|||')).filter(Boolean);
177+
const hasPathMatch = (p.euroSciVoc || []).some(sv => {
178+
const parts = (sv.path || '').trim('/').split('/').map(x => x.trim()).filter(Boolean);
179+
return selectedPath.length && selectedPath.every((seg, i) => parts[i] === seg);
180+
});
181+
if (hasPathMatch) return true;
182+
if (selectedPath.length === 1 && projectCats(p, 'l1').some(c => c === selectedPath[0])) return true;
176183
const exactIds = window._domToIds && window._domToIds[df.name];
177184
if (exactIds && exactIds.size > 0) return exactIds.has(p.id + '|' + p.programme);
178185
return projectCats(p).some(c => c === df.name);
@@ -346,7 +353,7 @@ function bindEvents() {
346353
SEARCH = ''; SORT = 'startDate-desc'; DOMAIN_FILTERS = []; DOMAIN_OPERATOR = 'OR';
347354
REGION_FILTER = null; PARTNER_FILTER = null;
348355
Object.values(FILTERS).forEach(s => s.clear());
349-
FILTERS.scope = new Set(['IT']); // restore default scope
356+
FILTERS.scope = new Set(); // restore default scope: ALL
350357
persistScope();
351358
document.getElementById('search').value = '';
352359
document.getElementById('sort').value = 'startDate-desc';

0 commit comments

Comments
 (0)