forked from MapComplete/MapComplete
Studio: UX work
This commit is contained in:
parent
bf4f7d3f88
commit
8685ec8ccc
45 changed files with 532 additions and 312 deletions
|
@ -733,11 +733,12 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
|
|||
context.enters("mappings", i).err("No `if` is defined")
|
||||
}
|
||||
const en = mapping?.then?.["en"]
|
||||
if (en && en.toLowerCase().match(/(yes|no)([ ,:;.?]|$)/)) {
|
||||
if (en && this.detectYesOrNo(en)) {
|
||||
console.log("Found a match with yes or no: ", { en })
|
||||
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"
|
||||
"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 phrasing in the information box"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -854,6 +855,17 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
|
|||
|
||||
return json
|
||||
}
|
||||
|
||||
/**
|
||||
* const obj = new MiscTagRenderingChecks()
|
||||
* obj.detectYesOrNo("Yes, this place has") // => true
|
||||
* obj.detectYesOrNo("Yes") // => true
|
||||
* obj.detectYesOrNo("No, this place does not have...") // => true
|
||||
* obj.detectYesOrNo("This place does not have...") // => false
|
||||
*/
|
||||
private detectYesOrNo(en: string): boolean {
|
||||
return en.toLowerCase().match(/^(yes|no)([,:;.?]|$)/) !== null
|
||||
}
|
||||
}
|
||||
|
||||
export class ValidateTagRenderings extends Fuse<TagRenderingConfigJson> {
|
||||
|
@ -1014,10 +1026,11 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
}
|
||||
{
|
||||
// duplicate ids in tagrenderings check
|
||||
const duplicates = Utils.Dedup(
|
||||
const duplicates = Utils.NoNull(
|
||||
Utils.Duplicates(Utils.NoNull((json.tagRenderings ?? []).map((tr) => tr["id"])))
|
||||
)
|
||||
if (duplicates.length > 0) {
|
||||
// It is tempting to add an index to this warning; however, due to labels the indices here might be different from the index in the tagRendering list
|
||||
context
|
||||
.enter("tagRenderings")
|
||||
.err("Some tagrenderings have a duplicate id: " + duplicates.join(", "))
|
||||
|
|
|
@ -89,7 +89,7 @@ export default interface PointRenderingConfigJson {
|
|||
* For example: `<div style="background: white">{name}</div>`
|
||||
*
|
||||
* If the icon is undefined, then the label is shown in the center of the feature.
|
||||
* types: Dynamic value | string
|
||||
* types: Dynamic value based on the attributes ; string
|
||||
* inline: Always show label <b>{value}</b> beneath the marker
|
||||
* ifunset: Do not show a label beneath the marker
|
||||
*/
|
||||
|
|
|
@ -85,7 +85,7 @@ export interface TagRenderingConfigJson {
|
|||
/**
|
||||
*
|
||||
* question: When should this item be shown?
|
||||
*
|
||||
* type: tag
|
||||
* Only show this tagrendering (or ask the question) if the selected object also matches the tags specified as `condition`.
|
||||
*
|
||||
* This is useful to ask a follow-up question.
|
||||
|
@ -126,9 +126,8 @@ export interface TagRenderingConfigJson {
|
|||
* */
|
||||
condition?: TagConfigJson
|
||||
|
||||
/**
|
||||
*
|
||||
* question: When should this item be shown (including special conditions)?
|
||||
/** question: When should this item be shown (including special conditions)?
|
||||
* type: tag
|
||||
*
|
||||
* If set, this tag will be evaluated agains the _usersettings/application state_ table.
|
||||
* Enable 'show debug info' in user settings to see available options.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue