forked from MapComplete/MapComplete
Add test
This commit is contained in:
parent
b888a6da36
commit
7a87d41649
2 changed files with 27 additions and 8 deletions
|
@ -7,6 +7,7 @@ import {TagsFilter} from "../../Tags/TagsFilter"
|
||||||
import {And} from "../../Tags/And"
|
import {And} from "../../Tags/And"
|
||||||
import {Tag} from "../../Tags/Tag"
|
import {Tag} from "../../Tags/Tag"
|
||||||
import {Utils} from "../../../Utils";
|
import {Utils} from "../../../Utils";
|
||||||
|
import {OsmId} from "../../../Models/OsmFeature";
|
||||||
|
|
||||||
export default class DeleteAction extends OsmChangeAction {
|
export default class DeleteAction extends OsmChangeAction {
|
||||||
private readonly _softDeletionTags: TagsFilter
|
private readonly _softDeletionTags: TagsFilter
|
||||||
|
@ -15,12 +16,13 @@ export default class DeleteAction extends OsmChangeAction {
|
||||||
specialMotivation: string
|
specialMotivation: string
|
||||||
changeType: "deletion"
|
changeType: "deletion"
|
||||||
}
|
}
|
||||||
private readonly _id: string
|
private readonly _id: OsmId
|
||||||
private _hardDelete: boolean
|
private readonly _hardDelete: boolean
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
id: string,
|
id: OsmId,
|
||||||
softDeletionTags: TagsFilter,
|
softDeletionTags: TagsFilter | undefined,
|
||||||
meta: {
|
meta: {
|
||||||
theme: string
|
theme: string
|
||||||
specialMotivation: string
|
specialMotivation: string
|
||||||
|
@ -43,9 +45,25 @@ export default class DeleteAction extends OsmChangeAction {
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {
|
*
|
||||||
const osmObject = await OsmObject.DownloadObjectAsync(this._id)
|
* import {OsmNode} from "../OsmObject"
|
||||||
|
*
|
||||||
|
* const obj : OsmNode= new OsmNode(1)
|
||||||
|
* obj.tags = {id:"node/1",name:"Monte Piselli - San Giacomo"}
|
||||||
|
* const da = new DeleteAction("node/1", new Tag("man_made",""), {theme: "test", specialMotivation: "Testcase"}, true)
|
||||||
|
* const descr = await da.CreateChangeDescriptions(new Changes(), obj)
|
||||||
|
* descr[0] // => {doDelete: true, meta: {theme: "test", specialMotivation: "Testcase",changeType: "deletion"}, type: "node",id: 1 }
|
||||||
|
*
|
||||||
|
* // Must not crash if softDeletionTags are undefined
|
||||||
|
* const da = new DeleteAction("node/1", undefined, {theme: "test", specialMotivation: "Testcase"}, true)
|
||||||
|
* const obj : OsmNode= new OsmNode(1)
|
||||||
|
* obj.tags = {id:"node/1",name:"Monte Piselli - San Giacomo"}
|
||||||
|
* const descr = await da.CreateChangeDescriptions(new Changes(), obj)
|
||||||
|
* descr[0] // => {doDelete: true, meta: {theme: "test", specialMotivation: "Testcase", changeType: "deletion"}, type: "node",id: 1 }
|
||||||
|
*/
|
||||||
|
public async CreateChangeDescriptions(changes: Changes, object?: OsmObject): Promise<ChangeDescription[]> {
|
||||||
|
const osmObject = object ?? await OsmObject.DownloadObjectAsync(this._id)
|
||||||
|
|
||||||
if (this._hardDelete) {
|
if (this._hardDelete) {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -22,6 +22,7 @@ import Title from "../Base/Title"
|
||||||
import { SubstitutedTranslation } from "../SubstitutedTranslation"
|
import { SubstitutedTranslation } from "../SubstitutedTranslation"
|
||||||
import FeaturePipelineState from "../../Logic/State/FeaturePipelineState"
|
import FeaturePipelineState from "../../Logic/State/FeaturePipelineState"
|
||||||
import TagRenderingQuestion from "./TagRenderingQuestion"
|
import TagRenderingQuestion from "./TagRenderingQuestion"
|
||||||
|
import {OsmId} from "../../Models/OsmFeature";
|
||||||
|
|
||||||
export default class DeleteWizard extends Toggle {
|
export default class DeleteWizard extends Toggle {
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +44,7 @@ export default class DeleteWizard extends Toggle {
|
||||||
* @param state: the state of the application
|
* @param state: the state of the application
|
||||||
* @param options softDeletionTags: the tags to apply if the user doesn't have permission to delete, e.g. 'disused:amenity=public_bookcase', 'amenity='. After applying, the element should not be picked up on the map anymore. If undefined, the wizard will only show up if the point can be (hard) deleted
|
* @param options softDeletionTags: the tags to apply if the user doesn't have permission to delete, e.g. 'disused:amenity=public_bookcase', 'amenity='. After applying, the element should not be picked up on the map anymore. If undefined, the wizard will only show up if the point can be (hard) deleted
|
||||||
*/
|
*/
|
||||||
constructor(id: string, state: FeaturePipelineState, options: DeleteConfig) {
|
constructor(id: OsmId, state: FeaturePipelineState, options: DeleteConfig) {
|
||||||
const deleteAbility = new DeleteabilityChecker(id, state, options.neededChangesets)
|
const deleteAbility = new DeleteabilityChecker(id, state, options.neededChangesets)
|
||||||
const tagsSource = state.allElements.getEventSourceById(id)
|
const tagsSource = state.allElements.getEventSourceById(id)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue