Propagate 'store' where applicable, improve docs

This commit is contained in:
pietervdvn 2022-06-19 13:55:33 +02:00
parent 4a318c1073
commit 9bfbdf012a
6 changed files with 21 additions and 15 deletions

View file

@ -1,5 +1,5 @@
/// Given a feature source, calculates a list of OSM-contributors who mapped the latest versions /// Given a feature source, calculates a list of OSM-contributors who mapped the latest versions
import {UIEventSource} from "./UIEventSource"; import {Store, UIEventSource} from "./UIEventSource";
import FeaturePipeline from "./FeatureSource/FeaturePipeline"; import FeaturePipeline from "./FeatureSource/FeaturePipeline";
import Loc from "../Models/Loc"; import Loc from "../Models/Loc";
import {BBox} from "./BBox"; import {BBox} from "./BBox";
@ -7,10 +7,10 @@ import {BBox} from "./BBox";
export default class ContributorCount { export default class ContributorCount {
public readonly Contributors: UIEventSource<Map<string, number>> = new UIEventSource<Map<string, number>>(new Map<string, number>()); public readonly Contributors: UIEventSource<Map<string, number>> = new UIEventSource<Map<string, number>>(new Map<string, number>());
private readonly state: { featurePipeline: FeaturePipeline, currentBounds: UIEventSource<BBox>, locationControl: UIEventSource<Loc> }; private readonly state: { featurePipeline: FeaturePipeline, currentBounds: Store<BBox>, locationControl: Store<Loc> };
private lastUpdate: Date = undefined; private lastUpdate: Date = undefined;
constructor(state: { featurePipeline: FeaturePipeline, currentBounds: UIEventSource<BBox>, locationControl: UIEventSource<Loc> }) { constructor(state: { featurePipeline: FeaturePipeline, currentBounds: Store<BBox>, locationControl: Store<Loc> }) {
this.state = state; this.state = state;
const self = this; const self = this;
state.currentBounds.map(bbox => { state.currentBounds.map(bbox => {

View file

@ -1,9 +1,14 @@
/** /**
* Rewrites and multiplies the given renderings of type T. * Rewrites and multiplies the given renderings of type T.
* *
* This can be used for introducing many similar questions automatically,
* which also makes translations easier.
*
* (Note that the key does _not_ need to be wrapped in {}.
* However, we recommend to use them if the key is used in a translation, as missing keys will be picked up and warned for by the translation scripts)
*
* For example: * For example:
* *
*
* ``` * ```
* { * {
* rewrite: { * rewrite: {
@ -13,9 +18,9 @@
* ["Y", 1], * ["Y", 1],
* ["Z", 2] * ["Z", 2]
* ], * ],
* renderings: { * renderings: [{
* "key":"a|b|c" * "key":"a|b|c"
* } * }]
* } * }
* } * }
* ``` * ```

View file

@ -1,6 +1,6 @@
import Combine from "../Base/Combine"; import Combine from "../Base/Combine";
import Translations from "../i18n/Translations"; import Translations from "../i18n/Translations";
import {UIEventSource} from "../../Logic/UIEventSource"; import {Store, UIEventSource} from "../../Logic/UIEventSource";
import {FixedUiElement} from "../Base/FixedUiElement"; import {FixedUiElement} from "../Base/FixedUiElement";
import * as licenses from "../../assets/generated/license_info.json" import * as licenses from "../../assets/generated/license_info.json"
import SmallLicense from "../../Models/smallLicense"; import SmallLicense from "../../Models/smallLicense";
@ -48,7 +48,7 @@ export class OpenIdEditor extends VariableUiElement {
export class OpenJosm extends Combine { export class OpenJosm extends Combine {
constructor(state: { osmConnection: OsmConnection, currentBounds: UIEventSource<BBox>, }, iconStyle?: string) { constructor(state: { osmConnection: OsmConnection, currentBounds: Store<BBox>, }, iconStyle?: string) {
const t = Translations.t.general.attribution const t = Translations.t.general.attribution
const josmState = new UIEventSource<string>(undefined) const josmState = new UIEventSource<string>(undefined)
@ -98,10 +98,10 @@ export default class CopyrightPanel extends Combine {
constructor(state: { constructor(state: {
layoutToUse: LayoutConfig, layoutToUse: LayoutConfig,
featurePipeline: FeaturePipeline, featurePipeline: FeaturePipeline,
currentBounds: UIEventSource<BBox>, currentBounds: Store<BBox>,
locationControl: UIEventSource<Loc>, locationControl: UIEventSource<Loc>,
osmConnection: OsmConnection, osmConnection: OsmConnection,
isTranslator: UIEventSource<boolean> isTranslator: Store<boolean>
}) { }) {
const t = Translations.t.general.attribution const t = Translations.t.general.attribution

View file

@ -6,7 +6,7 @@ import MapControlButton from "../MapControlButton";
import Svg from "../../Svg"; import Svg from "../../Svg";
import AllDownloads from "./AllDownloads"; import AllDownloads from "./AllDownloads";
import FilterView from "./FilterView"; import FilterView from "./FilterView";
import {UIEventSource} from "../../Logic/UIEventSource"; import {Store, UIEventSource} from "../../Logic/UIEventSource";
import BackgroundMapSwitch from "./BackgroundMapSwitch"; import BackgroundMapSwitch from "./BackgroundMapSwitch";
import Lazy from "../Base/Lazy"; import Lazy from "../Base/Lazy";
import {VariableUiElement} from "../Base/VariableUIElement"; import {VariableUiElement} from "../Base/VariableUIElement";
@ -28,7 +28,7 @@ export default class LeftControls extends Combine {
const currentViewFL = state.currentView?.layer const currentViewFL = state.currentView?.layer
const currentViewAction = new Toggle( const currentViewAction = new Toggle(
new Lazy(() => { new Lazy(() => {
const feature: UIEventSource<any> = state.currentView.features.map(ffs => ffs[0]?.feature) const feature: Store<any> = state.currentView.features.map(ffs => ffs[0]?.feature)
const icon = new VariableUiElement(feature.map(feature => { const icon = new VariableUiElement(feature.map(feature => {
const defaultIcon = Svg.checkbox_empty_svg() const defaultIcon = Svg.checkbox_empty_svg()
if (feature === undefined) { if (feature === undefined) {

View file

@ -11,7 +11,7 @@ import Link from "../Base/Link";
import LinkToWeblate from "../Base/LinkToWeblate"; import LinkToWeblate from "../Base/LinkToWeblate";
import Toggleable from "../Base/Toggleable"; import Toggleable from "../Base/Toggleable";
import Title from "../Base/Title"; import Title from "../Base/Title";
import {UIEventSource} from "../../Logic/UIEventSource"; import {Store, UIEventSource} from "../../Logic/UIEventSource";
import {SubtleButton} from "../Base/SubtleButton"; import {SubtleButton} from "../Base/SubtleButton";
import Svg from "../../Svg"; import Svg from "../../Svg";
import * as native_languages from "../../assets/language_native.json" import * as native_languages from "../../assets/language_native.json"
@ -19,7 +19,7 @@ import * as used_languages from "../../assets/generated/used_languages.json"
import BaseUIElement from "../BaseUIElement"; import BaseUIElement from "../BaseUIElement";
class TranslatorsPanelContent extends Combine { class TranslatorsPanelContent extends Combine {
constructor(layout: LayoutConfig, isTranslator: UIEventSource<boolean>) { constructor(layout: LayoutConfig, isTranslator: Store<boolean>) {
const t = Translations.t.translations const t = Translations.t.translations
const {completeness, untranslated, total} = TranslatorsPanel.MissingTranslationsFor(layout) const {completeness, untranslated, total} = TranslatorsPanel.MissingTranslationsFor(layout)
@ -106,7 +106,7 @@ class TranslatorsPanelContent extends Combine {
export default class TranslatorsPanel extends Toggle { export default class TranslatorsPanel extends Toggle {
constructor(state: { layoutToUse: LayoutConfig, isTranslator: UIEventSource<boolean> }, iconStyle?: string) { constructor(state: { layoutToUse: LayoutConfig, isTranslator: Store<boolean> }, iconStyle?: string) {
const t = Translations.t.translations const t = Translations.t.translations
super( super(
new Lazy(() => new TranslatorsPanelContent(state.layoutToUse, state.isTranslator) new Lazy(() => new TranslatorsPanelContent(state.layoutToUse, state.isTranslator)

View file

@ -6,6 +6,7 @@ import {Utils} from "../../Utils";
import Loc from "../../Models/Loc"; import Loc from "../../Models/Loc";
import {GeoOperations} from "../../Logic/GeoOperations"; import {GeoOperations} from "../../Logic/GeoOperations";
import Minimap from "../Base/Minimap"; import Minimap from "../Base/Minimap";
import BackgroundMapSwitch from "../BigComponents/BackgroundMapSwitch";
/** /**