commit all

This commit is contained in:
Peter Maquiran
2021-04-05 15:10:28 +01:00
parent 3727e73c1d
commit 016c006edc
7 changed files with 771 additions and 30 deletions
@@ -2,6 +2,7 @@ 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';
import { el } from 'date-fns/locale';
@Component({
selector: 'app-attendee-modal',
@@ -16,33 +17,43 @@ export class AttendeeModalPage implements OnInit {
selectedContact: EventPerson[] =[];
eventPersons: EventPerson[];
@Input() taskParticipants = [];
@Input() taskParticipantsCc= [];
@Input() eventAttendees: EventPerson[];
constructor(private modalCtrl: ModalController, private contactsService: ContactsService) { }
@Output() closeComponent = new EventEmitter<any>();
@Output() setContact = new EventEmitter<any>();
@Output() setIntervenient = new EventEmitter<any>();
@Output() setIntervenientCC = new EventEmitter<any>();
currentPath = window.location.pathname;
@Input() adding: "intervenient" | "CC";
ngOnInit() {
this.fetchContacts("");
this.selectedContact = this.eventAttendees;
this.taskParticipants = this.taskParticipants
this.taskParticipantsCc = this.taskParticipantsCc;
}
ngOnChanges(){
console.log('change !!!')
}
ngOnChanges(event){}
save(){
// set data to agenda component
this.setContact.emit(this.selectedContact);
this.setIntervenient.emit(this.taskParticipants);
this.setIntervenientCC.emit(this.taskParticipantsCc);
this.closeComponent.emit();
}
setContactWithClose(){
if(this.currentPath == '/home/gabinete-digital'){
this.setContact.emit(this.selectedContact);
this.setIntervenient.emit(this.taskParticipants);
this.setIntervenientCC.emit(this.taskParticipantsCc);
}
}
@@ -58,37 +69,75 @@ export class AttendeeModalPage implements OnInit {
filterSearchList(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;
if(this.adding == "intervenient"){
const result = this.taskParticipants.find((contact, index)=>{
if(contact.Name == itm.Name && contact.EmailAddress == itm.EmailAddress){
index = index;
return contact;
}
});
return undefined == result;
} else if (this.adding == "CC") {
const result = this.taskParticipantsCc.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(this.adding == "intervenient"){
if(contact.Name != itm.Name && contact.EmailAddress != itm.EmailAddress){
return contact;
}
return false;
this.taskParticipants = this.taskParticipants.filter((contact, index) =>{
});
if(contact.Name != itm.Name && contact.EmailAddress != itm.EmailAddress){
return contact;
}
return false;
});
} else if (this.adding == "CC") {
this.taskParticipantsCc = this.taskParticipantsCc.filter((contact, index) =>{
if(contact.Name != itm.Name && contact.EmailAddress != itm.EmailAddress){
return contact;
}
return false;
});
}
// run only in gabinete digital
this.setContactWithClose();
}
async selectContact(itm: EventPerson){
this.selectedContact.push(itm);
if(this.adding == "intervenient"){
this.taskParticipants.push(itm);
} else if (this.adding == "CC") {
this.taskParticipantsCc.push(itm);
}
// run only in gabinete digital
this.setContactWithClose();
}