Full code cleanup

This commit is contained in:
Pieter Vander Vennet 2021-11-07 16:34:51 +01:00
parent 8e6ee8c87f
commit bd21212eba
246 changed files with 19418 additions and 11729 deletions

View file

@ -16,9 +16,9 @@ export default class EditableTagRendering extends Toggle {
constructor(tags: UIEventSource<any>,
configuration: TagRenderingConfig,
units: Unit [],
options:{
editMode? : UIEventSource<boolean> ,
innerElementClasses?: string
options: {
editMode?: UIEventSource<boolean>,
innerElementClasses?: string
}
) {
@ -28,7 +28,7 @@ export default class EditableTagRendering extends Toggle {
const renderingIsShown = tags.map(tags =>
configuration.IsKnown(tags) &&
(configuration?.condition?.matchesProperties(tags) ?? true))
super(
new Lazy(() => {
const editMode = options.editMode ?? new UIEventSource<boolean>(false)
@ -40,8 +40,8 @@ export default class EditableTagRendering extends Toggle {
renderingIsShown
)
}
private static CreateRendering(tags: UIEventSource<any>, configuration: TagRenderingConfig, units: Unit[], editMode: UIEventSource<boolean>) : BaseUIElement{
private static CreateRendering(tags: UIEventSource<any>, configuration: TagRenderingConfig, units: Unit[], editMode: UIEventSource<boolean>): BaseUIElement {
const answer: BaseUIElement = new TagRenderingAnswer(tags, configuration)
answer.SetClass("w-full")
let rendering = answer;

View file

@ -77,23 +77,23 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
renderingsForGroup.push(questionBox)
} else {
let classes = innerClasses
let isHeader = renderingsForGroup.length === 0 && i > 0
if(isHeader){
let isHeader = renderingsForGroup.length === 0 && i > 0
if (isHeader) {
// This is the first element of a group!
// It should act as header and be sticky
classes= ""
classes = ""
}
const etr = new EditableTagRendering(tags, tr, layerConfig.units,{
const etr = new EditableTagRendering(tags, tr, layerConfig.units, {
innerElementClasses: innerClasses
})
if(isHeader){
if (isHeader) {
etr.SetClass("sticky top-0")
}
renderingsForGroup.push(etr)
}
}
allRenderings.push(...renderingsForGroup)
}

View file

@ -42,7 +42,7 @@ export default class MoveWizard extends Toggle {
changes: Changes,
layoutToUse: LayoutConfig,
allElements: ElementStorage
}, options : MoveConfig) {
}, options: MoveConfig) {
const t = Translations.t.move
const loginButton = new Toggle(
@ -64,7 +64,7 @@ export default class MoveWizard extends Toggle {
minZoom: 6
})
}
if(options.enableImproveAccuracy){
if (options.enableImproveAccuracy) {
reasons.push({
text: t.reasons.reasonInaccurate,
invitingText: t.inviteToMove.reasonInaccurate,
@ -79,8 +79,8 @@ export default class MoveWizard extends Toggle {
const currentStep = new UIEventSource<"start" | "reason" | "pick_location" | "moved">("start")
const moveReason = new UIEventSource<MoveReason>(undefined)
let moveButton : BaseUIElement;
if(reasons.length === 1){
let moveButton: BaseUIElement;
if (reasons.length === 1) {
const reason = reasons[0]
moveReason.setData(reason)
moveButton = new SubtleButton(
@ -89,7 +89,7 @@ export default class MoveWizard extends Toggle {
).onClick(() => {
currentStep.setData("pick_location")
})
}else{
} else {
moveButton = new SubtleButton(
Svg.move_ui().SetStyle("height: 1.5rem; width: auto"),
t.inviteToMove.generic
@ -97,7 +97,7 @@ export default class MoveWizard extends Toggle {
currentStep.setData("reason")
})
}
const moveAgainButton = new SubtleButton(
Svg.move_ui(),
@ -107,8 +107,6 @@ export default class MoveWizard extends Toggle {
})
const selectReason = new Combine(reasons.map(r => new SubtleButton(r.icon, r.text).onClick(() => {
moveReason.setData(r)
currentStep.setData("pick_location")
@ -129,16 +127,16 @@ export default class MoveWizard extends Toggle {
})
let background: string[]
if(typeof reason.background == "string"){
if (typeof reason.background == "string") {
background = [reason.background]
}else{
} else {
background = reason.background
}
const locationInput = new LocationInput({
minZoom: reason.minZoom,
centerLocation: loc,
mapBackground:AvailableBaseLayers.SelectBestLayerAccordingTo(loc, new UIEventSource(background))
mapBackground: AvailableBaseLayers.SelectBestLayerAccordingTo(loc, new UIEventSource(background))
})
if (reason.lockBounds) {
@ -198,8 +196,8 @@ export default class MoveWizard extends Toggle {
moveDisallowedReason.setData(t.isWay)
} else if (id.startsWith("relation")) {
moveDisallowedReason.setData(t.isRelation)
} else if(id.indexOf("-") < 0) {
} else if (id.indexOf("-") < 0) {
OsmObject.DownloadReferencingWays(id).then(referencing => {
if (referencing.length > 0) {
console.log("Got a referencing way, move not allowed")
@ -207,7 +205,7 @@ export default class MoveWizard extends Toggle {
}
})
OsmObject.DownloadReferencingRelations(id).then(partOf => {
if(partOf.length > 0){
if (partOf.length > 0) {
moveDisallowedReason.setData(t.partOfRelation)
}
})

View file

@ -32,6 +32,7 @@ export interface MultiApplyParams {
class MultiApplyExecutor {
private static executorCache = new Map<string, MultiApplyExecutor>()
private readonly originalValues = new Map<string, string>()
private readonly params: MultiApplyParams;
@ -48,7 +49,7 @@ class MultiApplyExecutor {
const self = this;
const relevantValues = p.tagsSource.map(tags => {
const currentValues = p.keysToApply.map(key => tags[key])
// By stringifying, we have a very clear ping when they changec
// By stringifying, we have a very clear ping when they changec
return JSON.stringify(currentValues);
})
relevantValues.addCallbackD(_ => {
@ -57,6 +58,15 @@ class MultiApplyExecutor {
}
}
public static GetApplicator(id: string, params: MultiApplyParams): MultiApplyExecutor {
if (MultiApplyExecutor.executorCache.has(id)) {
return MultiApplyExecutor.executorCache.get(id)
}
const applicator = new MultiApplyExecutor(params)
MultiApplyExecutor.executorCache.set(id, applicator)
return applicator
}
public applyTaggingOnOtherFeatures() {
console.log("Multi-applying changes...")
const featuresToChange = this.params.featureIds.data
@ -103,17 +113,6 @@ class MultiApplyExecutor {
}
}
private static executorCache = new Map<string, MultiApplyExecutor>()
public static GetApplicator(id: string, params: MultiApplyParams): MultiApplyExecutor {
if (MultiApplyExecutor.executorCache.has(id)) {
return MultiApplyExecutor.executorCache.get(id)
}
const applicator = new MultiApplyExecutor(params)
MultiApplyExecutor.executorCache.set(id, applicator)
return applicator
}
}
export default class MultiApply extends Toggle {

View file

@ -16,7 +16,7 @@ import Lazy from "../Base/Lazy";
export default class QuestionBox extends VariableUiElement {
constructor(tagsSource: UIEventSource<any>, tagRenderings: TagRenderingConfig[], units: Unit[]) {
const skippedQuestions: UIEventSource<number[]> = new UIEventSource<number[]>([])
tagRenderings = tagRenderings
@ -31,20 +31,20 @@ export default class QuestionBox extends VariableUiElement {
const tagRenderingQuestions = tagRenderings
.map((tagRendering, i) =>
new Lazy(() => new TagRenderingQuestion(tagsSource, tagRendering,
{
units: units,
afterSave: () => {
// We save and indicate progress by pinging and recalculating
skippedQuestions.ping();
},
cancelButton: Translations.t.general.skip.Clone()
.SetClass("btn btn-secondary mr-3")
.onClick(() => {
skippedQuestions.data.push(i);
{
units: units,
afterSave: () => {
// We save and indicate progress by pinging and recalculating
skippedQuestions.ping();
})
}
)));
},
cancelButton: Translations.t.general.skip.Clone()
.SetClass("btn btn-secondary mr-3")
.onClick(() => {
skippedQuestions.data.push(i);
skippedQuestions.ping();
})
}
)));
const skippedQuestionsButton = Translations.t.general.skippedQuestions
.onClick(() => {

View file

@ -23,7 +23,7 @@ export default class SplitRoadWizard extends Toggle {
source: {osmTags: "_cutposition=yes"},
mapRendering: [
{
location: ["point","centroid"],
location: ["point", "centroid"],
icon: {render: "circle:white;./assets/svg/scissors.svg"},
iconSize: {render: "30,30,center"}
}