Studio+UX: various UX tweaks after usertesting

This commit is contained in:
Pieter Vander Vennet 2023-11-03 02:04:42 +01:00
parent 4219b23af1
commit 3a915bdf25
31 changed files with 2476 additions and 108 deletions

View file

@ -732,6 +732,14 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
if (!mapping.if) {
context.enters("mappings", i).err("No `if` is defined")
}
const en = mapping?.then?.["en"]
if (en && en.toLowerCase().match(/(yes|no)([ ,:;.?]|$)/)) {
context
.enters("mappings", i, "then")
.warn(
"A mapping should not start with 'yes' or 'no'. If the attribute is known, it will only show 'yes' or 'no' <i>without</i> the question, resulting in a weird popup"
)
}
}
}
if (json["group"]) {
@ -1168,17 +1176,23 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
if (json.presets !== undefined) {
if (typeof json.source === "string") {
context.err("A special layer cannot have presets")
context.enter("presets").err("A special layer cannot have presets")
}
// Check that a preset will be picked up by the layer itself
const baseTags = TagUtils.Tag(json.source["osmTags"])
for (let i = 0; i < json.presets.length; i++) {
const preset = json.presets[i]
const tags: { k: string; v: string }[] = new And(
preset.tags.map((t) => TagUtils.Tag(t))
).asChange({ id: "node/-1" })
if (!preset.tags) {
context.enters("presets", i, "tags").err("No tags defined for this preset")
continue
}
if (!preset.tags) {
context.enters("presets", i, "title").err("No title defined for this preset")
}
const tags = new And(preset.tags.map((t) => TagUtils.Tag(t)))
const properties = {}
for (const tag of tags) {
for (const tag of tags.asChange({ id: "node/-1" })) {
properties[tag.k] = tag.v
}
const doMatch = baseTags.matchesProperties(properties)
@ -1187,7 +1201,7 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
.enters("presets", i, "tags")
.err(
"This preset does not match the required tags of this layer. This implies that a newly added point will not show up.\n A newly created point will have properties: " +
JSON.stringify(properties) +
tags.asHumanString(false, false, {}) +
"\n The required tags are: " +
baseTags.asHumanString(false, false, {})
)

View file

@ -338,6 +338,7 @@ export interface LayerConfigJson {
* (The first sentence is until the first '.'-character in the description)
*
* question: How would you describe this feature?
* ifunset: No extra description is given. This can be used to further explain the preset
*/
description?: Translatable
@ -375,7 +376,7 @@ export interface LayerConfigJson {
}[]
/**
* question: Which tagRenderings should be shown in the infobox?
* question: Edit this tagRendering
*
* A tag rendering is a block that either shows the known value or asks a question.
*

View file

@ -114,6 +114,8 @@ export interface MappingConfigJson {
* This can be done with `ifnot`
* Note that we can not explicitly render this negative case to the user, we cannot show `does _not_ accept coins`.
* If this is important to your usecase, consider using multiple radiobutton-fields without `multiAnswer`
*
* ifunset: Do not apply a tag if a different mapping is chosen.
*/
ifnot?: TagConfigJson
@ -199,8 +201,8 @@ export interface QuestionableTagRenderingConfigJson extends TagRenderingConfigJs
/**
* question: What is the name of the attribute that should be written to?
* This is the OpenStreetMap-key that that value will be written to
*
* ifunset: do not offer a freeform textfield as answer option
*
*/
key: string