From e391afa1c829c11c7e09d68909de3c3ae86db567 Mon Sep 17 00:00:00 2001 From: Daniel Kastl Date: Tue, 28 May 2024 17:08:16 +0900 Subject: [PATCH 1/2] Adds a clear map control, fixes #282 Signed-off-by: Daniel Kastl --- config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/ja.yml | 1 + lib/redmine_gtt/patches/issue_patch.rb | 2 +- src/components/gtt-client/helpers/index.ts | 14 +++++++++----- src/components/gtt-client/openlayers/index.ts | 11 +++++++++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index dd74f6ce..39288ae4 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -65,6 +65,7 @@ de: point: Punkteditor linestring: Linieneditor polygon: Flächeneditor + clear_map: "Clear map" modal: load: Laden cancel: Abbrechen diff --git a/config/locales/en.yml b/config/locales/en.yml index a20bdc3f..e80ee730 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,6 +105,7 @@ en: point: "Point editor" linestring: "Line editor" polygon: "Area editor" + clear_map: "Clear map" modal: load: "Load" cancel: "Cancel" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index b8d2a711..11a28bd3 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -105,6 +105,7 @@ ja: point: ポイント編集 linestring: ライン編集 polygon: エリア編集 + clear_map: "Clear map" modal: load: 読み込み cancel: キャンセル diff --git a/lib/redmine_gtt/patches/issue_patch.rb b/lib/redmine_gtt/patches/issue_patch.rb index 8b67a38a..b91d6790 100644 --- a/lib/redmine_gtt/patches/issue_patch.rb +++ b/lib/redmine_gtt/patches/issue_patch.rb @@ -29,7 +29,7 @@ def map # (i.e. [140.1250590699026,35.6097256061325] vs [140.1250590699026,35.60972560613251]) def ignore_small_geom_change - unless geom_change[0].nil? + unless geom_change[0].nil? || geom_change[1].nil? if geom_change[0].geometry_type == geom_change[1].geometry_type old_value = geom_change[0].coordinates new_value = geom_change[1].coordinates diff --git a/src/components/gtt-client/helpers/index.ts b/src/components/gtt-client/helpers/index.ts index 52d8ee28..045a7670 100644 --- a/src/components/gtt-client/helpers/index.ts +++ b/src/components/gtt-client/helpers/index.ts @@ -104,12 +104,16 @@ export const getObjectPathValue = (obj: any, path: string | Array, def: * @param updateAddressFlag - A flag to update the address field with reverse geocoding, default is false. */ export function updateForm(mapObj: any, features: FeatureLike[] | null, updateAddressFlag: boolean = false):void { - if (features == null) { - return - } - const geom = document.querySelector('#geom') as HTMLInputElement + + const geom = document.querySelector('#geom') as HTMLInputElement; if (!geom) { - return + return; + } + + if (features == null) { + // Clear the geom input field + geom.value = ''; + return; } const writer = new GeoJSON() diff --git a/src/components/gtt-client/openlayers/index.ts b/src/components/gtt-client/openlayers/index.ts index 34aaf0bb..1f995d60 100644 --- a/src/components/gtt-client/openlayers/index.ts +++ b/src/components/gtt-client/openlayers/index.ts @@ -201,6 +201,17 @@ export function setControls(types: Array) { editbar.addControl(control) }) + // Add the clear map control + const clearMapCtrl = new Button({ + html: '', + title: this.i18n.control.clear_map, + handleClick: () => { + this.vector.getSource().clear(); + updateForm(this, null); + } + }); + editbar.addControl(clearMapCtrl); + // Uses jQuery UI for GeoJSON Upload modal window const mapObj = this const dialog = $("#dialog-geojson-upload").dialog({ From 0f31d5dd26e6e993bb61959484ccf68242855239 Mon Sep 17 00:00:00 2001 From: Taro Matsuzawa Date: Thu, 30 May 2024 08:55:47 +0900 Subject: [PATCH 2/2] #284 update config/locales/ja --- config/locales/ja.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 11a28bd3..ab75a747 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -105,7 +105,7 @@ ja: point: ポイント編集 linestring: ライン編集 polygon: エリア編集 - clear_map: "Clear map" + clear_map: "地図をクリア" modal: load: 読み込み cancel: キャンセル