2020-09-13 03:29:44 +02:00
|
|
|
import {UIElement} from "../UIElement";
|
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
|
|
|
import Translations from "../i18n/Translations";
|
2020-10-02 19:00:24 +02:00
|
|
|
import CheckBox from "../Input/CheckBox";
|
2020-09-13 03:29:44 +02:00
|
|
|
import Combine from "../Base/Combine";
|
2020-10-02 19:00:24 +02:00
|
|
|
import State from "../../State";
|
2020-09-13 03:29:44 +02:00
|
|
|
import {Tag} from "../../Logic/Tags";
|
2020-11-06 04:02:53 +01:00
|
|
|
import Svg from "../../Svg";
|
2020-09-13 03:29:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
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 deleteButton = Translations.t.image.doDelete.Clone()
|
2021-02-06 00:05:38 +01:00
|
|
|
.SetClass("block w-full pl-4 pr-4")
|
|
|
|
.SetStyle("color:white;background:#ff8c8c; border-top-left-radius:30rem; border-top-right-radius: 30rem;")
|
2020-09-13 03:29:44 +02:00
|
|
|
.onClick(() => {
|
|
|
|
State.state?.changes.addTag(tags.data.id, new Tag(key, ""));
|
|
|
|
});
|
|
|
|
|
2021-02-06 00:05:38 +01:00
|
|
|
const cancelButton = Translations.t.general.cancel.SetClass("bg-white pl-4 pr-4").SetStyle( "border-bottom-left-radius:30rem; border-bottom-right-radius: 30rem;");
|
2020-09-13 03:29:44 +02:00
|
|
|
this.deleteDialog = new CheckBox(
|
|
|
|
new Combine([
|
|
|
|
deleteButton,
|
|
|
|
cancelButton
|
2021-02-06 00:05:38 +01:00
|
|
|
]).SetClass("flex flex-col background-black"),
|
|
|
|
Svg.delete_icon_svg().SetStyle("width: 2em; height: 2em; display:block;")
|
2020-09-13 03:29:44 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
2021-01-29 03:23:53 +01:00
|
|
|
if(! State.state?.featureSwitchUserbadge?.data){
|
2020-11-13 23:58:11 +01:00
|
|
|
return "";
|
|
|
|
}
|
2020-09-13 03:29:44 +02:00
|
|
|
|
|
|
|
const value = this.tags.data[this.key];
|
|
|
|
if (value === undefined || value === "") {
|
|
|
|
return this.isDeletedBadge.Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.deleteDialog.Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|