Skip to content

Commit

Permalink
Changing input from value to propertyValue
Browse files Browse the repository at this point in the history
  • Loading branch information
rugoncalves committed Oct 26, 2023
1 parent 38d099b commit 90c4cc5
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 98 deletions.
19 changes: 12 additions & 7 deletions src/Providers/Maps/Google/Marker/Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,18 @@ namespace Provider.Maps.Google.Marker {
}
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Marker[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Marker.location:
Helper.Conversions.ConvertToCoordinates(
value as string,
propertyValue as string,
this.map.config.apiKey
)
.then((response) => {
Expand All @@ -253,18 +256,20 @@ namespace Provider.Maps.Google.Marker {
});
return;
case OSFramework.Maps.Enum.OS_Config_Marker.allowDrag:
return this._provider.setDraggable(value as boolean);
return this._provider.setDraggable(
propertyValue as boolean
);
case OSFramework.Maps.Enum.OS_Config_Marker.iconHeight:
case OSFramework.Maps.Enum.OS_Config_Marker.iconWidth:
this._setIconSize();
return;
case OSFramework.Maps.Enum.OS_Config_Marker.iconUrl:
this._setIcon(value as string);
this._setIcon(propertyValue as string);
return;
case OSFramework.Maps.Enum.OS_Config_Marker.label:
return this._provider.setLabel(value as string);
return this._provider.setLabel(propertyValue as string);
case OSFramework.Maps.Enum.OS_Config_Marker.title:
return this._provider.setTitle(value as string);
return this._provider.setTitle(propertyValue as string);
}
}
}
Expand Down
31 changes: 18 additions & 13 deletions src/Providers/Maps/Google/OSMap/OSMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,12 @@ namespace Provider.Maps.Google.OSMap {
}
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue = OSFramework.Maps.Enum.OS_Config_Map[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Map.apiKey:
Expand All @@ -371,36 +374,38 @@ namespace Provider.Maps.Google.OSMap {
return;
case OSFramework.Maps.Enum.OS_Config_Map.center:
return this.features.center.updateCenter(
value as string
propertyValue as string
);
case OSFramework.Maps.Enum.OS_Config_Map.offset:
return this.features.offset.setOffset(
JSON.parse(value as string)
JSON.parse(propertyValue as string)
);
case OSFramework.Maps.Enum.OS_Config_Map.zoom:
return this.features.zoom.setLevel(
value as OSFramework.Maps.Enum.OSMap.Zoom
propertyValue as OSFramework.Maps.Enum.OSMap.Zoom
);
case OSFramework.Maps.Enum.OS_Config_Map.type:
return this._provider.setMapTypeId(value as string);
return this._provider.setMapTypeId(
propertyValue as string
);
case OSFramework.Maps.Enum.OS_Config_Map.style:
return this._provider.setOptions({
styles: GetStyleByStyleId(value as number)
styles: GetStyleByStyleId(propertyValue as number)
});
case OSFramework.Maps.Enum.OS_Config_Map.advancedFormat:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value = OSFramework.Maps.Helper.JsonFormatter(
value as string
propertyValue = OSFramework.Maps.Helper.JsonFormatter(
propertyValue as string
);
// Make sure the MapEvents that are associated in the advancedFormat get updated
this._setMapEvents(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(value as any).mapEvents as string[]
(propertyValue as any).mapEvents as string[]
);
return this._provider.setOptions(value);
return this._provider.setOptions(propertyValue);
case OSFramework.Maps.Enum.OS_Config_Map.showTraffic:
return this.features.trafficLayer.setState(
value as boolean
propertyValue as boolean
);
case OSFramework.Maps.Enum.OS_Config_Map
.markerClustererActive:
Expand All @@ -412,7 +417,7 @@ namespace Provider.Maps.Google.OSMap {
.markerClustererZoomOnClick:
return this.features.markerClusterer.changeProperty(
propertyName,
value
propertyValue
);
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/Providers/Maps/Google/OSMap/StaticMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ namespace Provider.Maps.Google.OSMap {
}

// ChangeProperty method can't be used on a StaticMap
public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
// If the StaticMap is already rendered then throw an error
if (this.isReady) {
this.mapEvents.trigger(
Expand All @@ -269,15 +272,16 @@ namespace Provider.Maps.Google.OSMap {
.CFG_APIKeyAlreadySetStaticMap
);
}
return super.changeProperty(propertyName, value);
return super.changeProperty(propertyName, propertyValue);
case OSFramework.Maps.Enum.OS_Config_StaticMap.center:
this._center = this._getCenter(value as string);
this._center = this._getCenter(propertyValue as string);
return;
case OSFramework.Maps.Enum.OS_Config_StaticMap.zoom:
this._zoom = this._getZoom(value as number);
this._zoom = this._getZoom(propertyValue as number);
return;
case OSFramework.Maps.Enum.OS_Config_StaticMap.type:
this._type = value as OSFramework.Maps.Enum.OSMap.Type;
this._type =
propertyValue as OSFramework.Maps.Enum.OSMap.Type;
return;
default:
this.mapEvents.trigger(
Expand Down
13 changes: 8 additions & 5 deletions src/Providers/Maps/Google/SearchPlaces/SearchPlaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,11 @@ namespace Provider.Maps.Google.SearchPlaces {
);
}

public changeProperty(propertyName: string, value: unknown): void {
super.changeProperty(propertyName, value);
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (
OSFramework.Maps.Enum.OS_Config_SearchPlaces[propertyName]
Expand All @@ -278,7 +281,7 @@ namespace Provider.Maps.Google.SearchPlaces {
.searchArea:
// eslint-disable-next-line no-case-declarations
const searchArea = this._buildSearchArea(
value as string
propertyValue as string
);
// If searchArea is undefined (should be a promise) -> don't apply the searchArea (bounds)
if (searchArea !== undefined) {
Expand Down Expand Up @@ -307,7 +310,7 @@ namespace Provider.Maps.Google.SearchPlaces {
return;
case OSFramework.Maps.Enum.OS_Config_SearchPlaces.countries:
// eslint-disable-next-line no-case-declarations
const countries = JSON.parse(value as string);
const countries = JSON.parse(propertyValue as string);
// If validation returns false -> do nothing
// Else set restrictions to component (apply countries)
return (
Expand All @@ -321,7 +324,7 @@ namespace Provider.Maps.Google.SearchPlaces {
return this.provider.setTypes([
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Provider.Maps.Google.SearchPlaces.SearchTypes[
value as string
propertyValue as string
]
]);
}
Expand Down
13 changes: 9 additions & 4 deletions src/Providers/Maps/Google/Shape/AbstractPolyshape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,20 @@ namespace Provider.Maps.Google.Shape {
this._buildProvider(shapePath);
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Shape[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Shape.locations:
// eslint-disable-next-line no-case-declarations
const shapePath = this._buildPath(value as string);
const shapePath = this._buildPath(
propertyValue as string
);
// If path is undefined (should be a promise) -> don't create the shape
if (shapePath !== undefined) {
shapePath
Expand All @@ -136,7 +141,7 @@ namespace Provider.Maps.Google.Shape {
return;
case OSFramework.Maps.Enum.OS_Config_Shape.fillColor:
case OSFramework.Maps.Enum.OS_Config_Shape.fillOpacity:
return this.provider.set(propertyName, value);
return this.provider.set(propertyName, propertyValue);
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/Providers/Maps/Google/Shape/AbstractProviderShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,28 @@ namespace Provider.Maps.Google.Shape {
return Constants.Shape.Events;
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Shape[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Shape.allowDrag:
return this.provider.set('draggable', value);
return this.provider.set('draggable', propertyValue);
case OSFramework.Maps.Enum.OS_Config_Shape.allowEdit:
return this.provider.set('editable', value);
return this.provider.set('editable', propertyValue);
case OSFramework.Maps.Enum.OS_Config_Shape.strokeOpacity:
return this.provider.set('strokeOpacity', value);
return this.provider.set(
'strokeOpacity',
propertyValue
);
case OSFramework.Maps.Enum.OS_Config_Shape.strokeColor:
return this.provider.set('strokeColor', value);
return this.provider.set('strokeColor', propertyValue);
case OSFramework.Maps.Enum.OS_Config_Shape.strokeWeight:
return this.provider.set('strokeWeight', value);
return this.provider.set('strokeWeight', propertyValue);
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/Providers/Maps/Google/Shape/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,20 @@ namespace Provider.Maps.Google.Shape {
super._buildProvider(shapeCenter);
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Shape[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Shape.center:
// eslint-disable-next-line no-case-declarations
const shapeCenter = this._buildCenter(value as string);
const shapeCenter = this._buildCenter(
propertyValue as string
);
// If path is undefined (should be a promise) -> don't create the shape
if (shapeCenter !== undefined) {
shapeCenter
Expand All @@ -151,10 +156,10 @@ namespace Provider.Maps.Google.Shape {
}
return;
case OSFramework.Maps.Enum.OS_Config_Shape.radius:
return this.provider.setRadius(value as number);
return this.provider.setRadius(propertyValue as number);
case OSFramework.Maps.Enum.OS_Config_Shape.fillColor:
case OSFramework.Maps.Enum.OS_Config_Shape.fillOpacity:
return this.provider.set(propertyName, value);
return this.provider.set(propertyName, propertyValue);
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/Providers/Maps/Google/Shape/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,23 @@ namespace Provider.Maps.Google.Shape {
super._buildProvider(bounds);
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Shape[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Shape.fillColor:
case OSFramework.Maps.Enum.OS_Config_Shape.fillOpacity:
return this.provider.set(propertyName, value);
return this.provider.set(propertyName, propertyValue);
case OSFramework.Maps.Enum.OS_Config_Shape.bounds:
// eslint-disable-next-line no-case-declarations
const shapeBounds = this._buildBounds(value as string);
const shapeBounds = this._buildBounds(
propertyValue as string
);
// If path is undefined (should be a promise) -> don't create the shape
if (shapeBounds !== undefined) {
shapeBounds
Expand Down
27 changes: 20 additions & 7 deletions src/Providers/Maps/Leaflet/DrawingTools/AbstractDrawShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,40 @@ namespace Provider.Maps.Leaflet.DrawingTools {
this.options = this.getProviderConfig();
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Shape[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.drawingTools.isReady) {
switch (propValue) {
// If the following configurations are not included on the configs of the tool, the AbstractTool will make sure to throw an error
case OSFramework.Maps.Enum.OS_Config_Shape.strokeOpacity:
this.options = { shapeOptions: { opacity: value } };
this.options = {
shapeOptions: { opacity: propertyValue }
};
return;
case OSFramework.Maps.Enum.OS_Config_Shape.strokeColor:
this.options = { shapeOptions: { color: value } };
this.options = {
shapeOptions: { color: propertyValue }
};
return;
case OSFramework.Maps.Enum.OS_Config_Shape.strokeWeight:
this.options = { shapeOptions: { weight: value } };
this.options = {
shapeOptions: { weight: propertyValue }
};
return;
case OSFramework.Maps.Enum.OS_Config_Shape.fillOpacity:
this.options = { shapeOptions: { fillOpacity: value } };
this.options = {
shapeOptions: { fillOpacity: propertyValue }
};
return;
case OSFramework.Maps.Enum.OS_Config_Shape.fillColor:
this.options = { shapeOptions: { fillColor: value } };
this.options = {
shapeOptions: { fillColor: propertyValue }
};
return;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Providers/Maps/Leaflet/DrawingTools/DrawMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,18 @@ namespace Provider.Maps.Leaflet.DrawingTools {
};
}

public changeProperty(propertyName: string, value: unknown): void {
public changeProperty(
propertyName: string,
propertyValue: unknown
): void {
const propValue =
OSFramework.Maps.Enum.OS_Config_Marker[propertyName];
super.changeProperty(propertyName, value);
super.changeProperty(propertyName, propertyValue);
if (this.drawingTools.isReady) {
switch (propValue) {
case OSFramework.Maps.Enum.OS_Config_Marker.iconUrl:
this.options = {
icon: this._createIcon(value as string)
icon: this._createIcon(propertyValue as string)
};
return;
}
Expand Down
Loading

0 comments on commit 90c4cc5

Please sign in to comment.