Files
doneit-web/src/app/pages/search/sender/sender.page.ts
T

61 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-01-16 17:45:09 +01:00
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
2021-01-19 08:52:43 +01:00
import { ContactsService } from 'src/app/services/contacts.service';
import { EventPerson } from 'src/app/models/eventperson.model';
2021-10-25 13:54:34 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2021-01-19 16:44:39 +01:00
2021-01-16 17:45:09 +01:00
@Component({
selector: 'app-sender',
templateUrl: './sender.page.html',
styleUrls:
['./sender.page.scss'],
})
export class SenderPage implements OnInit {
2021-01-19 08:52:43 +01:00
contacts: EventPerson[];
showContacts: EventPerson[];
2021-01-19 16:44:39 +01:00
sender: string;
selectedUser: string;
2021-01-19 08:52:43 +01:00
constructor(private modalController:ModalController,
2021-10-25 13:54:34 +01:00
private ContactsService: ContactsService,
public ThemeService: ThemeService) {
2021-01-19 08:52:43 +01:00
}
2021-01-16 17:45:09 +01:00
ngOnInit() {
2021-01-19 08:52:43 +01:00
this.getSender();
}
getSender(){
this.ContactsService.getContacts("").subscribe(res=>{
this.contacts = res;
2021-02-08 17:10:01 +01:00
this.showContacts = res
2021-01-19 08:52:43 +01:00
});
}
2021-01-19 16:44:39 +01:00
2021-03-30 15:35:22 +01:00
filterContact(event?:any){
2021-01-19 08:52:43 +01:00
2021-01-19 16:44:39 +01:00
const findPerson = this.sender.toLowerCase();
const persons = this.contacts.filter((person) => {
2021-01-19 08:52:43 +01:00
2021-01-19 16:44:39 +01:00
if (person.Name.toLowerCase().indexOf(findPerson) == 0){
return true;
}
2021-01-19 08:52:43 +01:00
2021-01-19 16:44:39 +01:00
});
2021-01-19 08:52:43 +01:00
2021-01-19 16:44:39 +01:00
this.showContacts = persons;
}
2021-01-19 08:52:43 +01:00
2023-08-11 16:14:25 +01:00
selectUser(username){
2021-01-19 16:44:39 +01:00
this.selectedUser = username;
this.close(this.selectedUser);
2021-01-16 17:45:09 +01:00
}
2021-03-30 15:35:22 +01:00
close(username?: string){
2021-01-19 16:44:39 +01:00
this.modalController.dismiss(username);
2021-01-16 17:45:09 +01:00
}
}