Merge pull request #13038 from vvlladd28/bug/place-item/multiple-clicl
Fixed place map item action on multiple header button clicks
This commit is contained in:
commit
dc23b15aa7
@ -91,7 +91,7 @@ export interface IWidgetUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaceMapItemActionData {
|
export interface PlaceMapItemActionData {
|
||||||
action: WidgetAction;
|
action: WidgetAction | WidgetActionDescriptor;
|
||||||
additionalParams?: any;
|
additionalParams?: any;
|
||||||
afterPlaceItemCallback: ($event: Event, descriptor: WidgetAction, entityId?: EntityId, entityName?: string,
|
afterPlaceItemCallback: ($event: Event, descriptor: WidgetAction, entityId?: EntityId, entityName?: string,
|
||||||
additionalParams?: any, entityLabel?: string) => void;
|
additionalParams?: any, entityLabel?: string) => void;
|
||||||
|
|||||||
@ -133,6 +133,7 @@ export abstract class TbMap<S extends BaseMapSettings> {
|
|||||||
private currentEditButton: L.TB.ToolbarButton;
|
private currentEditButton: L.TB.ToolbarButton;
|
||||||
|
|
||||||
private dragMode = true;
|
private dragMode = true;
|
||||||
|
private createMapItemActionId: string;
|
||||||
|
|
||||||
private get isPlacingItem(): boolean {
|
private get isPlacingItem(): boolean {
|
||||||
return !!this.currentEditButton;
|
return !!this.currentEditButton;
|
||||||
@ -686,9 +687,14 @@ export abstract class TbMap<S extends BaseMapSettings> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createItem(actionData: PlaceMapItemActionData, prepareDrawMode: () => void) {
|
private createItem(actionData: PlaceMapItemActionData, prepareDrawMode: () => void) {
|
||||||
if (this.isPlacingItem) {
|
const actionId = 'id' in actionData.action ? actionData.action.id : 'map-button';
|
||||||
|
if (this.createMapItemActionId === actionId) {
|
||||||
|
this.finishCreatedItem();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isDefined(this.createMapItemActionId)) {
|
||||||
|
this.finishCreatedItem();
|
||||||
|
}
|
||||||
this.updatePlaceItemState(actionData.additionalParams?.button, true);
|
this.updatePlaceItemState(actionData.additionalParams?.button, true);
|
||||||
|
|
||||||
this.map.once('pm:create', (e) => {
|
this.map.once('pm:create', (e) => {
|
||||||
@ -701,7 +707,7 @@ export abstract class TbMap<S extends BaseMapSettings> {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
e.layer._pmTempLayer = true;
|
e.layer._pmTempLayer = true;
|
||||||
e.layer.remove();
|
e.layer.remove();
|
||||||
this.finishAdd();
|
this.finishCreatedItem();
|
||||||
});
|
});
|
||||||
|
|
||||||
prepareDrawMode();
|
prepareDrawMode();
|
||||||
@ -714,10 +720,12 @@ export abstract class TbMap<S extends BaseMapSettings> {
|
|||||||
iconClass: 'tb-close',
|
iconClass: 'tb-close',
|
||||||
title: this.ctx.translate.instant('action.cancel'),
|
title: this.ctx.translate.instant('action.cancel'),
|
||||||
showText: true,
|
showText: true,
|
||||||
click: this.finishAdd
|
click: this.finishCreatedItem
|
||||||
}
|
}
|
||||||
], false);
|
], false);
|
||||||
|
|
||||||
|
this.createMapItemActionId = actionId;
|
||||||
|
|
||||||
const convertLayerToCoordinates = (type: MapItemType, layer: L.Layer): {x: number; y: number} | TbPolygonRawCoordinates | TbCircleData => {
|
const convertLayerToCoordinates = (type: MapItemType, layer: L.Layer): {x: number; y: number} | TbPolygonRawCoordinates | TbCircleData => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MapItemType.marker:
|
case MapItemType.marker:
|
||||||
@ -749,6 +757,11 @@ export abstract class TbMap<S extends BaseMapSettings> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private finishCreatedItem = () => {
|
||||||
|
delete this.createMapItemActionId;
|
||||||
|
this.finishAdd();
|
||||||
|
}
|
||||||
|
|
||||||
private finishAdd = () => {
|
private finishAdd = () => {
|
||||||
if (this.currentPopover) {
|
if (this.currentPopover) {
|
||||||
this.currentPopover.hide();
|
this.currentPopover.hide();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user