Improve Agenda save to local storage

This commit is contained in:
Peter Maquiran
2021-07-18 18:56:53 +01:00
parent c2e7ea799e
commit 9fed35f8df
9 changed files with 504 additions and 397 deletions
+1 -1
View File
@@ -85,7 +85,7 @@
<calendar
class="calendar-component"
[eventSource]="eventSource"
[eventSource]="calendarService.eventSource"
[calendarMode]="calendar.mode"
[currentDate]="calendar.currentDate"
(onEventSelected)="onEventSelected($event)"
+92 -382
View File
@@ -26,7 +26,8 @@ import { User } from 'src/app/models/user.model';
import { DateAdapter } from '@angular/material/core';
import { ToastService } from 'src/app/services/toast.service';
import { eventSource } from 'src/app/models/agenda/eventSource';
import { eventListBox as eventListBoxComponent } from './eventListBox'
import { CalendarService } from 'src/app/store/calendar.service';
@Component({
selector: 'app-agenda',
templateUrl: './agenda.page.html',
@@ -122,6 +123,8 @@ export class AgendaPage implements OnInit {
startTime: Date;
endTime: Date;
eventListBoxComponent = new eventListBoxComponent()
mobileComponent = {
showAddNewEvent: false,
showEditEvent: false,
@@ -158,7 +161,8 @@ export class AgendaPage implements OnInit {
private sanitizer: DomSanitizer,
authService: AuthService,
private dateAdapter: DateAdapter<any>,
private toastService: ToastService
private toastService: ToastService,
public calendarService: CalendarService
) {
this.dateAdapter.setLocale('es');
@@ -177,6 +181,10 @@ export class AgendaPage implements OnInit {
if(this.loggeduser.Profile == 'MDGPR') {
this.mobileComponent.showEventList = true;
}
setTimeout(()=>{
this.updateEventListBox()
}, 4000)
}
@@ -262,8 +270,7 @@ export class AgendaPage implements OnInit {
//Show information of the event
async onEventSelected(ev: { event: Event}){
/* this.viewEventDetail(ev.event.EventId); */
this.router.navigate(["/home/agenda", ev.event.EventId, 'agenda']);
}
@@ -293,6 +300,7 @@ export class AgendaPage implements OnInit {
this.rangeEndDate = ev.endTime;
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
this.updateEventListBox()
}
// for calendar
@@ -310,22 +318,8 @@ export class AgendaPage implements OnInit {
events.forEach(element => {
const startTimeSamp = new Date(element.startTime).toLocaleDateString()
const endTimeSamp = new Date(element.endTime).toLocaleDateString()
const endMinutes = new Date(element.endTime).getMinutes()
const endHours = new Date(element.endTime).getHours()
const endDay: number = new Date(element.endTime).getDate()
const startDay = new Date(element.startTime).getDate()
const profile_ = element.profile == 'md'? 'mdgpr': 'pr';
const eventtype = element.event.CalendarName;
// if (startTimeSamp < endTimeSamp && endDay == 29 && (endMinutes + endHours) == 0) {
// // console.log(id, (endMinutes + endHours))
// classs.push(`calendar-event-border`);
// }
classs.push(`calendar-event-border calendar-${profile_}-event-type-${eventtype}`);
@@ -341,8 +335,6 @@ export class AgendaPage implements OnInit {
get CalendarCurrentDay ():any {
/* console.log(this.viewDate.getDate(), '0_0') */
// console.log(this.viewDate.getDate(), '0_0')
return this.viewDate.getDate()
}
@@ -423,10 +415,6 @@ export class AgendaPage implements OnInit {
}
get LL () {
return this.eventSource.length
}
loadRangeEvents(startTime: Date, endTime: Date) {
this.eventSelectedDate = new Date(startTime);
@@ -440,7 +428,6 @@ export class AgendaPage implements OnInit {
switch (this.segment) {
case "Combinado":
//Inicializa o array eventSource
//this.eventSource=[];
if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR' ) {
this.eventService.getAllMdEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).then(
@@ -448,42 +435,12 @@ export class AgendaPage implements OnInit {
(response:any) => {
// calendar
// this.eventSource=[];
this.calendarService.removeRange(startTime, endTime, 'md')
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
return false
}
return true
})
const eventsList = response;
// loop
eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: 'md',
id: element.EventId,
});
});
this.calendarService.pushEvent(response, 'md');
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
// optional
this.TimelineMD = list;
console.log('TimelineMD', this.TimelineMD)
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -491,66 +448,31 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
this.showTimeline = true;
}).finally(()=>{
this.showLoader = false;
})
}
else if(this.profile == "pr" && this.loggeduser.Profile == 'MDGPR') {
console.log('HERE PR');
this.eventService.getAllSharedEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then(
(response:any) => {
this.eventService.getAllSharedEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
this.calendarService.removeRange(startTime, endTime, 'pr')
// calendar
//this.eventSource=[];
this.calendarService.pushEvent(response, 'pr');
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
return false
}
return true
})
const eventsList = response;
this.myCal.update();
this.myCal.loadEvents();
// calendar
eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: 'pr',
id: element.EventId,
});
});
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
this.TimelinePR = list;
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
this.showLoader = false;
this.showTimeline = true;
}).finally(()=>{
this.showLoader = false;
})
})
}
else if(this.loggeduser.Profile == 'PR') {
@@ -561,47 +483,21 @@ export class AgendaPage implements OnInit {
// this.eventSource=[];
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'pr')
const eventsList = response;
// calendar
eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: 'pr',
id: element.EventId,
});
});
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
this.TimelinePR = list;
this.calendarService.pushEvent(response, 'pr');
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
}).finally(()=>{
this.showLoader = false;
})
@@ -613,43 +509,14 @@ export class AgendaPage implements OnInit {
if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllMdPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
// this.eventSource=[];
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'md')
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
// loop
eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: 'md',
id: element.EventId,
});
});
this.calendarService.pushEvent(eventsList, 'md');
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
this.TimelineMD = list;
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -666,35 +533,14 @@ export class AgendaPage implements OnInit {
//this.eventSource=[];
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'pr')
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
eventsList.forEach(element => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
profile: 'pr',
id: element.EventId,
});
});
this.calendarService.pushEvent(eventsList, 'pr');
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
// optional
this.TimelinePR = list;
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -717,38 +563,14 @@ export class AgendaPage implements OnInit {
this.eventService.getAllMdEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((res:any) => {
// this.eventSource=[];
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'md')
const eventsList = res.filter(data => data.CalendarName == "Oficial");
eventsList.forEach(element => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
profile: 'md',
id: element.EventId,
});
});
this.calendarService.pushEvent(eventsList, 'md');
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBox(list)
this.events = list;
// Petencial error
this.TimelinePR = list;
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -764,37 +586,14 @@ export class AgendaPage implements OnInit {
// this.eventSource=[];
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'pr')
const eventsList = res.filter(data => data.CalendarName == "Oficial");
eventsList.forEach(element => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
profile: 'pr',
id: element.EventId,
});
});
this.calendarService.pushEvent(eventsList, 'pr');
const list = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
this.TimelineMDList = this.eventListBox(list)
this.events = list;
// optional
this.TimelinePR = list;
this.myCal.update();
this.myCal.loadEvents();
@@ -813,56 +612,18 @@ export class AgendaPage implements OnInit {
let counter = 0;
if(this.loggeduser.Profile == 'MDGPR') {
console.log('MDGPR');
this.eventService.getAllMdEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).then( (response:any) => {
let eventsList;
if(this.segment == 'Oficial') {
eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') {
eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else {
eventsList = response;
}
let eventsList = response;
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'md')
// loop
eventsList.forEach((element, eventIndex) => {
// calendar
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: this.EventTretment({
startTime: element.StartDate,
endTime: element.EndDate
}),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: 'md',
id: element.EventId,
});
});
this.calendarService.pushEvent(eventsList, 'md');
const MDEventList = this.timelineFilter(this.timelineFilterState, eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
this.TimelineMDList = this.eventListBox(MDEventList, 'md')
this.events = MDEventList;
this.TimelineMD = MDEventList;
this.myCal.update();
this.myCal.loadEvents();
@@ -873,7 +634,7 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
}
}).finally(()=>{
}).finally(()=> {
counter++;
if(counter==2) {
this.showLoader = false;
@@ -882,56 +643,26 @@ export class AgendaPage implements OnInit {
this.eventService.getAllSharedEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
let eventsList;
if(this.segment == 'Oficial') {
eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') {
eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else {
eventsList = response;
let eventsList = response;
// clear the current month only
this.calendarService.removeRange(startTime, endTime, 'pr')
this.calendarService.pushEvent(eventsList, 'pr');
this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
this.showTimelinePR = true;
counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
console.log('remove from agenda')
return false
}
return true
})
eventsList.forEach((element, eventIndex) => {
// calendar
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile:'pr',
id: element.EventId,
});
});
this.TimelinePR = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelinePRList = this.eventListBox(this.TimelinePR)
this.myCal.update();
this.myCal.loadEvents();
this.showTimelinePR = true;
counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
}).finally(()=>{
counter++;
@@ -940,7 +671,6 @@ export class AgendaPage implements OnInit {
}
})
} else {
this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
@@ -955,36 +685,13 @@ export class AgendaPage implements OnInit {
}
// clear the current month only
this.eventSource = this.eventSource.filter((e)=> {
if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
console.log('remove from agenda')
return false
}
return true
})
this.calendarService.removeRange(startTime, endTime, 'pr')
eventsList.forEach((element, eventIndex) => {
this.calendarService.pushEvent(eventsList, 'pr');
// calendar
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile:'pr',
id: element.EventId,
});
});
this.TimelinePR = this.timelineFilter(this.timelineFilterState, eventsList, 'pr');
this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
this.TimelinePRList = this.eventListBox(this.TimelinePR)
this.myCal.update();
this.myCal.loadEvents();
@@ -1007,6 +714,11 @@ export class AgendaPage implements OnInit {
}
}
updateEventListBox() {
this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
}
eventListBox(list, nice?) {
let days = {};
@@ -1034,17 +746,12 @@ export class AgendaPage implements OnInit {
if (new Date(startDate).toLocaleDateString() != new Date(endDate).toLocaleDateString()) {
console.log(new Date(startDate).toLocaleDateString(),'!=' , new Date(endDate).toLocaleDateString())
console.log(startDate.toISOString(),'iso' , endDate.toISOString() )
console.log(new Date(startDate).toLocaleTimeString('pt'),'time' , new Date(endDate).toLocaleTimeString('pt'))
// difference
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays <= 150 && !event.event.IsAllDayEvent ) {
console.log(event)
if (diffDays >= 1) {
@@ -1204,13 +911,16 @@ export class AgendaPage implements OnInit {
changeProfile() {
if(this.profile == "mdgpr"){
if(this.profile == "mdgpr") {
this.profile ="pr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
}
else{
else {
this.profile ="mdgpr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
}
}
@@ -1273,7 +983,7 @@ export class AgendaPage implements OnInit {
// open component
async viewEventDetail(eventId:any) {
console.log('View event '+eventId)
this.router.navigate(['/home/agenda', eventId, 'agenda']);
/* console.log(this.profile);
@@ -1515,7 +1225,7 @@ export class AgendaPage implements OnInit {
}
async showEventBox(event) {
if ( event.event.CalendarName == this.segment || this.segment == 'Combinado') {
return true
}
+251 -3
View File
@@ -1,5 +1,253 @@
import { eventSource } from 'src/app/models/agenda/eventSource';
import { setHours, setMinutes } from 'date-fns';
export class eventListBox {
filterProfile() {}
daysBetween(){}
list() {}
constructor(){}
EventEndDateTreatment ({startTime, endTime}) {
const startTimeSamp = new Date(startTime).toLocaleDateString()
const endTimeSamp = new Date(endTime).toLocaleDateString()
const endMinutes = new Date(endTime).getMinutes()
const endHours = new Date(endTime).getHours()
if (startTimeSamp < endTimeSamp && (endMinutes + endHours) == 0) {
endTime = new Date(endTime);
endTime.setSeconds(endTime.getSeconds() - 1);
return new Date(endTime)
} else {
return new Date(endTime)
}
}
filterProfile(eventSource: eventSource[], profile: 'md' | 'pr' | 'all') {
return eventSource.filter((e) => e.profile == profile)
}
getEventInsideRange(eventSource: eventSource[], 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()) {
return true
}
return false
})
}
daysBetween(){ }
list(eventSource: eventSource[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
if(profile != 'all') {
eventSource = this.filterProfile(eventSource, profile)
}
eventSource = this.getEventInsideRange(eventSource, rangeStartDate, randEndDate)
if(profile == 'pr') {
console.log('run', profile)
console.log(eventSource)
}
if(profile == 'md') {
eventSource = this.encapsulation(eventSource, 'mdgpr');
} else {
eventSource = this.encapsulation(eventSource, 'pr');
}
return this.display(eventSource)
}
display(list) {
let days = {};
list.forEach( (event:any, index)=> {
var startDate: any = new Date(event.start);
var endDate: any = this.EventEndDateTreatment({
startTime: startDate,
endTime: event.end
})
const day = (((new Date (event.start)).getDate())).toString().padStart(2,'0')
event.manyDays = false
event.todayOnly = new Date(event.start).toLocaleDateString() == new Date(event.end).toLocaleDateString()
if(!days.hasOwnProperty(day)) {
days[day] = []
}
if (new Date(startDate).toLocaleDateString() != new Date(endDate).toLocaleDateString()) {
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays <= 150 && !event.event.IsAllDayEvent ) {
console.log(event)
if (diffDays >= 1) {
const StartEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
startMany: true,
endMany: false,
middle: false
})
days[day].push(StartEvent)
let i = 1;
while (startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate()) {
const newDate = startDate.setDate(startDate.getDate()+ i)
let otherDays = (((new Date (newDate)).getDate())).toString().padStart(2,'0')
event.other = true
event.start = newDate
if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = []
}
if (!(startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate())) {
// last push
const EndEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
Subject: event.Subject,
startMany: false,
endMany: true,
middle: false
})
days[otherDays].push(EndEvent)
} else {
const EndEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
Subject: event.Subject,
startMany: false,
endMany: true,
middle: true
})
days[otherDays].push(EndEvent)
}
}
} else {
days[day].push(event)
}
} else {
days[day].push(event)
}
}
days[day].push(event)
})
setTimeout(()=>{
document.querySelectorAll('.EventListBox-container .EventListBox').forEach((e)=>{
if(e.childElementCount == 0) {
e.parentElement.style.display = 'none'
} else {
e.parentElement.style.display = 'block'
}
})
}, 10)
return days
}
encapsulation(eventsList, profile) {
// remove all event
let events = [];
eventsList.forEach((element, eventIndex) => {
events.push({
start: new Date(element.StartDate || element.startTime),
end: new Date(element.EndDate || element.endTime),
color: {
primary: '#0000',
secondary: '#0000'
},
id: element.EventId || element.id,
index: eventIndex,
profile: profile,
CalendarName: element.calendarName,
event: element.event,
});
});
return events;
}
}
@@ -1,20 +1,11 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { CalendarComponent } from 'ionic2-calendar';
import { DailyWorkTask, tasksList } from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { formatDate } from '@angular/common';
import { ModalController } from '@ionic/angular';
import { ExpedienteDetailPage } from 'src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
import { AlertService } from 'src/app/services/alert.service';
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
import { AuthService } from 'src/app/services/auth.service';
import { DespachoPage } from 'src/app/pages/gabinete-digital/despachos/despacho/despacho.page';
import { NavigationEnd, NavigationExtras, NavigationStart, Router } from '@angular/router';
import { NavigationStart, Router } from '@angular/router';
@Component({
selector: 'app-despachos',