forked from MapComplete/MapComplete
Refactoring of deleteWizard
This commit is contained in:
parent
b941fb2983
commit
fd90914c35
8 changed files with 207 additions and 206 deletions
|
@ -1,23 +1,43 @@
|
|||
import {Translation} from "../../UI/i18n/Translation";
|
||||
import {Translation, TypedTranslation} from "../../UI/i18n/Translation";
|
||||
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
||||
import {DeleteConfigJson} from "./Json/DeleteConfigJson";
|
||||
import Translations from "../../UI/i18n/Translations";
|
||||
import {TagUtils} from "../../Logic/Tags/TagUtils";
|
||||
|
||||
export default class DeleteConfig {
|
||||
public static readonly defaultDeleteReasons : {changesetMessage: string, explanation: Translation} [] = [
|
||||
{
|
||||
changesetMessage: "testing point",
|
||||
explanation: Translations.t.delete.reasons.test
|
||||
},
|
||||
{
|
||||
changesetMessage:"disused",
|
||||
explanation: Translations.t.delete.reasons.disused
|
||||
},
|
||||
{
|
||||
changesetMessage: "not found",
|
||||
explanation: Translations.t.delete.reasons.notFound
|
||||
},
|
||||
{
|
||||
changesetMessage: "duplicate",
|
||||
explanation:Translations.t.delete.reasons.duplicate
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
public readonly extraDeleteReasons?: {
|
||||
explanation: Translation,
|
||||
explanation: TypedTranslation<object>,
|
||||
changesetMessage: string
|
||||
}[]
|
||||
|
||||
public readonly nonDeleteMappings?: { if: TagsFilter, then: Translation }[]
|
||||
public readonly nonDeleteMappings?: { if: TagsFilter, then: TypedTranslation<object> }[]
|
||||
|
||||
public readonly softDeletionTags?: TagsFilter
|
||||
public readonly neededChangesets?: number
|
||||
|
||||
constructor(json: DeleteConfigJson, context: string) {
|
||||
|
||||
this.extraDeleteReasons = json.extraDeleteReasons?.map((reason, i) => {
|
||||
this.extraDeleteReasons = (json.extraDeleteReasons ?? []).map((reason, i) => {
|
||||
const ctx = `${context}.extraDeleteReasons[${i}]`
|
||||
if ((reason.changesetMessage ?? "").length <= 5) {
|
||||
throw `${ctx}.explanation is too short, needs at least 4 characters`
|
||||
|
@ -27,7 +47,7 @@ export default class DeleteConfig {
|
|||
changesetMessage: reason.changesetMessage
|
||||
}
|
||||
})
|
||||
this.nonDeleteMappings = json.nonDeleteMappings?.map((nonDelete, i) => {
|
||||
this.nonDeleteMappings = (json.nonDeleteMappings??[]).map((nonDelete, i) => {
|
||||
const ctx = `${context}.extraDeleteReasons[${i}]`
|
||||
return {
|
||||
if: TagUtils.Tag(nonDelete.if, ctx + ".if"),
|
||||
|
|
|
@ -36,7 +36,17 @@ export interface DeleteConfigJson {
|
|||
* By adding a 'nonDeleteMapping', an option can be added into the list which will retag the feature.
|
||||
* It is important that the feature will be retagged in such a way that it won't be picked up by the layer anymore!
|
||||
*/
|
||||
nonDeleteMappings?: { if: AndOrTagConfigJson, then: string | any }[],
|
||||
nonDeleteMappings?: {
|
||||
/**
|
||||
* The tags that will be given to the object.
|
||||
* This must remove tags so that the 'source/osmTags' won't match anymore
|
||||
*/
|
||||
if: AndOrTagConfigJson,
|
||||
/**
|
||||
* The human explanation for the options
|
||||
*/
|
||||
then: string | any,
|
||||
}[],
|
||||
|
||||
/**
|
||||
* In some cases, the contributor is not allowed to delete the current feature (e.g. because it isn't a point, the point is referenced by a relation or the user isn't experienced enough).
|
||||
|
@ -63,4 +73,5 @@ export interface DeleteConfigJson {
|
|||
* For some small features (e.g. bicycle racks) this is too much and this requirement can be lowered or dropped, which can be done here.
|
||||
*/
|
||||
neededChangesets?: number
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue