From e980bbdb2477d53f6db675768790e3925ffb7178 Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 20 Feb 2018 09:11:07 +0100 Subject: [PATCH] Less clicks to show fire info --- imports/ui/components/Maps/FireIconMark.js | 72 +++++++++++++--------- imports/ui/components/Maps/FirePopup.js | 14 +---- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/imports/ui/components/Maps/FireIconMark.js b/imports/ui/components/Maps/FireIconMark.js index 5e8af68..9817666 100644 --- a/imports/ui/components/Maps/FireIconMark.js +++ b/imports/ui/components/Maps/FireIconMark.js @@ -1,38 +1,54 @@ /* eslint-disable import/no-absolute-path */ -import React, { Fragment } from 'react'; +import React, { Component, Fragment } from 'react'; import { CircleMarker, Marker, Tooltip } from 'react-leaflet'; import PropTypes from 'prop-types'; import { fireIcon, nFireIcon, industryIcon } from '/imports/ui/components/Maps/Icons'; import { translate } from 'react-i18next'; import FirePopup from './FirePopup'; -const FireIconMark = ({ - lat, - lon, - nasa, - id, - history, - falsePositives, - when, - t -}) => ( -
- { !falsePositives && - - - } - { falsePositives && - - {t('Es una industria')} - { /* disabled because was a past fire (and can be marked multiple times) */ false && } - - } - { !falsePositives && - - - } -
-); +class FireIconMark extends Component { + constructor(props) { + super(props); + this.t = props.t; + this.onClick = this.onClick.bind(this); + } + + onClick() { + // console.log('onClick fired'); + this.props.history.push(`/fire/${this.props.nasa ? 'active' : 'alert'}/${this.props.id}`); + } + + render() { + const { + lat, + lon, + nasa, + id, + history, + falsePositives, + when, + t + } = this.props; + return ( +
+ { !falsePositives && + + + } + { falsePositives && + + {t('Es una industria')} + { /* disabled because was a past fire (and can be marked multiple times) */ false && } + + } + { !falsePositives && + + + } +
+ ); + } +} FireIconMark.propTypes = { // https://github.com/PaulLeCam/react-leaflet/tree/master/src/propTypes diff --git a/imports/ui/components/Maps/FirePopup.js b/imports/ui/components/Maps/FirePopup.js index c917a6b..c2519b9 100644 --- a/imports/ui/components/Maps/FirePopup.js +++ b/imports/ui/components/Maps/FirePopup.js @@ -1,9 +1,8 @@ /* eslint-disable import/no-absolute-path */ import React, { Fragment } from 'react'; -import { Popup, Tooltip } from 'react-leaflet'; +import { Tooltip } from 'react-leaflet'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; -import moment from 'moment'; const FirePopup = ({ lat, @@ -15,17 +14,6 @@ const FirePopup = ({ t }) => ( - - - {t('Coordenadas:')} {lat}, {lon}
- {nasa && {t('Fuente')}: {t(nasa ? 'NASA' : 'nuestros usuarios/as')}
} - {when && {t('Detectado')}: {moment(when).fromNow()}
} - - { /* if nasa === null means that the is a false positive fire */ } - history.push(`/fire/${nasa ? 'active' : 'alert'}/${id}`)}>{t('Más información sobre este fuego')} - -
-
{t('Pulsa para más información')}
);