Skip to content

Commit 656b6f2

Browse files
committed
[Map] Looks like Stimulus default values does not behave like Vue props, revert and use hassers instead
1 parent 8a512a1 commit 656b6f2

File tree

7 files changed

+83
-70
lines changed

7 files changed

+83
-70
lines changed

src/Map/assets/dist/abstract_map_controller.d.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,14 @@ export type InfoWindowDefinition<InfoWindowOptions> = {
4040
export type InfoWindowWithoutPositionDefinition<InfoWindowOptions> = Omit<InfoWindowDefinition<InfoWindowOptions>, 'position'>;
4141
export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindowOptions, InfoWindow, PolygonOptions, Polygon, PolylineOptions, Polyline> extends Controller<HTMLElement> {
4242
static values: {
43-
providerOptions: {
44-
type: ObjectConstructor;
45-
};
46-
center: {
47-
type: ObjectConstructor;
48-
default: null;
49-
};
50-
zoom: {
51-
type: NumberConstructor;
52-
default: null;
53-
};
54-
fitBoundsToMarkers: {
55-
type: BooleanConstructor;
56-
};
57-
markers: {
58-
type: ArrayConstructor;
59-
};
60-
polygons: {
61-
type: ArrayConstructor;
62-
};
63-
polylines: {
64-
type: ArrayConstructor;
65-
};
66-
options: {
67-
type: ObjectConstructor;
68-
};
43+
providerOptions: ObjectConstructor;
44+
center: ObjectConstructor;
45+
zoom: NumberConstructor;
46+
fitBoundsToMarkers: BooleanConstructor;
47+
markers: ArrayConstructor;
48+
polygons: ArrayConstructor;
49+
polylines: ArrayConstructor;
50+
options: ObjectConstructor;
6951
};
7052
centerValue: Point | null;
7153
zoomValue: number | null;
@@ -74,6 +56,13 @@ export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindow
7456
polygonsValue: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
7557
polylinesValue: Array<PolylineDefinition<PolylineOptions, InfoWindowOptions>>;
7658
optionsValue: MapOptions;
59+
hasCenterValue: boolean;
60+
hasZoomValue: boolean;
61+
hasFitBoundsToMarkersValue: boolean;
62+
hasMarkersValue: boolean;
63+
hasPolygonsValue: boolean;
64+
hasPolylinesValue: boolean;
65+
hasOptionsValue: boolean;
7766
protected map: Map;
7867
protected markers: globalThis.Map<string, Marker>;
7968
protected polygons: globalThis.Map<string, Polygon>;

src/Map/assets/dist/abstract_map_controller.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class default_1 extends Controller {
1515
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1616
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1717
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
18-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
18+
this.map = this.doCreateMap({
19+
center: this.hasCenterValue ? this.centerValue : null,
20+
zoom: this.hasZoomValue ? this.zoomValue : null,
21+
options
22+
});
1923
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2024
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2125
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));
@@ -88,14 +92,14 @@ class default_1 extends Controller {
8892
}
8993
}
9094
default_1.values = {
91-
providerOptions: { type: Object },
92-
center: { type: Object, default: null },
93-
zoom: { type: Number, default: null },
94-
fitBoundsToMarkers: { type: Boolean },
95-
markers: { type: Array },
96-
polygons: { type: Array },
97-
polylines: { type: Array },
98-
options: { type: Object },
95+
providerOptions: Object,
96+
center: Object,
97+
zoom: Number,
98+
fitBoundsToMarkers: Boolean,
99+
markers: Array,
100+
polygons: Array,
101+
polylines: Array,
102+
options: Object,
99103
};
100104

101105
export { default_1 as default };

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ export default abstract class<
9494
Polyline,
9595
> extends Controller<HTMLElement> {
9696
static values = {
97-
providerOptions: { type: Object },
98-
center: { type: Object, default: null },
99-
zoom: { type: Number, default: null },
100-
fitBoundsToMarkers: { type: Boolean },
101-
markers: { type: Array },
102-
polygons: { type: Array },
103-
polylines: { type: Array },
104-
options: { type: Object },
97+
providerOptions: Object,
98+
center: Object,
99+
zoom: Number,
100+
fitBoundsToMarkers: Boolean,
101+
markers: Array,
102+
polygons: Array,
103+
polylines: Array,
104+
options: Object,
105105
};
106106

107107
declare centerValue: Point | null;
@@ -112,6 +112,14 @@ export default abstract class<
112112
declare polylinesValue: Array<PolylineDefinition<PolylineOptions, InfoWindowOptions>>;
113113
declare optionsValue: MapOptions;
114114

115+
declare hasCenterValue: boolean;
116+
declare hasZoomValue: boolean;
117+
declare hasFitBoundsToMarkersValue: boolean;
118+
declare hasMarkersValue: boolean;
119+
declare hasPolygonsValue: boolean;
120+
declare hasPolylinesValue: boolean;
121+
declare hasOptionsValue: boolean;
122+
115123
protected map: Map;
116124
protected markers = new Map<Identifier, Marker>();
117125
protected polygons = new Map<Identifier, Polygon>();
@@ -140,7 +148,11 @@ export default abstract class<
140148
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
141149
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
142150

143-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
151+
this.map = this.doCreateMap({
152+
center: this.hasCenterValue ? this.centerValue : null,
153+
zoom: this.hasZoomValue ? this.zoomValue : null,
154+
options
155+
});
144156
this.markersValue.forEach((definition) => this.createMarker({ definition }));
145157
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
146158
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));

src/Map/src/Bridge/Google/assets/dist/map_controller.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ class default_1 extends Controller {
1616
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1717
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1818
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
19-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
19+
this.map = this.doCreateMap({
20+
center: this.hasCenterValue ? this.centerValue : null,
21+
zoom: this.hasZoomValue ? this.zoomValue : null,
22+
options
23+
});
2024
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2125
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2226
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));
@@ -89,14 +93,14 @@ class default_1 extends Controller {
8993
}
9094
}
9195
default_1.values = {
92-
providerOptions: { type: Object },
93-
center: { type: Object, default: null },
94-
zoom: { type: Number, default: null },
95-
fitBoundsToMarkers: { type: Boolean },
96-
markers: { type: Array },
97-
polygons: { type: Array },
98-
polylines: { type: Array },
99-
options: { type: Object },
96+
providerOptions: Object,
97+
center: Object,
98+
zoom: Number,
99+
fitBoundsToMarkers: Boolean,
100+
markers: Array,
101+
polygons: Array,
102+
polylines: Array,
103+
options: Object,
100104
};
101105

102106
let _google;
@@ -121,12 +125,12 @@ class map_controller extends default_1 {
121125
super.connect();
122126
}
123127
centerValueChanged() {
124-
if (this.map && this.centerValue) {
128+
if (this.map && this.hasCenterValue && this.centerValue) {
125129
this.map.setCenter(this.centerValue);
126130
}
127131
}
128132
zoomValueChanged() {
129-
if (this.map && this.zoomValue) {
133+
if (this.map && this.hasZoomValue && this.zoomValue) {
130134
this.map.setZoom(this.zoomValue);
131135
}
132136
}

src/Map/src/Bridge/Google/assets/src/map_controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ export default class extends AbstractMapController<
8686
}
8787

8888
public centerValueChanged(): void {
89-
if (this.map && this.centerValue) {
89+
if (this.map && this.hasCenterValue && this.centerValue) {
9090
this.map.setCenter(this.centerValue);
9191
}
9292
}
9393

9494
public zoomValueChanged(): void {
95-
if (this.map && this.zoomValue) {
95+
if (this.map && this.hasZoomValue && this.zoomValue) {
9696
this.map.setZoom(this.zoomValue);
9797
}
9898
}

src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class default_1 extends Controller {
1717
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1818
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1919
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
20-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
20+
this.map = this.doCreateMap({
21+
center: this.hasCenterValue ? this.centerValue : null,
22+
zoom: this.hasZoomValue ? this.zoomValue : null,
23+
options
24+
});
2125
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2226
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2327
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));
@@ -90,14 +94,14 @@ class default_1 extends Controller {
9094
}
9195
}
9296
default_1.values = {
93-
providerOptions: { type: Object },
94-
center: { type: Object, default: null },
95-
zoom: { type: Number, default: null },
96-
fitBoundsToMarkers: { type: Boolean },
97-
markers: { type: Array },
98-
polygons: { type: Array },
99-
polylines: { type: Array },
100-
options: { type: Object },
97+
providerOptions: Object,
98+
center: Object,
99+
zoom: Number,
100+
fitBoundsToMarkers: Boolean,
101+
markers: Array,
102+
polygons: Array,
103+
polylines: Array,
104+
options: Object,
101105
};
102106

103107
class map_controller extends default_1 {
@@ -112,12 +116,12 @@ class map_controller extends default_1 {
112116
super.connect();
113117
}
114118
centerValueChanged() {
115-
if (this.map && this.centerValue && this.zoomValue) {
119+
if (this.map && this.hasCenterValue && this.centerValue && this.hasZoomValue && this.zoomValue) {
116120
this.map.setView(this.centerValue, this.zoomValue);
117121
}
118122
}
119123
zoomValueChanged() {
120-
if (this.map && this.zoomValue) {
124+
if (this.map && this.hasZoomValue && this.zoomValue) {
121125
this.map.setZoom(this.zoomValue);
122126
}
123127
}

src/Map/src/Bridge/Leaflet/assets/src/map_controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ export default class extends AbstractMapController<
4848
}
4949

5050
public centerValueChanged(): void {
51-
if (this.map && this.centerValue && this.zoomValue) {
51+
if (this.map && this.hasCenterValue && this.centerValue && this.hasZoomValue && this.zoomValue) {
5252
this.map.setView(this.centerValue, this.zoomValue);
5353
}
5454
}
5555

5656
public zoomValueChanged(): void {
57-
if (this.map && this.zoomValue) {
57+
if (this.map && this.hasZoomValue && this.zoomValue) {
5858
this.map.setZoom(this.zoomValue);
5959
}
6060
}

0 commit comments

Comments
 (0)