Merge branch 'develop' into feature/station-map

This commit is contained in:
Robin van der Linde 2022-12-07 13:49:48 +01:00
commit 2ae77ee0e8
Signed by untrusted user: Robin-van-der-Linde
GPG key ID: 53956B3252478F0D
157 changed files with 4654 additions and 756 deletions

View file

@ -291,7 +291,7 @@ class ExpandTagRendering extends Conversion<
name +
" was not found.\n\tDid you mean one of " +
candidates.join(", ") +
"?"
"?\n(Hint: did you add a new label and are you trying to use this label at the same time? Run 'reset:layeroverview' first"
)
continue
}

View file

@ -5,7 +5,7 @@ import Translations from "../../UI/i18n/Translations"
import { TagUtils } from "../../Logic/Tags/TagUtils"
export default class DeleteConfig {
public static readonly defaultDeleteReasons: {
private static readonly defaultDeleteReasons: {
changesetMessage: string
explanation: Translation
}[] = [
@ -27,8 +27,8 @@ export default class DeleteConfig {
},
]
public readonly extraDeleteReasons?: {
explanation: TypedTranslation<object>
public readonly deleteReasons?: {
explanation: TypedTranslation<object> | Translation
changesetMessage: string
}[]
@ -38,7 +38,7 @@ export default class DeleteConfig {
public readonly neededChangesets?: number
constructor(json: DeleteConfigJson, context: string) {
this.extraDeleteReasons = (json.extraDeleteReasons ?? []).map((reason, i) => {
this.deleteReasons = (json.extraDeleteReasons ?? []).map((reason, i) => {
const ctx = `${context}.extraDeleteReasons[${i}]`
if ((reason.changesetMessage ?? "").length <= 5) {
throw `${ctx}.explanation is too short, needs at least 4 characters`
@ -48,6 +48,16 @@ export default class DeleteConfig {
changesetMessage: reason.changesetMessage,
}
})
if(!json.omitDefaultDeleteReasons ){
for (const defaultDeleteReason of DeleteConfig.defaultDeleteReasons) {
this.deleteReasons.push({
changesetMessage: defaultDeleteReason.changesetMessage,
explanation: defaultDeleteReason.explanation.Clone(/*Must clone, hides translation otherwise*/)
})
}
}
this.nonDeleteMappings = (json.nonDeleteMappings ?? []).map((nonDelete, i) => {
const ctx = `${context}.extraDeleteReasons[${i}]`
return {
@ -56,6 +66,10 @@ export default class DeleteConfig {
}
})
if(this.nonDeleteMappings.length + this.deleteReasons.length == 0){
throw "At "+context+": a deleteconfig should have some reasons to delete: either the default delete reasons or a nonDeleteMapping or extraDeletereason should be given"
}
this.softDeletionTags = undefined
if (json.softDeletionTags !== undefined) {
this.softDeletionTags = TagUtils.Tag(

View file

@ -10,6 +10,9 @@ import { FilterState } from "../FilteredLayer"
import { QueryParameters } from "../../Logic/Web/QueryParameters"
import { Utils } from "../../Utils"
import { RegexTag } from "../../Logic/Tags/RegexTag"
import BaseUIElement from "../../UI/BaseUIElement";
import Table from "../../UI/Base/Table";
import Combine from "../../UI/Base/Combine";
export default class FilterConfig {
public readonly id: string
@ -242,4 +245,21 @@ export default class FilterConfig {
reset
)
}
public GenerateDocs(): BaseUIElement {
const hasField = this.options.some(opt => opt.fields?.length > 0)
return new Table(
Utils.NoNull(["id","question","osmTags",hasField ? "fields" : undefined]),
this.options.map((opt, i) => {
const isDefault = this.options.length > 1 && ((this.defaultSelection ?? 0) == i)
return Utils.NoNull([
this.id + "." + i,
isDefault ? new Combine([opt.question.SetClass("font-bold"), "(default)"]) : opt.question ,
opt.osmTags?.asHumanString(false, false, {}) ?? "",
opt.fields?.length > 0 ? new Combine(opt.fields.map(f => f.name+" ("+f.type+")")) : undefined
]);
})
);
}
}

View file

@ -72,4 +72,10 @@ export interface DeleteConfigJson {
* For some small features (e.g. bicycle racks) this is too much and this requirement can be lowered or dropped, which can be done here.
*/
neededChangesets?: number
/**
* Set this flag if the default delete reasons should be omitted from the dialog.
* This requires at least one extraDeleteReason or nonDeleteMapping
*/
omitDefaultDeleteReasons?: false | boolean
}

View file

@ -602,6 +602,11 @@ export default class LayerConfig extends WithContextLoader {
}
}
const filterDocs: (string | BaseUIElement)[] = []
if(this.filters.length > 0){
filterDocs.push(new Title("Filters", 4))
filterDocs.push(...this.filters.map(filter => filter.GenerateDocs()))
}
return new Combine([
new Combine([new Title(this.id, 1), iconImg, this.description, "\n"]).SetClass(
"flex flex-col"
@ -616,6 +621,7 @@ export default class LayerConfig extends WithContextLoader {
new Title("Supported attributes", 2),
quickOverview,
...this.tagRenderings.map((tr) => tr.GenerateDocumentation()),
...filterDocs
])
.SetClass("flex-col")
.SetClass("link-underline")

View file

@ -684,9 +684,8 @@ export default class TagRenderingConfig {
let condition: BaseUIElement = undefined
if (this.condition !== undefined && !this.condition?.matchesProperties({})) {
condition = new Combine([
"Only visible if ",
new FixedUiElement(this.condition.asHumanString(false, false, {})).SetClass("code"),
" is shown",
"This tagrendering is only visible in the popup if the following condition is met:",
new FixedUiElement(this.condition.asHumanString(false, false, {})).SetClass("code")
])
}