mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge with developer-prod changes
This commit is contained in:
@@ -59,10 +59,10 @@
|
||||
<mat-option *ngFor="let calendars of eventService.calendarNamesAry" value="{{calendars.Fullname || calendars}}">
|
||||
|
||||
<div *ngIf="environment.presidential">
|
||||
<div *ngIf="calendars.Role == 'Presidente da República'"> PR </div>
|
||||
<div *ngIf="calendars.Role == 'Presidente da República'"> PR </div>
|
||||
<div *ngIf="calendars.Role == 'Ministro e Director do Gabinete do PR'"> MDGPR </div>
|
||||
<div *ngIf="calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República' && calendars.Fullname"> Agenda do {{calendars.Fullname}} </div>
|
||||
<div *ngIf="calendars.Role != 'Presidente da República' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars == 'Meu calendario' ">
|
||||
<div *ngIf="calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República' && calendars.Fullname"> Agenda do {{calendars.Fullname}} </div>
|
||||
<div *ngIf="calendars.Role != 'Presidente da República' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars == 'Meu calendario' ">
|
||||
<!-- <span *ngIf="SessionStore.user.Profile == 'PR' ">PR</span>
|
||||
<span *ngIf="SessionStore.user.Profile == 'MDGPR' ">MDGPR</span>
|
||||
<span *ngIf="SessionStore.user.Profile != 'MDGPR' && SessionStore.user.Profile != 'PR' ">Minha agenda</span> -->
|
||||
@@ -71,9 +71,9 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="!environment.presidential">
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
<div *ngIf="calendars == 'Meu calendario'">Minha agenda</div>
|
||||
</div>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
<div class="float-button">
|
||||
|
||||
<button title="Visualizar a lista de Eventos para aprovação" class="cursor-pointer resize pr-20-rem" (click)="viewEventsToApprove()" *ngIf="p.userPermission([p.permissionList.Gabinete.aprove_event])">
|
||||
<button title="Visualizar a lista de Eventos para aprovação" class="cursor-pointer resize pr-20-rem" (click)="viewEventsToApprove()" *ngIf="p.userPermission([p.permissionList.Gabinete.aprove_event])">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="right-icons" src="assets/images/icons-received-event.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && !mobileComponent.showEventList" class="right-icons" src="assets/images/theme/gov/icons-received-event.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && mobileComponent.showEventList" class="right-icons" src="assets/images/theme/gov/icons-received-event-selected.svg"></ion-icon>
|
||||
@@ -109,7 +109,7 @@
|
||||
</ion-row>
|
||||
<ion-row class="ion-align-items-center calendar-options">
|
||||
|
||||
<button title="Visualizar a lista de Eventos para aprovação" class="cursor-pointer resize pr-10" (click)="viewEventsToApprove()" *ngIf="p.userPermission([p.permissionList.Gabinete.aprove_event])">
|
||||
<button title="Visualizar a lista de Eventos para aprovação" class="cursor-pointer resize pr-10" (click)="viewEventsToApprove()" *ngIf="p.userPermission([p.permissionList.Gabinete.aprove_event])">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="right-icons" src="assets/images/icons-received-event.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && !mobileComponent.showEventList" class="right-icons" src="assets/images/theme/gov/icons-received-event.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && mobileComponent.showEventList" class="right-icons" src="assets/images/theme/gov/icons-received-event-selected.svg"></ion-icon>
|
||||
@@ -215,33 +215,34 @@
|
||||
</div>
|
||||
<div class="timeline-wrapper flex-grow-1 height-100" >
|
||||
<div class="height-100">
|
||||
<div class="timeline-container height-100 d-flex pt-10 pl-20 filter-{{segment}}" >
|
||||
<div class="timeline-container height-100 d-flex pt-10 pl-20 filter-{{segment}} flex-column" >
|
||||
|
||||
<!-- <div class="ss-timeline timeline-mobile flex-grow-1 pr-10 text-black height-100 width-100 overflow-y-auto" >
|
||||
-->
|
||||
|
||||
<!-- <div class="timeline-date align-center" *ngIf="isSelectedDayHasEvent && hasEventToday">
|
||||
<div class="timeline-date align-center" *ngIf="isSelectedDayHasEvent && hasEventToday">
|
||||
<span >Hoje, </span> {{ timelineDate }}
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="ss-timeline timeline-mobile flex-grow-1 pr-10 text-black height-100 width-100 overflow-y-auto" >
|
||||
|
||||
<div *ngFor="let year of TimelineMDList " >
|
||||
<!-- {{year.yearInfo.yearName}} -->
|
||||
<div *ngFor="let month of year.months " class="header-day" >
|
||||
<!-- {{ month.monthInfo.monthName | json }} -->
|
||||
<!-- <hr> -->
|
||||
|
||||
<div *ngFor="let events of TimelineMDList | keyvalue; " >
|
||||
<div *ngFor="let day of month.days " class="EventListBox-container" >
|
||||
|
||||
<div class="EventListBox-container" >
|
||||
<div class="day " [class.dayShow]="isSelectedDayHasEvent && hasEventToday" >
|
||||
{{ TimelineDay(events.key)}} <div style="text-transform: capitalize; display: inline;">{{ events.value[0].start | date: 'MMMM'}}</div>
|
||||
</div>
|
||||
<div class="day " [class.dayShow]="isSelectedDayHasEvent && hasEventToday" >
|
||||
{{ day.daysInfo.dayName }} <div style="text-transform: capitalize; display: inline;">{{month.monthInfo.monthName}}</div>
|
||||
</div>
|
||||
|
||||
<div *ngFor="let event of events.value" class="EventListBox mb-10" >
|
||||
|
||||
<div class="d-flex content-{{event.profile}}-{{event.event.CalendarName}} mt-10 cursor-pointer width-100 " (click)="eventClicked(event)"
|
||||
<div *ngFor="let event of day.events " class="EventListBox mb-10" >
|
||||
<div class="d-flex content-{{event.profile}}-{{event.event.CalendarName}} mt-10 cursor-pointer width-100 " (click)="eventClicked(event)"
|
||||
*ngIf="viewEventMonth <= dateMonth(event) ">
|
||||
|
||||
<div class="schedule-time" *ngIf="!event.event.IsAllDayEvent">
|
||||
|
||||
<div *ngIf="event.startMany && !event.middle" class="time-start labelb">Início</div>
|
||||
<div *ngIf="event.startMany && !event.middle" class="time-start labelb">InÃcio</div>
|
||||
<div *ngIf="event.endMany && !event.middle " class="time-end labelb">Fim</div>
|
||||
|
||||
<div *ngIf="!(event.endMany && !event.middle) && !event.middle" class="time-start">{{event.event.StartDate | date: 'HH:mm'}}</div>
|
||||
@@ -263,10 +264,11 @@
|
||||
<div class="font-13 calendar-owner"*ngIf="eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId) == 'Meu calendario'">{{SessionStore.user.FullName}} </div>
|
||||
<ng-template #other_content>{{eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId)}}</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -875,13 +875,12 @@ $font-size: rem(15);
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.ss-timeline > :nth-child(2) .dayShow {
|
||||
display: none;
|
||||
.header-day .dayShow:nth-child(1) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.ss-timeline > :nth-child(1) .dayShow {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.calendar-options {
|
||||
position: relative;
|
||||
|
||||
@@ -105,7 +105,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
selectedEvent: Event;
|
||||
selectedEventId: string | number;
|
||||
selectedEventCalendarId : string | number;
|
||||
selectedEventCalendarId: string | number;
|
||||
postEvent: any;
|
||||
|
||||
// temporary data
|
||||
@@ -213,7 +213,7 @@ export class AgendaPage implements OnInit {
|
||||
} else if (this.loggeduser.Profile == 'PR') {
|
||||
this.profile = "pr";
|
||||
} else {
|
||||
if(this.eventService.usersCalendarIds.length >= 2) {
|
||||
if (this.eventService.usersCalendarIds.length >= 2) {
|
||||
this.profile = "mdgpr";
|
||||
} else if (this.eventService.hasOwnCalendar) {
|
||||
this.profile = "mdgpr";
|
||||
@@ -309,8 +309,8 @@ export class AgendaPage implements OnInit {
|
||||
let weekNum = 0;
|
||||
|
||||
function Week(a) {
|
||||
for(let b of a.querySelectorAll('td')) {
|
||||
if(!b.className.includes('text-muted')) {
|
||||
for (let b of a.querySelectorAll('td')) {
|
||||
if (!b.className.includes('text-muted')) {
|
||||
weekNum++;
|
||||
return true
|
||||
}
|
||||
@@ -320,18 +320,18 @@ export class AgendaPage implements OnInit {
|
||||
const dayBoxHeight = document.querySelector('.monthview-container .swiper-container .swiper-slide-active table tbody tr td').clientHeight
|
||||
const weeks = document.querySelectorAll('.monthview-container .swiper-container .swiper-slide-active table tbody tr');
|
||||
|
||||
for (let week of weeks as any ){
|
||||
for (let week of weeks as any) {
|
||||
Week(week)
|
||||
}
|
||||
|
||||
this.showCalendar = true
|
||||
this.listBoxService.height = (weekNum * dayBoxHeight) +'px'
|
||||
this.listBoxService.height = (weekNum * dayBoxHeight) + 'px'
|
||||
|
||||
if(dayBoxHeight == 0) {
|
||||
if (dayBoxHeight == 0) {
|
||||
this.weekToShow()
|
||||
}
|
||||
} catch (e) {
|
||||
setTimeout(()=> {
|
||||
setTimeout(() => {
|
||||
this.weekToShow()
|
||||
}, 100)
|
||||
}
|
||||
@@ -339,8 +339,8 @@ export class AgendaPage implements OnInit {
|
||||
}
|
||||
|
||||
setCalendarByDefault() {
|
||||
if(!this.CalendarName) {
|
||||
if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
if (!this.CalendarName) {
|
||||
if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.CalendarName = 'Meu calendario';
|
||||
} else {
|
||||
this.CalendarName = this.eventService.calendarNamesAry[0]
|
||||
@@ -421,13 +421,16 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
onDropDownScrollWeal() {
|
||||
|
||||
setTimeout(() => {
|
||||
document.querySelector('.dropdown-scroll-weel').querySelectorAll('.active')[0].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
try {
|
||||
setTimeout(() => {
|
||||
document.querySelector('.dropdown-scroll-weel').querySelectorAll('.active')[1].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}, 300)
|
||||
}, 10)
|
||||
|
||||
document.querySelector('.dropdown-scroll-weel').querySelectorAll('.active')[0].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
setTimeout(() => {
|
||||
document.querySelector('.dropdown-scroll-weel').querySelectorAll('.active')[1].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}, 300)
|
||||
}, 10)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +448,7 @@ export class AgendaPage implements OnInit {
|
||||
this.rangeStartDate = ev.startTime;
|
||||
this.rangeEndDate = ev.endTime;
|
||||
|
||||
if(this.currentMoth.rangeEndDate == null) {
|
||||
if (this.currentMoth.rangeEndDate == null) {
|
||||
this.currentMoth = {
|
||||
rangeStartDate: ev.startTime,
|
||||
rangeEndDate: ev.endTime
|
||||
@@ -579,7 +582,7 @@ export class AgendaPage implements OnInit {
|
||||
loadRangeEvents(startTime: Date, endTime: Date) {
|
||||
this.weekToShow()
|
||||
|
||||
if(!this.eventService.hasAnyCalendar) {
|
||||
if (!this.eventService.hasAnyCalendar) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -589,9 +592,9 @@ export class AgendaPage implements OnInit {
|
||||
this.showLoader = true;
|
||||
|
||||
const index = `${startTime}${endTime}`
|
||||
if(!this.loadRequest[index]) {
|
||||
this.loadRequest[index] = {startTime, endTime}
|
||||
this.loadRequestHistory[index] = {lastTimeUpdate: new Date()}
|
||||
if (!this.loadRequest[index]) {
|
||||
this.loadRequest[index] = { startTime, endTime }
|
||||
this.loadRequestHistory[index] = { lastTimeUpdate: new Date() }
|
||||
|
||||
this.loadRangeEventRun(startTime, endTime)
|
||||
} else {
|
||||
@@ -606,7 +609,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
loadRangeEventRun(startTime: Date, endTime: Date) {
|
||||
|
||||
if(SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) {
|
||||
if (SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -628,16 +631,16 @@ export class AgendaPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
let load = 0;
|
||||
let load = 0;
|
||||
|
||||
for ( const selectedCalendar of selectedCalendarIds) {
|
||||
for (const selectedCalendar of selectedCalendarIds) {
|
||||
this.eventService.getEventsByCalendarId(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59'), selectedCalendar.CalendarId).then((response: any) => {
|
||||
|
||||
let label;
|
||||
|
||||
if(SessionStore.user.Profile == 'PR') {
|
||||
if (SessionStore.user.Profile == 'PR') {
|
||||
label = "pr"
|
||||
} else if(SessionStore.user.OwnerCalendars.find(e => e.CalendarId == selectedCalendar.CalendarId)) {
|
||||
} else if (SessionStore.user.OwnerCalendars.find(e => e.CalendarId == selectedCalendar.CalendarId)) {
|
||||
label = 'md'
|
||||
} else {
|
||||
label = "pr"
|
||||
@@ -656,7 +659,7 @@ export class AgendaPage implements OnInit {
|
||||
this.deleteLoadRangeEvent(startTime, endTime);
|
||||
|
||||
load++
|
||||
if(load == selectedCalendarIds.length) {
|
||||
if (load == selectedCalendarIds.length) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
@@ -669,9 +672,9 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
selectedAgenda = {}
|
||||
|
||||
getSelectedAgendaCalendars () {
|
||||
getSelectedAgendaCalendars() {
|
||||
|
||||
if(this.CalendarName == 'PR+MDGPR') {
|
||||
if (this.CalendarName == 'PR+MDGPR') {
|
||||
|
||||
let result = this.SessionStore.user.OwnerCalendars
|
||||
|
||||
@@ -682,46 +685,46 @@ export class AgendaPage implements OnInit {
|
||||
return result.concat(join)
|
||||
} else {
|
||||
|
||||
const calendar = this.eventService.calendarNamesType[this.CalendarName];
|
||||
let Oficial = calendar?.['OficialId']
|
||||
let Pessoal = calendar?.['PessoalId']
|
||||
const calendar = this.eventService.calendarNamesType[this.CalendarName];
|
||||
let Oficial = calendar?.['OficialId']
|
||||
let Pessoal = calendar?.['PessoalId']
|
||||
|
||||
if(Oficial && Pessoal) {
|
||||
if (Oficial && Pessoal) {
|
||||
|
||||
return [
|
||||
{
|
||||
CalendarId : Oficial,
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarName: calendar.CalendarName
|
||||
},
|
||||
{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId : Pessoal,
|
||||
CalendarName: calendar.CalendarName
|
||||
return [
|
||||
{
|
||||
CalendarId: Oficial,
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarName: calendar.CalendarName
|
||||
},
|
||||
{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId: Pessoal,
|
||||
CalendarName: calendar.CalendarName
|
||||
}
|
||||
]
|
||||
|
||||
} else if (Oficial) {
|
||||
try {
|
||||
return [{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId: Oficial,
|
||||
CalendarName: calendar.CalendarName
|
||||
}]
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return [{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId: Pessoal,
|
||||
CalendarName: calendar.CalendarName
|
||||
}]
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
]
|
||||
|
||||
} else if (Oficial) {
|
||||
try {
|
||||
return [{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId : Oficial,
|
||||
CalendarName: calendar.CalendarName
|
||||
}]
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return [{
|
||||
OwnerId: calendar.OwnerId,
|
||||
CalendarId : Pessoal,
|
||||
CalendarName: calendar.CalendarName
|
||||
}]
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -737,8 +740,8 @@ export class AgendaPage implements OnInit {
|
||||
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
|
||||
|
||||
const selectedDay = momentG(this.eventSelectedDate, 'dd', 'pt');
|
||||
if(this.TimelineMDList[selectedDay]) {
|
||||
if(momentG(new Date(this.TimelineMDList[selectedDay][0].start), 'MMMM', 'pt') == momentG(this.eventSelectedDate, 'MMMM', 'pt')) {
|
||||
if (this.TimelineMDList[selectedDay]) {
|
||||
if (momentG(new Date(this.TimelineMDList[selectedDay][0].start), 'MMMM', 'pt') == momentG(this.eventSelectedDate, 'MMMM', 'pt')) {
|
||||
this.hasEventToday = true
|
||||
}
|
||||
|
||||
@@ -769,7 +772,7 @@ export class AgendaPage implements OnInit {
|
||||
} catch (e) { }
|
||||
|
||||
this.updateEventListBox()
|
||||
} else {}
|
||||
} else { }
|
||||
|
||||
}
|
||||
|
||||
@@ -908,7 +911,7 @@ export class AgendaPage implements OnInit {
|
||||
this.myCal.loadEvents();
|
||||
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
@@ -923,7 +926,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
let navigationExtras: NavigationExtras = { queryParams: { CalendarId } }
|
||||
|
||||
this.router.navigate(['/home/agenda/',eventId,'agenda'], navigationExtras);
|
||||
this.router.navigate(['/home/agenda/', eventId, 'agenda'], navigationExtras);
|
||||
|
||||
}
|
||||
|
||||
@@ -938,13 +941,13 @@ export class AgendaPage implements OnInit {
|
||||
this.postEvent = data.event;
|
||||
|
||||
this.mobileComponent.showEditEvent = true;
|
||||
} else if(data.type == 'delete') {
|
||||
} else if (data.type == 'delete') {
|
||||
|
||||
}
|
||||
|
||||
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.onCurrentChanged(this.eventSelectedDate)
|
||||
}, 500)
|
||||
|
||||
@@ -1173,10 +1176,10 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
function endOfMonth(myDate){
|
||||
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.setMonth(date.getMonth() + 1);
|
||||
date.setDate(0);
|
||||
date.setHours(23);
|
||||
date.setMinutes(59);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CustomCalendarEvent, EventListStore } from 'src/app/models/agenda/AgendaEventList';
|
||||
import { DateService } from '../date.service';
|
||||
import { momentG } from 'src/plugin/momentG';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -9,6 +10,7 @@ export class ListBoxService {
|
||||
|
||||
height = "unset"
|
||||
|
||||
|
||||
constructor(
|
||||
private dateService: DateService
|
||||
){}
|
||||
@@ -35,7 +37,7 @@ export class ListBoxService {
|
||||
|
||||
daysBetween(){ }
|
||||
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'Combinado', selectedDate= null}) {
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'Combinado', selectedDate= null}): Year[] {
|
||||
|
||||
// // filter range
|
||||
// if(selectedDate) {
|
||||
@@ -45,7 +47,6 @@ export class ListBoxService {
|
||||
// )
|
||||
// }
|
||||
|
||||
|
||||
if(segment!='Combinado') {
|
||||
eventSource = this.filterSegment(eventSource, segment)
|
||||
}
|
||||
@@ -54,11 +55,32 @@ export class ListBoxService {
|
||||
// eventSource = this.filterProfile(eventSource, profile)
|
||||
// }
|
||||
|
||||
let newStracture:CustomCalendarEvent[];
|
||||
|
||||
let newStracture:CustomCalendarEvent[];
|
||||
newStracture = this.encapsulation(eventSource);
|
||||
|
||||
return this.display(newStracture, selectedDate)
|
||||
// const object = {}
|
||||
|
||||
// for (const e of newStracture.reverse()) {
|
||||
// if(!object[momentG(new Date(e.start), 'MMMM yyyy')]) {
|
||||
// object[momentG(new Date(e.start), 'MMMM yyyy')] = []
|
||||
// }
|
||||
// object[momentG(new Date(e.start), 'MMMM yyyy')].push(e)
|
||||
// }
|
||||
|
||||
// console.log({object})
|
||||
|
||||
// const daysStringNum = Object.keys(object).reverse()
|
||||
|
||||
// const daysObject = {}
|
||||
|
||||
// for(const day of daysStringNum) {
|
||||
// daysObject[day] = object[day]
|
||||
// }
|
||||
|
||||
// console.log({daysObject})
|
||||
|
||||
|
||||
return this.display(newStracture, selectedDate).year
|
||||
|
||||
// console.log({daysObject})
|
||||
|
||||
@@ -74,12 +96,19 @@ export class ListBoxService {
|
||||
// return daysObject
|
||||
}
|
||||
|
||||
sortArrayISODate(myArray: any): any[] {
|
||||
|
||||
return myArray.sort((a,b) =>
|
||||
Date.parse(b.start )
|
||||
-
|
||||
Date.parse(a.start))
|
||||
}
|
||||
|
||||
display(list: CustomCalendarEvent[], selectedDate) {
|
||||
let days = {};
|
||||
const year: Year[] = []
|
||||
|
||||
list.forEach( (event:CustomCalendarEvent, index) => {
|
||||
|
||||
this.sortArrayISODate(list).reverse().forEach( (event:CustomCalendarEvent, index) => {
|
||||
|
||||
var startDate: any = new Date(event.start);
|
||||
|
||||
@@ -109,7 +138,7 @@ export class ListBoxService {
|
||||
|
||||
const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false})
|
||||
|
||||
if(this.CanPush(event, selectedDate)) days[day].push(StartEvent)
|
||||
if(this.CanPush(event, selectedDate)) {days[day].push(StartEvent); this.push(StartEvent, year)}
|
||||
|
||||
let i = 1;
|
||||
|
||||
@@ -135,28 +164,28 @@ export class ListBoxService {
|
||||
// last push
|
||||
|
||||
const EndEvent = this.transForm(event, {startMany: false, endMany: true, middle: false})
|
||||
if(this.CanPush(event, selectedDate)) days[otherDays].push(EndEvent)
|
||||
if(this.CanPush(event, selectedDate)) {days[otherDays].push(EndEvent) ; this.push(event, year)}
|
||||
|
||||
} else {
|
||||
|
||||
const EndEvent = this.transForm(event, {startMany: false,endMany: true, middle: true})
|
||||
if(this.CanPush(event, selectedDate)) days[otherDays].push(EndEvent)
|
||||
if(this.CanPush(event, selectedDate)) {days[otherDays].push(EndEvent) ; this.push(event, year)}
|
||||
}
|
||||
|
||||
days[otherDays] = days[otherDays]
|
||||
days[otherDays] = days[otherDays].reverse()
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if(this.CanPush(event, selectedDate)) days[day].push(event)
|
||||
if(this.CanPush(event, selectedDate)) { days[day].push(event) ; this.push(event, year) }
|
||||
}
|
||||
} else {
|
||||
if(this.CanPush(event, selectedDate)) days[day].push(event)
|
||||
if(this.CanPush(event, selectedDate)) { days[day].push(event) ; this.push(event, year) }
|
||||
}
|
||||
} else {
|
||||
if(this.CanPush(event, selectedDate) && diffDays != 2) days[day].push(event)
|
||||
if(this.CanPush(event, selectedDate) && diffDays != 2) { days[day].push(event) ; this.push(event, year) }
|
||||
}
|
||||
|
||||
//
|
||||
@@ -173,18 +202,69 @@ export class ListBoxService {
|
||||
|
||||
})
|
||||
|
||||
return days
|
||||
return {days, year}
|
||||
}
|
||||
|
||||
|
||||
push(event: any, year: Year[]) {
|
||||
const date = new Date(event.start)
|
||||
|
||||
const yearName = momentG(new Date(date), 'yyyy')
|
||||
const monthName = momentG(new Date(date), 'MMMM')
|
||||
const dayName = momentG(new Date(date), 'dd')
|
||||
|
||||
|
||||
let YearIndex = year.findIndex( x => x.yearInfo.yearName == yearName)
|
||||
|
||||
|
||||
|
||||
if(YearIndex == -1) {
|
||||
YearIndex = year.push({
|
||||
yearInfo: {
|
||||
yearName: yearName
|
||||
},
|
||||
months: []
|
||||
})
|
||||
|
||||
YearIndex--
|
||||
}
|
||||
|
||||
let MonthNameIndex = year[YearIndex].months.findIndex( x => x.monthInfo.monthName == monthName)
|
||||
|
||||
if(MonthNameIndex == -1) {
|
||||
MonthNameIndex = year[YearIndex].months.push({
|
||||
monthInfo: {
|
||||
monthName: monthName
|
||||
},
|
||||
days: []
|
||||
})
|
||||
|
||||
MonthNameIndex --
|
||||
}
|
||||
|
||||
let DayNameIndex = year[YearIndex].months[MonthNameIndex].days.findIndex( x => x.daysInfo.dayName == dayName)
|
||||
|
||||
if(DayNameIndex == -1) {
|
||||
year[YearIndex].months[MonthNameIndex].days.push({
|
||||
daysInfo: {
|
||||
dayName: dayName
|
||||
},
|
||||
events: [event]
|
||||
})
|
||||
} else {
|
||||
year[YearIndex].months[MonthNameIndex].days[DayNameIndex].events.push(event)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CanPush(event: any, selectedDate: Date) {
|
||||
|
||||
const limite = this.endOfMonth(selectedDate)
|
||||
limite.setDate(limite.getDate() + 10)
|
||||
limite.setHours(0)
|
||||
|
||||
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()
|
||||
return (selectedDate.getTime() <= new Date(event.start).getTime() || selectedDate.getTime() <= new Date(event.end).getTime()) &&
|
||||
(limite.getTime() >= new Date(event.start).getTime() || limite.getTime() >= new Date(event.end).getTime())
|
||||
}
|
||||
|
||||
encapsulation(eventsList:EventListStore[]): CustomCalendarEvent[] {
|
||||
@@ -262,3 +342,67 @@ export class ListBoxService {
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
interface DayInfo {
|
||||
// Define properties for dayInfo here
|
||||
dayName: string
|
||||
}
|
||||
|
||||
interface Day {
|
||||
// Define properties for day here
|
||||
|
||||
}
|
||||
|
||||
interface Month {
|
||||
monthInfo: {
|
||||
monthName: string
|
||||
// Define properties for yearInfo inside months here
|
||||
}
|
||||
days: {
|
||||
daysInfo: DayInfo;
|
||||
events: Day[];
|
||||
}[]
|
||||
}
|
||||
|
||||
interface Year {
|
||||
yearInfo: {
|
||||
yearName: string
|
||||
// Define properties for yearInfo here
|
||||
};
|
||||
months: Month[];
|
||||
}
|
||||
|
||||
const years: Year[] = [
|
||||
{
|
||||
yearInfo: {
|
||||
yearName: ""
|
||||
// Define properties for yearInfo inside the first year here
|
||||
},
|
||||
months: [
|
||||
{
|
||||
monthInfo: {
|
||||
monthName: "",
|
||||
// Define properties for yearInfo inside the first month here
|
||||
},
|
||||
days: [
|
||||
{
|
||||
daysInfo: {
|
||||
dayName: "",
|
||||
// Define properties for dayInfo inside the first day here
|
||||
},
|
||||
events: [
|
||||
{
|
||||
// Define properties for the first day here
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
// Add more months here as needed
|
||||
],
|
||||
},
|
||||
// Add more years here as needed
|
||||
];
|
||||
|
||||
|
||||
years[0].months[0].days[0].events
|
||||
Reference in New Issue
Block a user