mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Attendees Enhancments
This commit is contained in:
@@ -1,15 +1,26 @@
|
|||||||
<ion-header>
|
<ion-header class="ion-no-border">
|
||||||
<ion-toolbar>
|
<ion-toolbar>
|
||||||
<ion-title>attendee-modal</ion-title>
|
<ion-title>Adicionar intervenientes</ion-title>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
<ion-searchbar [(ngModel)]="searchCountryString" (ionChange)="onChange($event)" placeholder="Search"></ion-searchbar>
|
||||||
|
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<ion-searchbar [(ngModel)]="searchCountryString" (input)="searchCountry($event)" placeholder="Search"></ion-searchbar>
|
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<button ion-item *ngFor="let attendee of eventAttendees">
|
<ion-item-sliding>
|
||||||
{{attendee.Name}}
|
<ion-item lines="none" *ngFor="let attendee of contacts">
|
||||||
</button>
|
<ion-checkbox slot="end" [disabled]="isCheckboxDisabled" (ionChange)="selectContact(attendee)"></ion-checkbox>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="div-up">
|
||||||
|
<div class="div-content-attachment">
|
||||||
|
<h3>{{ attendee.Name }}</h3>
|
||||||
|
<p>{{ attendee.EmailAddress }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ion-item>
|
||||||
|
</ion-item-sliding>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<ion-footer class="ion-no-border">
|
<ion-footer class="ion-no-border">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController } from '@ionic/angular';
|
import { ModalController } from '@ionic/angular';
|
||||||
|
import { ContactsService } from 'src/app/services/contacts.service';
|
||||||
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||||
|
import { ThrowStmt, removeSummaryDuplicates } from '@angular/compiler';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-attendee-modal',
|
selector: 'app-attendee-modal',
|
||||||
@@ -8,42 +11,51 @@ import { ModalController } from '@ionic/angular';
|
|||||||
})
|
})
|
||||||
export class AttendeeModalPage implements OnInit {
|
export class AttendeeModalPage implements OnInit {
|
||||||
|
|
||||||
constructor(private modalCtrl: ModalController) { }
|
contacts: EventPerson[];
|
||||||
|
showLoader: boolean = false;
|
||||||
|
eventPersons: EventPerson[];
|
||||||
|
|
||||||
|
constructor(private modalCtrl: ModalController, private contactsService: ContactsService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.fetchContacts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
save(){
|
save(){
|
||||||
//this.eventService.postEvent(this.postEvent, this.postEvent.CalendarName).subscribe();
|
this.modalCtrl.dismiss(this.contacts.filter(function(contact) {
|
||||||
this.modalCtrl.dismiss();
|
return contact.IsRequired == true;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
close(){
|
close(){
|
||||||
this.modalCtrl.dismiss();
|
this.modalCtrl.dismiss(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(evt: any) {
|
onChange(evt: any) {
|
||||||
console.log(evt);
|
this.fetchContacts(evt.detail.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
searchCountry(searchbar) {
|
selectContact(itm: EventPerson){
|
||||||
// reset countries list with initial call
|
itm.IsRequired = !itm.IsRequired;
|
||||||
//this.eventAttendees = this.eventAttendeesInitial;
|
}
|
||||||
|
|
||||||
// set q to the value of the searchbar
|
async fetchContacts(filter: string) {
|
||||||
var q = searchbar.value;
|
this.showLoader = true;
|
||||||
|
|
||||||
// if the value is an empty string don't filter the items
|
this.contactsService.getContacts(filter).subscribe(result =>
|
||||||
// if (q.trim() == '') {
|
{
|
||||||
// return;
|
this.eventPersons.forEach(attendee => {
|
||||||
// }
|
const index: number = result.findIndex((cont) => {
|
||||||
|
return cont.EmailAddress == attendee.EmailAddress
|
||||||
|
});
|
||||||
|
|
||||||
// this.eventAttendees = this.eventAttendees.filter((v) => {
|
result.splice(index, 1);
|
||||||
// if (v.Name.toLowerCase().indexOf(q.toLowerCase()) > -1) {
|
});
|
||||||
// return true;
|
|
||||||
// }
|
this.contacts = result;
|
||||||
// return false;
|
this.showLoader = false;
|
||||||
// })
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<ion-header>
|
<ion-header class="ion-no-border">
|
||||||
<ion-toolbar>
|
<ion-toolbar>
|
||||||
<ion-title>attendees</ion-title>
|
<ion-title>Intervenientes</ion-title>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
<ion-button (click)="addAttendees()" expand="block">
|
||||||
<ion-content>
|
<ion-label>Adicionar intervenientes</ion-label>
|
||||||
|
</ion-button>
|
||||||
<ion-toolbar>
|
<ion-toolbar>
|
||||||
<ion-segment [(ngModel)]="segment" (ionChange)="onSegmentChange()">
|
<ion-segment [(ngModel)]="segment" (ionChange)="onSegmentChange()">
|
||||||
<ion-segment-button value="required">
|
<ion-segment-button value="required">
|
||||||
@@ -14,10 +15,12 @@
|
|||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
</ion-header>
|
||||||
|
<ion-content>
|
||||||
<div [ngSwitch]="segment">
|
<div [ngSwitch]="segment">
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<ion-item-sliding>
|
<ion-item-sliding>
|
||||||
<ion-item lines="none" *ngFor="let attendee of eventAttendees">
|
<ion-item lines="none" *ngFor="let attendee of showAttendees">
|
||||||
<div class="div-item">
|
<div class="div-item">
|
||||||
<div class="div-up">
|
<div class="div-up">
|
||||||
<div class="div-content-attachment">
|
<div class="div-content-attachment">
|
||||||
@@ -32,7 +35,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<ion-footer class="ion-no-border">
|
<ion-footer class="ion-no-border">
|
||||||
<ion-button (click)="addAttendees()" expand="block">
|
<ion-toolbar color="primary">
|
||||||
<ion-lable>Adicionar intervenientes</ion-lable>
|
<ion-buttons slot="start">
|
||||||
|
<ion-button (click)="close()">
|
||||||
|
<ion-label>Cancelar</ion-label>
|
||||||
|
<ion-icon name="close" slot="start"></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
|
</ion-buttons>
|
||||||
|
<ion-buttons slot="end">
|
||||||
|
<ion-button (click)="save()">
|
||||||
|
<ion-label>Gravar</ion-label>
|
||||||
|
<ion-icon name="checkmark" slot="start"></ion-icon>
|
||||||
|
</ion-button>
|
||||||
|
</ion-buttons>
|
||||||
|
</ion-toolbar>
|
||||||
</ion-footer>
|
</ion-footer>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||||
import { EventsService } from 'src/app/services/events.service';
|
import { EventsService } from 'src/app/services/events.service';
|
||||||
import { ModalController } from '@ionic/angular';
|
import { ModalController, NavController } from '@ionic/angular';
|
||||||
import { AttendeeModalPage } from '../attendee-modal/attendee-modal.page';
|
import { AttendeeModalPage } from '../attendee-modal/attendee-modal.page';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -11,14 +11,15 @@ import { AttendeeModalPage } from '../attendee-modal/attendee-modal.page';
|
|||||||
})
|
})
|
||||||
export class AttendeesPage implements OnInit {
|
export class AttendeesPage implements OnInit {
|
||||||
|
|
||||||
eventAttendeesInitial: EventPerson[];
|
|
||||||
eventAttendees: EventPerson[];
|
eventAttendees: EventPerson[];
|
||||||
segment:string = "required";
|
segment:string = "required";
|
||||||
shouldShowCancel:boolean = true;
|
shouldShowCancel:boolean = true;
|
||||||
|
showAttendees: EventPerson[];
|
||||||
|
|
||||||
searchCountryString = ''; // initialize your searchCountryString string empty
|
searchCountryString = ''; // initialize your searchCountryString string empty
|
||||||
|
|
||||||
constructor(private eventService: EventsService, private modalCtrl: ModalController) {
|
constructor(private eventService: EventsService, private modalCtrl: ModalController,
|
||||||
|
private navCtrl: NavController) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -31,22 +32,49 @@ export class AttendeesPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadAttendees(){
|
loadAttendees(){
|
||||||
let isRequired: boolean = (this.segment == "required");
|
let isrequired: boolean = (this.segment == "required");
|
||||||
this.eventAttendees = this.eventService.lastloadedevent.Attendees.filter(function(person) {
|
this.showAttendees = this.eventAttendees.filter(function(person) {
|
||||||
return person.IsRequired == isRequired;
|
return person.IsRequired == isrequired;
|
||||||
});
|
});
|
||||||
this.eventAttendeesInitial = this.eventAttendees;
|
}
|
||||||
|
|
||||||
|
save(){
|
||||||
|
this.modalCtrl.dismiss(this.eventAttendees);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(){
|
||||||
|
this.modalCtrl.dismiss(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addAttendees()
|
async addAttendees()
|
||||||
{
|
{
|
||||||
const modal = await this.modalCtrl.create({
|
const modal = await this.modalCtrl.create({
|
||||||
component: AttendeeModalPage,
|
component: AttendeeModalPage,
|
||||||
|
componentProps: {
|
||||||
|
eventPersons: this.eventAttendees
|
||||||
|
},
|
||||||
cssClass: 'attendee-modal',
|
cssClass: 'attendee-modal',
|
||||||
backdropDismiss: false
|
backdropDismiss: false
|
||||||
});
|
});
|
||||||
|
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss();
|
|
||||||
|
modal.onDidDismiss().then((data) => {
|
||||||
|
let newattendees: EventPerson[] = data['data'];
|
||||||
|
|
||||||
|
if (newattendees != null)
|
||||||
|
{
|
||||||
|
newattendees.forEach(newattendee => {
|
||||||
|
let att = {
|
||||||
|
"EmailAddress": newattendee.EmailAddress,
|
||||||
|
"Name": newattendee.Name,
|
||||||
|
"IsRequired": (this.segment == "required")
|
||||||
|
};
|
||||||
|
this.eventAttendees.push(att);
|
||||||
|
this.showAttendees.push(att);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,7 @@
|
|||||||
<ion-input [(ngModel)]='loadedEvent.Location'></ion-input>
|
<ion-input [(ngModel)]='loadedEvent.Location'></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item-sliding>
|
<ion-item-sliding>
|
||||||
<ion-item
|
<ion-item (click)="openAttendees()">
|
||||||
[routerLink]="['/home/attendees']">
|
|
||||||
<ion-label position="stacked">Pessoas</ion-label>
|
<ion-label position="stacked">Pessoas</ion-label>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-item-sliding>
|
</ion-item-sliding>
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import { EventsService } from 'src/app/services/events.service';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Event } from '../../../models/event.model';
|
import { Event } from '../../../models/event.model';
|
||||||
import { EventBody } from 'src/app/models/eventbody.model';
|
import { EventBody } from 'src/app/models/eventbody.model';
|
||||||
import { AlertController } from '@ionic/angular';
|
import { AlertController, ModalController } from '@ionic/angular';
|
||||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||||
|
import { AttendeesPage } from 'src/app/pages/events/attendees/attendees.page';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-event-detail',
|
selector: 'app-event-detail',
|
||||||
@@ -16,7 +17,7 @@ export class EventDetailPage implements OnInit {
|
|||||||
|
|
||||||
loadedEvent: Event;
|
loadedEvent: Event;
|
||||||
|
|
||||||
constructor(public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute, private eventsService: EventsService) {
|
constructor(public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute, private eventsService: EventsService, private modalCtrl: ModalController) {
|
||||||
this.loadedEvent = new Event();
|
this.loadedEvent = new Event();
|
||||||
this.loadedEvent.Body = new EventBody();
|
this.loadedEvent.Body = new EventBody();
|
||||||
}
|
}
|
||||||
@@ -37,12 +38,32 @@ export class EventDetailPage implements OnInit {
|
|||||||
this.eventsService.getEvent(paramMap.get('eventId')).subscribe(response =>
|
this.eventsService.getEvent(paramMap.get('eventId')).subscribe(response =>
|
||||||
{
|
{
|
||||||
this.loadedEvent = response;
|
this.loadedEvent = response;
|
||||||
this.eventsService.lastloadedevent = this.loadedEvent;
|
//this.eventsService.lastloadedevent = this.loadedEvent;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async openAttendees()
|
||||||
|
{
|
||||||
|
const modal = await this.modalCtrl.create({
|
||||||
|
component: AttendeesPage,
|
||||||
|
componentProps: {
|
||||||
|
eventAttendees: this.loadedEvent.Attendees
|
||||||
|
},
|
||||||
|
cssClass: 'attendee',
|
||||||
|
backdropDismiss: false
|
||||||
|
});
|
||||||
|
|
||||||
|
await modal.present();
|
||||||
|
|
||||||
|
modal.onDidDismiss().then((data) => {
|
||||||
|
let newattendees: EventPerson[] = data['data'];
|
||||||
|
this.loadedEvent.Attendees = newattendees;
|
||||||
|
console.log(this.loadedEvent.Attendees);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getEventAttendees(): EventPerson[]
|
getEventAttendees(): EventPerson[]
|
||||||
{
|
{
|
||||||
return this.loadedEvent.Attendees;
|
return this.loadedEvent.Attendees;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ContactsService } from './contacts.service';
|
||||||
|
|
||||||
|
describe('ContactsService', () => {
|
||||||
|
let service: ContactsService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(ContactsService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { EventPerson } from '../models/eventperson.model';
|
||||||
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
import { AuthService } from '../services/auth.service';
|
||||||
|
import { User } from '../models/user.model';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ContactsService {
|
||||||
|
|
||||||
|
authheader = {};
|
||||||
|
loggeduser: User;
|
||||||
|
headers: HttpHeaders;
|
||||||
|
|
||||||
|
constructor(private http: HttpClient, user: AuthService) {
|
||||||
|
this.loggeduser = user.ValidatedUser;
|
||||||
|
this.headers = new HttpHeaders();
|
||||||
|
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
getContacts(namefilter:string): Observable<EventPerson[]>{
|
||||||
|
const geturl = environment.apiURL + 'contacts/get';
|
||||||
|
let params = new HttpParams();
|
||||||
|
|
||||||
|
params = params.set("namefilter", namefilter);
|
||||||
|
params = params.set("domain", environment.domain);
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.http.get<EventPerson[]>(`${geturl}`, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ export class EventsService {
|
|||||||
authheader = {};
|
authheader = {};
|
||||||
loggeduser: User;
|
loggeduser: User;
|
||||||
headers: HttpHeaders;
|
headers: HttpHeaders;
|
||||||
lastloadedevent: Event;
|
//lastloadedevent: Event;
|
||||||
|
|
||||||
constructor(private http: HttpClient, user: AuthService) {
|
constructor(private http: HttpClient, user: AuthService) {
|
||||||
this.loggeduser = user.ValidatedUser;
|
this.loggeduser = user.ValidatedUser;
|
||||||
|
|||||||
Reference in New Issue
Block a user