Merge branches

This commit is contained in:
Pieter Vander Vennet 2022-01-21 02:25:56 +01:00
commit e58b93e562
4 changed files with 66 additions and 13 deletions

View file

@ -83,12 +83,15 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti
} }
} }
const tagsFilter = Array.from(layer.appliedFilters.data.values()); const appliedFilters = layer.appliedFilters?.data
for (const filter of tagsFilter ?? []) { if(appliedFilters !== undefined){
const neededTags : TagsFilter = filter?.currentFilter const tagsFilter = Array.from(appliedFilters.values());
if (neededTags !== undefined && !neededTags.matchesProperties(f.feature.properties)) { for (const filter of tagsFilter ?? []) {
// Hidden by the filter on the layer itself - we want to hide it no matter wat const neededTags : TagsFilter = filter?.currentFilter
return false; if (neededTags !== undefined && !neededTags.matchesProperties(f.feature.properties)) {
// Hidden by the filter on the layer itself - we want to hide it no matter wat
return false;
}
} }
} }

View file

@ -2,7 +2,7 @@ import {Utils} from "../Utils";
export default class Constants { export default class Constants {
public static vNumber = "0.14.1"; public static vNumber = "0.14.2";
public static ImgurApiKey = '7070e7167f0a25a' public static ImgurApiKey = '7070e7167f0a25a'
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85" public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"

View file

@ -11,6 +11,7 @@ import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson";
import {Translation} from "../../../UI/i18n/Translation"; import {Translation} from "../../../UI/i18n/Translation";
import {SubstitutedTranslation} from "../../../UI/SubstitutedTranslation"; import {SubstitutedTranslation} from "../../../UI/SubstitutedTranslation";
import DependencyCalculator from "../DependencyCalculator"; import DependencyCalculator from "../DependencyCalculator";
import Translations from "../../../UI/i18n/Translations";
class SubstituteLayer extends Conversion<(string | LayerConfigJson), LayerConfigJson[]> { class SubstituteLayer extends Conversion<(string | LayerConfigJson), LayerConfigJson[]> {
constructor() { constructor() {
@ -178,7 +179,7 @@ class AddImportLayers extends DesugaringStep<LayoutConfigJson> {
} }
} }
class AddMiniMap extends DesugaringStep<LayerConfigJson> { export class AddMiniMap extends DesugaringStep<LayerConfigJson> {
constructor() { constructor() {
super("Adds a default 'minimap'-element to the tagrenderings if none of the elements define such a minimap", ["tagRenderings"]); super("Adds a default 'minimap'-element to the tagrenderings if none of the elements define such a minimap", ["tagRenderings"]);
} }
@ -187,8 +188,9 @@ class AddMiniMap extends DesugaringStep<LayerConfigJson> {
* Returns true if this tag rendering has a minimap in some language. * Returns true if this tag rendering has a minimap in some language.
* Note: this minimap can be hidden by conditions * Note: this minimap can be hidden by conditions
*/ */
private static hasMinimap(renderingConfig: TagRenderingConfigJson): boolean { public static hasMinimap(renderingConfig: TagRenderingConfigJson): boolean {
const translations: Translation[] = Utils.NoNull([renderingConfig.render, ...(renderingConfig.mappings ?? []).map(m => m.then)]); const translations: Translation[] = Utils.NoNull([renderingConfig.render, ...(renderingConfig.mappings ?? []).map(m => m.then)])
.map(Translations.T);
for (const translation of translations) { for (const translation of translations) {
for (const key in translation.translations) { for (const key in translation.translations) {
if (!translation.translations.hasOwnProperty(key)) { if (!translation.translations.hasOwnProperty(key)) {

View file

@ -1,5 +1,5 @@
import T from "./TestHelper"; import T from "./TestHelper";
import {FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"; import {AddMiniMap, FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"; import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"; import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson"; import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson";
@ -146,14 +146,62 @@ export default class LegacyThemeLoaderSpec extends T {
["Walking_node_theme", () => { ["Walking_node_theme", () => {
const config = LegacyThemeLoaderSpec.walking_node_theme const config = LegacyThemeLoaderSpec.walking_node_theme
const fixed = new FixLegacyTheme().convert({tagRenderings: new Map<string, TagRenderingConfigJson>(), sharedLayers: new Map<string, LayerConfigJson>()}, const fixed = new FixLegacyTheme().convert({
tagRenderings: new Map<string, TagRenderingConfigJson>(),
sharedLayers: new Map<string, LayerConfigJson>()
},
// @ts-ignore // @ts-ignore
config, config,
"While testing") "While testing")
T.isTrue(fixed.errors.length === 0, "Could not fix the legacy theme") T.isTrue(fixed.errors.length === 0, "Could not fix the legacy theme")
const theme = new LayoutConfig(fixed.result) const theme = new LayoutConfig(fixed.result)
}] }],
["Detect minimaps", () => {
function shouldHave(config: TagRenderingConfigJson) {
T.equals(AddMiniMap.hasMinimap(config), true, "Did _not_ dected a minimap, even though there is one in " + JSON.stringify(config))
}
function shouldNot(config: TagRenderingConfigJson) {
T.equals(AddMiniMap.hasMinimap(config), false, "Did erronously dected a minimap, even though there is none in " + JSON.stringify(config))
}
shouldHave({
render: "{minimap()}"
});
shouldHave({
render: {en:"{minimap()}"}
});
shouldHave({
render: {en:"{minimap()}",nl:"{minimap()}"}
});
shouldHave({
render: {en:"{minimap()}",nl:"No map for the dutch!"}
});
shouldHave({
render: "{minimap()}"
})
shouldHave({
render: "{minimap(18,featurelist)}"
})
shouldHave({
mappings: [
{
if: "xyz=abc",
then: "{minimap(18,featurelist)}"
}
]
})
shouldNot({
render: "Some random value {key}"
})
shouldNot({
render: "Some random value {minimap}"
})
}
]
] ]
); );
} }