| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  | import State from "../../../State"; | 
					
						
							|  |  |  | import {OsmObject} from "../OsmObject"; | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  | import OsmChangeAction from "./OsmChangeAction"; | 
					
						
							|  |  |  | import {Changes} from "../Changes"; | 
					
						
							|  |  |  | import {ChangeDescription} from "./ChangeDescription"; | 
					
						
							|  |  |  | import ChangeTagAction from "./ChangeTagAction"; | 
					
						
							|  |  |  | import {TagsFilter} from "../../Tags/TagsFilter"; | 
					
						
							|  |  |  | import {And} from "../../Tags/And"; | 
					
						
							|  |  |  | import {Tag} from "../../Tags/Tag"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default class DeleteAction extends OsmChangeAction { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private readonly _softDeletionTags: TagsFilter; | 
					
						
							|  |  |  |     private readonly meta: { | 
					
						
							|  |  |  |         theme: string, | 
					
						
							|  |  |  |         specialMotivation: string, | 
					
						
							|  |  |  |         changeType: "deletion" | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |     private readonly _id: string; | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  |     private _hardDelete: boolean; | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-01 02:26:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  |     constructor(id: string, | 
					
						
							|  |  |  |                 softDeletionTags: TagsFilter, | 
					
						
							|  |  |  |                 meta: { | 
					
						
							|  |  |  |                     theme: string, | 
					
						
							|  |  |  |                     specialMotivation: string | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 hardDelete: boolean) { | 
					
						
							|  |  |  |         super() | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |         this._id = id; | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  |         this._hardDelete = hardDelete; | 
					
						
							|  |  |  |         this.meta = {...meta, changeType: "deletion"}; | 
					
						
							|  |  |  |         this._softDeletionTags = new And([softDeletionTags, | 
					
						
							|  |  |  |             new Tag("fixme", `A mapcomplete user marked this feature to be deleted (${meta.specialMotivation})`) | 
					
						
							|  |  |  |         ]); | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-01 02:26:45 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  |     protected async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const osmObject = await OsmObject.DownloadObjectAsync(this._id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (this._hardDelete) { | 
					
						
							|  |  |  |             return [{ | 
					
						
							|  |  |  |                 meta: this.meta, | 
					
						
							|  |  |  |                 doDelete: true, | 
					
						
							|  |  |  |                 type: osmObject.type, | 
					
						
							|  |  |  |                 id: osmObject.id, | 
					
						
							|  |  |  |             }] | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return await new ChangeTagAction( | 
					
						
							|  |  |  |                 this._id, this._softDeletionTags, osmObject.tags, | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     theme: State.state?.layoutToUse?.id ?? "unkown", | 
					
						
							|  |  |  |                     changeType: "soft-delete" | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-10-04 03:12:42 +02:00
										 |  |  |             ).CreateChangeDescriptions(changes) | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |