- {{ TimelineDay(events.key)}}
{{ viewTitle }}
+ {{ TimelineDay(events.key)}}
{{ events.value[0].start | date: 'MMMM'}}
diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts
index 23aa44e11..f90403029 100644
--- a/src/app/pages/agenda/agenda.page.ts
+++ b/src/app/pages/agenda/agenda.page.ts
@@ -271,16 +271,19 @@ export class AgendaPage implements OnInit {
}
if (realoadCounter != 0) {
- if(this.currentMoth.rangeStartDate != null) {
-
- this.loadRangeEvents(this.currentMoth.rangeStartDate, this.currentMoth.rangeEndDate)
- } else {
- this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
- }
-
-
- this.updateEventListBox()
}
+
+
+ this.calendar.currentDate = new Date();
+
+ try {
+ this.myCal.update();
+ this.myCal.loadEvents();
+ this.onDropDownScrollWeal()
+ } catch (e) { }
+
+ this.updateEventListBox()
+
realoadCounter++;
this.weekToShow()
}
@@ -735,7 +738,10 @@ export class AgendaPage implements OnInit {
const selectedDay = momentG(this.eventSelectedDate, 'dd', 'pt');
if(this.TimelineMDList[selectedDay]) {
- this.hasEventToday = true
+ if(momentG(new Date(this.TimelineMDList[selectedDay][0].start), 'MMMM', 'pt') == momentG(this.eventSelectedDate, 'MMMM', 'pt')) {
+ this.hasEventToday = true
+ }
+
} else {
this.hasEventToday = false
}
@@ -763,10 +769,7 @@ export class AgendaPage implements OnInit {
} catch (e) { }
this.updateEventListBox()
- } else {
-
- }
-
+ } else {}
}
@@ -1150,10 +1153,8 @@ export class AgendaPage implements OnInit {
// THIS LINE
this.updateEventListBox();
-
}
-
shoeEventDay(events: any[]) {
if (this.segment == 'Combinado') {
@@ -1171,3 +1172,18 @@ export class AgendaPage implements OnInit {
}
}
+
+function endOfMonth(myDate){
+ let date = new Date(myDate);
+ date.setDate(1); // Avoids edge cases on the 31st day of some months
+ date.setMonth(date.getMonth() +1);
+ date.setDate(0);
+ date.setHours(23);
+ date.setMinutes(59);
+ date.setSeconds(59);
+ return date;
+}
+
+const addDays = 5;
+const endDateRange = endOfMonth(new Date(5))
+endDateRange.setDate(endDateRange.getDate() + addDays)
diff --git a/src/app/services/agenda/list-box.service.ts b/src/app/services/agenda/list-box.service.ts
index 5b9747fca..986327729 100644
--- a/src/app/services/agenda/list-box.service.ts
+++ b/src/app/services/agenda/list-box.service.ts
@@ -8,12 +8,12 @@ import { DateService } from '../date.service';
export class ListBoxService {
height = "unset"
-
+
constructor(
private dateService: DateService
){}
-
+
filterProfile(eventSource: EventListStore[] = [], profile: 'md' | 'pr' | 'all') {
return eventSource.filter((e) => e.profile == profile)
}
@@ -21,7 +21,7 @@ export class ListBoxService {
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()) {
+ new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) {
return true
}
return false
@@ -29,7 +29,7 @@ export class ListBoxService {
}
filterSegment(eventSource: EventListStore[], segment): EventListStore[] {
-
+
return eventSource.filter( data => data.calendarName == segment)
}
@@ -39,17 +39,17 @@ export class ListBoxService {
// // filter range
// if(selectedDate) {
- // eventSource = eventSource.filter(data =>
- // data.startTime.toLocaleDateString('pt') >= new Date(rangeStartDate).toLocaleDateString('pt') &&
+ // eventSource = eventSource.filter(data =>
+ // data.startTime.toLocaleDateString('pt') >= new Date(rangeStartDate).toLocaleDateString('pt') &&
// data.startTime.toLocaleDateString('pt') <= new Date(rangeStartDate).toLocaleDateString('pt')
// )
// }
if(segment!='Combinado') {
- eventSource = this.filterSegment(eventSource, segment)
+ eventSource = this.filterSegment(eventSource, segment)
}
-
+
// if(profile != 'all') {
// eventSource = this.filterProfile(eventSource, profile)
// }
@@ -59,8 +59,22 @@ export class ListBoxService {
newStracture = this.encapsulation(eventSource);
return this.display(newStracture, selectedDate)
+
+ // console.log({daysObject})
+
+ // const daysStringNum = Object.keys(daysObject)
+
+ // for(const day of daysStringNum) {
+ // daysObject[day] = daysObject[day].reverse()
+ // }
+
+
+ // daysObject = this.transformObjectKeyOrder(daysObject, daysStringNum)
+
+ // return daysObject
}
+
display(list: CustomCalendarEvent[], selectedDate) {
let days = {};
@@ -74,8 +88,8 @@ export class ListBoxService {
endTime: event.end
})
- const day = this.dateService.getDay(event.start)
-
+ const day = this.dateService.getDay(event.start)
+
event['manyDays'] = !this.dateService.isSameDate(event.start, event.end)
event['todayOnly'] = this.dateService.isSameDate(event.start, event.end)
@@ -94,28 +108,28 @@ export class ListBoxService {
if (diffDays >= 1) {
const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false})
-
+
if(this.CanPush(event, selectedDate)) days[day].push(StartEvent)
-
+
let i = 1;
-
+
// create event between date
- while (startDate.getFullYear() != endDate.getFullYear() ||
+ while (startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate()) {
const newDate = startDate.setDate(startDate.getDate()+ i)
- let otherDays = this.dateService.getDay(newDate)
-
+ let otherDays = this.dateService.getDay(newDate)
+
event['other'] = true
-
+
event.start = newDate
if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = []
}
-
- if (!(startDate.getFullYear() != endDate.getFullYear() ||
+
+ if (!(startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate())) {
// last push
@@ -128,7 +142,9 @@ export class ListBoxService {
const EndEvent = this.transForm(event, {startMany: false,endMany: true, middle: true})
if(this.CanPush(event, selectedDate)) days[otherDays].push(EndEvent)
}
-
+
+ days[otherDays] = days[otherDays].reverse()
+
}
} else {
@@ -143,7 +159,7 @@ export class ListBoxService {
if(this.CanPush(event, selectedDate) && diffDays != 2) days[day].push(event)
}
- //
+ //
})
@@ -162,9 +178,13 @@ export class ListBoxService {
CanPush(event: any, selectedDate: Date) {
- return new Date(event.start).getMonth() == selectedDate.getMonth() &&
- new Date(event.start).getFullYear() == selectedDate.getFullYear() &&
- new Date(event.start).getDate() >= selectedDate.getDate()
+ const limite = this.endOfMonth(selectedDate)
+ limite.setDate(limite.getDate() + 10)
+
+ return new Date(event.start).getFullYear() >= selectedDate.getFullYear() &&
+ new Date(event.start).getMonth() >= selectedDate.getMonth() &&
+ new Date(event.start).getTime() >= selectedDate.getTime() &&
+ new Date(event.start).getTime() <= limite.getTime()
}
encapsulation(eventsList:EventListStore[]): CustomCalendarEvent[] {
@@ -173,7 +193,7 @@ export class ListBoxService {
let events: CustomCalendarEvent[] = [];
eventsList.forEach((element, eventIndex) => {
-
+
events.push({
start: new Date(element.startTime),
end: new Date(element.endTime),
@@ -209,4 +229,36 @@ export class ListBoxService {
})
}
+
+
+ transformObjectKeyOrder(originalObject, keyOrder) {
+ const transformedObject = {};
+
+ for (const key of keyOrder) {
+ if (originalObject.hasOwnProperty(key)) {
+ transformedObject[key] = originalObject[key];
+ }
+ }
+
+ // Include any remaining keys not in the specified order
+ for (const key in originalObject) {
+ if (!keyOrder.includes(key) && originalObject.hasOwnProperty(key)) {
+ transformedObject[key] = originalObject[key];
+ }
+ }
+
+ return transformedObject;
+ }
+
+
+ endOfMonth(myDate){
+ let date = new Date(myDate);
+ date.setDate(1); // Avoids edge cases on the 31st day of some months
+ date.setMonth(date.getMonth() +1);
+ date.setDate(0);
+ date.setHours(23);
+ date.setMinutes(59);
+ date.setSeconds(59);
+ return date;
+ }
}