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