Skip to content

Commit a3b6127

Browse files
authored
Merge pull request #142 from OutSystems/ROU-4375
ROU-4375: Add types to events
2 parents 4733133 + 9048e5a commit a3b6127

9 files changed

Lines changed: 73 additions & 34 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
namespace OSFramework.Maps.DrawingTools {
3+
export interface IDrawingToolsEventParams {
4+
coordinates: string;
5+
isNewElement: boolean;
6+
location: string | string[];
7+
uniqueId: string;
8+
}
9+
}

src/OSFramework/Maps/Event/FileLayer/FileLayersEventsManager.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ namespace OSFramework.Maps.Event.FileLayer {
5050
*/
5151
public trigger(
5252
eventType: FileLayersEventType,
53-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
54-
...args: any
53+
data?: string,
54+
fileLayerEventParams?: Maps.FileLayer.IFileLayerEventParams,
55+
...args: unknown[]
5556
): void {
5657
// Check if the FileLayer has any events associated
5758
if (this.handlers.has(eventType)) {
@@ -69,8 +70,9 @@ namespace OSFramework.Maps.Event.FileLayer {
6970
this._fileLayer.map.widgetId, // Id of Map block that was clicked
7071
this._fileLayer.widgetId ||
7172
this._fileLayer.uniqueId, // Id of File Layer block that was clicked
72-
args[0].coordinates, // LatLng from the click event
73-
args[0].featureData // FeatureData from the FileLayer that was clicked
73+
fileLayerEventParams.coordinates, // LatLng from the click event
74+
fileLayerEventParams.featureData, // FeatureData from the FileLayer that was clicked
75+
...args
7476
);
7577
break;
7678
// If the event is not valid we can fall in the default case of the switch and throw an error

src/OSFramework/Maps/Event/SearchPlaces/SearchPlacesEventsManager.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace OSFramework.Maps.Event.SearchPlaces {
3939
SearchPlaces.SearchPlacesEventType.OnError,
4040
this._searchPlaces,
4141
Enum.ErrorCodes.GEN_UnsupportedEventSearchPlaces,
42+
undefined,
4243
`${eventType}`
4344
);
4445
return;
@@ -77,8 +78,8 @@ namespace OSFramework.Maps.Event.SearchPlaces {
7778
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7879
searchPlaces?: OSFramework.Maps.SearchPlaces.ISearchPlaces,
7980
eventInfo?: string,
80-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
81-
...args: any
81+
searchPlacesEventParams?: Maps.SearchPlaces.ISearchPlacesEventParams,
82+
...args: unknown[]
8283
): void {
8384
// Check if the FileLayer has any events associated
8485
if (this.handlers.has(eventType)) {
@@ -103,20 +104,20 @@ namespace OSFramework.Maps.Event.SearchPlaces {
103104
break;
104105
case SearchPlacesEventType.OnPlaceSelect:
105106
handlerEvent.trigger(
106-
this._searchPlaces, // SearchPlaces Object where the place selection occurred.
107-
this._searchPlaces.widgetId ||
108-
this._searchPlaces.uniqueId, // Id of SearchPlaces block that was clicked
109-
args[0].name, // name of the place selected
110-
args[0].coordinates, // coordinates of the place selected
111-
args[0].address // full address of the place selected
107+
searchPlaces, // SearchPlaces Object where the place selection occurred.
108+
searchPlaces.widgetId || searchPlaces.uniqueId, // Id of SearchPlaces block that was clicked
109+
searchPlacesEventParams.name, // name of the place selected
110+
searchPlacesEventParams.coordinates, // coordinates of the place selected
111+
searchPlacesEventParams.address // full address of the place selected
112112
);
113113
break;
114114
// If the event is not valid we can fall in the default case of the switch and throw an error
115115
default:
116116
this._searchPlaces.searchPlacesEvents.trigger(
117117
SearchPlaces.SearchPlacesEventType.OnError,
118-
this._searchPlaces,
118+
searchPlaces,
119119
Enum.ErrorCodes.GEN_UnsupportedEventSearchPlaces,
120+
undefined,
120121
`${eventType}`
121122
);
122123
return;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
namespace OSFramework.Maps.FileLayer {
3+
export interface IFileLayerEventParams {
4+
coordinates: string;
5+
featureData: string;
6+
}
7+
}

src/OSFramework/Maps/SearchPlaces/AbstractSearchPlaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ namespace OSFramework.Maps.SearchPlaces {
8282
Event.SearchPlaces.SearchPlacesEventType.OnError,
8383
this,
8484
Enum.ErrorCodes.GEN_InvalidChangePropertySearchPlaces,
85+
undefined,
8586
`${propertyName}`
8687
);
8788
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
namespace OSFramework.Maps.SearchPlaces {
3+
export interface ISearchPlacesEventParams {
4+
address: string;
5+
coordinates: string;
6+
name: string;
7+
}
8+
}

src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,24 @@ namespace Provider.Maps.Google.DrawingTools {
2828
eventName: string,
2929
shapeCoordinates: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
3030
) => {
31-
this.drawingTools.drawingToolsEvents.trigger(
32-
// EventType
33-
OSFramework.Maps.Event.DrawingTools
34-
.DrawingToolsEventType.ProviderEvent,
35-
// EventName
36-
this.completedToolEventName,
37-
// The extra parameters, uniqueId and isNewElement set to false indicating that the element is not new
31+
const dtParams: OSFramework.Maps.DrawingTools.IDrawingToolsEventParams =
3832
{
3933
uniqueId: _shape.uniqueId,
4034
isNewElement: false,
4135
location: JSON.stringify(shapeCoordinates.location),
4236
coordinates: JSON.stringify(
4337
shapeCoordinates.coordinates
4438
)
45-
}
39+
};
40+
41+
this.drawingTools.drawingToolsEvents.trigger(
42+
// EventType
43+
OSFramework.Maps.Event.DrawingTools
44+
.DrawingToolsEventType.ProviderEvent,
45+
// EventName
46+
this.completedToolEventName,
47+
// The extra parameters, uniqueId and isNewElement set to false indicating that the element is not new
48+
dtParams
4649
);
4750
}
4851
);

src/Providers/Maps/Google/FileLayer/FileLayer.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ namespace Provider.Maps.Google.FileLayer {
3333
this.provider.addListener(
3434
'click',
3535
(event: google.maps.KmlMouseEvent) => {
36-
this.fileLayerEvents.trigger(
37-
OSFramework.Maps.Event.FileLayer.FileLayersEventType
38-
.OnClick,
39-
// Extra parameters to be passed as arguments on the callback of the OnClick event handler
36+
const flParams: OSFramework.Maps.FileLayer.IFileLayerEventParams =
4037
{
4138
// Coordinates from the event that was triggered (by the click)
4239
coordinates: JSON.stringify({
@@ -50,7 +47,13 @@ namespace Provider.Maps.Google.FileLayer {
5047
featureData: JSON.stringify(
5148
event.featureData as google.maps.KmlFeatureData
5249
)
53-
}
50+
};
51+
this.fileLayerEvents.trigger(
52+
OSFramework.Maps.Event.FileLayer.FileLayersEventType
53+
.OnClick,
54+
undefined,
55+
// Extra parameters to be passed as arguments on the callback of the OnClick event handler
56+
flParams
5457
);
5558
}
5659
);

src/Providers/Maps/Google/SearchPlaces/SearchPlaces.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ namespace Provider.Maps.Google.SearchPlaces {
115115
this,
116116
OSFramework.Maps.Enum.ErrorCodes
117117
.LIB_FailedGeocodingSearchAreaLocations,
118+
undefined,
118119
`${error}`
119120
);
120121
});
@@ -178,21 +179,24 @@ namespace Provider.Maps.Google.SearchPlaces {
178179
Constants.SearchPlaces.Events.OnPlaceSelect,
179180
() => {
180181
const place = this._provider.getPlace();
182+
const spParams: OSFramework.Maps.SearchPlaces.ISearchPlacesEventParams =
183+
{
184+
name: place.name,
185+
coordinates: JSON.stringify({
186+
Lat: place.geometry.location.lat(),
187+
Lng: place.geometry.location.lng()
188+
}),
189+
address: place.formatted_address
190+
};
191+
181192
place.geometry &&
182193
this.searchPlacesEvents.trigger(
183194
OSFramework.Maps.Event.SearchPlaces
184195
.SearchPlacesEventType.OnPlaceSelect,
185196
this, // searchPlacesObj
186197
Constants.SearchPlaces.Events.OnPlaceSelect, // event name (eventInfo)
187198
// Extra parameters to be passed as arguments on the callback of the OnPlaceSelect event handler
188-
{
189-
name: place.name,
190-
coordinates: JSON.stringify({
191-
Lat: place.geometry.location.lat(),
192-
Lng: place.geometry.location.lng()
193-
}),
194-
address: place.formatted_address
195-
}
199+
spParams
196200
);
197201
}
198202
);
@@ -286,6 +290,7 @@ namespace Provider.Maps.Google.SearchPlaces {
286290
this,
287291
OSFramework.Maps.Enum.ErrorCodes
288292
.CFG_InvalidSearchPlacesSearchArea,
293+
undefined,
289294
`${error}`
290295
);
291296
});

0 commit comments

Comments
 (0)