import {UIElement} from "../UIElement"; import {ImageSearcher} from "../../Logic/ImageSearcher"; import {SlideShow} from "../SlideShow"; import {UIEventSource} from "../../Logic/UIEventSource"; import { Dependencies, TagDependantUIElement, TagDependantUIElementConstructor } from "../../Customizations/UIElementConstructor"; import Translation from "../i18n/Translation"; import Combine from "../Base/Combine"; import DeleteImage from "./DeleteImage"; export class ImageCarouselConstructor implements TagDependantUIElementConstructor { IsKnown(properties: any): boolean { return true; } IsQuestioning(properties: any): boolean { return false; } Priority(): number { return 0; } construct(dependencies: Dependencies): TagDependantUIElement { return new ImageCarousel(dependencies.tags); } GetContent(tags: any): Translation { return new Translation({"en":"Images without upload"}); } } export class ImageCarousel extends TagDependantUIElement { public readonly slideshow: SlideShow; constructor(tags: UIEventSource) { super(tags); const searcher : UIEventSource<{url:string}[]> = new ImageSearcher(tags); const uiElements = searcher.map((imageURLS: {key: string, url:string}[]) => { const uiElements: UIElement[] = []; for (const url of imageURLS) { let image = ImageSearcher.CreateImageElement(url.url); if(url.key !== undefined){ image = new Combine([ image, new DeleteImage(url.key, tags) ]); } uiElements.push(image); } return uiElements; }); this.slideshow = new SlideShow(uiElements).HideOnEmpty(true); } InnerRender(): string { return this.slideshow.Render(); } IsKnown(): boolean { return true; } IsQuestioning(): boolean { return false; } IsSkipped(): boolean { return false; } Priority(): number { return 0; } }