This commit is contained in:
Peter Maquiran
2021-08-31 09:00:33 +01:00
parent 23d73c6d5f
commit 6b61630abc
11 changed files with 157 additions and 58 deletions
+18 -13
View File
@@ -1,5 +1,7 @@
import { eventSource } from 'src/app/models/agenda/eventSource';
import { setHours, setMinutes } from 'date-fns';
import { CustomCalendarEvent, EventList, EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { CalendarEvent } from 'angular-calendar';
export class eventListBox {
@@ -24,11 +26,11 @@ export class eventListBox {
}
filterProfile(eventSource: eventSource[], profile: 'md' | 'pr' | 'all') {
filterProfile(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all') {
return eventSource.filter((e) => e.profile == profile)
}
getEventInsideRange(eventSource: eventSource[], rangeStartDate, randEndDate) {
getEventInsideRange(eventSource: EventListStore[], rangeStartDate, randEndDate) {
return eventSource.filter((e)=> {
if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() &&
new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) {
@@ -40,7 +42,7 @@ export class eventListBox {
daysBetween(){ }
list(eventSource: eventSource[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
if(profile != 'all') {
eventSource = this.filterProfile(eventSource, profile)
@@ -48,19 +50,21 @@ export class eventListBox {
eventSource = this.getEventInsideRange(eventSource, rangeStartDate, randEndDate)
let newStracture:CustomCalendarEvent[];
if(profile == 'md') {
eventSource = this.encapsulation(eventSource, 'mdgpr');
newStracture = this.encapsulation(eventSource, 'mdgpr');
} else {
eventSource = this.encapsulation(eventSource, 'pr');
newStracture = this.encapsulation(eventSource, 'pr');
}
return this.display(eventSource)
return this.display(newStracture)
}
display(list) {
let days = {};
console.log(list)
list.forEach( (event:any, index)=> {
list.forEach( (event, index)=> {
var startDate: any = new Date(event.start);
@@ -215,27 +219,28 @@ export class eventListBox {
return days
}
encapsulation(eventsList, profile) {
encapsulation(eventsList, profile): CustomCalendarEvent[] {
// remove all event
let events = [];
let events: CustomCalendarEvent[] = [];
eventsList.forEach((element, eventIndex) => {
events.push({
start: new Date(element.StartDate || element.startTime),
end: new Date(element.EndDate || element.endTime),
start: new Date(element.startTime),
end: new Date(element.endTime),
color: {
primary: '#0000',
secondary: '#0000'
},
id: element.EventId || element.id,
id: element.id,
index: eventIndex,
profile: profile,
CalendarName: element.calendarName,
event: element.event,
});
console.log('element.event', element.event)
});
return events;
+1 -1
View File
@@ -53,7 +53,7 @@ export class EventsPage implements OnInit {
customText = false;
totalEvent=0;
currentHoursMinutes: Date;
currentHoursMinutes: Date | string;
showLoader: boolean;