Skip to content

Commit

Permalink
fix: yAxis shown, fix filters
Browse files Browse the repository at this point in the history
  • Loading branch information
lubojr committed Oct 25, 2023
1 parent a633b9a commit e804ee1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 66 deletions.
16 changes: 9 additions & 7 deletions app/src/components/IndicatorData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ export default {
};
},
mounted() {
const d = this.indicatorObject.time[this.indicatorObject.time.length - 1];
if (d.toFormat) {
const formatted = d.toFormat('dd. MMM');
this.dataLayerTime = {
value: formatted,
name: formatted,
};
if (Array.isArray(this.indicatorObject.time)) {
const d = this.indicatorObject.time[this.indicatorObject.time.length - 1];
if (d.toFormat) {
const formatted = d.toFormat('dd. MMM');
this.dataLayerTime = {
value: formatted,
name: formatted,
};
}
}
// add event listener for map up
window.addEventListener('message', this.mapTimeUpdatedHandler);
Expand Down
73 changes: 14 additions & 59 deletions app/src/store/modules/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,56 +99,8 @@ const getters = {
})
.sort((a, b) => ((a.name > b.name) ? 1 : -1));
},
getFeatures(state/* , _, rootState */) {
getFeatures(state) {
let features = state.allFeatures;
// TODO: with current approach we should not need any filtering for features here
/*
if (state.featureFilters.countries.length > 0) {
features = features
.filter((f) => {
if (Array.isArray(f.properties.indicatorObject.country)) {
return f.properties.indicatorObject.country
.includes(state.featureFilters.countries);
} else { // eslint-disable-line
return state.featureFilters.countries
.includes(f.properties.indicatorObject.country)
|| f.properties.indicatorObject.city === 'World';
}
});
}
if (state.featureFilters.indicators.length > 0) {
features = features
.filter((f) => {
if (['N9', 'N10'].includes(f.properties.indicatorObject.indicator)) {
return state.featureFilters.indicators.includes('N1');
}
return state.featureFilters.indicators
.includes(f.properties.indicatorObject.indicator);
});
}
if (state.featureFilters.themes.length > 0) {
features = features
.filter((f) => rootState.themes.currentPOIsIncludedInTheme
.includes(`${
f.properties.indicatorObject.aoiID}-${
f.properties.indicatorObject.indicator}`));
}
if (state.featureFilters.custom.length > 0) {
features = features
.filter((f) => state.featureFilters.custom
.map((c) => getLocationCode(c.properties.indicatorObject))
.includes(getLocationCode(f.properties.indicatorObject)));
}
if (!state.featureFilters.includeArchived) {
features = features.filter(
(f) => (
f.properties.indicatorObject.updateFrequency
? f.properties.indicatorObject.updateFrequency.toLowerCase() !== 'archived' : true
)
);
}
*/
// due to a mismatch in keys (e.g. 'countries' vs. 'country' etc.) between the STAC properties
// and the indicatorObject properties this cannot be 100% automated and a keymap is necessary
// TODO as soon as keys are harmonized, automate this
Expand All @@ -159,16 +111,19 @@ const getters = {
const indicatorsFilter = document.querySelector('eox-itemfilter');
if (indicatorsFilter) {
const { filters } = indicatorsFilter;
Object.keys(filters).forEach((filterName) => {
const whiteList = Object.entries(filters[filterName].state)
.filter(([, value]) => !!value)
.map(([key]) => key);
if (whiteList.length > 0) {
features = features.filter(
(f) => whiteList.includes(f.properties.indicatorObject[keyMap[filterName]]),
);
}
});
Object.keys(filters)
.filter((filterName) => Object.keys(keyMap).includes(filterName))
.forEach((filterName) => {
// remove features not matching active countries or cities filter
const whiteList = Object.entries(filters[filterName].state)
.filter(([, value]) => !!value)
.map(([key]) => key);
if (whiteList.length > 0) {
features = features.filter(
(f) => whiteList.includes(f.properties.indicatorObject[keyMap[filterName]]),
);
}
});
}
features = features
.sort((a, b) => ((a.properties.indicatorObject.country > b.properties.indicatorObject.country)
Expand Down
1 change: 1 addition & 0 deletions app/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ export async function loadIndicatorData(baseConfig, payload) {
featureObject.isFeature = true;
featureObject.aoi = latLng([coordinates[0], coordinates[1]]);
featureObject.indicator = indicatorObject.indicator;
featureObject.yAxis = indicatorObject.yAxis;
featureObject.indicatorValue = [''];
featureObject.city = link.city ? link.city : link.name;
featureObject.country = link.country;
Expand Down

0 comments on commit e804ee1

Please sign in to comment.