Skip to content

Commit 9c5f552

Browse files
committed
Merge branch 'main' into v5
2 parents 94bc346 + 27b96be commit 9c5f552

File tree

5 files changed

+45
-54
lines changed

5 files changed

+45
-54
lines changed

frontend/src/lib/components/legend/legend-content.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@
7979
</div>
8080

8181
<template v-for="(type, idx) in items" :key="type.key">
82-
<hr v-if="idx > 0">
83-
<h3 @click="toggleFilter(type)" :class="{ filtered: type.filtered }">{{type.name}}</h3>
82+
<hr v-if="idx > 0 && (type.items.length > 1 || items[idx - 1].items.length > 1)">
8483
<dl>
8584
<template v-for="(item, idx) in type.items" :key="item.key">
8685
<dt
87-
:class="[ 'fm-legend-icon', 'fm-' + type.type, { filtered: item.filtered, first: (item.first && idx !== 0), bright: item.bright } ]"
86+
:class="[ 'fm-legend-icon', 'fm-' + type.type, { filtered: item.filtered, first: (item.first && idx !== 0), bright: item.bright, main: idx === 0 } ]"
8887
@click="toggleFilter(type, item)"
8988
v-html-async="makeIcon(type, item)"
9089
@mouseenter="togglePopover(item.key, true)"
@@ -93,7 +92,7 @@
9392
></dt>
9493
<dd
9594
class="text-break"
96-
:class="[ 'fm-' + type.type, { filtered: item.filtered, first: (item.first && idx !== 0), bright: item.bright } ]"
95+
:class="[ 'fm-' + type.type, { filtered: item.filtered, first: (item.first && idx !== 0), bright: item.bright, main: idx === 0 } ]"
9796
@click="toggleFilter(type, item)"
9897
:style="item.strikethrough ? {'text-decoration': 'line-through'} : {}"
9998
@mouseenter="togglePopover(item.key, true)"
@@ -176,6 +175,11 @@
176175
cursor: pointer;
177176
}
178177
178+
dt, dd {
179+
display: inline-flex;
180+
align-items: center;
181+
}
182+
179183
dt.fm-marker {
180184
grid-column: 1 / 2;
181185
}
@@ -201,6 +205,11 @@
201205
}
202206
}
203207
208+
.main {
209+
font-size: 1.1em;
210+
font-weight: bold;
211+
}
212+
204213
.filtered {
205214
opacity: 0.5;
206215
}

frontend/src/lib/components/legend/legend-utils.ts

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,38 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
4646
const items: LegendItem[] = [ ];
4747
const fields: Record<string, string[]> = Object.create(null);
4848

49-
if (
50-
type.colourFixed ||
51-
(type.type == "marker" && type.iconFixed && type.defaultIcon && (iconList.includes(type.defaultIcon) || type.defaultIcon.length == 1)) ||
52-
(type.type == "marker" && type.shapeFixed) ||
53-
(type.type == "line" && type.widthFixed) ||
54-
(type.type === "line" && type.strokeFixed)
55-
) {
56-
const item: LegendItem = {
57-
key: `legend-item-${type.id}`,
58-
fieldId: undefined,
59-
value: type.name,
60-
label: formatTypeName(type.name),
61-
filtered: true
62-
};
63-
64-
if (type.colourFixed) {
65-
item.colour = type.defaultColour ? `#${type.defaultColour}` : undefined;
66-
}
67-
if (type.type == "marker" && type.iconFixed && type.defaultIcon && (iconList.includes(type.defaultIcon) || type.defaultIcon.length == 1)) {
68-
item.icon = type.defaultIcon;
69-
}
70-
if (type.type == "marker" && type.shapeFixed) {
71-
item.shape = type.defaultShape ?? "";
72-
}
73-
if (type.type == "line" && type.widthFixed) {
74-
item.width = type.defaultWidth ?? undefined;
75-
}
76-
if (type.type === "line" && type.strokeFixed) {
77-
item.stroke = type.defaultStroke;
49+
const mainItem: LegendItem = {
50+
key: `legend-item-${type.id}`,
51+
fieldId: undefined,
52+
value: type.name,
53+
label: formatTypeName(type.name),
54+
filtered: true
55+
};
56+
57+
if (type.colourFixed) {
58+
mainItem.colour = type.defaultColour ? `#${type.defaultColour}` : undefined;
59+
}
60+
if (type.type == "marker" && type.iconFixed && type.defaultIcon && (iconList.includes(type.defaultIcon) || type.defaultIcon.length == 1)) {
61+
mainItem.icon = type.defaultIcon;
62+
}
63+
if (type.type == "marker") {
64+
if (type.shapeFixed) {
65+
mainItem.shape = type.defaultShape ?? "";
66+
} else {
67+
mainItem.shape = "drop";
7868
}
69+
}
70+
if (type.type == "line" && type.widthFixed) {
71+
mainItem.width = type.defaultWidth ?? undefined;
72+
}
73+
if (type.type === "line" && type.strokeFixed) {
74+
mainItem.stroke = type.defaultStroke;
75+
}
7976

80-
if (item.colour)
81-
item.bright = isBright(item.colour);
77+
if (mainItem.colour)
78+
mainItem.bright = isBright(mainItem.colour);
8279

83-
items.push(item);
84-
}
80+
items.push(mainItem);
8581

8682
for (const field of type.fields) {
8783
if (
@@ -154,21 +150,6 @@ export function getLegendItems(context: FacilMapContext): LegendType[] {
154150
});
155151
}
156152

157-
if(items.length == 0) {
158-
const item: LegendItem = {
159-
key: `legend-item-${type.id}`,
160-
fieldId: undefined,
161-
value: type.name,
162-
label: formatTypeName(type.name),
163-
filtered: true
164-
};
165-
166-
if(type.type == "marker")
167-
item.shape = "drop";
168-
169-
items.push(item);
170-
}
171-
172153
const legendType: LegendType = {
173154
key: `legend-type-${type.id}`,
174155
type: type.type,

server/src/database-backend/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default class DatabaseTypesBackend {
7878
}
7979

8080
async* getTypes(mapId: ID): AsyncIterable<Type> {
81-
for await (const type of findAllStreamed(this.TypeModel, { where: { mapId } })) {
81+
for await (const type of findAllStreamed(this.TypeModel, { where: { mapId }, order: [["idx", "asc"]] })) {
8282
yield this.prepareType(type);
8383
}
8484
}

server/src/database-backend/view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class DatabaseViewsBackend {
5555
}
5656

5757
async* getViews(mapId: ID): AsyncIterable<View> {
58-
for await (const obj of findAllStreamed(this.ViewModel, { where: { mapId } })) {
58+
for await (const obj of findAllStreamed(this.ViewModel, { where: { mapId }, order: [["idx", "asc"]] })) {
5959
yield this.prepareView(obj);
6060
}
6161
}

utils/src/search.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ function _formatAddress(result: NominatimResult) {
421421
case "ar":
422422
case "at":
423423
case "ca":
424+
case "ch":
424425
case "de":
425426
case "hr":
426427
case "cz":

0 commit comments

Comments
 (0)