mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve Attendees component for agenda
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ContactsService } from 'src/app/services/contacts.service';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
@@ -12,22 +12,27 @@ export class AttendeeModalPage implements OnInit {
|
||||
|
||||
contacts: EventPerson[];
|
||||
showLoader: boolean = false;
|
||||
selectedContact: EventPerson[] =[];
|
||||
eventPersons: EventPerson[];
|
||||
|
||||
@Input() eventAttendees: EventPerson[];
|
||||
|
||||
constructor(private modalCtrl: ModalController, private contactsService: ContactsService) { }
|
||||
|
||||
@Output() openAttendeesComponent = new EventEmitter<any>();
|
||||
@Output() GoBackEditOrAdd = new EventEmitter<any>();
|
||||
|
||||
ngOnInit() {
|
||||
this.fetchContacts("");
|
||||
this.selectedContact = this.eventAttendees;
|
||||
}
|
||||
|
||||
save(){
|
||||
|
||||
this.openAttendeesComponent.emit(this.contacts.filter(function(contact) {
|
||||
return contact.IsRequired == true;
|
||||
}));
|
||||
|
||||
// set data to agenda component
|
||||
this.openAttendeesComponent.emit(this.selectedContact);
|
||||
// got back
|
||||
this.GoBackEditOrAdd.emit();
|
||||
}
|
||||
|
||||
close(){
|
||||
@@ -39,8 +44,45 @@ export class AttendeeModalPage implements OnInit {
|
||||
this.fetchContacts(evt.detail.value);
|
||||
}
|
||||
|
||||
selectContact(itm: EventPerson){
|
||||
itm.IsRequired = !itm.IsRequired;
|
||||
|
||||
checkbox(itm: EventPerson): boolean {
|
||||
const result = this.selectedContact.find((contact, index)=>{
|
||||
|
||||
if(contact.Name == itm.Name && contact.EmailAddress == itm.EmailAddress){
|
||||
index = index;
|
||||
return contact;
|
||||
}
|
||||
});
|
||||
|
||||
return undefined == result;
|
||||
}
|
||||
|
||||
remove(itm: EventPerson){
|
||||
|
||||
this.selectedContact = this.selectedContact.filter((contact, index) =>{
|
||||
|
||||
if(contact.Name != itm.Name && contact.EmailAddress != itm.EmailAddress){
|
||||
return contact;
|
||||
}
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async selectContact(itm: EventPerson){
|
||||
|
||||
const index = 0;
|
||||
const findIndex = this.selectedContact.find((contact, index)=>{
|
||||
|
||||
if(contact.Name == itm.Name && contact.EmailAddress == itm.EmailAddress){
|
||||
index = index;
|
||||
return contact;
|
||||
}
|
||||
});
|
||||
|
||||
this.selectedContact.push(itm);
|
||||
|
||||
}
|
||||
|
||||
async fetchContacts(filter: string) {
|
||||
|
||||
Reference in New Issue
Block a user