[ceaed42] | 1 | import { Component, OnInit } from '@angular/core';
|
---|
| 2 | import { NgForm } from '@angular/forms';
|
---|
| 3 | import { MatDialogRef } from '@angular/material/dialog';
|
---|
| 4 | import { ActivatedRoute } from '@angular/router';
|
---|
| 5 | import { PlannerLocationDto } from 'src/app/_models/dto/plannerLocationDto';
|
---|
| 6 | import { Location } from 'src/app/_models/location';
|
---|
| 7 | import { Planner } from 'src/app/_models/planner';
|
---|
| 8 | import { LocationService } from 'src/app/_services/location.service';
|
---|
| 9 | import { PlannerService } from 'src/app/_services/planner.service';
|
---|
| 10 |
|
---|
| 11 | @Component({
|
---|
| 12 | selector: 'app-add-location-to-planner-panel',
|
---|
| 13 | templateUrl: './add-location-to-planner-panel.component.html',
|
---|
| 14 | styleUrls: ['./add-location-to-planner-panel.component.css']
|
---|
| 15 | })
|
---|
| 16 | export class AddLocationToPlannerPanelComponent implements OnInit {
|
---|
| 17 |
|
---|
| 18 | planners: Planner[];
|
---|
| 19 | location: Location;
|
---|
| 20 | plannerId: number;
|
---|
| 21 | locationId: number;
|
---|
| 22 | plannerLocationDto: PlannerLocationDto;
|
---|
| 23 |
|
---|
| 24 | constructor(private dialogRef: MatDialogRef<AddLocationToPlannerPanelComponent>, private plannerService: PlannerService,
|
---|
| 25 | private locationService: LocationService, private route: ActivatedRoute) {
|
---|
| 26 | this.planners = [];
|
---|
| 27 | this.location = new Location;
|
---|
| 28 | this.plannerId = 1;
|
---|
| 29 | this.locationId = 1;
|
---|
| 30 | this.plannerLocationDto = new PlannerLocationDto();
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | ngOnInit(): void {
|
---|
| 34 | this.plannerService.getAllPlanners().subscribe(
|
---|
| 35 | data => {
|
---|
| 36 | this.planners = data;
|
---|
| 37 | }
|
---|
| 38 | );
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | this.route.queryParams
|
---|
| 42 | .subscribe(params => {
|
---|
| 43 | this.locationId = params.locationId;
|
---|
| 44 | }
|
---|
| 45 | );
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | onCancelClick(): void {
|
---|
| 49 | this.dialogRef.close();
|
---|
| 50 |
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | onFormSavePlanner(plannerId: number) {
|
---|
| 54 | console.log("PLANNER ID: " + plannerId);
|
---|
| 55 | console.log("LOC ID "+ this.locationId);
|
---|
| 56 | this.plannerLocationDto.locationId = this.locationId;
|
---|
| 57 | this.plannerLocationDto.plannerId = plannerId;
|
---|
| 58 | this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe(
|
---|
| 59 | data => {
|
---|
| 60 | console.log(data);
|
---|
| 61 | }
|
---|
| 62 | );
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | }
|
---|