mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
lot of changes
This commit is contained in:
@@ -8,6 +8,7 @@ import { ViewChild } from '@angular/core';
|
||||
import { Searchbar } from 'ionic-angular';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-attendee-modal',
|
||||
@@ -31,8 +32,8 @@ export class AttendeePage implements OnInit {
|
||||
@Output() dynamicSetIntervenient = new EventEmitter<any>();
|
||||
|
||||
|
||||
@Input() taskParticipants:EventPerson[] = [];
|
||||
@Input() taskParticipantsCc:EventPerson[] = [];
|
||||
@Input() taskParticipants: EventPerson[] = [];
|
||||
@Input() taskParticipantsCc: EventPerson[] = [];
|
||||
@Input() loggedAttendSon: boolean;
|
||||
|
||||
@Input() footer: boolean;
|
||||
@@ -40,49 +41,67 @@ export class AttendeePage implements OnInit {
|
||||
@Input() selectLogUser: boolean = true;
|
||||
|
||||
@ViewChild('Searchbar') searchbar: Searchbar;
|
||||
@Input() taskType: any;
|
||||
|
||||
LtaskParticipants: EventPerson[] = [];
|
||||
LtaskParticipantsCc: EventPerson[] = [];
|
||||
loggeduser: LoginUserRespose;
|
||||
listOfNotAllowdRoute = ['/home/gabinete-digital/despachos/', ]
|
||||
|
||||
constructor(
|
||||
private modalCtrl: ModalController,
|
||||
private modalCtrl: ModalController,
|
||||
private contactsService: ContactsService,
|
||||
public ThemeService: ThemeService ) {
|
||||
public ThemeService: ThemeService,
|
||||
private router: Router,) {
|
||||
|
||||
|
||||
|
||||
this.LtaskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.LtaskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
this.loggeduser = SessionStore.user;
|
||||
|
||||
this.LtaskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.LtaskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
this.loggeduser = SessionStore.user;
|
||||
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.LtaskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.LtaskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.LtaskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
console.log('PARTE PARTE',this.loggedAttendSon)
|
||||
console.log('PARTE PARTE', this.loggedAttendSon)
|
||||
}
|
||||
|
||||
|
||||
currentPath = window.location.pathname;
|
||||
@Input() adding: "intervenient" | "CC";
|
||||
|
||||
ngOnInit() {
|
||||
console.log('TASK TYPE',this.taskType);
|
||||
console.log('Pesquisa de contactos current path3', this.router.url)
|
||||
setTimeout(() => {
|
||||
console.log('PARTE PARTE',this.loggedAttendSon)
|
||||
});
|
||||
|
||||
console.log('PARTE PARTE', this.loggedAttendSon)
|
||||
});
|
||||
|
||||
this.fetchContacts("");
|
||||
|
||||
if(this.LtaskParticipants == null || this.LtaskParticipants == undefined) {
|
||||
|
||||
if (this.LtaskParticipants == null || this.LtaskParticipants == undefined) {
|
||||
this.LtaskParticipants = [];
|
||||
}
|
||||
|
||||
if(this.LtaskParticipantsCc == null || this.LtaskParticipantsCc == undefined) {
|
||||
if (this.LtaskParticipantsCc == null || this.LtaskParticipantsCc == undefined) {
|
||||
this.LtaskParticipantsCc = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
removeIdfromRoute(route: string) {
|
||||
let lastIndex: number = route.lastIndexOf('/');
|
||||
if (lastIndex !== -1) {
|
||||
let modifiedString: string = route.slice(0, lastIndex + 1);
|
||||
console.log(modifiedString);
|
||||
|
||||
} else {
|
||||
console.log("No '/' found in the string.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
save() {
|
||||
|
||||
this.setIntervenient.emit(removeDuplicate(this.LtaskParticipants));
|
||||
@@ -94,10 +113,10 @@ export class AttendeePage implements OnInit {
|
||||
|
||||
setContactWithClose() {
|
||||
|
||||
if(this.currentPath == '/home/gabinete-digital') {
|
||||
if (this.currentPath == '/home/gabinete-digital') {
|
||||
this.setIntervenient.emit(this.LtaskParticipants);
|
||||
this.setIntervenientCC.emit(this.LtaskParticipantsCc);
|
||||
}
|
||||
}
|
||||
|
||||
this.dynamicSetIntervenient.emit({
|
||||
taskParticipants: this.LtaskParticipants,
|
||||
@@ -108,19 +127,19 @@ export class AttendeePage implements OnInit {
|
||||
|
||||
async selectContact(itm: EventPerson) {
|
||||
|
||||
if(this.adding == "intervenient") {
|
||||
if (this.adding == "intervenient") {
|
||||
|
||||
itm.IsRequired = true;
|
||||
this.LtaskParticipants.push(itm);
|
||||
|
||||
|
||||
} else if (this.adding == "CC") {
|
||||
|
||||
|
||||
itm.IsRequired = false;
|
||||
this.LtaskParticipantsCc.push(itm);
|
||||
} else {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
// run only in gabinete digital
|
||||
|
||||
this.setContactWithClose();
|
||||
@@ -136,115 +155,116 @@ export class AttendeePage implements OnInit {
|
||||
|
||||
filterSearchList(itm: EventPerson): boolean {
|
||||
|
||||
const result = this.LtaskParticipants.concat(this.LtaskParticipantsCc).find((contact, index)=>{
|
||||
const result = this.LtaskParticipants.concat(this.LtaskParticipantsCc).find((contact, index) => {
|
||||
|
||||
if(this.checkStringNull(contact.Name) == this.checkStringNull(itm.Name) && this.checkStringNull(contact.EmailAddress) == this.checkStringNull(itm.EmailAddress)){
|
||||
if (this.checkStringNull(contact.Name) == this.checkStringNull(itm.Name) && this.checkStringNull(contact.EmailAddress) == this.checkStringNull(itm.EmailAddress)) {
|
||||
index = index;
|
||||
return contact;
|
||||
}
|
||||
});
|
||||
|
||||
// if to show
|
||||
if(undefined != result){
|
||||
if (undefined != result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const result2 = this.LtaskParticipantsCc.find((contact, index)=>{
|
||||
|
||||
if(this.checkStringNull(contact.Name) == itm.Name && this.checkStringNull(contact.EmailAddress) == this.checkStringNull(itm.EmailAddress)){
|
||||
|
||||
const result2 = this.LtaskParticipantsCc.find((contact, index) => {
|
||||
|
||||
if (this.checkStringNull(contact.Name) == itm.Name && this.checkStringNull(contact.EmailAddress) == this.checkStringNull(itm.EmailAddress)) {
|
||||
index = index;
|
||||
return contact;
|
||||
}
|
||||
});
|
||||
|
||||
// if to show
|
||||
if(undefined != result2) {
|
||||
if (undefined != result2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// don't show
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
remove(itm: EventPerson) {
|
||||
|
||||
if(this.adding == "intervenient"){
|
||||
if (this.adding == "intervenient") {
|
||||
|
||||
this.LtaskParticipants = this.LtaskParticipants.filter((contact, index) =>{
|
||||
this.LtaskParticipants = this.LtaskParticipants.filter((contact, index) => {
|
||||
|
||||
if(contact.Name.toLocaleLowerCase() != itm.Name.toLocaleLowerCase() && contact.EmailAddress.toLocaleLowerCase() != itm.EmailAddress.toLocaleLowerCase()){
|
||||
if (contact.Name.toLocaleLowerCase() != itm.Name.toLocaleLowerCase() && contact.EmailAddress.toLocaleLowerCase() != itm.EmailAddress.toLocaleLowerCase()) {
|
||||
return contact;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
});
|
||||
|
||||
} else if (this.adding == "CC") {
|
||||
|
||||
this.LtaskParticipantsCc = this.LtaskParticipantsCc.filter((contact, index) =>{
|
||||
this.LtaskParticipantsCc = this.LtaskParticipantsCc.filter((contact, index) => {
|
||||
|
||||
if(contact.Name.toLocaleLowerCase() != itm.Name.toLocaleLowerCase() && contact.EmailAddress.toLocaleLowerCase() != itm.EmailAddress.toLocaleLowerCase()){
|
||||
if (contact.Name.toLocaleLowerCase() != itm.Name.toLocaleLowerCase() && contact.EmailAddress.toLocaleLowerCase() != itm.EmailAddress.toLocaleLowerCase()) {
|
||||
return contact;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
this.setContactWithClose();
|
||||
|
||||
|
||||
}
|
||||
|
||||
sort(data: []) {
|
||||
return data.sort(function (a: any, b: any) {
|
||||
if (a.Name > b.Name) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
if (b.Name > a.Name) {
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}).reverse()
|
||||
}).reverse()
|
||||
}
|
||||
|
||||
async fetchContacts(filter: string) {
|
||||
this.showLoader = true;
|
||||
|
||||
this.contactsService.getContacts(filter).subscribe(result =>
|
||||
{
|
||||
if (this.eventPersons != null)
|
||||
{
|
||||
this.eventPersons.forEach(attendee => {
|
||||
const index: number = result.findIndex((cont) => {
|
||||
return this.checkStringNull(cont.EmailAddress) == this.checkStringNull(attendee.EmailAddress)
|
||||
});
|
||||
|
||||
result.splice(index, 1);
|
||||
this.contactsService.getContacts(filter).subscribe(result => {
|
||||
if (this.eventPersons != null) {
|
||||
this.eventPersons.forEach(attendee => {
|
||||
const index: number = result.findIndex((cont) => {
|
||||
return this.checkStringNull(cont.EmailAddress) == this.checkStringNull(attendee.EmailAddress)
|
||||
});
|
||||
}
|
||||
|
||||
if(this.loggedAttendSon) {
|
||||
this.contacts = this.sort(result as any);
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
this.contacts = this.sort(result as any);
|
||||
console.log('Attendes Email',this.loggeduser.Email)
|
||||
result.splice(index, 1);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.loggedAttendSon) {
|
||||
this.contacts = this.sort(result as any);
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
this.contacts = this.sort(result as any);
|
||||
console.log('Attendes Email', this.loggeduser.Email)
|
||||
let filterLoggedUserEmail = this.contacts.filter(item => item.EmailAddress.toLocaleLowerCase() != this.loggeduser.Email.toLocaleLowerCase())
|
||||
if(this.taskType == 0 || this.taskType == 1){
|
||||
filterLoggedUserEmail = this.contacts.filter(item => item.IsPR == false)
|
||||
}
|
||||
console.log('Attendes Email', filterLoggedUserEmail)
|
||||
let filterEmptyEmail = filterLoggedUserEmail.filter(item => item.EmailAddress.toLocaleLowerCase() != "")
|
||||
this.contacts = filterEmptyEmail;
|
||||
console.log('Attendes Email', this.contacts)
|
||||
this.showLoader = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
checkStringNull(value: string) {
|
||||
if(value) {
|
||||
if (value) {
|
||||
return value.toLowerCase();
|
||||
} else {
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user