Skip to content

Commit

Permalink
Add more bicycle options to cycle rental; add deletion and images to …
Browse files Browse the repository at this point in the history
…cycle rental, fix #703
  • Loading branch information
pietervdvn committed Mar 14, 2022
1 parent 2d35647 commit b406d17
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 114 deletions.
25 changes: 15 additions & 10 deletions Models/ThemeConfig/TagRenderingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,29 +366,34 @@ export default class TagRenderingConfig {

// A flag to check that the freeform key isn't matched multiple times
// If it is undefined, it is "used" already, or at least we don't have to check for it anymore
let freeformKeyUsed = this.freeform?.key === undefined;
let freeformKeyDefined = this.freeform?.key !== undefined;
let usedFreeformValues = new Set<string>()
// We run over all the mappings first, to check if the mapping matches
const applicableMappings: { then: Translation, img?: string }[] = Utils.NoNull((this.mappings ?? [])?.map(mapping => {
if (mapping.if === undefined) {
return mapping;
}
if (TagUtils.MatchesMultiAnswer(mapping.if, tags)) {
if (!freeformKeyUsed) {
if (mapping.if.usedKeys().indexOf(this.freeform.key) >= 0) {
// This mapping matches the freeform key - we mark the freeform key to be ignored!
freeformKeyUsed = true;
}
if (freeformKeyDefined && mapping.if.isUsableAsAnswer()) {
// THe freeform key is defined: what value does it use though?
// We mark the value to see if we have any leftovers
const value = mapping.if.asChange({}).find(kv => kv.k === this.freeform.key).v
usedFreeformValues.add(value)
}
return mapping;
}
return undefined;
}))


if (!freeformKeyUsed
&& tags[this.freeform.key] !== undefined) {
applicableMappings.push({then: this.render})
if(freeformKeyDefined && tags[this.freeform.key] !== undefined){
const freeformValues = tags[this.freeform.key].split(";")
const leftovers = freeformValues.filter(v => !usedFreeformValues.has(v))
for (const leftover of leftovers) {
applicableMappings.push({then: this.render.OnEveryLanguage(str =>
str.replace(new RegExp("{"+this.freeform.key+"}", "g"), leftover))})
}
}

return applicableMappings
}

Expand Down
2 changes: 1 addition & 1 deletion UI/Popup/TagRenderingQuestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export default class TagRenderingQuestion extends Combine {

if (freeform.inline) {

inputTagsFilter.SetClass("w-16-imp")
inputTagsFilter.SetClass("w-48-imp")
inputTagsFilter = new InputElementWrapper(inputTagsFilter, configuration.render, freeform.key, tags, state)
inputTagsFilter.SetClass("block")

Expand Down
46 changes: 41 additions & 5 deletions assets/layers/bicycle_rental/bicycle_rental.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@
},
"render": {
"en": "{rental} is rented here",
"nl": "{rental} wordt hier uitgeleend"
"nl": "{rental} kunnen hier uitgeleend worden"
},
"freeform": {
"key": "rental"
"key": "rental",
"inline": true
},
"multiAnswer": true,
"mappings": [
Expand Down Expand Up @@ -194,6 +195,13 @@
"en": "Tandem bicycles can be rented here",
"nl": "Tandems kunnen hier gehuurd worden"
}
},
{
"if": "rental=racebike",
"then": {
"en": "Race bicycles can be rented here",
"nl": "Wielerfietsen (sportfietsen) kunnen hier gehuurd worden"
}
}
]
},
Expand Down Expand Up @@ -222,7 +230,7 @@
"kid_bike",
{
"en": "bikes for children",
"nl": "Kinderfietsen"
"nl": "kinderfietsen"
}
],
[
Expand All @@ -249,7 +257,7 @@
[
"tandem_bicycle",
{
"en": "tandem bicycle",
"en": "tandem",
"nl": "tandem"
}
]
Expand Down Expand Up @@ -320,5 +328,33 @@
"render": "2"
}
}
]
],
"allowMove": {
"enableImproveAccuracy": true,
"enableRelocation": true
},
"deletion": {
"softDeletionTags": {
"and": ["disused:amenity=bicycle_rental", "bicycle_rental=", "rental="]
},
"neededChangesets": 10,
"extraDeleteReasons": [{
"explanation": {
"nl": "{title()} is permanent gestopt",
"en": "{title()} has closed down permanently"
},
"changesetMessage": "shop_closed"
}],
"nonDeleteMappings": [{
"if": {
"and": [
"service:bicycle:rental=no"
]
},
"then": {
"en": "This bicycle shop used to rent out bikes but doesn't rent out bikes anymore",
"nl": "Deze fietszaak verhuurde vroeger fietsen, maar nu niet meer"
}
}]
}
}
9 changes: 8 additions & 1 deletion assets/layers/cafe_pub/cafe_pub.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,14 @@
"amenity=",
"disused:amenity:={amenity}"
]
}
},
"extraDeleteReasons": [{
"explanation": {
"nl": "{title()} is permanent gestopt",
"en": "{title()} has closed down permanently"
},
"changesetMessage": "shop_closed"
}]
},
"allowMove": true,
"mapRendering": [
Expand Down
9 changes: 8 additions & 1 deletion assets/layers/food/food.json
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,14 @@
"amenity=",
"disused:amenity:={amenity}"
]
}
},
"extraDeleteReasons": [{
"explanation": {
"nl": "{title()} is permanent gestopt",
"en": "{title()} has closed down permanently"
},
"changesetMessage": "shop_closed"
}]
},
"allowMove": true,
"mapRendering": [
Expand Down
9 changes: 8 additions & 1 deletion assets/layers/shops/shops.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,14 @@
"amenity=",
"disused:amenity:={amenity}"
]
}
},
"extraDeleteReasons": [{
"explanation": {
"nl": "{title()} is permanent gestopt",
"en": "{title()} has closed down permanently"
},
"changesetMessage": "shop_closed"
}]
},
"allowMove": true,
"mapRendering": [
Expand Down
42 changes: 14 additions & 28 deletions assets/themes/mapcomplete-changes/mapcomplete-changes.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"id": "mapcomplete-changes",
"title": {
"en": "Changes made with MapComplete",
"de": "Änderungen mit MapComplete"
"en": "Changes made with MapComplete"
},
"shortDescription": {
"en": "Shows changes made by MapComplete",
"de": "Zeigt Änderungen, die von MapComplete vorgenommen wurden"
"en": "Shows changes made by MapComplete"
},
"description": {
"en": "This maps shows all the changes made with MapComplete",
"de": "Diese Karte zeigt alle mit MapComplete vorgenommenen Änderungen"
"en": "This maps shows all the changes made with MapComplete"
},
"maintainer": "",
"icon": "./assets/svg/logo.svg",
Expand All @@ -25,8 +22,7 @@
{
"id": "mapcomplete-changes",
"name": {
"en": "Changeset centers",
"de": "Schwerpunkte von Änderungssätzen"
"en": "Changeset centers"
},
"minzoom": 0,
"source": {
Expand All @@ -40,41 +36,35 @@
],
"title": {
"render": {
"en": "Changeset for {theme}",
"de": "Änderungssatz für {theme}"
"en": "Changeset for {theme}"
}
},
"description": {
"en": "Shows all MapComplete changes",
"de": "Zeigt alle MapComplete-Änderungen"
"en": "Shows all MapComplete changes"
},
"tagRenderings": [
{
"id": "render_id",
"render": {
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>",
"de": "Änderungssatz <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
}
},
{
"id": "contributor",
"render": {
"en": "Change made by <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a>",
"de": "Geändert von <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a>"
"en": "Change made by <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a>"
}
},
{
"id": "theme",
"render": {
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>",
"de": "Änderung mit Thema <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
},
"mappings": [
{
"if": "theme~http.*",
"then": {
"en": "Change with <b>unofficial</b> theme <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>",
"de": "Änderung mit <b>inoffiziellem</b> Thema <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>"
"en": "Change with <b>unofficial</b> theme <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>"
}
}
]
Expand Down Expand Up @@ -338,8 +328,7 @@
}
],
"question": {
"en": "Themename contains {search}",
"de": "Themenname enthält {search}"
"en": "Themename contains {search}"
}
}
]
Expand All @@ -355,8 +344,7 @@
}
],
"question": {
"en": "Made by contributor {search}",
"de": "Erstellt von Mitwirkendem {search}"
"en": "Made by contributor {search}"
}
}
]
Expand All @@ -372,8 +360,7 @@
}
],
"question": {
"en": "<b>Not</b> made by contributor {search}",
"de": "<b> Nicht</b> erstellt von Mitwirkendem {search}"
"en": "<b>Not</b> made by contributor {search}"
}
}
]
Expand All @@ -388,8 +375,7 @@
{
"id": "link_to_more",
"render": {
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>",
"de": "Weitere Statistiken finden Sie <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>hier</a>"
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>"
}
},
{
Expand Down
8 changes: 8 additions & 0 deletions css/index-tailwind-output.css
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,14 @@ a {
width: 4rem !important;
}

.w-32-imp {
width: 8rem !important;
}

.w-48-imp {
width: 12rem !important;
}

.link-underline a {
-webkit-text-decoration: underline 1px var(--foreground-color);
text-decoration: underline 1px var(--foreground-color);
Expand Down
8 changes: 8 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ a {
width: 4rem !important;
}

.w-32-imp {
width: 8rem !important;
}

.w-48-imp {
width: 12rem !important;
}

.link-underline a {
text-decoration: underline 1px var(--foreground-color);
}
Expand Down
Loading

0 comments on commit b406d17

Please sign in to comment.