Merge develop

This commit is contained in:
Pieter Vander Vennet 2021-10-28 00:13:18 +02:00
commit 897c59f97a
35 changed files with 1792 additions and 1172 deletions

View file

@ -19,6 +19,7 @@ import Img from "./Img";
export default class ScrollableFullScreen extends UIElement {
private static readonly empty = new FixedUiElement("");
private static _currentlyOpen: ScrollableFullScreen;
private hashToShow: string;
public isShown: UIEventSource<boolean>;
private _component: BaseUIElement;
private _fullscreencomponent: BaseUIElement;
@ -28,6 +29,7 @@ export default class ScrollableFullScreen extends UIElement {
isShown: UIEventSource<boolean> = new UIEventSource<boolean>(false)
) {
super();
this.hashToShow = hashToShow;
this.isShown = isShown;
if (hashToShow === undefined) {
@ -45,24 +47,25 @@ export default class ScrollableFullScreen extends UIElement {
self.Activate();
Hash.hash.setData(hashToShow)
} else {
ScrollableFullScreen.clear();
self.clear();
}
})
Hash.hash.addCallback(hash => {
if (hash === hashToShow) {
return
if (!isShown.data) {
return;
}
if (hash === undefined || hash === "") {
isShown.setData(false)
}
isShown.setData(false)
})
}
private static clear() {
private clear() {
ScrollableFullScreen.empty.AttachTo("fullscreen")
const fs = document.getElementById("fullscreen");
ScrollableFullScreen._currentlyOpen?.isShown?.setData(false);
fs.classList.add("hidden")
Hash.hash.setData(undefined);
}
InnerRender(): BaseUIElement {

View file

@ -21,6 +21,9 @@ export class TabbedComponent extends Combine {
let element = elements[i];
const header = Translations.W(element.header).onClick(() => openedTabSrc.setData(i))
openedTabSrc.addCallbackAndRun(selected => {
if(selected >= elements.length){
selected = 0
}
if (selected === i) {
header.SetClass("tab-active")
header.RemoveClass("tab-non-active")

View file

@ -114,10 +114,8 @@ export default class DefaultGUI {
Utils.LoadCustomCss(state.layoutToUse.customCss);
}
this.SetupUIElements();
this.SetupMap()
}

View file

@ -111,7 +111,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
layerConfig.allowMove
);
})
)
).SetClass("text-base")
);
}
@ -122,14 +122,14 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
id,
layerConfig.deletion
))
))
).SetClass("text-base"))
}
if (layerConfig.allowSplit) {
editElements.push(
new VariableUiElement(tags.map(tags => tags.id).map(id =>
new SplitRoadWizard(id))
))
).SetClass("text-base"))
}

View file

@ -16,6 +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
@ -33,7 +34,7 @@ export default class QuestionBox extends VariableUiElement {
{
units: units,
afterSave: () => {
// We save
// We save and indicate progress by pinging and recalculating
skippedQuestions.ping();
},
cancelButton: Translations.t.general.skip.Clone()
@ -45,7 +46,7 @@ export default class QuestionBox extends VariableUiElement {
}
)));
const skippedQuestionsButton = Translations.t.general.skippedQuestions.Clone()
const skippedQuestionsButton = Translations.t.general.skippedQuestions
.onClick(() => {
skippedQuestions.setData([]);
})

View file

@ -48,7 +48,7 @@ export default class TagRenderingQuestion extends Combine {
const applicableMappingsSrc =
UIEventSource.ListStabilized(tags.map(tags => {
const applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter }[] = []
const applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter, addExtraTags: Tag[] }[] = []
for (const mapping of configuration.mappings ?? []) {
if (mapping.hideInAnswer === true) {
continue
@ -107,9 +107,9 @@ export default class TagRenderingQuestion extends Combine {
const saveButton = new Combine([
options.saveButtonConstr(inputElement.GetValue()),
new Toggle(Translations.t.general.testing, undefined, State.state.featureSwitchIsTesting).SetClass("alert")
new Toggle(Translations.t.general.testing.SetClass("alert"), undefined, State.state.featureSwitchIsTesting)
])
let bottomTags: BaseUIElement;
if (options.bottomText !== undefined) {
bottomTags = options.bottomText(inputElement.GetValue())
@ -146,7 +146,7 @@ export default class TagRenderingQuestion extends Combine {
private static GenerateInputElement(configuration: TagRenderingConfig,
applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter }[],
applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter, addExtraTags: Tag[] }[],
applicableUnit: Unit,
tagsSource: UIEventSource<any>)
: InputElement<TagsFilter> {
@ -340,12 +340,16 @@ export default class TagRenderingQuestion extends Combine {
mapping: {
if: TagsFilter,
then: Translation,
addExtraTags: Tag[]
}, ifNot?: TagsFilter[]): InputElement<TagsFilter> {
let tagging: TagsFilter = mapping.if;
if (ifNot !== undefined) {
tagging = new And([mapping.if, ...ifNot])
}
if (mapping.addExtraTags) {
tagging = new And([tagging, ...mapping.addExtraTags])
}
return new FixedInputElement(
new SubstitutedTranslation(mapping.then, tagsSource),

View file

@ -281,7 +281,6 @@ export default class ShowDataLayer {
infobox.isShown.addCallback(isShown => {
if (!isShown) {
this._selectedElement?.setData(undefined);
leafletLayer.closePopup()
}
});
@ -293,7 +292,7 @@ export default class ShowDataLayer {
}
});
// Add the feature to the index to open the popup when needed
this.leafletLayersPerId.set(feature.properties.id + feature.geometry.type, {

View file

@ -508,7 +508,7 @@ There are also some technicalities in your theme to keep in mind:
return new Combine([new FixedUiElement("The import button is disabled for unofficial themes to prevent accidents.").SetClass("alert"),
new FixedUiElement("To test, add 'test=true' to the URL. The changeset will be printed in the console. Please open a PR to officialize this theme to actually enable the import button.")])
}
const tgsSpec = args[0].split(",").map(spec => {
const tgsSpec = args[0].split(";").map(spec => {
const kv = spec.split("=").map(s => s.trim());
if (kv.length != 2) {
throw "Invalid key spec: multiple '=' found in " + spec