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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue