Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix undeined fields and html entities in field titles

Jason Kentfc0ed23bd0f4
diff --git a/web/css/facets.css b/web/css/facets.css
index 47e34a82f..603428966 100644
--- a/web/css/facets.css
+++ b/web/css/facets.css
@@ -9,14 +9,16 @@
padding: 3px;
}
& .filter-chip {
- padding: 3px 20px 3px 5px;
+ padding: 3px 20px 3px 7px;
margin: 4px;
background: #ccc;
color: #333;
border-radius: 20px;
position: relative;
display: inline-block;
- font-weight: 500;
+ span {
+ font-weight: 500;
+ }
cursor: pointer;
&:hover {
background: #eee;
@@ -28,6 +30,7 @@
& .svg-inline--fa {
position: absolute;
right: 2px;
+ top: calc(50% - 7px);
color: #666;
}
}
diff --git a/web/js/components/layer/product-picker/search/filter-chips.js b/web/js/components/layer/product-picker/search/filter-chips.js
index 5837e12cc..33b716558 100644
--- a/web/js/components/layer/product-picker/search/filter-chips.js
+++ b/web/js/components/layer/product-picker/search/filter-chips.js
@@ -28,7 +28,7 @@ export default function FilterChips(props) {
className="filter-chip"
onClick={() => removeFilter(field, value)}
>
- {displayValue}
+ <span dangerouslySetInnerHTML={{ __html: displayValue }} />
<FontAwesomeIcon
icon="times"
fixedWidth
diff --git a/web/js/modules/product-picker/format-config.js b/web/js/modules/product-picker/format-config.js
index 43a063012..79d62e12a 100644
--- a/web/js/modules/product-picker/format-config.js
+++ b/web/js/modules/product-picker/format-config.js
@@ -4,6 +4,7 @@ import {
} from 'lodash';
import moment from 'moment';
import { available } from '../layers/selectors';
+import util from '../../util/util';
const periodIntervalMap = {
daily: 'Day',
@@ -19,13 +20,14 @@ function capitalizeFirstLetter(string) {
function setLayerProp (layer, prop, value) {
const featuredMeasurement = prop === 'measurements' && (value && value.includes('Featured'));
- if (!layer || featuredMeasurement) {
+ if (!layer || featuredMeasurement || !value) {
return;
}
+ const decodedValue = value.includes('&') ? util.decodeHTML(value) : value;
if (!layer[prop]) {
- layer[prop] = [value];
- } else if (!layer[prop].includes(value)) {
- layer[prop].push(value);
+ layer[prop] = [decodedValue];
+ } else if (!layer[prop].includes(decodedValue)) {
+ layer[prop].push(decodedValue);
}
}
diff --git a/web/js/modules/product-picker/selectors.js b/web/js/modules/product-picker/selectors.js
index 4a577a07e..f783eafa7 100644
--- a/web/js/modules/product-picker/selectors.js
+++ b/web/js/modules/product-picker/selectors.js
@@ -5,12 +5,7 @@ import {
import { createSelector } from 'reselect';
import buildLayerFacetProps from './format-config';
import getSelectedDate from '../date/selectors';
-
-const decodeHtml = (html) => {
- const txt = document.createElement('textarea');
- txt.innerHTML = html;
- return txt.value;
-};
+import util from '../../util/util';
// State selectors
const getConfig = ({ config }) => config;
@@ -31,7 +26,7 @@ export const getLayersForProjection = createSelector(
if (projectionMeta.subtitle) layer.subtitle = projectionMeta.subtitle;
// Decode HTML entities in the subtitle
if (layer.subtitle && layer.subtitle.includes('&')) {
- layer.subtitle = decodeHtml(layer.subtitle);
+ layer.subtitle = util.decodeHTML(layer.subtitle);
}
return layer;
});
diff --git a/web/js/util/util.js b/web/js/util/util.js
index e61cc5289..6fe83e1b8 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -1124,5 +1124,11 @@ export default (function(self) {
return false;
};
+ self.decodeHTML = (html) => {
+ const txt = document.createElement('textarea');
+ txt.innerHTML = html;
+ return txt.value;
+ };
+
return self;
}({}));