Improved subs form
This commit is contained in:
parent
b40309e80b
commit
93d9ca43f1
8 changed files with 81 additions and 71 deletions
|
|
@ -2,6 +2,7 @@ import i18n from 'i18next';
|
||||||
import backend from 'i18next-xhr-backend';
|
import backend from 'i18next-xhr-backend';
|
||||||
import LngDetector from 'i18next-browser-languagedetector';
|
import LngDetector from 'i18next-browser-languagedetector';
|
||||||
import Cache from 'i18next-localstorage-cache';
|
import Cache from 'i18next-localstorage-cache';
|
||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { T9n } from 'meteor-accounts-t9n';
|
import { T9n } from 'meteor-accounts-t9n';
|
||||||
import en from 'meteor-accounts-t9n/build/en';
|
import en from 'meteor-accounts-t9n/build/en';
|
||||||
import es from 'meteor-accounts-t9n/build/es';
|
import es from 'meteor-accounts-t9n/build/es';
|
||||||
|
|
@ -47,6 +48,9 @@ var backOpts = {
|
||||||
|
|
||||||
T9N_LANGUAGES='es,en';
|
T9N_LANGUAGES='es,en';
|
||||||
|
|
||||||
|
const forceDebug = false;
|
||||||
|
const shouldDebug = (forceDebug && !Meteor.isProduction);
|
||||||
|
|
||||||
i18n.use(backend)
|
i18n.use(backend)
|
||||||
.use(LngDetector)
|
.use(LngDetector)
|
||||||
.use(Cache)
|
.use(Cache)
|
||||||
|
|
@ -75,10 +79,10 @@ i18n.use(backend)
|
||||||
whitelist: false,
|
whitelist: false,
|
||||||
// whitelist: ['es', 'en'], // allowed languages
|
// whitelist: ['es', 'en'], // allowed languages
|
||||||
load: 'all', // es-ES -> es, en-US -> en
|
load: 'all', // es-ES -> es, en-US -> en
|
||||||
debug: false,
|
debug: shouldDebug,
|
||||||
ns: 'common',
|
ns: 'common',
|
||||||
defaultNS: 'common',
|
defaultNS: 'common',
|
||||||
saveMissing: true, // if true seems it's fails to getResourceBundle
|
saveMissing: shouldDebug, // if true seems it's fails to getResourceBundle
|
||||||
saveMissingTo: 'es',
|
saveMissingTo: 'es',
|
||||||
keySeparator: 'ß',
|
keySeparator: 'ß',
|
||||||
nsSeparator: 'ð',
|
nsSeparator: 'ð',
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
import RavenLogger from 'meteor/flowkey:raven';
|
import RavenLogger from 'meteor/flowkey:raven';
|
||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
|
||||||
var ravenOptions = {};
|
if (Meteor.isProduction) {
|
||||||
|
var ravenOptions = {};
|
||||||
|
|
||||||
export const ravenLogger = new RavenLogger({
|
export const ravenLogger = new RavenLogger({
|
||||||
publicDSN: Meteor.settings.public.sentryPublicDSN, // will be used on the client
|
publicDSN: Meteor.settings.public.sentryPublicDSN, // will be used on the client
|
||||||
privateDSN: Meteor.settings.sentryPrivateDSN, // will be used on the server
|
privateDSN: Meteor.settings.sentryPrivateDSN, // will be used on the server
|
||||||
shouldCatchConsoleError: true, // default
|
shouldCatchConsoleError: true, // default
|
||||||
trackUser: false, // default
|
trackUser: false, // default
|
||||||
}, ravenOptions);
|
}, ravenOptions);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class DistanceSlider extends React.Component {
|
||||||
railStyle={{ backgroundColor: 'orange', height: 8 }}
|
railStyle={{ backgroundColor: 'orange', height: 8 }}
|
||||||
dotStyle={{ top: 0, marginLeft: -1, width: 2, height: 8 }}
|
dotStyle={{ top: 0, marginLeft: -1, width: 2, height: 8 }}
|
||||||
marks={{
|
marks={{
|
||||||
10: {style: {}, label: "10"},
|
10: {style: {}, label: "10км"},
|
||||||
20: {style: {}, label: "20"},
|
20: {style: {}, label: "20"},
|
||||||
30: {style: {}, label: "30"},
|
30: {style: {}, label: "30"},
|
||||||
40: {style: {}, label: "40"},
|
40: {style: {}, label: "40"},
|
||||||
|
|
@ -73,7 +73,7 @@ class DistanceSlider extends React.Component {
|
||||||
70: {style: {}, label: "70"},
|
70: {style: {}, label: "70"},
|
||||||
80: {style: {}, label: "80"},
|
80: {style: {}, label: "80"},
|
||||||
90: {style: {}, label: "90"},
|
90: {style: {}, label: "90"},
|
||||||
100: {style: {}, label: "100"}
|
100: {style: {}, label: "100км"}
|
||||||
}}
|
}}
|
||||||
handleStyle={{
|
handleStyle={{
|
||||||
borderColor: 'green',
|
borderColor: 'green',
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,13 @@ import PropTypes from 'prop-types';
|
||||||
import { Map, TileLayer, Marker, Popup, CircleMarker, Circle} from 'react-leaflet';
|
import { Map, TileLayer, Marker, Popup, CircleMarker, Circle} from 'react-leaflet';
|
||||||
import Leaflet from 'leaflet';
|
import Leaflet from 'leaflet';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
import { translate } from 'react-i18next';
|
import { translate, Trans } from 'react-i18next';
|
||||||
import geolocation from '/imports/startup/client/geolocation';
|
import geolocation from '/imports/startup/client/geolocation';
|
||||||
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.css';
|
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.css';
|
||||||
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js';
|
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js';
|
||||||
|
import Control from 'react-leaflet-control';
|
||||||
|
import { Button } from 'react-bootstrap';
|
||||||
|
import DistanceSlider from '/imports/ui/components/DistanceSlider/DistanceSlider';
|
||||||
|
|
||||||
const positionIcon = new Leaflet.Icon({
|
const positionIcon = new Leaflet.Icon({
|
||||||
iconUrl: "/your-position.png",
|
iconUrl: "/your-position.png",
|
||||||
|
|
@ -70,6 +73,10 @@ class SelectionMap extends Component {
|
||||||
var graphicScale = L.control.graphicScale([options]).addTo(map);
|
var graphicScale = L.control.graphicScale([options]).addTo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doSubs = (event) => {
|
||||||
|
console.log(event);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
this.state.center = !this.state.modified && this.props.lat?
|
this.state.center = !this.state.modified && this.props.lat?
|
||||||
[this.props.lat, this.props.lng]: this.state.center;
|
[this.props.lat, this.props.lng]: this.state.center;
|
||||||
|
|
@ -90,6 +97,7 @@ class SelectionMap extends Component {
|
||||||
onDragend={this.updatePosition}
|
onDragend={this.updatePosition}
|
||||||
position={this.state.marker}
|
position={this.state.marker}
|
||||||
icon={positionIcon}
|
icon={positionIcon}
|
||||||
|
title={this.props.t("Arrastrar para seleccionar otro punto")}
|
||||||
ref="marker">
|
ref="marker">
|
||||||
</Marker>
|
</Marker>
|
||||||
<CircleMarker
|
<CircleMarker
|
||||||
|
|
@ -104,6 +112,11 @@ class SelectionMap extends Component {
|
||||||
fillColor="green"
|
fillColor="green"
|
||||||
fillOpacity={.1}
|
fillOpacity={.1}
|
||||||
radius={this.state.distance * 1000} />
|
radius={this.state.distance * 1000} />
|
||||||
|
<Control position="topright" >
|
||||||
|
<Button bsStyle="success" onClick={this.doSubs}>
|
||||||
|
{this.props.t("Subscribirme a fuegos en este rádio")}
|
||||||
|
</Button>
|
||||||
|
</Control>
|
||||||
</Map> }
|
</Map> }
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Button, Row, Col } from 'react-bootstrap';
|
import { Row, Col } from 'react-bootstrap';
|
||||||
import { Trans, translate } from 'react-i18next';
|
import { Trans, translate } from 'react-i18next';
|
||||||
import DistanceSlider from '/imports/ui/components/DistanceSlider/DistanceSlider';
|
import DistanceSlider from '/imports/ui/components/DistanceSlider/DistanceSlider';
|
||||||
import SelectionMap from '/imports/ui/components/SelectionMap/SelectionMap';
|
import SelectionMap from '/imports/ui/components/SelectionMap/SelectionMap';
|
||||||
|
|
||||||
import update from 'immutability-helper';
|
import update from 'immutability-helper';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
import getGKeys from '/imports/startup/client/gkeys';
|
import getGKeys from '/imports/startup/client/gkeys';
|
||||||
|
|
@ -14,19 +13,14 @@ class FireSubscription extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
adddress: '',
|
|
||||||
init: false
|
init: false
|
||||||
};
|
};
|
||||||
self = this;
|
|
||||||
// this.handleSelect = this.handleSelect.bind(this)
|
|
||||||
// this.handleChange = this.handleChange.bind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
self = this;
|
|
||||||
getGKeys(function(err, key) {
|
getGKeys(function(err, key) {
|
||||||
self.setState(update(self.state, {$merge: {init: true}}));
|
this.setState({init: true});
|
||||||
});
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
onAutocompleteChange = (value) => {
|
onAutocompleteChange = (value) => {
|
||||||
|
|
@ -40,11 +34,12 @@ class FireSubscription extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
// https://developers.google.com/places/web-service/search
|
// https://developers.google.com/places/web-service/search
|
||||||
// https://github.com/kenny-hibino/react-places-autocomplete/blob/master/demo/Demo.js
|
// https://github.com/kenny-hibino/react-places-autocomplete/blob/master/demo/Demo.js
|
||||||
let init = this.state.init
|
|
||||||
|
|
||||||
|
if (!this.state.init) {
|
||||||
|
return <div/>
|
||||||
|
} else
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{ init &&
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={12} sm={12} md={6} lg={6} >
|
<Col xs={12} sm={12} md={6} lg={6} >
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -54,10 +49,8 @@ class FireSubscription extends React.Component {
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={12} sm={12} md={6} lg={6} >
|
<Col xs={12} sm={12} md={6} lg={6} >
|
||||||
<DistanceSlider onChange={this.onSliderChange} />
|
<DistanceSlider onChange={this.onSliderChange} />
|
||||||
<Button bsStyle="success" type="submit"><Trans parent="span">Subscribir</Trans></Button>
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
}
|
|
||||||
<Row className="align-items-center justify-content-center">
|
<Row className="align-items-center justify-content-center">
|
||||||
<SelectionMap lat={this.state.lat} lng={this.state.lng} distance={this.state.distance || 10} />
|
<SelectionMap lat={this.state.lat} lng={this.state.lng} distance={this.state.distance || 10} />
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ class SubsAutocomplete extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
adddress: '',
|
adddress: '',
|
||||||
}
|
}
|
||||||
|
this.onChange = (address) => { this.setState({ address }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = (address) => { this.setState({ address }) }
|
|
||||||
|
|
||||||
handleSelect = (address) => {
|
handleSelect = (address) => {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
@ -58,6 +58,7 @@ class SubsAutocomplete extends React.Component {
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<ControlLabel>
|
<ControlLabel>
|
||||||
<Trans parent="span">Indícanos la posición a vigilar (por ej. tu pueblo, una calle, etc):</Trans>
|
<Trans parent="span">Indícanos la posición a vigilar (por ej. tu pueblo, una calle, etc):</Trans>
|
||||||
|
</ControlLabel>
|
||||||
<PlacesAutocomplete
|
<PlacesAutocomplete
|
||||||
styles={myStyles}
|
styles={myStyles}
|
||||||
classNames={{
|
classNames={{
|
||||||
|
|
@ -80,11 +81,10 @@ class SubsAutocomplete extends React.Component {
|
||||||
value: this.state.address,
|
value: this.state.address,
|
||||||
onChange: this.onChange,
|
onChange: this.onChange,
|
||||||
placeholder: this.props.t("Escribe aquí un lugar "),
|
placeholder: this.props.t("Escribe aquí un lugar "),
|
||||||
onBlur:() => { console.log('Blur event!'); },
|
onBlur:() => { /* console.log('Blur event!'); */ },
|
||||||
onFocus:() => { console.log('Focused!'); },
|
onFocus:() => { /* console.log('Focused!'); */ },
|
||||||
autoFocus:true
|
autoFocus:true
|
||||||
}} />
|
}} />
|
||||||
</ControlLabel>
|
|
||||||
<HelpBlock><Trans parent="span">También puedes seleccionar el lugar en el mapa arrastrando el puntero naranja.</Trans></HelpBlock>
|
<HelpBlock><Trans parent="span">También puedes seleccionar el lugar en el mapa arrastrando el puntero naranja.</Trans></HelpBlock>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,20 @@ class Sandbox extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
lat: 0,
|
init: false
|
||||||
lng: 0
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onSliderChange = (value) => {
|
componentDidMount = () => {
|
||||||
this.setState(update(this.state, {$merge: {distance: value}}));
|
this.setState({init: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FireSubscription />
|
<FireSubscription />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default translate([], { wait: true }) (Sandbox);
|
export default translate([], { wait: true }) (Sandbox);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
"react-dom": "^15.6.1",
|
"react-dom": "^15.6.1",
|
||||||
"react-i18next": "^6.1.0",
|
"react-i18next": "^6.1.0",
|
||||||
"react-leaflet": "^1.7.7",
|
"react-leaflet": "^1.7.7",
|
||||||
|
"react-leaflet-control": "^1.4.0",
|
||||||
"react-places-autocomplete": "^5.4.3",
|
"react-places-autocomplete": "^5.4.3",
|
||||||
"react-resize-detector": "^1.1.0",
|
"react-resize-detector": "^1.1.0",
|
||||||
"react-router-bootstrap": "^0.24.3",
|
"react-router-bootstrap": "^0.24.3",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue