2020-09-13 03:29:44 +02:00
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
|
|
|
import Translations from "../i18n/Translations";
|
2021-06-10 01:36:20 +02:00
|
|
|
import Toggle from "../Input/Toggle";
|
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-11-06 04:02:53 +01:00
|
|
|
import Svg from "../../Svg";
|
2021-03-29 00:41:53 +02:00
|
|
|
import {Tag} from "../../Logic/Tags/Tag";
|
2020-09-13 03:29:44 +02:00
|
|
|
|
|
|
|
|
2021-06-15 16:18:58 +02:00
|
|
|
export default class DeleteImage extends Toggle {
|
2020-09-13 03:29:44 +02:00
|
|
|
|
|
|
|
constructor(key: string, tags: UIEventSource<any>) {
|
2021-06-15 16:18:58 +02:00
|
|
|
const oldValue = tags.data[key]
|
|
|
|
const isDeletedBadge = Translations.t.image.isDeleted.Clone()
|
|
|
|
.SetClass("rounded-full p-1")
|
|
|
|
.SetStyle("color:white;background:#ff8c8c")
|
|
|
|
.onClick(() => {
|
|
|
|
State.state?.changes?.addTag(tags.data.id, new Tag(key, oldValue), tags);
|
|
|
|
});
|
2020-09-13 03:29:44 +02:00
|
|
|
|
|
|
|
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(() => {
|
2021-06-15 16:18:58 +02:00
|
|
|
State.state?.changes?.addTag(tags.data.id, new Tag(key, ""), tags);
|
2020-09-13 03:29:44 +02:00
|
|
|
});
|
|
|
|
|
2021-06-15 16:18:58 +02:00
|
|
|
const cancelButton = Translations.t.general.cancel.Clone().SetClass("bg-white pl-4 pr-4").SetStyle("border-bottom-left-radius:30rem; border-bottom-right-radius: 30rem;");
|
|
|
|
const openDelete = Svg.delete_icon_svg().SetStyle("width: 2em; height: 2em; display:block;")
|
|
|
|
const deleteDialog = new Toggle(
|
2020-09-13 03:29:44 +02:00
|
|
|
new Combine([
|
|
|
|
deleteButton,
|
|
|
|
cancelButton
|
2021-02-06 00:05:38 +01:00
|
|
|
]).SetClass("flex flex-col background-black"),
|
2021-06-15 16:18:58 +02:00
|
|
|
openDelete
|
|
|
|
)
|
|
|
|
|
|
|
|
cancelButton.onClick(() => deleteDialog.isEnabled.setData(false))
|
|
|
|
openDelete.onClick(() => deleteDialog.isEnabled.setData(true))
|
|
|
|
|
|
|
|
super(
|
|
|
|
new Toggle(
|
|
|
|
deleteDialog,
|
|
|
|
isDeletedBadge,
|
|
|
|
tags.map(tags => (tags[key] ?? "") !== "")
|
|
|
|
),
|
|
|
|
undefined /*Login (and thus editing) is disabled*/,
|
|
|
|
State.state?.featureSwitchUserbadge ?? new UIEventSource<boolean>(true)
|
|
|
|
)
|
|
|
|
this.SetClass("cursor-pointer")
|
2020-09-13 03:29:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|