Optimize rendering

This commit is contained in:
Pieter Vander Vennet 2020-10-14 12:15:09 +02:00
parent 8babafaadb
commit a721d3137a
21 changed files with 361 additions and 362 deletions

View file

@ -23,8 +23,6 @@ import * as bike_shops from "../../assets/layers/bike_shop/bike_shop.json"
import * as maps from "../../assets/layers/maps/maps.json"
import * as information_boards from "../../assets/layers/information_board/information_board.json"
import {Utils} from "../../Utils";
import ImageCarouselWithUploadConstructor from "../../UI/Image/ImageCarouselWithUpload";
import {ImageCarouselConstructor} from "../../UI/Image/ImageCarousel";
import State from "../../State";
export class FromJSON {
@ -139,23 +137,15 @@ export class FromJSON {
if (typeof json === "string") {
switch (json) {
case "picture": {
return new ImageCarouselWithUploadConstructor()
}
case "pictures": {
return new ImageCarouselWithUploadConstructor()
}
case "image": {
return new ImageCarouselWithUploadConstructor()
json = "{image_carousel()}{image_upload()}";
break;
}
case "images": {
return new ImageCarouselWithUploadConstructor()
}
case "picturesNoUpload": {
return new ImageCarouselConstructor()
json = "{image_carousel()}{image_upload()}";
}
}
console.warn("Possible literal rendering:", json)
return new TagRenderingOptions({
freeform: {

View file

@ -16,9 +16,9 @@ export class OnlyShowIfConstructor implements TagDependantUIElementConstructor{
this._embedded = embedded;
}
construct(dependencies): TagDependantUIElement {
return new OnlyShowIf(dependencies.tags,
this._embedded.construct(dependencies),
construct(tags: UIEventSource<any>): TagDependantUIElement {
return new OnlyShowIf(tags,
this._embedded.construct(tags),
this._tagsFilter);
}

View file

@ -1,4 +1,4 @@
import {Dependencies, TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor";
import {TagDependantUIElement, TagDependantUIElementConstructor} from "./UIElementConstructor";
import {TagsFilter, TagUtils} from "../Logic/Tags";
import {OnlyShowIfConstructor} from "./OnlyShowIf";
import {UIEventSource} from "../Logic/UIEventSource";
@ -137,8 +137,8 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor {
mappings?: { k: TagsFilter; txt: string | Translation; priority?: number; substitute?: boolean, hideInAnswer?: boolean }[]
}) => TagDependantUIElement;
construct(dependencies: Dependencies): TagDependantUIElement {
return TagRenderingOptions.tagRendering(dependencies.tags, this.options);
construct(tags: UIEventSource<any>): TagDependantUIElement {
return TagRenderingOptions.tagRendering(tags, this.options);
}
IsKnown(properties: any): boolean {

View file

@ -2,14 +2,9 @@ import {UIElement} from "../UI/UIElement";
import {UIEventSource} from "../Logic/UIEventSource";
import Translation from "../UI/i18n/Translation";
export interface Dependencies {
tags: UIEventSource<any>
}
export interface TagDependantUIElementConstructor {
construct(dependencies: Dependencies): TagDependantUIElement;
construct(tags: UIEventSource<any>): TagDependantUIElement;
IsKnown(properties: any): boolean;
IsQuestioning(properties: any): boolean;
GetContent(tags: any): Translation;