Feature: add 'copy-button' capabilities

This commit is contained in:
Pieter Vander Vennet 2025-07-07 18:26:04 +02:00
parent 3d442d0558
commit 2f89f9203d
6 changed files with 204 additions and 10 deletions

View file

@ -408,6 +408,12 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
delete json.allowSplit
}
if (json.allowCopy && !usedSpecialFunctions.has("create_copy")) {
json.tagRenderings.push({
id: "create_copy",
render: { "*": "{create_copy()}" },
})
}
if (json.allowMove && !usedSpecialFunctions.has("move_button")) {
json.tagRenderings.push({
id: "move-button",
@ -421,6 +427,14 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
})
}
const spacerIndex = json.tagRenderings.findIndex(item => item?.["id"] === "spacer")
if (spacerIndex >= 0) {
json.tagRenderings.splice(spacerIndex, 1)
}
json.tagRenderings.push({
id: "spacer",
render: { "*": "<div class='m-4'/>" },
})
json.tagRenderings.push(...this._addedByDefault.filter((tr) => !allIds.has(tr.id)))
if (!usedSpecialFunctions.has("all_tags")) {
@ -893,7 +907,7 @@ class AddFavouriteBadges extends DesugaringStep<LayerConfigJson> {
const pr = json.pointRendering?.[0]
if (pr) {
pr.iconBadges ??= []
if (!pr.iconBadges.some((ti) => ti.if === "_favourite=yes")) {
if (!pr.iconBadges.some((ti) => ti["if"] === "_favourite=yes")) {
pr.iconBadges.push({ if: "_favourite=yes", then: "circle:white;heart:red" })
}
}