[fa375fe] | 1 | {"ast":null,"code":"import { FormControl } from '@angular/forms';\nimport { map, startWith, switchMap } from 'rxjs/operators';\nimport { Observable } from 'rxjs';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"../_services/city.service\";\nimport * as i2 from \"../_services/country.service\";\nimport * as i3 from \"../_services/companion.service\";\nimport * as i4 from \"@angular/forms\";\nimport * as i5 from \"@angular/material/form-field\";\nimport * as i6 from \"@angular/material/input\";\nimport * as i7 from \"@angular/material/autocomplete\";\nimport * as i8 from \"@angular/common\";\nimport * as i9 from \"@angular/material/core\";\n\nfunction LocationsFormComponent_mat_option_7_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-option\", 6);\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const option_r4 = ctx.$implicit;\n i0.ɵɵproperty(\"value\", option_r4.name);\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", option_r4.name, \" \");\n }\n}\n\nfunction LocationsFormComponent_mat_option_15_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-option\", 6);\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const option_r5 = ctx.$implicit;\n i0.ɵɵproperty(\"value\", option_r5.name);\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", option_r5.name, \" \");\n }\n}\n\nexport class LocationsFormComponent {\n constructor(cityService, countryService, companionService) {\n this.cityService = cityService;\n this.countryService = countryService;\n this.companionService = companionService;\n this.myControl = new FormControl();\n this.myControlCompanion = new FormControl();\n this.filteredOptions = new Observable();\n this.cities = [];\n this.countries = [];\n this.companions = [];\n this.filteredOptionsCompanion = new Observable();\n }\n\n ngOnInit() {\n this.filteredOptions = this.myControl.valueChanges.pipe(startWith(''), switchMap(val => {\n return this.filter(val || '');\n }));\n this.filteredOptionsCompanion = this.myControlCompanion.valueChanges.pipe(startWith(''), switchMap(val => {\n return this.filter(val || '');\n }));\n }\n\n filter(val) {\n // call the service which makes the http-request\n return this.cityService.getAllCities().pipe(map(response => response.filter(option => {\n return option.name.toLowerCase().indexOf(val.toLowerCase()) === 0;\n })));\n }\n\n filterCompanion(val) {\n return this.companionService.getAllCompanions();\n }\n\n}\n\nLocationsFormComponent.ɵfac = function LocationsFormComponent_Factory(t) {\n return new (t || LocationsFormComponent)(i0.ɵɵdirectiveInject(i1.CityService), i0.ɵɵdirectiveInject(i2.CountryService), i0.ɵɵdirectiveInject(i3.CompanionService));\n};\n\nLocationsFormComponent.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: LocationsFormComponent,\n selectors: [[\"app-locations-form\"]],\n decls: 17,\n vars: 10,\n consts: [[1, \"example-form\"], [\"appearance\", \"fill\", 1, \"example-full-width\"], [\"type\", \"text\", \"placeholder\", \"Pick one\", \"aria-label\", \"Place\", \"matInput\", \"\", 3, \"formControl\", \"matAutocomplete\"], [\"autoActiveFirstOption\", \"\"], [\"auto\", \"matAutocomplete\"], [3, \"value\", 4, \"ngFor\", \"ngForOf\"], [3, \"value\"]],\n template: function LocationsFormComponent_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"form\", 0);\n i0.ɵɵelementStart(1, \"mat-form-field\", 1);\n i0.ɵɵelementStart(2, \"mat-label\");\n i0.ɵɵtext(3, \"Please select a place\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(4, \"input\", 2);\n i0.ɵɵelementStart(5, \"mat-autocomplete\", 3, 4);\n i0.ɵɵtemplate(7, LocationsFormComponent_mat_option_7_Template, 2, 2, \"mat-option\", 5);\n i0.ɵɵpipe(8, \"async\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(9, \"mat-form-field\", 1);\n i0.ɵɵelementStart(10, \"mat-label\");\n i0.ɵɵtext(11, \"Please select a place\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(12, \"input\", 2);\n i0.ɵɵelementStart(13, \"mat-autocomplete\", 3, 4);\n i0.ɵɵtemplate(15, LocationsFormComponent_mat_option_15_Template, 2, 2, \"mat-option\", 5);\n i0.ɵɵpipe(16, \"async\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const _r0 = i0.ɵɵreference(6);\n\n i0.ɵɵadvance(4);\n i0.ɵɵproperty(\"formControl\", ctx.myControl)(\"matAutocomplete\", _r0);\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"ngForOf\", i0.ɵɵpipeBind1(8, 6, ctx.filteredOptions));\n i0.ɵɵadvance(5);\n i0.ɵɵproperty(\"formControl\", ctx.myControl)(\"matAutocomplete\", _r0);\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"ngForOf\", i0.ɵɵpipeBind1(16, 8, ctx.filteredOptions));\n }\n },\n directives: [i4.ɵNgNoValidate, i4.NgControlStatusGroup, i4.NgForm, i5.MatFormField, i5.MatLabel, i6.MatInput, i4.DefaultValueAccessor, i7.MatAutocompleteTrigger, i4.NgControlStatus, i4.FormControlDirective, i7.MatAutocomplete, i8.NgForOf, i9.MatOption],\n pipes: [i8.AsyncPipe],\n styles: [\".example-form[_ngcontent-%COMP%] {\\r\\n min-width: 150px;\\r\\n max-width: 500px;\\r\\n width: 100%;\\r\\n}\\r\\n\\r\\n.example-full-width[_ngcontent-%COMP%] {\\r\\n width: 100%;\\r\\n}\\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxvY2F0aW9ucy1mb3JtLmNvbXBvbmVudC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxnQkFBZ0I7RUFDaEIsZ0JBQWdCO0VBQ2hCLFdBQVc7QUFDYjs7QUFFQTtFQUNFLFdBQVc7QUFDYiIsImZpbGUiOiJsb2NhdGlvbnMtZm9ybS5jb21wb25lbnQuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLmV4YW1wbGUtZm9ybSB7XHJcbiAgbWluLXdpZHRoOiAxNTBweDtcclxuICBtYXgtd2lkdGg6IDUwMHB4O1xyXG4gIHdpZHRoOiAxMDAlO1xyXG59XHJcblxyXG4uZXhhbXBsZS1mdWxsLXdpZHRoIHtcclxuICB3aWR0aDogMTAwJTtcclxufSJdfQ== */\"]\n});","map":{"version":3,"sources":["C:\\Users\\DELL\\Desktop\\bachelor-thesis\\trip-planner-front\\src\\app\\locations-form\\locations-form.component.ts","C:\\Users\\DELL\\Desktop\\bachelor-thesis\\trip-planner-front\\src\\app\\locations-form\\locations-form.component.html"],"names":[],"mappings":"AACA,SAAS,WAAT,QAA4B,gBAA5B;AACA,SAAQ,GAAR,EAAa,SAAb,EAAwB,SAAxB,QAAwC,gBAAxC;AACA,SAAkB,UAAlB,QAAmC,MAAnC;;;;;;;;;;;;;;ACOM,IAAA,EAAA,CAAA,cAAA,CAAA,CAAA,EAAA,YAAA,EAAA,CAAA;AACE,IAAA,EAAA,CAAA,MAAA,CAAA,CAAA;AACF,IAAA,EAAA,CAAA,YAAA;;;;;AAF2D,IAAA,EAAA,CAAA,UAAA,CAAA,OAAA,EAAA,SAAA,CAAA,IAAA;AACzD,IAAA,EAAA,CAAA,SAAA,CAAA,CAAA;AAAA,IAAA,EAAA,CAAA,kBAAA,CAAA,GAAA,EAAA,SAAA,CAAA,IAAA,EAAA,GAAA;;;;;;AAcF,IAAA,EAAA,CAAA,cAAA,CAAA,CAAA,EAAA,YAAA,EAAA,CAAA;AACE,IAAA,EAAA,CAAA,MAAA,CAAA,CAAA;AACF,IAAA,EAAA,CAAA,YAAA;;;;;AAF2D,IAAA,EAAA,CAAA,UAAA,CAAA,OAAA,EAAA,SAAA,CAAA,IAAA;AACzD,IAAA,EAAA,CAAA,SAAA,CAAA,CAAA;AAAA,IAAA,EAAA,CAAA,kBAAA,CAAA,GAAA,EAAA,SAAA,CAAA,IAAA,EAAA,GAAA;;;;ADVR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AAA,SAAA,EAAyB,iBAAzB,EAAyB,GAAzB;AAG0B,MAAA,EAAA,CAAA,SAAA,CAAA,CAAA;AAAA,MAAA,EAAA,CAAA,UAAA,CAAA,SAAA,EAAA,EAAA,CAAA,WAAA,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,CAAA,eAAA,CAAA","sourcesContent":["import { Component, Injectable, OnInit } from '@angular/core';\nimport { FormControl } from '@angular/forms';\nimport {map, startWith, switchMap} from 'rxjs/operators';\nimport {forkJoin, Observable} from 'rxjs';\nimport { CityService } from '../_services/city.service';\nimport { City } from '../_models/city';\nimport { Country } from '../_models/country';\nimport { CountryService } from '../_services/country.service';\nimport { Companion } from '../_models/companion';\nimport { CompanionService } from '../_services/companion.service';\n\n@Component({\n selector: 'app-locations-form',\n templateUrl: './locations-form.component.html',\n styleUrls: ['./locations-form.component.css']\n})\nexport class LocationsFormComponent implements OnInit {\n\n myControl = new FormControl();\n cities: City[];\n countries: Country[];\n companions: Companion[];\n filteredOptions: Observable<City[]>;\n filteredOptionsCompanion: Observable<Companion[]>;\n myControlCompanion= new FormControl();\n\n constructor(private cityService : CityService, private countryService : CountryService,\n private companionService : CompanionService){\n this.filteredOptions = new Observable<City[]>();\n this.cities = [];\n this.countries = [];\n this.companions = [];\n this.filteredOptionsCompanion = new Observable<Companion[]>();\n }\n \n ngOnInit() :void {\n this.filteredOptions = this.myControl.valueChanges\n .pipe(\n startWith(''),\n switchMap(val => {\n return this.filter(val || '')\n }) \n );\n\n this.filteredOptionsCompanion = this.myControlCompanion.valueChanges\n .pipe(\n startWith(''),\n switchMap(val => {\n return this.filter(val || '')\n })\n );\n\n \n }\n \n filter(val: string): Observable<any[]> {\n // call the service which makes the http-request\n return this.cityService.getAllCities()\n .pipe(\n map(response => response.filter(option => { \n return option.name.toLowerCase().indexOf(val.toLowerCase()) === 0\n }))\n )\n \n } \n\n filterCompanion(val: string) : Observable<Companion[]>{\n return this.companionService.getAllCompanions()\n }\n\n\n}\n","<form class=\"example-form\">\n <mat-form-field class=\"example-full-width\" appearance=\"fill\">\n <mat-label>Please select a place</mat-label>\n <input type=\"text\"\n placeholder=\"Pick one\"\n aria-label=\"Place\"\n matInput\n [formControl]=\"myControl\"\n [matAutocomplete]=\"auto\">\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of filteredOptions | async\" [value]=\"option.name\">\n {{option.name}}\n </mat-option>\n </mat-autocomplete>\n </mat-form-field>\n\n <mat-form-field class=\"example-full-width\" appearance=\"fill\">\n <mat-label>Please select a place</mat-label>\n <input type=\"text\"\n placeholder=\"Pick one\"\n aria-label=\"Place\"\n matInput\n [formControl]=\"myControl\"\n [matAutocomplete]=\"auto\">\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of filteredOptions | async\" [value]=\"option.name\">\n {{option.name}}\n </mat-option>\n </mat-autocomplete>\n </mat-form-field>\n</form>"],"sourceRoot":""},"metadata":{},"sourceType":"module"} |
---|