forked from MapComplete/MapComplete
Themes: disable 'disused' from delete config, delete less fast for shops but use softdeletion instead
This commit is contained in:
parent
53ea4273df
commit
28e737ed2e
5 changed files with 37 additions and 13 deletions
|
@ -637,12 +637,27 @@
|
|||
"softDeletionTags": {
|
||||
"and": [
|
||||
"shop=",
|
||||
"phone=",
|
||||
"website=",
|
||||
"email=",
|
||||
"opening_hours=",
|
||||
"disused:shop:={shop}"
|
||||
]
|
||||
},
|
||||
"extraDeleteReasons": [
|
||||
"omitDefaultDeleteReasons": ["disused"],
|
||||
"nonDeleteMappings": [
|
||||
{
|
||||
"explanation": {
|
||||
"if": {
|
||||
"and": [
|
||||
"shop=",
|
||||
"phone=",
|
||||
"website=",
|
||||
"email=",
|
||||
"opening_hours=",
|
||||
"disused:shop:={shop}"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"nl": "{title()} is permanent gestopt",
|
||||
"en": "{title()} has closed down permanently",
|
||||
"de": "{title()} wurde dauerhaft geschlossen",
|
||||
|
@ -650,8 +665,7 @@
|
|||
"fr": "{title()} a fermé définitivement",
|
||||
"ca": "{title()} ha tancat permanentment",
|
||||
"cs": "{title()} je trvale uzavřen"
|
||||
},
|
||||
"changesetMessage": "shop_closed"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -35,11 +35,9 @@ export default class DeleteConfig {
|
|||
explanation: TypedTranslation<object> | Translation
|
||||
changesetMessage: string
|
||||
}[]
|
||||
|
||||
private readonly nonDeleteMappings?: { if: TagConfigJson; then: Translation }[]
|
||||
|
||||
public readonly softDeletionTags?: TagsFilter
|
||||
public readonly neededChangesets?: number
|
||||
private readonly nonDeleteMappings?: { if: TagConfigJson; then: Translation }[]
|
||||
|
||||
constructor(json: DeleteConfigJson, context: string) {
|
||||
this.deleteReasons = (json.extraDeleteReasons ?? []).map((reason, i) => {
|
||||
|
@ -53,8 +51,17 @@ export default class DeleteConfig {
|
|||
}
|
||||
})
|
||||
|
||||
if (!json.omitDefaultDeleteReasons) {
|
||||
for (const defaultDeleteReason of DeleteConfig.defaultDeleteReasons) {
|
||||
{
|
||||
let deleteReasons = DeleteConfig.defaultDeleteReasons
|
||||
if (json.omitDefaultDeleteReasons === true) {
|
||||
deleteReasons = []
|
||||
} else if (json.omitDefaultDeleteReasons) {
|
||||
const forbidden = <string[]>json.omitDefaultDeleteReasons
|
||||
deleteReasons = deleteReasons.filter(
|
||||
(dl) => forbidden.indexOf(dl.changesetMessage) < 0
|
||||
)
|
||||
}
|
||||
for (const defaultDeleteReason of deleteReasons) {
|
||||
this.deleteReasons.push({
|
||||
changesetMessage: defaultDeleteReason.changesetMessage,
|
||||
explanation:
|
||||
|
@ -117,6 +124,7 @@ export default class DeleteConfig {
|
|||
mappings,
|
||||
id: "why-delete",
|
||||
}
|
||||
console.log("Delete config", config)
|
||||
return new TagRenderingConfig(config)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
import { UploadableTag } from "../../../Logic/Tags/TagUtils"
|
||||
|
||||
export interface DeleteConfigJson {
|
||||
/***
|
||||
|
@ -100,5 +101,5 @@ export interface DeleteConfigJson {
|
|||
* iffalse: Show the default delete reasons
|
||||
* ifunset: Show the default delete reasons (default behaviour)
|
||||
*/
|
||||
omitDefaultDeleteReasons?: false | boolean
|
||||
omitDefaultDeleteReasons?: false | boolean | ("disused" | string)[]
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
import type { Feature } from "geojson"
|
||||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||
import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
|
||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||
import type { UploadableTag } from "../../../Logic/Tags/TagUtils"
|
||||
import OsmChangeAction from "../../../Logic/Osm/Actions/OsmChangeAction"
|
||||
import DeleteAction from "../../../Logic/Osm/Actions/DeleteAction"
|
||||
import ChangeTagAction from "../../../Logic/Osm/Actions/ChangeTagAction"
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
const t = Translations.t.delete
|
||||
|
||||
let selectedTags: TagsFilter
|
||||
let selectedTags: UploadableTag
|
||||
let changedProperties = undefined
|
||||
$: changedProperties = TagUtils.changeAsProperties(selectedTags?.asChange(tags?.data ?? {}) ?? [])
|
||||
let isHardDelete = undefined
|
||||
|
|
|
@ -988,6 +988,7 @@ export default class SpecialVisualizations {
|
|||
return undefined
|
||||
}
|
||||
return new SvelteUIElement(SpecialTranslation, {
|
||||
t: title,
|
||||
tags: tagsSource,
|
||||
state,
|
||||
feature,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue