Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { NgOptimizedImage } from '@angular/common';
import { Component, Input, OnInit, inject, input, output } from '@angular/core';
import { FlagService } from '@services/flag.service';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { CityClass } from '@classes/city.class';
import { PreviewDestinationModalComponent } from '../preview-destination-modal/preview-destination-modal.component';
@Component({
selector: 'grt-citybox-mobile',
templateUrl: './citybox-mobile.component.html',
styleUrl: './citybox-mobile.component.scss',
imports: [ NgOptimizedImage],
providers: [BsModalService],
})
export class CityboxMobileComponent implements OnInit {
private modalService = inject(BsModalService);
flagService = inject(FlagService);
@Input() city!: CityClass;
readonly index = input.required<number>();
readonly deselect = output<CityClass>();
readonly selected = output<CityClass>();
readonly showdetails = output<CityClass>();
selectedCity!: CityClass;
countryName!: string;
modalRef!: BsModalRef;
hover = false;
ngOnInit() {
this.countryName = this.city && this.city.countryName.replace(/\s+/g, '-');
}
replaceUrl(url: string) {
return url.replace(/https:\/\/res-(?:[1-5]\.|)\bcloudinary.com\/gorealtravel\/image\/upload\//g, '');
}
add() {
this.selected.emit(this.city);
}
remove() {
this.deselect.emit(this.city);
}
details() {
this.showdetails.emit(this.city);
}
openModal(data: any) {
const initialState = {
city: data, // Pass data to the modal
};
this.modalRef = this.modalService.show(PreviewDestinationModalComponent, {
initialState,
});
this.modalRef.content.addCityToTrip.subscribe(() => {
this.add(); // Call the function in the parent component
});
this.modalRef.content.removeCityFromTrip.subscribe(() => {
this.remove(); // Call the function in the parent component
});
}
setHover(bool: boolean) {
this.hover = bool;
}
}
|