Permalink
Browse files

don't show inactive routes (#182)

  • Loading branch information...
jlyon1 authored and garoller committed Nov 9, 2018
1 parent b5fc7eb commit 0d6b9f07f92bed6f74e76126d952eeefbe026948
@@ -132,7 +132,7 @@ export default Vue.extend({
const div = L.DomUtil.create('div', 'info legend');
let legendstring = '';
this.$store.state.Routes.forEach((route: Route) => {
if (route.enabled) {
if (route.shouldShow()) {
legendstring += `<li><img class="legend-icon" src=` + getMarkerString(route.color) + `
width="12" height="12"> ` +
route.name;
@@ -76,7 +76,7 @@ const store: StoreOptions<StoreState> = {
const arr = new Array<L.Polyline>();
if (state.Routes !== undefined && state.Routes.length !== 0) {
state.Routes.forEach((r: Route) => {
if (r.enabled) {
if (r.shouldShow()) {
const points = new Array<L.LatLng>();
if (r.coords !== undefined) {
r.coords.forEach((p: {latitude: number, longitude: number}) => {
@@ -8,21 +8,29 @@ export default class Route {
public enabled: boolean;
public color: string;
public width: number;
public active: boolean;
public coords: [{
latitude: number,
longitude: number,
}];
constructor(id: number, name: string, description: string, enabled: boolean,
color: string, width: number, coords: [{
color: string, width: number, coords: [{
latitude: number,
longitude: number,
}]) {
}], active: boolean) {
this.id = id;
this.name = name;
this.description = description;
this.enabled = enabled;
this.color = color;
this.width = Number(width);
this.coords = coords;
this.active = active;
}
// shouldShow returns true if the route is active and enabled
public shouldShow(): boolean{
return this.active && this.enabled;
}
}
@@ -40,9 +40,10 @@ export default class InfoServiceProvider {
latitude: number,
longitude: number,
}],
active: boolean,
}) => {
ret.push(new Route(element.id, element.name, element.description,
element.enabled, element.color, Number(element.width), element.points));
element.enabled, element.color, Number(element.width), element.points, element.active));
});
return ret;
});

0 comments on commit 0d6b9f0

Please sign in to comment.