|
|
@ -33,7 +33,8 @@ import { |
|
|
formattedDataArrayFromDatasourceData, |
|
|
formattedDataArrayFromDatasourceData, |
|
|
formattedDataFormDatasourceData, |
|
|
formattedDataFormDatasourceData, |
|
|
isDefined, |
|
|
isDefined, |
|
|
isDefinedAndNotNull, isUndefined, |
|
|
isDefinedAndNotNull, |
|
|
|
|
|
isUndefined, |
|
|
mergeDeepIgnoreArray |
|
|
mergeDeepIgnoreArray |
|
|
} from '@core/utils'; |
|
|
} from '@core/utils'; |
|
|
import { DeepPartial } from '@shared/models/common'; |
|
|
import { DeepPartial } from '@shared/models/common'; |
|
|
@ -48,7 +49,7 @@ import { |
|
|
UnplacedMapDataItem, |
|
|
UnplacedMapDataItem, |
|
|
} from '@home/components/widget/lib/maps/data-layer/map-data-layer'; |
|
|
} from '@home/components/widget/lib/maps/data-layer/map-data-layer'; |
|
|
import { IWidgetSubscription, WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
|
|
import { IWidgetSubscription, WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
|
|
import { FormattedData, MapItemType, WidgetAction, WidgetActionType, widgetType } from '@shared/models/widget.models'; |
|
|
import { FormattedData, MapItemType, WidgetAction, widgetType } from '@shared/models/widget.models'; |
|
|
import { EntityDataPageLink } from '@shared/models/query/query.models'; |
|
|
import { EntityDataPageLink } from '@shared/models/query/query.models'; |
|
|
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; |
|
|
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; |
|
|
import { TbMarkersDataLayer } from '@home/components/widget/lib/maps/data-layer/markers-data-layer'; |
|
|
import { TbMarkersDataLayer } from '@home/components/widget/lib/maps/data-layer/markers-data-layer'; |
|
|
@ -545,66 +546,67 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
title: customTranslate.transform(actionButton.label) |
|
|
title: customTranslate.transform(actionButton.label) |
|
|
}; |
|
|
}; |
|
|
const toolbarButton = this.customActionsToolbar.toolbarButton(actionButtonConfig); |
|
|
const toolbarButton = this.customActionsToolbar.toolbarButton(actionButtonConfig); |
|
|
if (actionButton.action.type !== WidgetActionType.placeMapItem) { |
|
|
toolbarButton.onClick((e, button) => this.ctx.actionsApi.handleWidgetAction(e, actionButton.action, null, null, {button})); |
|
|
toolbarButton.onClick((e) => this.ctx.actionsApi.handleWidgetAction(e, actionButton.action)); |
|
|
|
|
|
} else { |
|
|
|
|
|
switch (actionButton.action.mapItemType) { |
|
|
|
|
|
case MapItemType.marker: |
|
|
|
|
|
toolbarButton.onClick((e, button) => this.createMarker(e, {button, action: actionButton.action})); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.polygon: |
|
|
|
|
|
toolbarButton.onClick((e, button) => this.createPolygon(e, {button, action: actionButton.action})); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.rectangle: |
|
|
|
|
|
toolbarButton.onClick((e, button) => this.createRectangle(e, {button, action: actionButton.action})); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.circle: |
|
|
|
|
|
toolbarButton.onClick((e, button) => this.createCircle(e, {button, action: actionButton.action})); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createMarker(e: MouseEvent, actionData: CustomActionData) { |
|
|
public placeMapItem(actionData: CustomActionData): void { |
|
|
this.createItem(e, actionData, () => this.prepareDrawMode('Marker', { |
|
|
switch (actionData.action.mapItemType) { |
|
|
|
|
|
case MapItemType.marker: |
|
|
|
|
|
this.createMarker(actionData); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.polygon: |
|
|
|
|
|
this.createPolygon(actionData); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.rectangle: |
|
|
|
|
|
this.createRectangle(actionData); |
|
|
|
|
|
break; |
|
|
|
|
|
case MapItemType.circle: |
|
|
|
|
|
this.createCircle(actionData); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private createMarker(actionData: CustomActionData) { |
|
|
|
|
|
this.createItem(actionData, () => this.prepareDrawMode('Marker', { |
|
|
placeMarker: this.ctx.translate.instant('widgets.maps.data-layer.marker.place-marker-hint') |
|
|
placeMarker: this.ctx.translate.instant('widgets.maps.data-layer.marker.place-marker-hint') |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createRectangle(e: MouseEvent, actionData: CustomActionData): void { |
|
|
private createRectangle(actionData: CustomActionData): void { |
|
|
this.createItem(e, actionData, () => this.prepareDrawMode('Rectangle', { |
|
|
this.createItem(actionData, () => this.prepareDrawMode('Rectangle', { |
|
|
firstVertex: this.ctx.translate.instant('widgets.maps.data-layer.polygon.rectangle-place-first-point-hint'), |
|
|
firstVertex: this.ctx.translate.instant('widgets.maps.data-layer.polygon.rectangle-place-first-point-hint'), |
|
|
finishRect: this.ctx.translate.instant('widgets.maps.data-layer.polygon.finish-rectangle-hint') |
|
|
finishRect: this.ctx.translate.instant('widgets.maps.data-layer.polygon.finish-rectangle-hint') |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createPolygon(e: MouseEvent, actionData: CustomActionData): void { |
|
|
private createPolygon(actionData: CustomActionData): void { |
|
|
this.createItem(e, actionData, () => this.prepareDrawMode('Polygon', { |
|
|
this.createItem(actionData, () => this.prepareDrawMode('Polygon', { |
|
|
firstVertex: this.ctx.translate.instant('widgets.maps.data-layer.polygon.polygon-place-first-point-hint'), |
|
|
firstVertex: this.ctx.translate.instant('widgets.maps.data-layer.polygon.polygon-place-first-point-hint'), |
|
|
continueLine: this.ctx.translate.instant('widgets.maps.data-layer.polygon.continue-polygon-hint'), |
|
|
continueLine: this.ctx.translate.instant('widgets.maps.data-layer.polygon.continue-polygon-hint'), |
|
|
finishPoly: this.ctx.translate.instant('widgets.maps.data-layer.polygon.finish-polygon-hint') |
|
|
finishPoly: this.ctx.translate.instant('widgets.maps.data-layer.polygon.finish-polygon-hint') |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createCircle(e: MouseEvent, actionData: CustomActionData): void { |
|
|
private createCircle(actionData: CustomActionData): void { |
|
|
this.createItem(e, actionData, () => this.prepareDrawMode('Circle', { |
|
|
this.createItem(actionData, () => this.prepareDrawMode('Circle', { |
|
|
startCircle: this.ctx.translate.instant('widgets.maps.data-layer.circle.place-circle-center-hint'), |
|
|
startCircle: this.ctx.translate.instant('widgets.maps.data-layer.circle.place-circle-center-hint'), |
|
|
finishCircle: this.ctx.translate.instant('widgets.maps.data-layer.circle.finish-circle-hint') |
|
|
finishCircle: this.ctx.translate.instant('widgets.maps.data-layer.circle.finish-circle-hint') |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createItem(e: MouseEvent, actionData: CustomActionData, prepareDrawMode: () => void) { |
|
|
private createItem(actionData: CustomActionData, prepareDrawMode: () => void) { |
|
|
if (this.isPlacingItem) { |
|
|
if (this.isPlacingItem) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.updatePlaceItemState(actionData.button); |
|
|
this.updatePlaceItemState(actionData.button, true); |
|
|
|
|
|
|
|
|
this.map.once('pm:create', (e) => { |
|
|
this.map.once('pm:create', (e) => { |
|
|
this.ctx.actionsApi.handleWidgetAction(e as any, actionData.action, null, null, { |
|
|
actionData.afterPlaceItemCallback(e as any, actionData.action, null, null, { |
|
|
coordinates: convertLayerToCoordinates(actionData.action.mapItemType, e.layer), |
|
|
coordinates: convertLayerToCoordinates(actionData.action.mapItemType, e.layer), |
|
|
layer: e.layer |
|
|
layer: e.layer, |
|
|
|
|
|
button: actionData.button |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
// @ts-ignore
|
|
|
@ -673,7 +675,7 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
L.DomUtil.addClass(this.map.pm.Draw[shape]._hintMarker.getTooltip()._container, 'tb-place-item-label'); |
|
|
L.DomUtil.addClass(this.map.pm.Draw[shape]._hintMarker.getTooltip()._container, 'tb-place-item-label'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private updatePlaceItemState(addButton?: L.TB.ToolbarButton): void { |
|
|
private updatePlaceItemState(addButton?: L.TB.ToolbarButton, disabled = false): void { |
|
|
if (addButton) { |
|
|
if (addButton) { |
|
|
this.deselectItem(false, true); |
|
|
this.deselectItem(false, true); |
|
|
addButton.setActive(true); |
|
|
addButton.setActive(true); |
|
|
@ -681,7 +683,7 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
this.currentAddButton.setActive(false); |
|
|
this.currentAddButton.setActive(false); |
|
|
} |
|
|
} |
|
|
this.currentAddButton = addButton; |
|
|
this.currentAddButton = addButton; |
|
|
this.updateAddButtonsStates(); |
|
|
this.updateAddButtonsStates(disabled); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createdControlButtonTooltip(root: HTMLElement, side: TooltipPositioningSide) { |
|
|
private createdControlButtonTooltip(root: HTMLElement, side: TooltipPositioningSide) { |
|
|
@ -856,8 +858,8 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private updateAddButtonsStates() { |
|
|
private updateAddButtonsStates(disabled = false) { |
|
|
if (this.currentAddButton) { |
|
|
if (this.currentAddButton || disabled) { |
|
|
if (this.addMarkerButton && this.addMarkerButton !== this.currentAddButton) { |
|
|
if (this.addMarkerButton && this.addMarkerButton !== this.currentAddButton) { |
|
|
this.addMarkerButton.setDisabled(true); |
|
|
this.addMarkerButton.setDisabled(true); |
|
|
} |
|
|
} |
|
|
|