forked from MapComplete/MapComplete
More cleanup of code: remove the overly complicated layer selection
This commit is contained in:
parent
257194c063
commit
9777a2666b
13 changed files with 199 additions and 304 deletions
53
UI/Image/DeleteImage.ts
Normal file
53
UI/Image/DeleteImage.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
import {UIElement} from "../UIElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import Translations from "../i18n/Translations";
|
||||
import {CheckBox} from "../Input/CheckBox";
|
||||
import Combine from "../Base/Combine";
|
||||
import {State} from "../../State";
|
||||
import {Tag} from "../../Logic/Tags";
|
||||
|
||||
|
||||
export default class DeleteImage extends UIElement {
|
||||
private readonly key: string;
|
||||
private readonly tags: UIEventSource<any>;
|
||||
|
||||
private readonly isDeletedBadge: UIElement;
|
||||
private readonly deleteDialog: UIElement;
|
||||
|
||||
constructor(key: string, tags: UIEventSource<any>) {
|
||||
super(tags);
|
||||
this.tags = tags;
|
||||
this.key = key;
|
||||
|
||||
this.isDeletedBadge = Translations.t.image.isDeleted;
|
||||
|
||||
const style = "display:block;color:white;width:100%;"
|
||||
const deleteButton = Translations.t.image.doDelete.Clone()
|
||||
.SetStyle(style+"background:#ff8c8c;")
|
||||
.onClick(() => {
|
||||
State.state?.changes.addTag(tags.data.id, new Tag(key, ""));
|
||||
});
|
||||
|
||||
const cancelButton = Translations.t.general.cancel;
|
||||
this.deleteDialog = new CheckBox(
|
||||
new Combine([
|
||||
deleteButton,
|
||||
cancelButton
|
||||
|
||||
]).SetStyle("display:flex;flex-direction:column;"),
|
||||
"<img src='./assets/delete.svg' style='width:1.5em;'>"
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
|
||||
const value = this.tags.data[this.key];
|
||||
if (value === undefined || value === "") {
|
||||
return this.isDeletedBadge.Render();
|
||||
}
|
||||
|
||||
return this.deleteDialog.Render();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,8 @@ import {
|
|||
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 {
|
||||
|
@ -34,16 +36,21 @@ export class ImageCarouselConstructor implements TagDependantUIElementConstructo
|
|||
|
||||
export class ImageCarousel extends TagDependantUIElement {
|
||||
|
||||
public readonly searcher: ImageSearcher;
|
||||
public readonly slideshow: SlideShow;
|
||||
|
||||
constructor(tags: UIEventSource<any>) {
|
||||
super(tags);
|
||||
this.searcher = new ImageSearcher(tags);
|
||||
const uiElements = this.searcher.map((imageURLS: string[]) => {
|
||||
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) {
|
||||
const image = ImageSearcher.CreateImageElement(url);
|
||||
let image = ImageSearcher.CreateImageElement(url.url);
|
||||
if(url.key !== undefined){
|
||||
image = new Combine([
|
||||
image,
|
||||
new DeleteImage(url.key, tags)
|
||||
]);
|
||||
}
|
||||
uiElements.push(image);
|
||||
}
|
||||
return uiElements;
|
||||
|
|
|
@ -4,7 +4,7 @@ import {LicenseInfo} from "../../Logic/Web/Wikimedia";
|
|||
import {Imgur} from "../../Logic/Web/Imgur";
|
||||
|
||||
|
||||
export class ImgurImage extends UIElement {
|
||||
export class ImgurImage extends UIElement {
|
||||
|
||||
|
||||
/***
|
||||
|
|
|
@ -35,7 +35,7 @@ export class WikimediaImage extends UIElement {
|
|||
|
||||
const wikimediaLink =
|
||||
"<a href='https://commons.wikimedia.org/wiki/" + this._imageLocation + "' target='_blank'>" +
|
||||
"<img class='wikimedia-link' src='./assets/wikimedia-commons-white.svg' alt='Wikimedia Commons Logo'/>" +
|
||||
"<img style='width:2em;height: 2em' class='wikimedia-link' src='./assets/wikimedia-commons-white.svg' alt='Wikimedia Commons Logo'/>" +
|
||||
"</a> ";
|
||||
|
||||
const attribution =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue