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";
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|