Skip to content

Commit

Permalink
Handle active tab logic
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kastl <[email protected]>
  • Loading branch information
dkastl committed Jun 4, 2024
1 parent 7c55b94 commit be2a79d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/gtt-client/openlayers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export function setControls(types: Array<string>) {
html: `<i class="mdi ${mdi}" ></i>`,
title: this.i18n.control[type.toLowerCase()],
interaction: draw,
active: (type === geometryType),
active: false,
onToggle: (active: boolean) => {
modify.setActive(false);
if (active) {
Expand All @@ -266,6 +266,7 @@ export function setControls(types: Array<string>) {
editbar.addControl(control)
})

// Add the edit control
const editModeControl = new Toggle({
html: '<i class="mdi mdi-pencil"></i>',
title: this.i18n.control.edit_mode,
Expand All @@ -286,6 +287,16 @@ export function setControls(types: Array<string>) {
});
editbar.addControl(editModeControl);

// if the vector layer is not empty, set the editModeControl to active
if (this.vector.getSource().getFeatures().length > 0) {
editModeControl.setActive(true);
}
// otherwise set the first draw control to active
else {
const firstControl = editbar.getControls()[0] as Toggle;
firstControl.setActive(true);
}

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

0 comments on commit be2a79d

Please sign in to comment.