Skip to content

Commit b52d2c0

Browse files
author
Sebastian Thulin
committed
Merge branch 'main' of github.com:helsingborg-stad/modularity-frontend-form
2 parents bdab5f8 + d4d2d40 commit b52d2c0

17 files changed

+307
-86
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"minimum-stability": "stable",
2323
"require": {
2424
"helsingborg-stad/wpservice": "^2.0",
25-
"helsingborg-stad/acfservice": "^0.9.1"
25+
"helsingborg-stad/acfservice": "^1.0.1"
2626
},
2727
"require-dev": {
2828
"brain/monkey": "^2.6",

composer.lock

Lines changed: 49 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
class GoogleMap implements GoogleMapInterface {
2+
constructor(
3+
private field: HTMLElement,
4+
private openstreetmapInstance: OpenstreetmapInterface,
5+
private name: string,
6+
private googleMapValidator: ConditionValidatorInterface,
7+
private conditionsHandler: ConditionsHandlerInterface
8+
) {
9+
}
10+
11+
public init(conditionBuilder: ConditionBuilderInterface): void {
12+
this.conditionsHandler.init(this, conditionBuilder);
13+
this.googleMapValidator.init(this);
14+
this.openstreetmapInstance.init();
15+
}
16+
17+
public getName(): string {
18+
return this.name;
19+
}
20+
21+
public getConditionsHandler(): ConditionsHandlerInterface {
22+
return this.conditionsHandler;
23+
}
24+
25+
public getConditionValidator(): ConditionValidatorInterface {
26+
return this.googleMapValidator;
27+
}
28+
29+
public getOpenstreetmap(): OpenstreetmapInterface {
30+
return this.openstreetmapInstance;
31+
}
32+
33+
public getField(): HTMLElement {
34+
return this.field;
35+
}
36+
}
37+
38+
export default GoogleMap;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class GoogleMapConditionValidator implements ConditionValidatorInterface {
2+
private parent: GoogleMapInterface|null = null;
3+
4+
public init(parent: GoogleMapInterface): void {
5+
this.parent = parent;
6+
}
7+
8+
public validate(condition: any): boolean {
9+
const value = this.parent?.getOpenstreetmap().hasMarker() ? true : false;
10+
11+
switch (condition.operator) {
12+
case '==':
13+
case '=':
14+
case '===':
15+
case '!=empty':
16+
case '==contains':
17+
return value === true;
18+
case '!=':
19+
case '!==':
20+
case '==empty':
21+
case '!=contains':
22+
return value === false;
23+
default:
24+
console.error('Invalid operator:', condition.operator);
25+
return false;
26+
}
27+
28+
}
29+
}
30+
31+
export default GoogleMapConditionValidator;

0 commit comments

Comments
 (0)