| 
									
										
										
										
											2021-01-04 04:06:21 +01:00
										 |  |  | import {VariableUiElement} from "../Base/VariableUIElement"; | 
					
						
							|  |  |  | import Svg from "../../Svg"; | 
					
						
							|  |  |  | import Combine from "../Base/Combine"; | 
					
						
							|  |  |  | import {SubtleButton} from "../Base/SubtleButton"; | 
					
						
							|  |  |  | import Translations from "../i18n/Translations"; | 
					
						
							| 
									
										
										
										
											2021-07-26 18:02:55 +02:00
										 |  |  | import * as personal from "../../assets/themes/personal/personal.json" | 
					
						
							| 
									
										
										
										
											2021-01-04 04:06:21 +01:00
										 |  |  | import Constants from "../../Models/Constants"; | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  | import BaseUIElement from "../BaseUIElement"; | 
					
						
							| 
									
										
										
										
											2021-08-07 23:11:34 +02:00
										 |  |  | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  | import {UIEventSource} from "../../Logic/UIEventSource"; | 
					
						
							|  |  |  | import Loc from "../../Models/Loc"; | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  | import {OsmConnection} from "../../Logic/Osm/OsmConnection"; | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  | import UserRelatedState from "../../Logic/State/UserRelatedState"; | 
					
						
							|  |  |  | import Toggle from "../Input/Toggle"; | 
					
						
							|  |  |  | import {Utils} from "../../Utils"; | 
					
						
							|  |  |  | import Title from "../Base/Title"; | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  | import * as themeOverview from "../../assets/generated/theme_overview.json" | 
					
						
							|  |  |  | import {Translation} from "../i18n/Translation"; | 
					
						
							| 
									
										
										
										
											2020-07-29 15:48:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  | export default class MoreScreen extends Combine { | 
					
						
							| 
									
										
										
										
											2020-07-29 15:48:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-17 21:04:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |     constructor(state: UserRelatedState & { | 
					
						
							|  |  |  |         locationControl?: UIEventSource<Loc>, | 
					
						
							|  |  |  |         layoutToUse?: LayoutConfig | 
					
						
							|  |  |  |     }, onMainScreen: boolean = false) { | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |         const tr = Translations.t.general.morescreen; | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         let themeButtonStyle = "" | 
					
						
							|  |  |  |         let themeListStyle = "" | 
					
						
							|  |  |  |         if (onMainScreen) { | 
					
						
							|  |  |  |             themeButtonStyle = "h-32 min-h-32 max-h-32 overflow-ellipsis overflow-hidden" | 
					
						
							|  |  |  |             themeListStyle = "md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-g4 gap-4" | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |         super([ | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |             MoreScreen.createOfficialThemesList(state, themeButtonStyle).SetClass(themeListStyle), | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |             MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle, themeListStyle), | 
					
						
							|  |  |  |             MoreScreen.createUnofficialThemeList(themeButtonStyle, state, themeListStyle), | 
					
						
							| 
									
										
										
										
											2021-06-13 15:04:55 +02:00
										 |  |  |             tr.streetcomplete.Clone().SetClass("block text-base mx-10 my-3 mb-10") | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |         ]); | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Creates a button linking to the given theme | 
					
						
							|  |  |  |      * @private | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static createLinkButton( | 
					
						
							|  |  |  |         state: { | 
					
						
							|  |  |  |             locationControl?: UIEventSource<Loc>, | 
					
						
							|  |  |  |             layoutToUse?: LayoutConfig | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |         }, layout: { | 
					
						
							|  |  |  |             id: string, | 
					
						
							|  |  |  |             icon: string, | 
					
						
							|  |  |  |             title: any, | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  |             shortDescription: any, | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |             definition?: any, | 
					
						
							|  |  |  |             mustHaveLanguage?: boolean | 
					
						
							| 
									
										
										
										
											2021-12-21 20:57:25 +01:00
										 |  |  |         }, isCustom: boolean = false | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |     ): | 
					
						
							|  |  |  |         BaseUIElement { | 
					
						
							|  |  |  |         if (layout === undefined) { | 
					
						
							|  |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (layout.id === undefined) { | 
					
						
							|  |  |  |             console.error("ID is undefined for layout", layout); | 
					
						
							|  |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (layout.id === state?.layoutToUse?.id) { | 
					
						
							|  |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const currentLocation = state?.locationControl; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         let path = window.location.pathname; | 
					
						
							|  |  |  |         // Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
 | 
					
						
							|  |  |  |         path = path.substr(0, path.lastIndexOf("/")); | 
					
						
							|  |  |  |         // Path will now contain '/dir/dir', or empty string in case of nothing
 | 
					
						
							|  |  |  |         if (path === "") { | 
					
						
							|  |  |  |             path = "." | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         let linkPrefix = `${path}/${layout.id.toLowerCase()}.html?` | 
					
						
							|  |  |  |         if (location.hostname === "localhost" || location.hostname === "127.0.0.1") { | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |             linkPrefix = `${path}/theme.html?layout=${layout.id}&` | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 20:57:25 +01:00
										 |  |  |         if (isCustom) { | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |             linkPrefix = `${path}/theme.html?userlayout=${layout.id}&` | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  |         let hash = "" | 
					
						
							|  |  |  |         if(layout.definition !== undefined){ | 
					
						
							|  |  |  |             hash = "#"+btoa(JSON.stringify(layout.definition)) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |         const linkText = currentLocation?.map(currentLocation => { | 
					
						
							|  |  |  |             const params = [ | 
					
						
							|  |  |  |                 ["z", currentLocation?.zoom], | 
					
						
							|  |  |  |                 ["lat", currentLocation?.lat], | 
					
						
							|  |  |  |                 ["lon", currentLocation?.lon] | 
					
						
							|  |  |  |             ].filter(part => part[1] !== undefined) | 
					
						
							|  |  |  |                 .map(part => part[0] + "=" + part[1]) | 
					
						
							|  |  |  |                 .join("&") | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  |             return `${linkPrefix}${params}${hash}`; | 
					
						
							| 
									
										
										
										
											2021-12-21 20:57:25 +01:00
										 |  |  |         }) ?? new UIEventSource<string>(`${linkPrefix}`) | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |         return new SubtleButton(layout.icon, | 
					
						
							|  |  |  |             new Combine([ | 
					
						
							|  |  |  |                 `<dt class='text-lg leading-6 font-medium text-gray-900 group-hover:text-blue-800'>`, | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |                 new Translation(layout.title, !isCustom && !layout.mustHaveLanguage ? "themes:"+layout.id+".title" : undefined), | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |                 `</dt>`, | 
					
						
							|  |  |  |                 `<dd class='mt-1 text-base text-gray-500 group-hover:text-blue-900 overflow-ellipsis'>`, | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |                 new Translation(layout.shortDescription)?.SetClass("subtle") ?? "", | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |                 `</dd>`, | 
					
						
							|  |  |  |             ]), {url: linkText, newTab: false}); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 21:26:07 +01:00
										 |  |  |     public static CreateProffessionalSerivesButton() { | 
					
						
							| 
									
										
										
										
											2022-01-18 00:09:01 +01:00
										 |  |  |         const t = Translations.t.professional.indexPage; | 
					
						
							|  |  |  |         return new Combine([ | 
					
						
							|  |  |  |             new Title(t.hook, 4), | 
					
						
							|  |  |  |             t.hookMore, | 
					
						
							|  |  |  |             new SubtleButton(undefined, t.button, {url: "./professional.html"}), | 
					
						
							|  |  |  |         ]).SetClass("flex flex-col border border-gray-300 p-2 rounded-lg") | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-08 18:29:21 +01:00
										 |  |  |     private static createUnofficialButtonFor(state: UserRelatedState, id: string): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |         const allPreferences = state.osmConnection.preferencesHandler.preferences.data; | 
					
						
							| 
									
										
										
										
											2022-02-08 18:29:21 +01:00
										 |  |  |         const length = Number(allPreferences[id + "-length"]) | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |         let str = ""; | 
					
						
							|  |  |  |         for (let i = 0; i < length; i++) { | 
					
						
							|  |  |  |             str += allPreferences[id + "-" + i] | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-10 23:16:14 +01:00
										 |  |  |         if(str === undefined || str === "undefined"){ | 
					
						
							|  |  |  |             return undefined | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |         try { | 
					
						
							|  |  |  |             const value: { | 
					
						
							|  |  |  |                 id: string | 
					
						
							|  |  |  |                 icon: string, | 
					
						
							|  |  |  |                 title: any, | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  |                 shortDescription: any, | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |                 definition?: any, | 
					
						
							|  |  |  |                 isOfficial: boolean | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |             } = JSON.parse(str) | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |             value.isOfficial = false | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |             return MoreScreen.createLinkButton(state, value, true) | 
					
						
							|  |  |  |         } catch (e) { | 
					
						
							| 
									
										
										
										
											2022-02-08 18:29:21 +01:00
										 |  |  |             console.debug("Could not parse unofficial theme information for " + id, "The json is: ", str, e) | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |             return undefined | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |     private static createUnofficialThemeList(buttonClass: string, state: UserRelatedState, themeListClasses): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-02-04 14:36:26 +01:00
										 |  |  |         const prefix = "mapcomplete-unofficial-theme-"; | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         var currentIds: UIEventSource<string[]> = state.osmConnection.preferencesHandler.preferences | 
					
						
							|  |  |  |             .map(allPreferences => { | 
					
						
							|  |  |  |                 const ids: string[] = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 for (const key in allPreferences) { | 
					
						
							|  |  |  |                     if (key.startsWith(prefix) && key.endsWith("-combined-length")) { | 
					
						
							|  |  |  |                         const id = key.substring(0, key.length - "-length".length) | 
					
						
							|  |  |  |                         ids.push(id) | 
					
						
							| 
									
										
										
										
											2022-02-04 14:36:26 +01:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return ids | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2022-02-10 23:16:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |         var stableIds = UIEventSource.ListStabilized<string>(currentIds) | 
					
						
							| 
									
										
										
										
											2022-02-10 23:16:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |         return new VariableUiElement( | 
					
						
							|  |  |  |             stableIds.map(ids => { | 
					
						
							|  |  |  |                 const allThemes: BaseUIElement[] = [] | 
					
						
							|  |  |  |                 for (const id of ids) { | 
					
						
							| 
									
										
										
										
											2022-02-08 18:29:21 +01:00
										 |  |  |                     const link = this.createUnofficialButtonFor(state, id) | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  |                     if (link !== undefined) { | 
					
						
							|  |  |  |                         allThemes.push(link.SetClass(buttonClass)) | 
					
						
							| 
									
										
										
										
											2022-02-04 14:36:26 +01:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-02-04 15:48:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (allThemes.length <= 0) { | 
					
						
							|  |  |  |                     return undefined; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 return new Combine([ | 
					
						
							|  |  |  |                     Translations.t.general.customThemeIntro.Clone(), | 
					
						
							|  |  |  |                     new Combine(allThemes).SetClass(themeListClasses) | 
					
						
							|  |  |  |                 ]); | 
					
						
							|  |  |  |             })); | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string, themeListStyle: string) { | 
					
						
							|  |  |  |         const t = Translations.t.general.morescreen | 
					
						
							|  |  |  |         const prefix = "mapcomplete-hidden-theme-" | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |         const hiddenThemes = themeOverview["default"].filter(layout => layout.hideFromOverview) | 
					
						
							|  |  |  |         const hiddenTotal = hiddenThemes.length | 
					
						
							| 
									
										
										
										
											2022-01-18 00:09:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |         return new Toggle( | 
					
						
							|  |  |  |             new VariableUiElement( | 
					
						
							|  |  |  |                 state.osmConnection.preferencesHandler.preferences.map(allPreferences => { | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |                     const knownThemes: Set<string> = new Set(Utils.NoNull(Object.keys(allPreferences) | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |                         .filter(key => key.startsWith(prefix)) | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |                         .map(key => key.substring(prefix.length, key.length - "-enabled".length)))); | 
					
						
							| 
									
										
										
										
											2022-01-18 00:09:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     if (knownThemes.size === 0) { | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |                         return undefined | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2022-01-18 00:09:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     const knownThemeDescriptions = hiddenThemes.filter(theme => knownThemes.has(theme.id)) | 
					
						
							|  |  |  |                         .map(theme => MoreScreen.createLinkButton(state, theme)?.SetClass(buttonClass)); | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |                     const knownLayouts = new Combine(knownThemeDescriptions).SetClass(themeListStyle) | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     return new Combine([ | 
					
						
							|  |  |  |                         new Title(t.previouslyHiddenTitle), | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |                         t.hiddenExplanation.Subs({ | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |                             hidden_discovered: "" + knownThemes.size, | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |                             total_hidden: "" + hiddenTotal | 
					
						
							|  |  |  |                         }), | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |                         knownLayouts | 
					
						
							|  |  |  |                     ]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |                 }) | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |             ).SetClass("flex flex-col"), | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |             undefined, | 
					
						
							|  |  |  |             state.osmConnection.isLoggedIn | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |     private static createOfficialThemesList(state: { osmConnection: OsmConnection, locationControl?: UIEventSource<Loc> }, buttonClass: string): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2021-12-21 18:35:31 +01:00
										 |  |  |         let officialThemes = themeOverview["default"]; | 
					
						
							| 
									
										
										
										
											2021-06-23 03:00:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         let buttons = officialThemes.map((layout) => { | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |             if (layout === undefined) { | 
					
						
							| 
									
										
										
										
											2021-07-12 13:38:38 +02:00
										 |  |  |                 console.trace("Layout is undefined") | 
					
						
							|  |  |  |                 return undefined | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |             if (layout.hideFromOverview) { | 
					
						
							| 
									
										
										
										
											2021-10-15 19:58:02 +02:00
										 |  |  |                 return undefined; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |             const button = MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass); | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |             if (layout.id === personal.id) { | 
					
						
							| 
									
										
										
										
											2021-06-23 03:00:21 +02:00
										 |  |  |                 return new VariableUiElement( | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |                     state.osmConnection.userDetails.map(userdetails => userdetails.csCount) | 
					
						
							| 
									
										
										
										
											2021-06-23 03:00:21 +02:00
										 |  |  |                         .map(csCount => { | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |                             if (csCount < Constants.userJourney.personalLayoutUnlock) { | 
					
						
							| 
									
										
										
										
											2021-06-23 03:00:21 +02:00
										 |  |  |                                 return undefined | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |                             } else { | 
					
						
							| 
									
										
										
										
											2021-06-23 03:00:21 +02:00
										 |  |  |                                 return button | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         }) | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return button; | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 00:09:01 +01:00
										 |  |  |         const professional = MoreScreen.CreateProffessionalSerivesButton(); | 
					
						
							|  |  |  |         const customGeneratorLink = MoreScreen.createCustomGeneratorButton(state) | 
					
						
							|  |  |  |         buttons.splice(0, 0, customGeneratorLink, professional); | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         return new Combine(buttons) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* | 
					
						
							|  |  |  |     * Returns either a link to the issue tracker or a link to the custom generator, depending on the achieved number of changesets | 
					
						
							|  |  |  |     * */ | 
					
						
							| 
									
										
										
										
											2021-10-15 05:20:02 +02:00
										 |  |  |     private static createCustomGeneratorButton(state: { osmConnection: OsmConnection }): VariableUiElement { | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         const tr = Translations.t.general.morescreen; | 
					
						
							|  |  |  |         return new VariableUiElement( | 
					
						
							|  |  |  |             state.osmConnection.userDetails.map(userDetails => { | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |                 if (userDetails.csCount < Constants.userJourney.themeGeneratorReadOnlyUnlock) { | 
					
						
							| 
									
										
										
										
											2021-06-13 15:04:55 +02:00
										 |  |  |                     return new SubtleButton(null, tr.requestATheme.Clone(), { | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |                         url: "https://github.com/pietervdvn/MapComplete/issues", | 
					
						
							|  |  |  |                         newTab: true | 
					
						
							|  |  |  |                     }); | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-06-13 15:04:55 +02:00
										 |  |  |                 return new SubtleButton(Svg.pencil_ui(), tr.createYourOwnTheme.Clone(), { | 
					
						
							| 
									
										
										
										
											2021-06-18 16:19:07 +02:00
										 |  |  |                     url: "https://pietervdvn.github.io/mc/legacy/070/customGenerator.html", | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |                     newTab: false | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |             }) | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-05-30 00:17:31 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-29 15:48:21 +02:00
										 |  |  | } |