mapcomplete/UI/BigComponents/LicensePicker.ts

35 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-06-11 22:51:45 +02:00
import {DropDown} from "../Input/DropDown";
import Translations from "../i18n/Translations";
2021-06-14 19:21:33 +02:00
import {UIEventSource} from "../../Logic/UIEventSource";
2021-12-21 18:35:31 +01:00
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
import {Translation} from "../i18n/Translation";
2021-06-11 22:51:45 +02:00
export default class LicensePicker extends DropDown<string> {
private static readonly cc0 = "CC0"
private static readonly ccbysa = "CC-BY-SA 4.0"
private static readonly ccby = "CC-BY 4.0"
2021-12-21 18:35:31 +01:00
constructor(state: {osmConnection: OsmConnection}) {
2021-06-15 00:55:12 +02:00
super(Translations.t.image.willBePublished.Clone(),
2021-06-11 22:51:45 +02:00
[
{value:LicensePicker. cc0, shown: Translations.t.image.cco.Clone()},
{value:LicensePicker. ccbysa, shown: Translations.t.image.ccbs.Clone()},
{value: LicensePicker. ccby, shown: Translations.t.image.ccb.Clone()}
2021-06-11 22:51:45 +02:00
],
2021-12-21 18:35:31 +01:00
state?.osmConnection?.GetPreference("pictures-license") ?? new UIEventSource<string>("CC0")
2021-06-11 22:51:45 +02:00
)
this.SetClass("flex flex-col sm:flex-row").SetStyle("float:left");
2021-06-11 22:51:45 +02:00
}
public static LicenseExplanations() : Map<string, Translation>{
let dict = new Map<string, Translation>();
dict.set(LicensePicker. cc0, Translations.t.image.ccoExplanation)
dict.set(LicensePicker. ccby, Translations.t.image.ccbExplanation)
dict.set(LicensePicker. ccbysa, Translations.t.image.ccbsExplanation)
return dict
}
2021-06-11 22:51:45 +02:00
}