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

primeNG components

Location:
trip-planner-front/src/app/location/add-location-to-planner-panel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/location/add-location-to-planner-panel/add-location-to-planner-panel.component.html

    r59329aa re29cc2e  
    1 <form  >
    2     <h1 mat-dialog-title>Please select a planner where u want your location to be saved</h1>
    3    
    4 <table class="table" >
    5   <tbody>
    6     <tr *ngFor="let planner of planners">
    7       <td>{{planner.name}}</td>
    8       <td><button mat-raised-button color="primary" (click)="onFormSavePlanner(planner.id)">Save</button></td>
    9     </tr>
    10    
    11   </tbody>
    12 </table>
    13   </form>
    14  
    15   <button type="button"  mat-button (click)="onCancelClick()">Cancel</button>
     1<p-table [value]="planners" [paginator]="true" [rows]="3" [responsive]="true">
     2    <ng-template pTemplate="header">
     3        <tr>
     4            <th pSortableColumn="name">Name <p-sortIcon field="vin"></p-sortIcon>
     5            </th>
     6            <th style="width:4em"></th>
     7        </tr>
     8    </ng-template>
     9    <ng-template pTemplate="body" let-planner>
     10        <tr>
     11            <td>{{planner.name}}</td>
     12
     13            <td>
     14                <button pButton pRipple type="button" icon="pi pi-heart"
     15                    class="p-button-rounded p-button-help p-button-text" (click)="selectPlanner(planner)"></button>
     16            </td>
     17        </tr>
     18    </ng-template>
     19</p-table>
     20
  • trip-planner-front/src/app/location/add-location-to-planner-panel/add-location-to-planner-panel.component.ts

    r59329aa re29cc2e  
    11import { Component, OnInit } from '@angular/core';
    2 import { MatDialogRef } from '@angular/material/dialog';
    32import { ActivatedRoute } from '@angular/router';
    4 import { PlannerLocationDto } from 'src/app/_models/dto/plannerLocationDto';
    5 import { Location } from 'src/app/_models/location';
    63import { Planner } from 'src/app/_models/planner';
    7 import { LocationService } from 'src/app/_services/location.service';
    84import { PlannerService } from 'src/app/_services/planner.service';
     5import { DynamicDialogRef } from 'primeng/dynamicdialog';
     6
     7
     8
    99
    1010@Component({
     
    1616
    1717  planners: Planner[];
    18   location: Location;
    19   plannerId: number;
    20   locationId: number;
    21   plannerLocationDto: PlannerLocationDto;
    22   locationsInPlanner: Location[];
    2318
    2419
    25   constructor(private dialogRef: MatDialogRef<AddLocationToPlannerPanelComponent>, private plannerService: PlannerService,
    26     private locationService: LocationService, private route: ActivatedRoute) {
     20
     21  constructor(private plannerService: PlannerService,
     22    private route: ActivatedRoute, private ref: DynamicDialogRef) {
    2723    this.planners = [];
    28     this.location = new Location;
    29     this.plannerId = 1;
    30     this.locationId = 1;
    31     this.plannerLocationDto = new PlannerLocationDto();
    32     this.locationsInPlanner = [];
    3324  }
    3425
    3526  ngOnInit(): void {
     27
    3628    this.plannerService.getAllPlanners().subscribe(
    37       data => {
    38         this.planners = data;
     29      planner => {
     30        this.planners = planner;
    3931      }
    4032    );
     33  }
     34
     35  selectPlanner(planner: Planner) {
     36    this.ref.close(planner);
     37  }
    4138
    4239
    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;
    60     /*
    61     this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe(
    62       data => {
    63         console.log(data);
    64       }
    65     );
    66     */
    67 
    68    // window.location.reload();
    69     }
    7040
    7141}
Note: See TracChangeset for help on using the changeset viewer.