forked from MapComplete/MapComplete
Small fixes
This commit is contained in:
parent
f548ddea84
commit
e3e6566c12
9 changed files with 91 additions and 42 deletions
|
@ -14,9 +14,10 @@ export class AllKnownLayouts {
|
||||||
new Groen(),
|
new Groen(),
|
||||||
new GRB(),
|
new GRB(),
|
||||||
new BikePumpsLayout(),
|
new BikePumpsLayout(),
|
||||||
|
new Bookcases()
|
||||||
/*new Toilets(),
|
/*new Toilets(),
|
||||||
new Statues(),
|
new Statues(),
|
||||||
new Bookcases()*/
|
*/
|
||||||
];
|
];
|
||||||
const allSets = {};
|
const allSets = {};
|
||||||
for (const layout of layouts) {
|
for (const layout of layouts) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import L from "leaflet";
|
||||||
import {Tag} from "../../Logic/TagsFilter";
|
import {Tag} from "../../Logic/TagsFilter";
|
||||||
import {QuestionDefinition} from "../../Logic/Question";
|
import {QuestionDefinition} from "../../Logic/Question";
|
||||||
import {TagRenderingOptions} from "../TagRendering";
|
import {TagRenderingOptions} from "../TagRendering";
|
||||||
|
import {NameInline} from "../Questions/NameInline";
|
||||||
|
|
||||||
export class Bookcases extends LayerDefinition {
|
export class Bookcases extends LayerDefinition {
|
||||||
|
|
||||||
|
@ -10,21 +11,38 @@ export class Bookcases extends LayerDefinition {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.name = "boekenkast";
|
this.name = "boekenkast";
|
||||||
this.newElementTags = [new Tag( "amenity", "public_bookcase")];
|
this.newElementTags = [new Tag("amenity", "public_bookcase")];
|
||||||
this.icon = "./assets/bookcase.svg";
|
this.icon = "./assets/bookcase.svg";
|
||||||
this.overpassFilter = new Tag("amenity","public_bookcase");
|
this.overpassFilter = new Tag("amenity", "public_bookcase");
|
||||||
this.minzoom = 13;
|
this.minzoom = 13;
|
||||||
|
|
||||||
|
this.title = new NameInline("ruilboekenkastje");
|
||||||
|
this.elementsToShow = [
|
||||||
|
|
||||||
this.questions = [
|
new TagRenderingOptions(
|
||||||
|
{
|
||||||
|
question: "Hoeveel boeken passen in dit boekenruilkastje?",
|
||||||
|
freeform: {
|
||||||
|
renderTemplate: "Er passen {capacity} boeken in dit boekenruilkastje",
|
||||||
|
template: "Er passen $$$ boeken in dit boekenruilkastje",
|
||||||
|
key: "capacity",
|
||||||
|
placeholder: "aantal"
|
||||||
|
},
|
||||||
|
priority: 15
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/* this.questions = [
|
||||||
QuestionDefinition.noNameOrNameQuestion("Wat is de naam van dit boekenruilkastje?", "Dit boekenruilkastje heeft niet echt een naam", 20),
|
QuestionDefinition.noNameOrNameQuestion("Wat is de naam van dit boekenruilkastje?", "Dit boekenruilkastje heeft niet echt een naam", 20),
|
||||||
QuestionDefinition.textQuestion("Hoeveel boeken kunnen er in?", "capacity", 15),
|
|
||||||
QuestionDefinition.textQuestion("Heeft dit boekenkastje een peter, meter of voogd?", "operator", 10),
|
QuestionDefinition.textQuestion("Heeft dit boekenkastje een peter, meter of voogd?", "operator", 10),
|
||||||
// QuestionDefinition.textQuestion("Wie kunnen we (per email) contacteren voor dit boekenruilkastje?", "email", 5),
|
// QuestionDefinition.textQuestion("Wie kunnen we (per email) contacteren voor dit boekenruilkastje?", "email", 5),
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
;
|
;
|
||||||
|
*/
|
||||||
|
|
||||||
this.style = function (tags) {
|
this.style = function (tags) {
|
||||||
return {
|
return {
|
||||||
|
@ -36,6 +54,7 @@ export class Bookcases extends LayerDefinition {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
this.elementsToShow = [
|
this.elementsToShow = [
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +77,7 @@ export class Bookcases extends LayerDefinition {
|
||||||
|
|
||||||
new TagMappingOptions({key: "description", template: "Extra beschrijving: <br /> <p>{description}</p>"}),
|
new TagMappingOptions({key: "description", template: "Extra beschrijving: <br /> <p>{description}</p>"}),
|
||||||
]
|
]
|
||||||
;
|
;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,29 @@ export class Park extends LayerDefinition {
|
||||||
this.minzoom = 13;
|
this.minzoom = 13;
|
||||||
this.style = this.generateStyleFunction();
|
this.style = this.generateStyleFunction();
|
||||||
this.title = new NameInline("park");
|
this.title = new NameInline("park");
|
||||||
this.elementsToShow = [new NameQuestion()];
|
this.elementsToShow = [new NameQuestion(),
|
||||||
|
new TagRenderingOptions({
|
||||||
|
question: "Is dit park publiek toegankelijk?",
|
||||||
|
mappings: [
|
||||||
|
{k: new Tag("access", "yes"), txt: "Publiek toegankelijk"},
|
||||||
|
{k: new Tag("access", ""), txt: "Publiek toegankelijk"},
|
||||||
|
{k: new Tag("access", "no"), txt: "Niet publiek toegankelijk"},
|
||||||
|
{k: new Tag("access", "guided"), txt: "Enkel met een gids of tijdens activiteiten"},
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
new TagRenderingOptions({
|
||||||
|
question: "Wie beheert dit park?",
|
||||||
|
freeform: {
|
||||||
|
key: "operator",
|
||||||
|
renderTemplate: "Dit park wordt beheerd door {operator}",
|
||||||
|
template: "$$$",
|
||||||
|
},
|
||||||
|
mappings: [{
|
||||||
|
k: null, txt: "De gemeente beheert dit park"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {Layout} from "../Layout";
|
||||||
export class Groen extends Layout {
|
export class Groen extends Layout {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("groen",
|
super("buurtnatuur",
|
||||||
"Buurtnatuur",
|
"Buurtnatuur",
|
||||||
[new NatureReserves(), new Park(), new Bos()],
|
[new NatureReserves(), new Park(), new Bos()],
|
||||||
10,
|
10,
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class TagRenderingOptions {
|
||||||
const tagsKV = TagUtils.proprtiesToKV(tags);
|
const tagsKV = TagUtils.proprtiesToKV(tags);
|
||||||
|
|
||||||
for (const oneOnOneElement of this.options.mappings) {
|
for (const oneOnOneElement of this.options.mappings) {
|
||||||
if (oneOnOneElement.k.matches(tagsKV)) {
|
if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tagsKV)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,10 @@ export class TagRendering extends UIElement {
|
||||||
this.elementPriority = options.priority ?? 0;
|
this.elementPriority = options.priority ?? 0;
|
||||||
|
|
||||||
// Prepare the choices for the Radio buttons
|
// Prepare the choices for the Radio buttons
|
||||||
let i = 0;
|
|
||||||
const choices: UIElement[] = [];
|
const choices: UIElement[] = [];
|
||||||
|
|
||||||
|
const usedChoices: string [] = [];
|
||||||
|
|
||||||
for (const choice of options.mappings ?? []) {
|
for (const choice of options.mappings ?? []) {
|
||||||
if (choice.k === null) {
|
if (choice.k === null) {
|
||||||
this._mapping.push(choice);
|
this._mapping.push(choice);
|
||||||
|
@ -159,18 +160,24 @@ export class TagRendering extends UIElement {
|
||||||
let choiceSubbed = choice;
|
let choiceSubbed = choice;
|
||||||
if (choice.substitute) {
|
if (choice.substitute) {
|
||||||
choiceSubbed = {
|
choiceSubbed = {
|
||||||
k : choice.k.substituteValues(
|
k: choice.k.substituteValues(
|
||||||
options.tagsPreprocessor(this._source.data)),
|
options.tagsPreprocessor(this._source.data)),
|
||||||
txt : this.ApplyTemplate(choice.txt),
|
txt: this.ApplyTemplate(choice.txt),
|
||||||
substitute: false,
|
substitute: false,
|
||||||
priority: choice.priority
|
priority: choice.priority
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
choices.push(new FixedUiElement(choiceSubbed.txt));
|
|
||||||
this._mapping.push(choiceSubbed);
|
const txt = choiceSubbed.txt
|
||||||
i++;
|
// Choices is what is shown in the radio buttons
|
||||||
|
if (usedChoices.indexOf(txt) < 0) {
|
||||||
|
|
||||||
|
choices.push(new FixedUiElement(txt));
|
||||||
|
usedChoices.push(txt);
|
||||||
|
// This is used to convert the radio button index into tags needed to add
|
||||||
|
this._mapping.push(choiceSubbed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map radiobutton choice and textfield answer onto tagfilter. That tagfilter will be pushed into the changes later on
|
// Map radiobutton choice and textfield answer onto tagfilter. That tagfilter will be pushed into the changes later on
|
||||||
|
@ -200,6 +207,7 @@ export class TagRendering extends UIElement {
|
||||||
// Prepare the actual input element -> pick an appropriate implementation
|
// Prepare the actual input element -> pick an appropriate implementation
|
||||||
let inputElement: UIInputElement<TagsFilter>;
|
let inputElement: UIInputElement<TagsFilter>;
|
||||||
|
|
||||||
|
|
||||||
if (this._freeform !== undefined && this._mapping !== undefined) {
|
if (this._freeform !== undefined && this._mapping !== undefined) {
|
||||||
// Radio buttons with 'other'
|
// Radio buttons with 'other'
|
||||||
inputElement = new UIRadioButtonWithOther(
|
inputElement = new UIRadioButtonWithOther(
|
||||||
|
@ -210,14 +218,15 @@ export class TagRendering extends UIElement {
|
||||||
pickString
|
pickString
|
||||||
);
|
);
|
||||||
this._questionElement = inputElement;
|
this._questionElement = inputElement;
|
||||||
} else if (this._mapping !== undefined) {
|
} else if (this._mapping !== [] && this._mapping.length > 0) {
|
||||||
// This is a classic radio selection element
|
// This is a classic radio selection element
|
||||||
inputElement = new UIRadioButton(new UIEventSource(choices), pickChoice)
|
inputElement = new UIRadioButton(new UIEventSource(choices), pickChoice, false)
|
||||||
this._questionElement = inputElement;
|
this._questionElement = inputElement;
|
||||||
} else if (this._freeform !== undefined) {
|
} else if (this._freeform !== undefined) {
|
||||||
this._textField = new TextField(new UIEventSource<string>(this._freeform.placeholder), pickString);
|
this._textField = new TextField(new UIEventSource<string>(this._freeform.placeholder), pickString);
|
||||||
inputElement = this._textField;
|
inputElement = this._textField;
|
||||||
this._questionElement = new FixedUiElement(this._freeform.template.replace("$$$", inputElement.Render()))
|
this._questionElement = new FixedUiElement(
|
||||||
|
"<div>" + this._freeform.template.replace("$$$", inputElement.Render()) + "</div>")
|
||||||
} else {
|
} else {
|
||||||
throw "Invalid questionRendering, expected at least choices or a freeform"
|
throw "Invalid questionRendering, expected at least choices or a freeform"
|
||||||
}
|
}
|
||||||
|
@ -234,6 +243,7 @@ export class TagRendering extends UIElement {
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
self._questionSkipped.setData(true);
|
self._questionSkipped.setData(true);
|
||||||
self._editMode.setData(false);
|
self._editMode.setData(false);
|
||||||
|
self._source.ping(); // Send a ping upstream to render the next question
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the save button and it's action
|
// Setup the save button and it's action
|
||||||
|
@ -352,7 +362,7 @@ export class TagRendering extends UIElement {
|
||||||
|
|
||||||
|
|
||||||
return "<div class='question'>" +
|
return "<div class='question'>" +
|
||||||
this._question +
|
"<span class='question-text'>" + this._question + "</span>" +
|
||||||
(this._question !== "" ? "<br/>" : "") +
|
(this._question !== "" ? "<br/>" : "") +
|
||||||
this._questionElement.Render() +
|
this._questionElement.Render() +
|
||||||
this._skipButton.Render() +
|
this._skipButton.Render() +
|
||||||
|
|
|
@ -74,9 +74,11 @@ export class UIRadioButton<T> extends UIInputElement<T> {
|
||||||
if (this.SelectedElementIndex.data == null) {
|
if (this.SelectedElementIndex.data == null) {
|
||||||
if (this._selectFirstAsDefault) {
|
if (this._selectFirstAsDefault) {
|
||||||
const el = document.getElementById(this.IdFor(0));
|
const el = document.getElementById(this.IdFor(0));
|
||||||
// @ts-ignore
|
if (el) {
|
||||||
el.checked = true;
|
// @ts-ignore
|
||||||
checkButtons();
|
el.checked = true;
|
||||||
|
checkButtons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,10 @@ body {
|
||||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
#leafletDiv {
|
#leafletDiv {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -670,6 +674,11 @@ body {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.question-text{
|
||||||
|
font-size: larger;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.answer {
|
.answer {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0.1em;
|
margin: 0.1em;
|
||||||
|
|
4
index.ts
4
index.ts
|
@ -38,7 +38,7 @@ if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
||||||
// ----------------- SELECT THE RIGHT QUESTSET -----------------
|
// ----------------- SELECT THE RIGHT QUESTSET -----------------
|
||||||
|
|
||||||
|
|
||||||
let defaultQuest = "groen"
|
let defaultQuest = "buurtnatuur"
|
||||||
if (window.location.search) {
|
if (window.location.search) {
|
||||||
const params = window.location.search.substr(1).split("&");
|
const params = window.location.search.substr(1).split("&");
|
||||||
const paramDict: any = {};
|
const paramDict: any = {};
|
||||||
|
@ -88,7 +88,7 @@ const saveTimeout = 30000; // After this many milliseconds without changes, save
|
||||||
const allElements = new ElementStorage();
|
const allElements = new ElementStorage();
|
||||||
const osmConnection = new OsmConnection(dryRun);
|
const osmConnection = new OsmConnection(dryRun);
|
||||||
const changes = new Changes(
|
const changes = new Changes(
|
||||||
"Beantwoorden van vragen met MapComplete voor vragenset #" + questSetToRender.name,
|
"Beantwoorden van vragen met #MapComplete voor vragenset #" + questSetToRender.name,
|
||||||
osmConnection, allElements);
|
osmConnection, allElements);
|
||||||
const bm = new Basemap("leafletDiv", locationControl, new VariableUiElement(
|
const bm = new Basemap("leafletDiv", locationControl, new VariableUiElement(
|
||||||
locationControl.map((location) => {
|
locationControl.map((location) => {
|
||||||
|
|
14
test.ts
14
test.ts
|
@ -5,17 +5,3 @@ import {ElementStorage} from "./Logic/ElementStorage";
|
||||||
import {WikipediaLink} from "./Customizations/Questions/WikipediaLink";
|
import {WikipediaLink} from "./Customizations/Questions/WikipediaLink";
|
||||||
import {OsmLink} from "./Customizations/Questions/OsmLink";
|
import {OsmLink} from "./Customizations/Questions/OsmLink";
|
||||||
|
|
||||||
const tags = {name: "Test",
|
|
||||||
wikipedia: "nl:Pieter",
|
|
||||||
id: "node/-1"};
|
|
||||||
const tagsES = new UIEventSource(tags);
|
|
||||||
|
|
||||||
const login = new OsmConnection(true);
|
|
||||||
|
|
||||||
const allElements = new ElementStorage();
|
|
||||||
allElements.addElementById(tags.id, tagsES);
|
|
||||||
|
|
||||||
const changes = new Changes("Test", login, allElements)
|
|
||||||
|
|
||||||
|
|
||||||
new OsmLink(tagsES, changes).AttachTo("maindiv");
|
|
Loading…
Reference in a new issue