forked from MapComplete/MapComplete
		
	Use loginToggle, disable upload is gpxApi is offline
This commit is contained in:
		
							parent
							
								
									16aedfec4a
								
							
						
					
					
						commit
						9b0b87c878
					
				
					 1 changed files with 37 additions and 19 deletions
				
			
		|  | @ -4,30 +4,22 @@ import { FixedInputElement } from "../Input/FixedInputElement" | ||||||
| import Combine from "../Base/Combine" | import Combine from "../Base/Combine" | ||||||
| import Translations from "../i18n/Translations" | import Translations from "../i18n/Translations" | ||||||
| import { TextField } from "../Input/TextField" | import { TextField } from "../Input/TextField" | ||||||
| import { UIEventSource } from "../../Logic/UIEventSource" | import { Store, UIEventSource } from "../../Logic/UIEventSource" | ||||||
| import Title from "../Base/Title" | import Title from "../Base/Title" | ||||||
| import { SubtleButton } from "../Base/SubtleButton" | import { SubtleButton } from "../Base/SubtleButton" | ||||||
| import Svg from "../../Svg" | import Svg from "../../Svg" | ||||||
| import { OsmConnection } from "../../Logic/Osm/OsmConnection" | import { OsmConnection } from "../../Logic/Osm/OsmConnection" | ||||||
| import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" | ||||||
| import { Translation } from "../i18n/Translation" | import { Translation } from "../i18n/Translation" | ||||||
|  | import { LoginToggle } from "../Popup/LoginButton" | ||||||
| 
 | 
 | ||||||
| export default class UploadTraceToOsmUI extends Toggle { | export default class UploadTraceToOsmUI extends LoginToggle { | ||||||
|     private static createDefault(s: string, defaultValue: string) { |  | ||||||
|         if (defaultValue.length < 1) { |  | ||||||
|             throw "Default value should have some characters" |  | ||||||
|         } |  | ||||||
|         if (s === undefined || s === null || s === "") { |  | ||||||
|             return defaultValue |  | ||||||
|         } |  | ||||||
|         return s |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     constructor( |     constructor( | ||||||
|         trace: (title: string) => string, |         trace: (title: string) => string, | ||||||
|         state: { |         state: { | ||||||
|             layoutToUse: LayoutConfig |             layoutToUse: LayoutConfig | ||||||
|             osmConnection: OsmConnection |             osmConnection: OsmConnection | ||||||
|  |             readonly featureSwitchUserbadge: Store<boolean> | ||||||
|         }, |         }, | ||||||
|         options?: { |         options?: { | ||||||
|             whenUploaded?: () => void | Promise<void> |             whenUploaded?: () => void | Promise<void> | ||||||
|  | @ -119,15 +111,41 @@ export default class UploadTraceToOsmUI extends Toggle { | ||||||
|         ]).SetClass("flex flex-col p-4 rounded border-2 m-2 border-subtle") |         ]).SetClass("flex flex-col p-4 rounded border-2 m-2 border-subtle") | ||||||
| 
 | 
 | ||||||
|         super( |         super( | ||||||
|             new Combine([Svg.confirm_svg().SetClass("w-12 h-12 mr-2"), t.uploadFinished]).SetClass( |  | ||||||
|                 "flex p-2 rounded-xl border-2 subtle-border items-center" |  | ||||||
|             ), |  | ||||||
|             new Toggle( |             new Toggle( | ||||||
|                 confirmPanel, |                 new Toggle( | ||||||
|                 new SubtleButton(Svg.upload_svg(), t.title).onClick(() => clicked.setData(true)), |                     new Combine([ | ||||||
|                 clicked |                         Svg.confirm_svg().SetClass("w-12 h-12 mr-2"), | ||||||
|  |                         t.uploadFinished, | ||||||
|  |                     ]).SetClass("flex p-2 rounded-xl border-2 subtle-border items-center"), | ||||||
|  |                     new Toggle( | ||||||
|  |                         confirmPanel, | ||||||
|  |                         new SubtleButton(Svg.upload_svg(), t.title).onClick(() => | ||||||
|  |                             clicked.setData(true) | ||||||
|  |                         ), | ||||||
|  |                         clicked | ||||||
|  |                     ), | ||||||
|  |                     uploadFinished | ||||||
|  |                 ), | ||||||
|  |                 new Combine([ | ||||||
|  |                     Svg.invalid_ui().SetClass("w-8 h-8 m-2"), | ||||||
|  |                     t.gpxServiceOffline.SetClass("p-2"), | ||||||
|  |                 ]).SetClass("flex border alert items-center"), | ||||||
|  |                 state.osmConnection.gpxServiceIsOnline.map( | ||||||
|  |                     (serviceState) => serviceState === "online" | ||||||
|  |                 ) | ||||||
|             ), |             ), | ||||||
|             uploadFinished |             undefined, | ||||||
|  |             state | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     private static createDefault(s: string, defaultValue: string) { | ||||||
|  |         if (defaultValue.length < 1) { | ||||||
|  |             throw "Default value should have some characters" | ||||||
|  |         } | ||||||
|  |         if (s === undefined || s === null || s === "") { | ||||||
|  |             return defaultValue | ||||||
|  |         } | ||||||
|  |         return s | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue