Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/location/location.component.ts

    r59329aa re29cc2e  
    1 import { Component, Input, OnInit, Output } from '@angular/core';
     1import { Component, OnInit } from '@angular/core';
    22import { FormBuilder, FormGroup, Validators } from '@angular/forms';
    3 import { MatDialog } from '@angular/material/dialog';
    43import { ActivatedRoute, Router } from '@angular/router';
     4import { MessageService, PrimeNGConfig } from 'primeng/api';
     5import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
     6import { Planner } from '../_models/planner';
    57import { LocationService } from '../_services/location.service';
    68import { AddLocationToPlannerPanelComponent } from './add-location-to-planner-panel/add-location-to-planner-panel.component';
     9import { Location } from '../_models/location';
     10import { PlannerLocationDto } from '../_models/dto/plannerLocationDto';
     11
    712
    813@Component({
    914  selector: 'app-location',
    1015  templateUrl: './location.component.html',
    11   styleUrls: ['./location.component.css']
     16  styleUrls: ['./location.component.css'],
     17  providers: [DialogService, MessageService]
    1218})
    1319export class LocationComponent implements OnInit {
    1420
    15   form: FormGroup;
    1621  categoryIds: string;
    1722  cityId: number;
     
    2328  regionId: number;
    2429  locationId: number;
     30  plannerLocationDto: PlannerLocationDto;
     31  ref: DynamicDialogRef;
    2532
    26   constructor(private fb: FormBuilder, private route: ActivatedRoute, private locationService: LocationService,
    27     private router: Router, private dialog: MatDialog) {
    28     this.form = fb.group({
    29       title: fb.control('initial value', Validators.required)
    30     });
     33
     34
     35  constructor(private route: ActivatedRoute, private locationService: LocationService,
     36    private router: Router, private dialogService: DialogService, private messageService: MessageService) {
    3137    this.cityId = 1;
    3238    this.companionId = 1;
     
    3642    this.regionId = 1;
    3743    this.locationId = 1;
     44    this.ref = new DynamicDialogRef;
     45    this.plannerLocationDto = new PlannerLocationDto();
     46
    3847  }
    3948
     
    7180  }
    7281
    73   openDialogSave(locationId){
    74    // console.log(locationId);
    75       const dialogRef = this.dialog.open(AddLocationToPlannerPanelComponent, {
    76         width: '250px',
    77         data: {}
    78       });
    79       this.router.navigate(['locations'], {queryParams: {regionId: this.regionId, companionId: this.companionId, lengthOfStay: this.lengthOfStay, categoryIds: this.categoryIds, locationId: locationId}});
    80      
     82  onClickSeeDetails(id: number) {
     83    this.router.navigate(['location'], { queryParams: { id: id } });
    8184  }
    8285
    83   onClickSeeDetails(id: number){
    84     this.router.navigate(['location'], {queryParams: {id: id}});
     86  show(location: Location) {
     87    this.ref = this.dialogService.open(AddLocationToPlannerPanelComponent, {
     88      header: 'Choose a Planner',
     89      width: '70%',
     90      contentStyle: { "max-height": "500px", "overflow": "auto" },
     91      baseZIndex: 10000
     92    });
     93
     94    this.ref.onClose.subscribe((planner: Planner) => {
     95
     96      this.plannerLocationDto.locationId = location.id;
     97      this.plannerLocationDto.plannerId = planner.id;
     98      console.log("LOC ID: " + this.plannerLocationDto.locationId);
     99      console.log("PLANNER ID: " + this.plannerLocationDto.plannerId);
     100      this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe(
     101        data => {
     102          console.log(data);
     103        }
     104      );
     105      if (planner) {
     106        this.messageService.add({ severity: 'success', summary: 'Location ' + location.name +  ' has been added to planner: ' , detail: planner.name });
     107      }
     108    });
     109  }
     110
     111  ngOnDestroy() {
     112    if (this.ref) {
     113      this.ref.close();
     114    }
     115  }
     116
     117  onClickBackToMyPlanners(){
     118    this.router.navigate(['planners']);
    85119  }
    86120}
Note: See TracChangeset for help on using the changeset viewer.