Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a control button to clear the map #284

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ de:
point: Punkteditor
linestring: Linieneditor
polygon: Flächeneditor
clear_map: "Clear map"
modal:
load: Laden
cancel: Abbrechen
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ en:
point: "Point editor"
linestring: "Line editor"
polygon: "Area editor"
clear_map: "Clear map"
modal:
load: "Load"
cancel: "Cancel"
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ ja:
point: ポイント編集
linestring: ライン編集
polygon: エリア編集
clear_map: "地図をクリア"
modal:
load: 読み込み
cancel: キャンセル
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_gtt/patches/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/components/gtt-client/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,16 @@ export const getObjectPathValue = (obj: any, path: string | Array<string>, 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()
Expand Down
11 changes: 11 additions & 0 deletions src/components/gtt-client/openlayers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ export function setControls(types: Array<string>) {
editbar.addControl(control)
})

// Add the clear map control
const clearMapCtrl = new Button({
html: '<i class="mdi mdi-delete"></i>',
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({
Expand Down
Loading