UX: fix #2089, improve background selection hotkeys and add emoji to indicate categories of background layers

This commit is contained in:
Pieter Vander Vennet 2024-08-23 03:47:04 +02:00
parent 5b67ccc9e2
commit 2dc386fd9a
15 changed files with 600 additions and 525 deletions

View file

@ -19,13 +19,14 @@ export default class BackgroundLayerResetter {
return
}
currentBackgroundLayer.addCallbackAndRunD((l) => {
currentBackgroundLayer.addCallbackAndRunD(async (l) => {
if (
l.geometry !== undefined &&
AvailableRasterLayers.globalLayers.find(
(global) => global.properties.id !== l.properties.id
)
) {
await AvailableRasterLayers.editorLayerIndex()
BackgroundLayerResetter.installHandler(
currentBackgroundLayer,
availableLayers.store

View file

@ -61,9 +61,9 @@ export class PreferredRasterLayerSelector {
* Returns 'true' if the target layer is set or is the current layer
* @private
*/
private updateLayer() {
private async updateLayer() {
// What is the ID of the layer we have to (try to) load?
const targetLayerId = this._queryParameter.data ?? this._preferredBackgroundLayer.data
const targetLayerId = (this._queryParameter.data ?? this._preferredBackgroundLayer.data)?.toLowerCase()
if (targetLayerId === undefined || targetLayerId === "default") {
return
}
@ -74,12 +74,13 @@ export class PreferredRasterLayerSelector {
this._rasterLayerSetting.setData(global)
return
}
await AvailableRasterLayers.editorLayerIndex()
const isCategory =
targetLayerId === "photo" || targetLayerId === "osmbasedmap" || targetLayerId === "map"
const available = this._availableLayers.store.data
const foundLayer = isCategory
? available.find((l) => l.properties.category === targetLayerId)
: available.find((l) => l.properties.id === targetLayerId)
: available.find((l) => l.properties.id.toLowerCase() === targetLayerId)
console.debug("Updating background layer to", foundLayer?.id, {
targetLayerId,
queryParam: this._queryParameter?.data,