Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add conditional for draggable modals

ZachTRice649fa072856a
diff --git a/web/css/modal.css b/web/css/modal.css
index 3b87bdabd..d33416afb 100644
--- a/web/css/modal.css
+++ b/web/css/modal.css
@@ -15,13 +15,12 @@
}
.react-draggable.modal-dialog.vector-modal {
position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- margin: 0;
+ left: 50%;
width: 500px;
height: 160px;
+ margin-left: -250px;
+ margin-top: 10px;
+ margin-bottom: 0;
}
.template-modal.modal-dialog {
max-width: 625px;
diff --git a/web/js/components/vector-metadata/vector-metadata-table.js b/web/js/components/vector-metadata/vector-metadata-table.js
index d08a6f91b..3bddfe66b 100644
--- a/web/js/components/vector-metadata/vector-metadata-table.js
+++ b/web/js/components/vector-metadata/vector-metadata-table.js
@@ -23,6 +23,21 @@ export default class VectorMetaTable extends React.Component {
</th>
));
}
+
+ // Object.entries(metaFeatures).forEach(feature => {
+ // let featureName = feature[0];
+ // console.log('featureName', featureName); // TITLE LINE
+ // Object.values(metaLegend['mvt_properties']).forEach(property => {
+ // if (property['Identifier'] === featureName) { console.log('property', property); } // TOOLTIP LINE
+ // });
+ // });
+ // console.log('-------------------');
+ // Object.entries(metaFeatures).forEach(feature => {
+ // let featureData = feature[1];
+ // console.log('featureData', featureData); // DATA LINE (Should match table headings)
+ // });
+ // console.log('-------------------');
+
return (
<Table striped bordered size="sm">
<thead>
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index 4dec642d2..0127701c1 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -15,7 +15,8 @@ class ModalContainer extends Component {
this.state = {
offsetTop: props.customProps.offsetTop,
offsetLeft: props.customProps.offsetLeft,
- width: props.customProps.width
+ width: props.customProps.width,
+ isDraggable: props.isDraggable
};
}
// static getDerivedStateFromProps(newProps, state) {
@@ -51,6 +52,7 @@ class ModalContainer extends Component {
/>
);
}
+
render() {
const {
isCustom,
@@ -80,6 +82,7 @@ class ModalContainer extends Component {
CompletelyCustomModal,
bodyComponentProps,
timeout,
+ isDraggable,
desktopOnly,
size
} = newProps;
@@ -93,12 +96,17 @@ class ModalContainer extends Component {
onClose();
}
};
+ const DraggableWrap = ({ condition, wrapper, children }) =>
+ condition ? wrapper(children) : children;
if (isMobile && isOpen && desktopOnly) {
toggleWithClose();
}
return (
<ErrorBoundary>
- <Draggable>
+ <DraggableWrap
+ condition={isDraggable}
+ wrapper={children => <Draggable>{children}</Draggable>}
+ >
<Modal
isOpen={isOpen}
toggle={toggleWithClose}
@@ -142,7 +150,7 @@ class ModalContainer extends Component {
</DetectOuterClick>
)}
</Modal>
- </Draggable>
+ </DraggableWrap>
</ErrorBoundary>
);
}
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 9a72f27ac..cec3d4c0a 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -915,11 +915,15 @@ export function mapui(models, config, store, ui) {
map.un('rendercomplete', onRenderComplete);
};
map.on('rendercomplete', onRenderComplete);
- // Clicking on a vector shows it's attributes in console.
map.on('click', function(e) {
var metaTitle;
var def;
var metaArray = [];
+ var uniqueMeta = metaArray
+ .map(e => e['layer'])
+ .map((e, i, final) => final.indexOf(e) === i && i)
+ .filter(e => metaArray[e]).map(e => metaArray[e]);
+
map.forEachFeatureAtPixel(e.pixel, function(feature, layer) {
def = layer.wv.def;
metaTitle = def.title;
@@ -934,26 +938,18 @@ export function mapui(models, config, store, ui) {
metaArray.push(obj);
}
});
- const uniqueMeta = metaArray
- .map(e => e['layer'])
- // store the keys of the unique objects
- .map((e, i, final) => final.indexOf(e) === i && i)
- // eliminate the dead keys & store unique objects
- .filter(e => metaArray[e]).map(e => metaArray[e]);
if (uniqueMeta.length) {
let vectorPointMeta = uniqueMeta[0];
let vectorDataId = def.vectorData.id;
let legend = vectorPointMeta.legend;
- // MVT Features table (Use legend object as tooltips)
let features = vectorPointMeta.features;
-
store.dispatch(openCustomContent('Vector' + vectorDataId,
{
headerText: metaTitle,
backdrop: false,
clickableBehindModal: true,
- wrapClassName: 'clickable-behind-modal',
+ wrapClassName: 'clickable-behind-modal vector-modal-wrap',
modalClassName: 'vector-modal',
bodyComponent: VectorMetaTable,
bodyComponentProps: {
@@ -961,8 +957,9 @@ export function mapui(models, config, store, ui) {
metaFeatures: features,
metaLegend: legend
},
- offsetTop: (e.clientY + 10) + 'px',
- offsetLeft: (e.clientX- 5) + 'px'
+ isDraggable: true
+ // offsetTop: e.clientY + 'px',
+ // offsetLeft: e.clientX + 'px'
}
));
};