forked from MapComplete/MapComplete
		
	UX: add unlink button, simplify unlink code
This commit is contained in:
		
							parent
							
								
									45c0f1a8d6
								
							
						
					
					
						commit
						1192434b45
					
				
					 13 changed files with 117 additions and 69 deletions
				
			
		|  | @ -34,6 +34,9 @@ export default class GenericImageProvider extends ImageProvider { | |||
|                 provider: this, | ||||
|                 id: value, | ||||
|                 isSpherical: undefined, | ||||
|                 originalAttribute: { | ||||
|                     key, value | ||||
|                 } | ||||
|             }, | ||||
|         ] | ||||
|     } | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ export interface ProvidedImage { | |||
|     host?: string | ||||
|     isSpherical: boolean | ||||
|     license?: LicenseInfo | ||||
|     originalAttribute?: {key: string, value: string} | ||||
| } | ||||
| 
 | ||||
| export interface PanoramaView { | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ export class Imgur extends ImageProvider { | |||
|                     provider: this, | ||||
|                     id: value, | ||||
|                     isSpherical: false, | ||||
|                     originalAttribute: {key, value} | ||||
|                 }, | ||||
|             ] | ||||
|         } | ||||
|  |  | |||
|  | @ -170,8 +170,7 @@ export class Mapillary extends ImageProvider { | |||
|             properties: { | ||||
|                 url: response.thumb_2048_url, | ||||
|                 northOffset: response.computed_compass_angle, | ||||
|                 provider: this, | ||||
|                 imageMeta: <any>image | ||||
|                 provider: this | ||||
|             }, | ||||
|         } | ||||
|     } | ||||
|  | @ -246,6 +245,7 @@ export class Mapillary extends ImageProvider { | |||
|                 response.camera_type === "spherical" || response.camera_type === "equirectangular", | ||||
|             lat: geometry.coordinates[1], | ||||
|             lon: geometry.coordinates[0], | ||||
|             originalAttribute: {key, value} | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -174,6 +174,7 @@ export default class PanoramaxImageProvider extends ImageProvider { | |||
|         } | ||||
|         const providedImage = await this.getInfo(value) | ||||
|         providedImage.alt_id = alt_id | ||||
|         providedImage.originalAttribute = {key, value} | ||||
|         return [providedImage] | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -61,7 +61,11 @@ export class WikidataImageProvider extends ImageProvider { | |||
|             allImages.push(promises) | ||||
|         } | ||||
|         const resolved = await Promise.all(Utils.NoNull(allImages)) | ||||
|         return [].concat(...resolved) | ||||
|         const flattened = resolved.flatMap( x => x) | ||||
|         if(flattened.length === 1){ | ||||
|             flattened[0].originalAttribute = {key, value} | ||||
|         } | ||||
|         return flattened | ||||
|     } | ||||
| 
 | ||||
|     public DownloadAttribution(): Promise<undefined> { | ||||
|  |  | |||
|  | @ -145,14 +145,14 @@ export class WikimediaImageProvider extends ImageProvider { | |||
|                 .map((image) => this.UrlForImage(image)) | ||||
|         } | ||||
|         if (value.startsWith("File:")) { | ||||
|             return [this.UrlForImage(value)] | ||||
|             return [this.UrlForImage(value, key, value)] | ||||
|         } | ||||
|         if (value.startsWith("http")) { | ||||
|             // Probably an error
 | ||||
|             return undefined | ||||
|         } | ||||
|         // We do a last effort and assume this is a file
 | ||||
|         return [this.UrlForImage("File:" + value)] | ||||
|         return [this.UrlForImage("File:" + value, key, value)] | ||||
|     } | ||||
| 
 | ||||
|     public async DownloadAttribution(img: { id: string }): Promise<LicenseInfo> { | ||||
|  | @ -211,9 +211,9 @@ export class WikimediaImageProvider extends ImageProvider { | |||
|         return licenseInfo | ||||
|     } | ||||
| 
 | ||||
|     private UrlForImage(image: string): ProvidedImage { | ||||
|     private UrlForImage(image: string, key?: string, value?: string): ProvidedImage { | ||||
|         image = "File:" + WikimediaImageProvider.makeCanonical(image) | ||||
|         return { | ||||
|         const providedImage: ProvidedImage = { | ||||
|             url: WikimediaImageProvider.PrepareUrl(image), | ||||
|             url_hd: WikimediaImageProvider.PrepareUrl(image, true), | ||||
|             key: undefined, | ||||
|  | @ -221,6 +221,10 @@ export class WikimediaImageProvider extends ImageProvider { | |||
|             id: image, | ||||
|             isSpherical: false, | ||||
|         } | ||||
|         if(key && value){ | ||||
|             providedImage.originalAttribute = {key, value} | ||||
|         } | ||||
|         return providedImage | ||||
|     } | ||||
| 
 | ||||
|     getPanoramaInfo(): Promise<Feature<Point, PanoramaView>> | undefined { | ||||
|  |  | |||
|  | @ -200,7 +200,6 @@ export default class UserRelatedState { | |||
|     public static readonly usersettingsConfig = UserRelatedState.initUserSettingsState() | ||||
|     public static readonly availableUserSettingsIds: string[] = | ||||
|         UserRelatedState.usersettingsConfig?.tagRenderings?.map((tr) => tr.id) ?? [] | ||||
|     public static readonly SHOW_TAGS_VALUES = ["always", "yes", "full"] as const | ||||
|     /** | ||||
|      The user credentials | ||||
|      */ | ||||
|  | @ -212,6 +211,7 @@ export default class UserRelatedState { | |||
|     public readonly installedUserThemes: Store<string[]> | ||||
|     public readonly showAllQuestionsAtOnce: UIEventSource<boolean> | ||||
|     public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full"> | ||||
|     public readonly showTagsB: Store<boolean> | ||||
|     public readonly showCrosshair: UIEventSource<"yes" | "always" | "no" | undefined> | ||||
|     public readonly translationMode: UIEventSource<"false" | "true" | "mobile" | undefined | string> | ||||
| 
 | ||||
|  | @ -269,6 +269,20 @@ export default class UserRelatedState { | |||
|         ) | ||||
|         this.language = this.osmConnection.getPreference("language") | ||||
|         this.showTags = this.osmConnection.getPreference("show_tags") | ||||
|         this.showTagsB = this.showTags.map(showTags => { | ||||
|             if (showTags === "always" || showTags === "full") { | ||||
|                 return true | ||||
|             } | ||||
|             if (showTags === "no") { | ||||
|                 return false | ||||
|             } | ||||
|             const userdetails = this.osmConnection.userDetails.data | ||||
|             if (!userdetails) { | ||||
|                 return false | ||||
|             } | ||||
|             const csCount = userdetails.csCount | ||||
|             return csCount >= Constants.userJourney.tagsVisibleAt | ||||
|         }, [this.osmConnection.userDetails]) | ||||
|         this.showCrosshair = this.osmConnection.getPreference("show_crosshair") | ||||
|         this.fixateNorth = this.osmConnection.getPreference("fixate-north") | ||||
|         this.morePrivacy = this.osmConnection.getPreference("more_privacy", { defaultValue: "no" }) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue