Auto-formatting

This commit is contained in:
Pieter Vander Vennet 2022-12-16 13:45:07 +01:00
parent 9e000d521f
commit fed4cff878
26 changed files with 360 additions and 304 deletions

View file

@ -49,11 +49,12 @@ export default class DeleteConfig {
}
})
if(!json.omitDefaultDeleteReasons ){
if (!json.omitDefaultDeleteReasons) {
for (const defaultDeleteReason of DeleteConfig.defaultDeleteReasons) {
this.deleteReasons.push({
changesetMessage: defaultDeleteReason.changesetMessage,
explanation: defaultDeleteReason.explanation.Clone(/*Must clone, hides translation otherwise*/)
explanation:
defaultDeleteReason.explanation.Clone(/*Must clone, hides translation otherwise*/),
})
}
}
@ -66,8 +67,12 @@ 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"
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

View file

@ -10,9 +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";
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
@ -247,19 +247,22 @@ export default class FilterConfig {
}
public GenerateDocs(): BaseUIElement {
const hasField = this.options.some(opt => opt.fields?.length > 0)
const hasField = this.options.some((opt) => opt.fields?.length > 0)
return new Table(
Utils.NoNull(["id","question","osmTags",hasField ? "fields" : undefined]),
Utils.NoNull(["id", "question", "osmTags", hasField ? "fields" : undefined]),
this.options.map((opt, i) => {
const isDefault = this.options.length > 1 && ((this.defaultSelection ?? 0) == 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 ,
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
]);
opt.fields?.length > 0
? new Combine(opt.fields.map((f) => f.name + " (" + f.type + ")"))
: undefined,
])
})
);
)
}
}

View file

@ -70,7 +70,6 @@ export default interface PointRenderingConfigJson {
*/
css?: string | TagRenderingConfigJson
/**
* A snippet of css-classes. They can be space-separated
*/

View file

@ -301,7 +301,10 @@ export default class LayerConfig extends WithContextLoader {
const hasCenterRendering = this.mapRendering.some(
(r) =>
r.location.has("centroid") || r.location.has("projected_centerpoint") || r.location.has("start") || r.location.has("end")
r.location.has("centroid") ||
r.location.has("projected_centerpoint") ||
r.location.has("start") ||
r.location.has("end")
)
if (this.lineRendering.length === 0 && this.mapRendering.length === 0) {
@ -602,10 +605,10 @@ export default class LayerConfig extends WithContextLoader {
}
}
const filterDocs: (string | BaseUIElement)[] = []
if(this.filters.length > 0){
const filterDocs: (string | BaseUIElement)[] = []
if (this.filters.length > 0) {
filterDocs.push(new Title("Filters", 4))
filterDocs.push(...this.filters.map(filter => filter.GenerateDocs()))
filterDocs.push(...this.filters.map((filter) => filter.GenerateDocs()))
}
return new Combine([
new Combine([new Title(this.id, 1), iconImg, this.description, "\n"]).SetClass(
@ -621,7 +624,7 @@ export default class LayerConfig extends WithContextLoader {
new Title("Supported attributes", 2),
quickOverview,
...this.tagRenderings.map((tr) => tr.GenerateDocumentation()),
...filterDocs
...filterDocs,
])
.SetClass("flex-col")
.SetClass("link-underline")

View file

@ -12,7 +12,7 @@ import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import Img from "../../UI/Base/Img"
import Combine from "../../UI/Base/Combine"
import { VariableUiElement } from "../../UI/Base/VariableUIElement"
import {TagRenderingConfigJson} from "./Json/TagRenderingConfigJson";
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
export default class PointRenderingConfig extends WithContextLoader {
private static readonly allowed_location_codes = new Set<string>([
@ -64,7 +64,7 @@ export default class PointRenderingConfig extends WithContextLoader {
)
}
this.icon = this.tr("icon", undefined)
if(json.css !== undefined){
if (json.css !== undefined) {
this.cssDef = this.tr("css", undefined)
}
this.cssClasses = this.tr("cssClasses", undefined)
@ -247,8 +247,8 @@ export default class PointRenderingConfig extends WithContextLoader {
iconAndBadges.SetClass("w-full h-full")
}
const css= this.cssDef?.GetRenderValue(tags , undefined)?.txt
const cssClasses = this.cssClasses?.GetRenderValue(tags , undefined)?.txt
const css = this.cssDef?.GetRenderValue(tags, undefined)?.txt
const cssClasses = this.cssClasses?.GetRenderValue(tags, undefined)?.txt
let label = this.GetLabel(tags)
let htmlEl: BaseUIElement
@ -262,11 +262,11 @@ export default class PointRenderingConfig extends WithContextLoader {
htmlEl = new Combine([iconAndBadges, label]).SetStyle("flex flex-col")
}
if(css !== undefined){
if (css !== undefined) {
htmlEl?.SetStyle(css)
}
if(cssClasses !== undefined){
if (cssClasses !== undefined) {
htmlEl?.SetClass(cssClasses)
}
return {