Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix vector bugs and tests #2144

Benjamin King5e2e4c852db5
diff --git a/web/js/app.js b/web/js/app.js
index cf77ca458..354b0355f 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -101,12 +101,12 @@ class App extends React.Component {
}
render() {
- const { isAnimationWidgetActive, isTourActive, locationKey, mapIsClickable, modalId } = this.props;
- const mapClasses = mapIsClickable ? 'wv-map' + ' cursor-pointer' : 'wv-map';
+ const { isAnimationWidgetActive, isTourActive, locationKey, modalId, mapMouseEvents } = this.props;
return (
<div className="wv-content" id="wv-content" data-role="content">
<Toolbar />
+ <OlCoordinates mouseEvents={mapMouseEvents} />
<div id="wv-alert-container" className="wv-alert-container">
<FeatureAlert />
</div>
@@ -114,7 +114,6 @@ class App extends React.Component {
{isTourActive ? <Tour /> : null}
<div id="layer-modal" className="layer-modal" />
<div id="layer-settings-modal" />
- <div id="wv-map" className={mapClasses} />
<div id="eventsHolder" />
<div id="imagedownload" />
<div id="dlMap" />
@@ -123,7 +122,7 @@ class App extends React.Component {
{isAnimationWidgetActive ? <AnimationWidget /> : null}
</div>
<MeasureButton />
- <OlCoordinates mouseEvents={this.props.mapMouseEvents} />
+
<Modal key={modalId} />
<ErrorBoundary>
<Debug parameters={this.props.parameters} />
@@ -185,7 +184,6 @@ function mapStateToProps(state, ownProps) {
models: ownProps.models,
mapMouseEvents: ownProps.mapMouseEvents,
locationKey: state.location.key,
- mapIsClickable: state.map.isClickable,
modalId: state.modal.id
};
}
diff --git a/web/js/components/map/ol-coordinates-test.js b/web/js/components/map/ol-coordinates-test.js
new file mode 100644
index 000000000..8e7419797
--- /dev/null
+++ b/web/js/components/map/ol-coordinates-test.js
@@ -0,0 +1,49 @@
+import React from 'react';
+import renderer from 'react-test-renderer';
+import util from '../../util/util';
+import OlCoordinates from './ol-coordinates';
+import { registerProjections } from '../../fixtures';
+
+let events;
+let component;
+let map;
+
+beforeEach(() => {
+ registerProjections();
+ events = util.events();
+ component = renderer.create(<OlCoordinates mouseEvents={events} />);
+ map = {
+ getEventPixel: jest.fn(),
+ getCoordinateFromPixel: () => [0, 0]
+ };
+});
+
+afterEach(() => {
+ util.setCoordinateFormat('latlon-dd');
+});
+
+test('shows coordinates of (10, 20) when moving the mouse', () => {
+ map.getCoordinateFromPixel = () => [10, 20];
+ events.trigger('mousemove', {}, map, 'EPSG:4326');
+ expect(component.toJSON()).toMatchSnapshot();
+});
+
+test('shows 10°00.000\'N, 20°00.000\'E when set to degrees and minutes format', () => {
+ util.setCoordinateFormat('latlon-dm');
+ map.getCoordinateFromPixel = () => [10, 20];
+ events.trigger('mousemove', {}, map, 'EPSG:4326');
+ expect(component.toJSON()).toMatchSnapshot();
+});
+
+test('clears coordinates when mouse moves off the map', () => {
+ map.getCoordinateFromPixel = () => [10, 20];
+ events.trigger('mousemove', {}, map, 'EPSG:4326');
+ events.trigger('mouseout', {}, map, 'EPSG:4326');
+ expect(component.toJSON()).toMatchSnapshot();
+});
+
+test('reprojects (0,0) to (-45, 90) for EPSG:3413', () => {
+ map.getCoordinateFromPixel = () => [0, 0];
+ events.trigger('mousemove', {}, map, 'EPSG:3413');
+ expect(component.toJSON()).toMatchSnapshot();
+});
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
new file mode 100644
index 000000000..df7d50511
--- /dev/null
+++ b/web/js/components/map/ol-coordinates.js
@@ -0,0 +1,97 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import Coordinates from './coordinates';
+import util from '../../util/util';
+import { transform } from 'ol/proj';
+
+class OlCoordinates extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ hasMouse: false,
+ latitude: null,
+ longitude: null,
+ crs: null,
+ format: null
+ };
+ this.mouseMove = this.mouseMove.bind(this);
+ this.mouseOut = this.mouseOut.bind(this);
+ this.changeFormat = this.changeFormat.bind(this);
+ this.registerMouseListeners();
+ }
+
+ registerMouseListeners() {
+ this.props.mouseEvents.on('mousemove', this.mouseMove);
+ this.props.mouseEvents.on('mouseout', this.mouseOut);
+ }
+
+ mouseMove(event, map, crs) {
+ const pixels = map.getEventPixel(event);
+ const coord = map.getCoordinateFromPixel(pixels);
+ if (!coord) {
+ this.clearCoord();
+ return;
+ }
+
+ const pcoord = transform(coord, crs, 'EPSG:4326');
+ const [lon, lat] = pcoord;
+ if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
+ this.clearCoord();
+ return;
+ }
+
+ this.setState({
+ hasMouse: true,
+ format: util.getCoordinateFormat(),
+ latitude: pcoord[1],
+ longitude: pcoord[0],
+ crs
+ });
+ }
+
+ mouseOut(event) {
+ if (event.relatedTarget && event.relatedTarget.classList) {
+ const cl = event.relatedTarget.classList;
+ // Ignore when the mouse goes over the coordinate display. Clearing
+ // the coordinates in this situation causes a flicker.
+ if (cl.contains('map-coord')) {
+ return;
+ }
+ }
+ this.clearCoord();
+ }
+
+ clearCoord() {
+ this.setState({ latitude: null, longitude: null });
+ }
+
+ changeFormat(format) {
+ util.setCoordinateFormat(format);
+ this.setState({ format });
+ }
+
+ render() {
+ // Don't render until a mouse is being used
+ if (!this.state.hasMouse) {
+ return null;
+ }
+
+ return (
+ <div id='ol-coords-case'>
+ <Coordinates
+ format={this.state.format}
+ latitude={this.state.latitude}
+ longitude={this.state.longitude}
+ crs={this.state.crs}
+ onFormatChange={this.changeFormat}
+ />
+ </div>
+ );
+ }
+}
+
+OlCoordinates.propTypes = {
+ mouseEvents: PropTypes.object.isRequired
+};
+
+export default OlCoordinates;
diff --git a/web/js/components/vector-metadata/__snapshots__/table.test.js.snap b/web/js/components/vector-metadata/__snapshots__/table.test.js.snap
new file mode 100644
index 000000000..f4a35e290
--- /dev/null
+++ b/web/js/components/vector-metadata/__snapshots__/table.test.js.snap
@@ -0,0 +1,83 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Check that there is not popup 1`] = `
+<div>
+ <div>
+ <table
+ className="table table-sm"
+ >
+ <thead>
+ <tr>
+ <th>
+ Choclococha
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>
+ <div
+ className="vector-feature-name-cell"
+ >
+ GRAND_ID
+ </div>
+ </td>
+ <td>
+ <span>
+ 4886
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+`;
+
+exports[`If there is a valuemap, use valuemap 1`] = `
+<div>
+ <div>
+ <table
+ className="table table-sm"
+ >
+ <thead>
+ <tr>
+ <th>
+ Choclococha
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>
+ <div
+ className="vector-feature-name-cell"
+ >
+ GRAND_ID
+ </div>
+ </td>
+ <td>
+ <span>
+ 4886
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div
+ className="vector-feature-name-cell"
+ >
+ Urborrur
+ </div>
+ </td>
+ <td>
+ <span>
+ Urban
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+`;
diff --git a/web/js/components/vector-metadata/table.js b/web/js/components/vector-metadata/table.js
index de9058cbf..ef0a198c1 100644
--- a/web/js/components/vector-metadata/table.js
+++ b/web/js/components/vector-metadata/table.js
@@ -40,7 +40,11 @@ export default class VectorMetaTable extends React.Component {
<tbody>
{metaLegend.map((properties, index) => {
const featureId = properties.Identifier;
- const value = properties.ValueMap ? properties.ValueMap[metaFeatures[featureId]] : metaFeatures[featureId];
+ const isIntegerToStyle = properties.Function !== 'Identify' && (properties.DataType === 'int');
+ const value = properties.ValueMap
+ ? properties.ValueMap[metaFeatures[featureId]]
+ : isIntegerToStyle ? metaFeatures[featureId].toLocaleString('en')
+ : metaFeatures[featureId];
const id = util.cleanId(String(title + '-' + (metaIndex + index)));
if (!value) return undefined;
return (
@@ -71,6 +75,6 @@ export default class VectorMetaTable extends React.Component {
}
}
VectorMetaTable.propTypes = {
- metaFeatures: PropTypes.object.isRequired,
- metaLegend: PropTypes.object.isRequired
+ metaArray: PropTypes.array,
+ title: PropTypes.string
};
diff --git a/web/js/components/vector-metadata/table.test.js b/web/js/components/vector-metadata/table.test.js
new file mode 100644
index 000000000..df1f65c8d
--- /dev/null
+++ b/web/js/components/vector-metadata/table.test.js
@@ -0,0 +1,44 @@
+import React from 'react';
+import VectorMetaTable from './table';
+import renderer from 'react-test-renderer';
+
+let component;
+beforeEach(() => {
+ component = renderer.create(
+ <VectorMetaTable
+ metaArray={[{
+ features: {
+ GRAND_ID: 4886
+ },
+ legend: [{ Identifier: 'GRAND_ID' }],
+ featureTitle: 'Choclococha'
+ }]}
+ />
+ );
+});
+
+test('Check that there is not popup', () => {
+ expect(component.toJSON()).toMatchSnapshot();
+});
+test('If there is a valuemap, use valuemap', () => {
+ component = renderer.create(
+ <VectorMetaTable
+ metaArray={[{
+ features: {
+ GRAND_ID: 4886,
+ Urborrur: 'U'
+ },
+ legend: [
+ {
+ Identifier: 'GRAND_ID'
+ }, {
+ Identifier: 'Urborrur',
+ ValueMap: { U: 'Urban', R: 'Rural' }
+ }
+ ],
+ featureTitle: 'Choclococha'
+ }]}
+ />
+ );
+ expect(component.toJSON()).toMatchSnapshot();
+});
diff --git a/web/js/containers/__snapshots__/map-interactions.test.js.snap b/web/js/containers/__snapshots__/map-interactions.test.js.snap
index 063671c57..1ff40946f 100644
--- a/web/js/containers/__snapshots__/map-interactions.test.js.snap
+++ b/web/js/containers/__snapshots__/map-interactions.test.js.snap
@@ -1,101 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`clears coordinates when mouse moves off the map 1`] = `<div />`;
-
-exports[`if there is a feature at pixel dispatch changeCursor action 1`] = `
-<div>
- <div
- className="wv-coords-map wv-coords-map-btn"
- onClick={[Function]}
- >
- <span
- className="map-coord"
- >
- 90.0000°, -45.0000°
-
- EPSG:3413
- </span>
- <div
- className="coord-btn"
- >
- <i
- className="coord-switch"
- />
- </div>
- </div>
-</div>
-`;
-
-exports[`if there is a feature at pixel on click get dialod 1`] = `null`;
-
-exports[`reprojects (0,0) to (-45, 90) for EPSG:3413 1`] = `
-<div>
- <div
- className="wv-coords-map wv-coords-map-btn"
- onClick={[Function]}
- >
- <span
- className="map-coord"
- >
- 90.0000°, -45.0000°
-
- EPSG:3413
- </span>
- <div
- className="coord-btn"
- >
- <i
- className="coord-switch"
- />
- </div>
- </div>
-</div>
-`;
-
-exports[`shows 10°00.000'N, 20°00.000'E when set to degrees and minutes format 1`] = `
-<div>
- <div
- className="wv-coords-map wv-coords-map-btn"
- onClick={[Function]}
- >
- <span
- className="map-coord"
- >
- 20°00.000'N, 10°00.000'E
-
- EPSG:4326
- </span>
- <div
- className="coord-btn"
- >
- <i
- className="coord-switch"
- />
- </div>
- </div>
-</div>
-`;
-
-exports[`shows coordinates of (10, 20) when moving the mouse 1`] = `
-<div>
- <div
- className="wv-coords-map wv-coords-map-btn"
- onClick={[Function]}
- >
- <span
- className="map-coord"
- >
- 20.0000°, 10.0000°
-
- EPSG:4326
- </span>
- <div
- className="coord-btn"
- >
- <i
- className="coord-switch"
- />
- </div>
- </div>
-</div>
+exports[`Check that cursor-hover class is not present 1`] = `
+<div
+ className="wv-map"
+ id="wv-map"
+/>
`;
diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.js
index 82b731ac8..cd3f30a03 100644
--- a/web/js/containers/map-interactions.js
+++ b/web/js/containers/map-interactions.js
@@ -1,55 +1,46 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
-import Coordinates from '../components/map/coordinates';
-import util from '../util/util';
-import { transform } from 'ol/proj';
+import OlCoordinates from '../components/map/ol-coordinates';
import vectorDialog from './vector-dialog';
import { onMapClickGetVectorFeatures } from '../modules/vector-styles/util';
-import { openCustomContent } from '../modules/modal/actions';
+import { openCustomContent, onClose } from '../modules/modal/actions';
import { selectVectorFeatures } from '../modules/vector-styles/actions';
import { groupBy as lodashGroupBy } from 'lodash';
import { changeCursor } from '../modules/map/actions';
-export class OlCoordinates extends React.Component {
+export class MapInteractions extends React.Component {
constructor(props) {
super(props);
- this.state = {
- hasMouse: false,
- latitude: null,
- longitude: null,
- crs: null,
- format: null
- };
this.mouseMove = this.mouseMove.bind(this);
- this.mouseOut = this.mouseOut.bind(this);
- this.changeFormat = this.changeFormat.bind(this);
- this.mouseClick = this.mouseClick.bind(this);
+ this.singleClick = this.singleClick.bind(this);
this.registerMouseListeners();
}
registerMouseListeners() {
this.props.mouseEvents.on('mousemove', this.mouseMove);
- this.props.mouseEvents.on('mouseout', this.mouseOut);
- this.props.mouseEvents.on('singleclick', this.mouseClick);
+ this.props.mouseEvents.on('singleclick', this.singleClick);
}
- mouseClick(e, map) {
+ singleClick(e, map) {
+ const { lastSelected, openVectorDiaglog, onCloseModal, selectVectorFeatures, modalState, getDialogObject } = this.props;
+ const isVectorModalOpen = modalState.id.includes('vector_dialog') && modalState.isOpen;
const pixels = e.pixel;
- const { lastSelected, openVectorDiaglog, selectVectorFeatures, modalState, getDialogObject } = this.props;
const clickObj = getDialogObject(pixels, map);
const metaArray = clickObj.metaArray || [];
const selected = clickObj.selected || {};
const offsetLeft = clickObj.offsetLeft || 10;
const offsetTop = clickObj.offsetTop || 100;
- const dialogId = 'vector_dialog' + pixels[0] + pixels[1];
- const isVectorModalOpen = modalState.id.includes('vector_dialog') && modalState.isOpen;
+ const dialogId = isVectorModalOpen ? modalState.id : 'vector_dialog' + pixels[0] + pixels[1];
if (metaArray.length) {
openVectorDiaglog(dialogId, metaArray, offsetLeft, offsetTop);
}
if (Object.entries(selected).length || (Object.entries(lastSelected).length && !isVectorModalOpen)) {
selectVectorFeatures(selected);
+ } else if (isVectorModalOpen && !Object.entries(selected).length) {
+ onCloseModal();
+ selectVectorFeatures({});
}
}
@@ -67,60 +58,17 @@ export class OlCoordinates extends React.Component {
} else if (!hasFeatures && isShowingClick) {
changeCursor(false);
}
-
- const pcoord = transform(coord, crs, 'EPSG:4326');
- const [lon, lat] = pcoord;
- if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
- this.clearCoord();
- return;
- }
-
- this.setState({
- hasMouse: true,
- format: util.getCoordinateFormat(),
- latitude: pcoord[1],
- longitude: pcoord[0],
- crs
- });
- }
-
- mouseOut(event) {
- if (event.relatedTarget && event.relatedTarget.classList) {
- const cl = event.relatedTarget.classList;
- // Ignore when the mouse goes over the coordinate display. Clearing
- // the coordinates in this situation causes a flicker.
- if (cl.contains('map-coord')) {
- return;
- }
- }
- this.clearCoord();
- }
-
- clearCoord() {
- this.setState({ latitude: null, longitude: null });
- }
-
- changeFormat(format) {
- util.setCoordinateFormat(format);
- this.setState({ format });
}
render() {
- // Don't render until a mouse is being used
- if (!this.state.hasMouse) {
- return null;
- }
+ const { isShowingClick, mouseEvents } = this.props;
+ const mapClasses = isShowingClick ? 'wv-map' + ' cursor-pointer' : 'wv-map';
return (
- <div>
- <Coordinates
- format={this.state.format}
- latitude={this.state.latitude}
- longitude={this.state.longitude}
- crs={this.state.crs}
- onFormatChange={this.changeFormat}
- />
- </div>
+ <React.Fragment>
+ <div id="wv-map" className={mapClasses} />
+ <OlCoordinates mouseEvents={mouseEvents} />
+ </React.Fragment>
);
}
}
@@ -131,7 +79,9 @@ const mapDispatchToProps = dispatch => ({
changeCursor: (bool) => {
dispatch(changeCursor(bool));
},
-
+ onCloseModal: () => {
+ dispatch(onClose());
+ },
openVectorDiaglog: (dialogId, metaArray, offsetLeft, offsetTop) => {
dispatch(openCustomContent(dialogId,
{
@@ -164,10 +114,18 @@ function mapStateToProps(state) {
lastSelected: state.vectorStyles.selected
};
}
-OlCoordinates.propTypes = {
- mouseEvents: PropTypes.object.isRequired
+MapInteractions.propTypes = {
+ changeCursor: PropTypes.func.isRequired,
+ getDialogObject: PropTypes.func.isRequired,
+ isShowingClick: PropTypes.bool.isRequired,
+ modalState: PropTypes.object.isRequired,
+ mouseEvents: PropTypes.object.isRequired,
+ onCloseModal: PropTypes.func.isRequired,
+ openVectorDiaglog: PropTypes.func.isRequired,
+ selectVectorFeatures: PropTypes.func.isRequired,
+ lastSelected: PropTypes.object
};
export default connect(
mapStateToProps,
mapDispatchToProps
-)(OlCoordinates);
+)(MapInteractions);
diff --git a/web/js/containers/map-interactions.test.js b/web/js/containers/map-interactions.test.js
index 7a34411e9..1b3330e4a 100644
--- a/web/js/containers/map-interactions.test.js
+++ b/web/js/containers/map-interactions.test.js
@@ -1,8 +1,8 @@
import React from 'react';
-import renderer from 'react-test-renderer';
import util from '../util/util';
-import { OlCoordinates } from './map-interactions';
+import { MapInteractions } from './map-interactions';
import { registerProjections } from '../fixtures';
+import renderer from 'react-test-renderer';
let events;
let component;
@@ -19,7 +19,7 @@ beforeEach(() => {
selectVectorFeatures = jest.fn();
getDialogObject = () => { return { metaArray: [0], selected: [1], offsetLeft: 100, offsetTop: 100 }; };
component = renderer.create(
- <OlCoordinates
+ <MapInteractions
mouseEvents={events}
isShowingClick={false}
changeCursor={changeCursor}
@@ -27,8 +27,16 @@ beforeEach(() => {
openVectorDiaglog={openVectorDiaglog}
selectVectorFeatures={selectVectorFeatures}
lastSelected={{}}
+ onCloseModal={jest.fn()}
modalState={{ id: [], isOpen: false }}
- />
+ />,
+ {
+ createNodeMock: (element) => {
+ if (element.id === 'ol-coords-case') {
+ return null;
+ }
+ }
+ }
);
map = {
getEventPixel: jest.fn(),
@@ -37,48 +45,27 @@ beforeEach(() => {
};
});
-afterEach(() => {
- util.setCoordinateFormat('latlon-dd');
-});
-
-test('shows coordinates of (10, 20) when moving the mouse', () => {
- map.getCoordinateFromPixel = () => [10, 20];
- events.trigger('mousemove', {}, map, 'EPSG:4326');
- expect(component.toJSON()).toMatchSnapshot();
- expect(changeCursor.mock.calls.length).toBe(0);
-});
-test('shows 10°00.000\'N, 20°00.000\'E when set to degrees and minutes format', () => {
- util.setCoordinateFormat('latlon-dm');
- map.getCoordinateFromPixel = () => [10, 20];
- events.trigger('mousemove', {}, map, 'EPSG:4326');
- expect(component.toJSON()).toMatchSnapshot();
- expect(changeCursor.mock.calls.length).toBe(0);
-});
-
-test('clears coordinates when mouse moves off the map', () => {
- map.getCoordinateFromPixel = () => [10, 20];
- events.trigger('mousemove', {}, map, 'EPSG:4326');
- events.trigger('mouseout', {}, map, 'EPSG:4326');
- expect(component.toJSON()).toMatchSnapshot();
- expect(changeCursor.mock.calls.length).toBe(0);
-});
-
-test('reprojects (0,0) to (-45, 90) for EPSG:3413', () => {
- map.getCoordinateFromPixel = () => [0, 0];
- events.trigger('mousemove', {}, map, 'EPSG:3413');
- expect(component.toJSON()).toMatchSnapshot();
- expect(changeCursor.mock.calls.length).toBe(0);
-});
test('if there is a feature at pixel dispatch changeCursor action', () => {
map.hasFeatureAtPixel = () => true;
events.trigger('mousemove', {}, map, 'EPSG:3413');
- expect(component.toJSON()).toMatchSnapshot();
expect(changeCursor.mock.calls.length).toBe(1);
});
-test('if there is a feature at pixel on click get dialod', () => {
+test('if there is a feature at pixel on click get dialog', () => {
events.trigger('singleclick', { pixel: [0, 0] }, map, 'EPSG:4326');
- expect(component.toJSON()).toMatchSnapshot();
expect(changeCursor.mock.calls.length).toBe(0);
expect(selectVectorFeatures.mock.calls.length).toBe(1);
expect(openVectorDiaglog.mock.calls.length).toBe(1);
});
+test('if there is not a feature at pixel do not dispatch changeCursor action', () => {
+ map.hasFeatureAtPixel = () => false;
+ events.trigger('mousemove', { pixel: [0, 0] }, map, 'EPSG:4326');
+ expect(changeCursor.mock.calls.length).toBe(0);
+});
+test('Check that hover changes', () => {
+ map.hasFeatureAtPixel = () => false;
+ events.trigger('mousemove', { pixel: [0, 0] }, map, 'EPSG:4326');
+ expect(changeCursor.mock.calls.length).toBe(0);
+});
+test('Check that cursor-hover class is not present', () => {
+ expect(component.toJSON()).toMatchSnapshot();
+});
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index 94ee45d09..5a20af6c0 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -26,20 +26,24 @@ class ModalContainer extends Component {
this.state = {
width: props.customProps.width,
height: props.customProps.height,
- isDraggable: props.isDraggable
+ isDraggable: props.isDraggable,
+ offsetLeft: props.customProps.offsetLeft,
+ offsetTop: props.customProps.offsetTop,
+ offsetRight: props.customProps.offsetRight
};
this.onResize = this.onResize.bind(this);
}
- getStyle(state, props) {
- const isResizable = props.isResizable;
+ getStyle() {
+ const { offsetLeft, offsetRight, offsetTop, width, height } = this.state;
+
return {
- left: props.offsetLeft,
- right: props.offsetRight,
- top: props.offsetTop,
- width: isResizable ? state.width : props.width,
- height: isResizable ? state.height : props.height,
- maxHeight: isResizable ? state.height : props.height
+ left: offsetLeft,
+ right: offsetRight,
+ top: offsetTop,
+ width: width,
+ height: height,
+ maxHeight: height
};
}
@@ -98,12 +102,11 @@ class ModalContainer extends Component {
isResizable
} = newProps;
- const style = this.getStyle(this.state, newProps);
+ const style = this.getStyle();
const lowerCaseId = lodashToLower(id);
const BodyComponent = bodyComponent || '';
const allowOuterClick = !isOpen || type === 'selection' || clickableBehindModal;
const modalWrapClass = clickableBehindModal ? `clickable-behind-modal ${wrapClassName}` : wrapClassName;
-
const toggleFunction = toggleWithClose(onToggle, onClose, isOpen);
if (isMobile && isOpen && desktopOnly) {
toggleFunction();
@@ -229,5 +232,6 @@ ModalContainer.propTypes = {
isDraggable: PropTypes.bool,
isMobile: PropTypes.bool,
isOpen: PropTypes.bool,
- isTemplateModal: PropTypes.bool
+ isTemplateModal: PropTypes.bool,
+ screenHeight: PropTypes.number
};
diff --git a/web/js/containers/vector-dialog.js b/web/js/containers/vector-dialog.js
index 4d656e27a..1c1a273fb 100644
--- a/web/js/containers/vector-dialog.js
+++ b/web/js/containers/vector-dialog.js
@@ -70,6 +70,8 @@ export default connect(
null
)(VectorDialog);
VectorDialog.propTypes = {
+ modalHeight: PropTypes.number,
toggleWithClose: PropTypes.func,
- vectorMetaArray: PropTypes.Array
+ vectorMetaArray: PropTypes.array,
+ vectorMetaObject: PropTypes.object
};
diff --git a/web/js/modules/modal/actions.js b/web/js/modules/modal/actions.js
index b58531573..dd568213a 100644
--- a/web/js/modules/modal/actions.js
+++ b/web/js/modules/modal/actions.js
@@ -59,3 +59,8 @@ export function onToggle() {
type: TOGGLE
};
}
+export function onClose() {
+ return {
+ type: CLOSE
+ };
+}