Skip to content

Commit 5ab93bd

Browse files
authored
Merge pull request #111 from HSLdevcom/development
Development
2 parents 6dc96b6 + a0c2bfb commit 5ab93bd

11 files changed

Lines changed: 163 additions & 22 deletions

File tree

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Specify a non-default branch for pull requests for npm
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: "npm"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
# Raise pull requests for version updates
10+
# to npm against the `development` branch
11+
target-branch: "development"
12+
# Labels on pull requests for version updates only
13+
labels:
14+
- "NPM Dependencies"

app/actions/routeMapConfiguration.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const TOGGLE_ONLY_NEAR_BUSES = "TOGGLE_ONLY_NEAR_BUSES";
2121
export const TOGGLE_ZONE_SYMBOLS = "TOGGLE_ZONE_SYMBOLS";
2222
export const SET_SYMBOL_SIZE = "SET_SYMBOL_SIZE";
2323
export const LOAD_STATE = "LOAD_STATE";
24+
export const TOGGLE_JORE_ID_FILTERING = "TOGGLE_JORE_ID_FILTERING";
2425

2526
export function setBuild(id) {
2627
return {
@@ -138,3 +139,9 @@ export function setSymbolSize(size) {
138139
data: size
139140
};
140141
}
142+
143+
export function toggleJoreIdFiltering() {
144+
return {
145+
type: TOGGLE_JORE_ID_FILTERING
146+
};
147+
}

app/components/PointBuildTrigger.js

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import React, {Component} from "react";
22
import moment from "moment";
3+
import Modal from "react-modal";
34
import classNames from "classnames";
45
import DayPicker from "./DayPicker";
56
import Button from "./Button";
67
import s from "./pointBuildTrigger.css";
78
import {PointStatus} from "../reducers/publisherRequests";
9+
import {promptStyles} from "../utils/ui-utils";
810

911
export default class RouteMapConfigurator extends Component {
1012
constructor(props) {
1113
super(props);
12-
14+
this.state = {
15+
showPrompt: false
16+
};
1317
this.update = this.update.bind(this);
1418
this.sendDate = this.sendDate.bind(this);
1519
}
@@ -24,6 +28,7 @@ export default class RouteMapConfigurator extends Component {
2428
}
2529

2630
sendDate() {
31+
this.setState({showPrompt: false});
2732
this.props.setConfig(moment(this.props.date));
2833
}
2934

@@ -35,6 +40,14 @@ export default class RouteMapConfigurator extends Component {
3540
return this.props.config && this.props.config.status === "PENDING";
3641
}
3742

43+
showPrompt() {
44+
this.setState({showPrompt: true});
45+
}
46+
47+
hidePrompt() {
48+
this.setState({showPrompt: false});
49+
}
50+
3851
render() {
3952
let statusColor = "#DDD";
4053
let statusText = "Hakee";
@@ -94,11 +107,37 @@ export default class RouteMapConfigurator extends Component {
94107
/>
95108
<Button
96109
styleClass="lightWithBorder"
97-
onClick={this.sendDate}
110+
onClick={() => this.showPrompt()}
98111
disabled={this.isDisabled()}>
99112
Päivitä
100113
</Button>
101114
</div>
115+
<Modal
116+
isOpen={this.state.showPrompt}
117+
onRequestClose={() => this.hidePrompt}
118+
style={promptStyles}>
119+
<div className={s.prompt}>
120+
Generoidaan uusi poikkileikkauspäivä?
121+
<div className={s.promptButtonContainer}>
122+
<div className={s.button}>
123+
<Button
124+
styleClass="lightWithBorder"
125+
onClick={this.sendDate}
126+
disabled={this.isDisabled()}>
127+
Kyllä
128+
</Button>
129+
</div>
130+
<div className={s.button}>
131+
<Button
132+
styleClass="lightWithBorder"
133+
onClick={() => this.hidePrompt()}
134+
disabled={this.isDisabled()}>
135+
Ei
136+
</Button>
137+
</div>
138+
</div>
139+
</div>
140+
</Modal>
102141
</div>
103142
);
104143
}

app/components/RouteMapConfigurator.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class RouteMapConfigurator extends Component {
3030
this.setSymbolSize = this.setSymbolSize.bind(this);
3131
this.selectSymbol = this.selectSymbol.bind(this);
3232
this.addSymbol = this.addSymbol.bind(this);
33+
this.toggleJoreIdFiltering = this.toggleJoreIdFiltering.bind(this);
3334

3435
this.routesLayer = this.props.layers.find(
3536
(layer) => layer.id === "routes"
@@ -99,6 +100,10 @@ export default class RouteMapConfigurator extends Component {
99100
this.props.toggleZoneSymbols();
100101
}
101102

103+
toggleJoreIdFiltering() {
104+
this.props.toggleJoreIdFiltering();
105+
}
106+
102107
openAdvancedSettings() {
103108
this.setState({
104109
advancedSettingsOpen: true
@@ -181,6 +186,18 @@ export default class RouteMapConfigurator extends Component {
181186
/>
182187
</div>
183188
</div>
189+
<div className={style.element}>
190+
<div className={style.title}>Käytä jore-id:tä</div>
191+
<div className={style.value}>
192+
<input
193+
className={style.checkbox}
194+
type="checkbox"
195+
onChange={this.toggleJoreIdFiltering}
196+
value={this.props.useJoreId}
197+
checked={this.props.useJoreId}
198+
/>
199+
</div>
200+
</div>
184201
<div className={style.element}>
185202
<div className={style.title}>Vain lähibussit</div>
186203
<div className={style.value}>

app/components/pointBuildTrigger.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@
3939
.marginTop {
4040
margin-top: 20px;
4141
}
42+
43+
.prompt {
44+
display: flex;
45+
flex-direction: column;
46+
}
47+
48+
.promptButtonContainer {
49+
height: 125px;
50+
justify-content: space-between;
51+
align-items: end;
52+
display: flex;
53+
flex-direction: row;
54+
}
55+
56+
.button {
57+
width: 150px;
58+
}

app/containers/Map.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ function mapStateToProps(state) {
2020
style: styleFromLayers(
2121
state.layers,
2222
date,
23-
state.routeMapConfiguration.get("routeFilter")
23+
state.routeMapConfiguration.get("routeFilter"),
24+
state.routeMapConfiguration.get("useJoreId")
2425
),
2526
mapWidth: state.layout.mapWidth,
2627
mapHeight: state.layout.mapHeight,

app/containers/RouteMapConfigurator.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
setRouteFilter,
88
toggleOnlyNearBuses,
99
toggleZoneSymbols,
10-
setSymbolSize
10+
setSymbolSize,
11+
toggleJoreIdFiltering
1112
} from "../actions/routeMapConfiguration";
1213
import {addSymbol} from "../actions/viewport";
1314
import RouteMapConfigurator from "../components/RouteMapConfigurator";
@@ -24,7 +25,8 @@ function mapStateToProps(state) {
2425
showOnlyNearBuses: state.routeMapConfiguration.get("onlyNearBuses"),
2526
showZoneSymbols: state.routeMapConfiguration.get("zoneSymbols"),
2627
pointConfig: state.publisherRequests.pointConfig,
27-
symbolSize: state.routeMapConfiguration.get("symbolSize")
28+
symbolSize: state.routeMapConfiguration.get("symbolSize"),
29+
useJoreId: state.routeMapConfiguration.get("useJoreId")
2830
};
2931
}
3032

@@ -40,7 +42,8 @@ function mapDispatchToProps(dispatch) {
4042
toggleZoneSymbols,
4143
setSymbolSize,
4244
setLayer,
43-
addSymbol
45+
addSymbol,
46+
toggleJoreIdFiltering
4447
},
4548
dispatch
4649
);

app/reducers/routeMapConfiguration.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
TOGGLE_ONLY_NEAR_BUSES,
1919
TOGGLE_ZONE_SYMBOLS,
2020
SET_SYMBOL_SIZE,
21-
LOAD_STATE
21+
LOAD_STATE,
22+
TOGGLE_JORE_ID_FILTERING
2223
} from "../actions/routeMapConfiguration";
2324

2425
const initialState = fromJS({
@@ -38,7 +39,8 @@ const initialState = fromJS({
3839
stationFontSize: 12,
3940
onlyNearBuses: false,
4041
zoneSymbols: false,
41-
symbolSize: "200px"
42+
symbolSize: "200px",
43+
useJoreId: false
4244
});
4345

4446
export default function routeMapConfiguration(state = initialState, action) {
@@ -90,6 +92,9 @@ export default function routeMapConfiguration(state = initialState, action) {
9092
});
9193
return newState;
9294
}
95+
case TOGGLE_JORE_ID_FILTERING: {
96+
return state.set("useJoreId", !state.get("useJoreId"));
97+
}
9398
default:
9499
return state;
95100
}

app/utils/map-utils.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,36 @@ const mapLayers = (layers) => {
3535
return ret;
3636
};
3737

38-
export const styleFromLayers = memoize((layers, date, routeFilter) => {
39-
const style = hslMapStyle.generateStyle({
40-
components: mapLayers(layers),
41-
routeFilter
42-
});
43-
44-
sourcesWithDate.forEach((key) => {
45-
if (style.sources[key] && style.sources[key].url) {
46-
style.sources[key].url += `?date=${date}`;
38+
const parseRouteFilterIds = (routeFilter, useJoreId) => {
39+
if (routeFilter && routeFilter.length >= 0) {
40+
if (!useJoreId) {
41+
const mappedFilter = routeFilter.map((filter) => {
42+
return {idParsed: filter};
43+
});
44+
return mappedFilter;
4745
}
48-
});
46+
return routeFilter;
47+
}
48+
return [];
49+
};
4950

50-
return style;
51-
});
51+
export const styleFromLayers = memoize(
52+
(layers, date, routeFilter, useJoreId) => {
53+
console.log(useJoreId);
54+
const style = hslMapStyle.generateStyle({
55+
components: mapLayers(layers),
56+
routeFilter: parseRouteFilterIds(routeFilter, useJoreId)
57+
});
58+
59+
sourcesWithDate.forEach((key) => {
60+
if (style.sources[key] && style.sources[key].url) {
61+
style.sources[key].url += `?date=${date}`;
62+
}
63+
});
64+
65+
return style;
66+
}
67+
);
5268

5369
export const createMapOptions = (mapSelection) => {
5470
const tileScale = mapSelectionToTileScale(mapSelection);
@@ -88,7 +104,10 @@ export const createMapOptions = (mapSelection) => {
88104
export const createConfigurationOptions = (configuration, pointConfig) => ({
89105
date: moment(pointConfig.target_date).format("YYYY-MM-DD"),
90106
name: configuration.get("posterName"),
91-
routeFilter: configuration.get("routeFilter"),
107+
routeFilter: parseRouteFilterIds(
108+
configuration.get("routeFilter"),
109+
configuration.get("useJoreId")
110+
),
92111
scaleFontSize: configuration.get("scaleFontSize"),
93112
scaleLength: configuration.get("scaleLength"),
94113
maxAnchorLength: configuration.get("maxAnchorLineLength"),

app/utils/ui-utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,22 @@ export const deleteModalStyles = {
3535
"rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.4) 0px 3px 14px"
3636
}
3737
};
38+
39+
export const promptStyles = {
40+
content: {
41+
position: "fixed",
42+
height: "250px",
43+
width: "500px",
44+
top: "30%",
45+
left: "50%",
46+
background: "rgba(255, 255, 255, 1)",
47+
overflow: "auto",
48+
borderRadius: "2px",
49+
outline: "none",
50+
padding: "50px",
51+
transform: "translate(-40%, 0%)",
52+
right: "auto",
53+
boxShadow:
54+
"rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.4) 0px 3px 14px"
55+
}
56+
};

0 commit comments

Comments
 (0)