diff --git a/src/app/waypoint/waypoint-create/waypoint-create.component.html b/src/app/waypoint/waypoint-create/waypoint-create.component.html
index b87ca88..96792ba 100644
--- a/src/app/waypoint/waypoint-create/waypoint-create.component.html
+++ b/src/app/waypoint/waypoint-create/waypoint-create.component.html
@@ -27,6 +27,14 @@
+
+
+
+
+
+
diff --git a/src/app/waypoint/waypoint-create/waypoint-create.component.ts b/src/app/waypoint/waypoint-create/waypoint-create.component.ts
index e259405..87346b9 100644
--- a/src/app/waypoint/waypoint-create/waypoint-create.component.ts
+++ b/src/app/waypoint/waypoint-create/waypoint-create.component.ts
@@ -7,6 +7,7 @@ import {FormControl, FormGroup, Validators,} from '@angular/forms';
import {ModalDismissReasons, NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {PagedResourceCollection} from '@lagoshny/ngx-hateoas-client';
import {Coordinate} from "../../coordinate/coordinate.entity";
+import {CoordinateService} from "../../coordinate/coordinate.service";
@Component({
selector: 'app-waypoint-create',
@@ -16,7 +17,7 @@ import {Coordinate} from "../../coordinate/coordinate.entity";
export class WaypointCreateComponent implements OnInit {
closeResult = '';
public isModalSaved: boolean = false;
- public location: Coordinate = new Coordinate();
+ public coordinates: Coordinate[] = [];
public waypoints: Waypoint[] = [];
public waypoint: Waypoint;
public titleInput: string = '';
@@ -24,13 +25,15 @@ export class WaypointCreateComponent implements OnInit {
public showModal: boolean = false;
public waypointForm: FormGroup;
public types: string[] = ['Summit', 'Lake', 'River', 'Waterfall', 'Fountain',
- 'Cave', 'Risk', 'Valley', 'Panoramic view', 'Wildlife observation', 'Parking', 'Cliff', 'Shelter', 'Other'];
+ 'Cave', 'Risk', 'Valley', 'Panoramic view', 'Wildlife observation', 'Parking',
+ 'Cliff', 'Shelter', 'Other'];
constructor(
private router: Router,
private waypointService: WaypointService,
private authenticationService: AuthenticationBasicService,
- private modalService: NgbModal
+ private modalService: NgbModal,
+ private coordinateService: CoordinateService
) {
}
@@ -42,11 +45,19 @@ export class WaypointCreateComponent implements OnInit {
]),
description: new FormControl(this.titleInput),
type: new FormControl(''),
+ locate: new FormControl(''),
});
-
+ this.loadCoordinateList();
this.loadWaypointList();
}
+ loadCoordinateList() {
+ this.coordinateService.getPage({ pageParams: { size: 10 }, sort: { name: 'ASC' } })
+ .subscribe((coordinates: PagedResourceCollection
) => {
+ this.coordinates = coordinates.resources;
+ });
+ }
+
loadWaypointList() {
this.waypointService
.getPage({
@@ -59,34 +70,6 @@ export class WaypointCreateComponent implements OnInit {
});
}
- open(content) {
- this.modalService
- .open(content, {ariaLabelledBy: 'modal-basic-title'})
- .result.then(
- (result) => {
- this.closeResult = `Closed with: ${result}`;
- },
- (reason) => {
- this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
- }
- );
- }
-
- private getDismissReason(reason: any): string {
- if (reason === ModalDismissReasons.ESC) {
- return 'by pressing ESC';
- } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
- return 'by clicking on a backdrop';
- } else {
- return `with: ${reason}`;
- }
- }
-
- saveAndClose(modal: any) {
- this.isModalSaved = true;
- modal.close('Save click');
- }
-
get title() {
return this.waypointForm.get('title');
}
@@ -98,6 +81,9 @@ export class WaypointCreateComponent implements OnInit {
onSubmit(): void {
this.waypoint.title = this.title?.value;
this.waypoint.type = this.waypointForm.get('type')?.value;
+ this.waypoint.description = this.description?.value;
+ this.waypoint.location = this.waypointForm.get('locate')?.value;
+
this.waypointService
.createResource({body: this.waypoint})
.subscribe(() => {
diff --git a/src/app/waypoint/waypoint-list/waypoint-list.component.html b/src/app/waypoint/waypoint-list/waypoint-list.component.html
index ee42e25..de93b32 100644
--- a/src/app/waypoint/waypoint-list/waypoint-list.component.html
+++ b/src/app/waypoint/waypoint-list/waypoint-list.component.html
@@ -61,6 +61,10 @@ Description
Type
{{ waypoint.type }}
+
+
+
+
diff --git a/src/app/waypoint/waypoint-list/waypoint-list.component.ts b/src/app/waypoint/waypoint-list/waypoint-list.component.ts
index ae13172..9d19f81 100644
--- a/src/app/waypoint/waypoint-list/waypoint-list.component.ts
+++ b/src/app/waypoint/waypoint-list/waypoint-list.component.ts
@@ -41,12 +41,13 @@ export class WaypointListComponent implements OnInit{
this.waypoints = page.resources;
this.totalWaypoints = page.totalElements;
this.waypointsPagedResource = page;
- this.waypoints.map(waypoints => {
- waypoints.getRelation('coordinate')
- .subscribe((coordinate: Coordinate) => {
- waypoints.coordinate = coordinate;
- });
- });
+
+ // this.waypoints.map(waypoints => {
+ // waypoints.getRelation('coordinate')
+ // .subscribe((coordinate: Coordinate) => {
+ // waypoints.location = coordinate;
+ // });
+ // });
});
}
@@ -56,12 +57,12 @@ export class WaypointListComponent implements OnInit{
sort: {name: 'ASC'}}).subscribe(
(page: PagedResourceCollection) => {
this.waypoints = page.resources;
- this.waypoints.map(waypoint => {
- waypoint.getRelation('coordinate')
- .subscribe((coordinate: Coordinate) => {
- waypoint.coordinate = coordinate;
- });
- });
+ // this.waypoints.map(waypoint => {
+ // waypoint.getRelation('coordinate')
+ // .subscribe((coordinate: Coordinate) => {
+ // waypoint.location = coordinate;
+ // });
+ // });
});
}
diff --git a/src/app/waypoint/waypoint.ts b/src/app/waypoint/waypoint.ts
index 9736750..d7a592f 100644
--- a/src/app/waypoint/waypoint.ts
+++ b/src/app/waypoint/waypoint.ts
@@ -8,7 +8,7 @@ export class Waypoint extends Resource {
title: string;
description: string;
type: string;
- coordinate: Coordinate;
+ location: Coordinate;
_links: any;
constructor(values: object = {}) {