mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve agenda add-event-component by saving data on leave
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<div>
|
||||
<!-- Calendar is here -->
|
||||
<div [ngSwitch]="segment">
|
||||
<div class="calendar-container" *ngSwitchCase="'Combinada'" [style.height]="calendarHeight">
|
||||
<div class="calendar-container" *ngSwitchCase="'Combinado'" [style.height]="calendarHeight">
|
||||
|
||||
<ion-row class="ion-justify-content-between calendar-tool-tip">
|
||||
<ion-row class="ion-align-items-center">
|
||||
@@ -386,10 +386,8 @@
|
||||
(AproveEventEditEvent)="AproveEventEditEvent($event)"
|
||||
[eventAttendees]="contacts"
|
||||
>
|
||||
|
||||
</app-approve-event>
|
||||
|
||||
|
||||
<app-attendee-modal
|
||||
class="d-flex flex-column height-100"
|
||||
*ngIf="mobileComponent.showAttendees"
|
||||
|
||||
@@ -96,7 +96,8 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
||||
|
||||
segment:string;
|
||||
segment: "Combinado" | "Pessoal" | "Oficial";
|
||||
timelineSedment : "Combinado" | "Pessoal" | "Oficial";
|
||||
|
||||
profile:'mdgpr' | 'pr';
|
||||
|
||||
@@ -160,12 +161,10 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof NavigationEnd && event.url == "/home/agenda") {
|
||||
if (this.segment == null)
|
||||
{
|
||||
this.segment = "Combinada";
|
||||
if (this.segment == null){
|
||||
this.segment = "Combinado";
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||
}
|
||||
}
|
||||
@@ -506,7 +505,7 @@ export class AgendaPage implements OnInit {
|
||||
this.showTimeline = false;
|
||||
|
||||
switch (this.segment) {
|
||||
case "Combinada":
|
||||
case "Combinado":
|
||||
//Inicializa o array eventSource
|
||||
this.eventSource=[];
|
||||
|
||||
@@ -531,8 +530,11 @@ export class AgendaPage implements OnInit {
|
||||
profile: 'md'
|
||||
});
|
||||
});
|
||||
|
||||
this.events = this.timelineFilter(this.timelineFilterState, this.eventsList, 'md');
|
||||
|
||||
const list = this.timelineFilter(this.timelineFilterState, this.eventsList, 'md');
|
||||
|
||||
this.events = list;
|
||||
this.TimelineMD = list;
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -569,8 +571,13 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
});
|
||||
|
||||
this.events = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
|
||||
|
||||
|
||||
const list = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
|
||||
|
||||
this.events = list;
|
||||
|
||||
this.TimelinePR = list;
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
this.showLoader = false;
|
||||
@@ -602,9 +609,20 @@ export class AgendaPage implements OnInit {
|
||||
profile: 'md'
|
||||
});
|
||||
});
|
||||
|
||||
const list = this.timelineFilter(this.timelineFilterState, this.eventsList, 'md');
|
||||
|
||||
this.events = list;
|
||||
this.TimelineMD = list;
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showLoader = false;
|
||||
this.showTimeline = true;
|
||||
|
||||
this.timelineBoxCorrectHeight(500);
|
||||
this.centralizeTimeline(500);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -644,12 +662,23 @@ export class AgendaPage implements OnInit {
|
||||
endTime: new Date(element.EndDate),
|
||||
allDay: false,
|
||||
event: element,
|
||||
profile: 'md'
|
||||
profile: 'pr'
|
||||
});
|
||||
});
|
||||
|
||||
const list = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
|
||||
|
||||
this.events = list;
|
||||
this.TimelinePR = list;
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showLoader = false;
|
||||
this.showTimeline = true;
|
||||
|
||||
this.timelineBoxCorrectHeight(500);
|
||||
this.centralizeTimeline(500);
|
||||
});
|
||||
}else{
|
||||
this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).subscribe(res => {
|
||||
@@ -770,6 +799,7 @@ export class AgendaPage implements OnInit {
|
||||
showAlert(){
|
||||
this.alertController.presentAlert("Funcionalidade em desenvolvimento.");
|
||||
}
|
||||
|
||||
changeProfile(){
|
||||
|
||||
if(this.profile == "mdgpr"){
|
||||
|
||||
@@ -171,8 +171,10 @@
|
||||
<div class="ion-icon-class">
|
||||
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
|
||||
</div>
|
||||
<div class="ion-input-class">
|
||||
<ion-input placeholder="Detalhes" [(ngModel)]="postEvent.Body.Text"></ion-input>
|
||||
<div class="ion-input-class-no-height flex-grow-1">
|
||||
|
||||
<ion-textarea [(ngModel)]="postEvent.Body.Text" placeholder="Detalhes" ></ion-textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</span> -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container-div">
|
||||
<div class="ion-item-class-2 d-flex">
|
||||
<div class="ion-icon-class">
|
||||
@@ -171,8 +171,10 @@
|
||||
<div class="ion-icon-class">
|
||||
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
|
||||
</div>
|
||||
<div class="ion-input-class flex-grow-1">
|
||||
<ion-input placeholder="Detalhes" [(ngModel)]="postEvent.Body.Text"></ion-input>
|
||||
<div class="ion-input-class-no-height flex-grow-1">
|
||||
|
||||
<ion-textarea [(ngModel)]="postEvent.Body.Text" placeholder="Detalhes" ></ion-textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,6 @@ ion-content{
|
||||
}
|
||||
.container-div{
|
||||
margin-bottom: 15px;
|
||||
overflow: auto;
|
||||
}
|
||||
.ion-item-class-2{
|
||||
margin: 0px auto;
|
||||
|
||||
@@ -11,7 +11,9 @@ import { ModalController } from '@ionic/angular';
|
||||
templateUrl: './new-event.component.html',
|
||||
styleUrls: ['./new-event.component.scss'],
|
||||
})
|
||||
|
||||
export class NewEventPage implements OnInit {
|
||||
|
||||
postEvent: Event;
|
||||
eventBody: EventBody;
|
||||
segment:string = "true";
|
||||
@@ -32,69 +34,85 @@ export class NewEventPage implements OnInit {
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private eventService: EventsService,
|
||||
) {
|
||||
this.postEvent = new Event();
|
||||
this.eventBody = { BodyType : "1", Text : ""};
|
||||
this.postEvent.Body = this.eventBody;
|
||||
) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
console.log(this.profile);
|
||||
if(!this.restoreTemporaryData()){
|
||||
|
||||
this.postEvent = new Event();
|
||||
this.eventBody = { BodyType : "1", Text : ""};
|
||||
this.postEvent.Body = this.eventBody;
|
||||
|
||||
console.log(this.profile);
|
||||
|
||||
let selectedStartdDate = this.selectedDate;
|
||||
let selectedEndDate = new Date(this.selectedDate);
|
||||
/* Set + 30minutes to seleted datetime */
|
||||
selectedEndDate.setMinutes(this.selectedDate.getMinutes() + 30) ;
|
||||
this.minDate = this.selectedDate.toString();
|
||||
|
||||
if(this.selectedSegment != "Combinada"){
|
||||
this.postEvent ={
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
Body: this.eventBody,
|
||||
Location: '',
|
||||
CalendarId: '',
|
||||
CalendarName: this.selectedSegment,
|
||||
StartDate: selectedStartdDate,
|
||||
EndDate: new Date(selectedEndDate),
|
||||
EventType: 'Reunião',
|
||||
Attendees: null,
|
||||
IsMeeting: false,
|
||||
IsRecurring: false,
|
||||
AppointmentState: 0,
|
||||
TimeZone: '',
|
||||
Organizer: '',
|
||||
Categories: ['Reunião'],
|
||||
HasAttachments: false,
|
||||
};
|
||||
}
|
||||
else{
|
||||
this.postEvent ={
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
Body: this.eventBody,
|
||||
Location: '',
|
||||
CalendarId: '',
|
||||
CalendarName: 'Oficial',
|
||||
StartDate: selectedStartdDate,
|
||||
EndDate: new Date(selectedEndDate),
|
||||
EventType: 'Reunião',
|
||||
Attendees: null,
|
||||
IsMeeting: false,
|
||||
IsRecurring: false,
|
||||
AppointmentState: 0,
|
||||
TimeZone: '',
|
||||
Organizer: '',
|
||||
Categories: ['Reunião'],
|
||||
HasAttachments: false,
|
||||
};
|
||||
let selectedStartdDate = this.selectedDate;
|
||||
let selectedEndDate = new Date(this.selectedDate);
|
||||
/* Set + 30minutes to seleted datetime */
|
||||
selectedEndDate.setMinutes(this.selectedDate.getMinutes() + 30) ;
|
||||
this.minDate = this.selectedDate.toString();
|
||||
|
||||
if(this.selectedSegment != "Combinada"){
|
||||
this.postEvent ={
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
Body: this.eventBody,
|
||||
Location: '',
|
||||
CalendarId: '',
|
||||
CalendarName: this.selectedSegment,
|
||||
StartDate: selectedStartdDate,
|
||||
EndDate: new Date(selectedEndDate),
|
||||
EventType: 'Reunião',
|
||||
Attendees: null,
|
||||
IsMeeting: false,
|
||||
IsRecurring: false,
|
||||
AppointmentState: 0,
|
||||
TimeZone: '',
|
||||
Organizer: '',
|
||||
Categories: ['Reunião'],
|
||||
HasAttachments: false,
|
||||
};
|
||||
}
|
||||
else{
|
||||
this.postEvent ={
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
Body: this.eventBody,
|
||||
Location: '',
|
||||
CalendarId: '',
|
||||
CalendarName: 'Oficial',
|
||||
StartDate: selectedStartdDate,
|
||||
EndDate: new Date(selectedEndDate),
|
||||
EventType: 'Reunião',
|
||||
Attendees: null,
|
||||
IsMeeting: false,
|
||||
IsRecurring: false,
|
||||
AppointmentState: 0,
|
||||
TimeZone: '',
|
||||
Organizer: '',
|
||||
Categories: ['Reunião'],
|
||||
HasAttachments: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(){
|
||||
|
||||
this.deleteTemporaryData();
|
||||
|
||||
this.cloneAllmobileComponent.emit();
|
||||
this.clearContact.emit();
|
||||
}
|
||||
|
||||
save(){
|
||||
|
||||
if(this.profile=='mdgpr'){
|
||||
@@ -104,15 +122,48 @@ export class NewEventPage implements OnInit {
|
||||
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe();
|
||||
}
|
||||
|
||||
this.onAddEvent.emit(this.postEvent);
|
||||
this.deleteTemporaryData();
|
||||
|
||||
this.onAddEvent.emit(this.postEvent);
|
||||
this.GoBackEditOrAdd.emit();
|
||||
}
|
||||
|
||||
async openAttendees(data: any)
|
||||
{
|
||||
|
||||
this.saveTemporaryData();
|
||||
this.openAttendeesComponent.emit();
|
||||
}
|
||||
|
||||
saveTemporaryData(){
|
||||
|
||||
window['temp.path:/home/agenda/new-event.component.ts'] = {
|
||||
postEvent: this.postEvent,
|
||||
eventBody: this.eventBody,
|
||||
segment: this.segment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
restoreTemporaryData(): boolean{
|
||||
|
||||
const restoredData = window['temp.path:/home/agenda/new-event.component.ts']
|
||||
|
||||
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
|
||||
console.log('restore1111', restoredData)
|
||||
this.postEvent = restoredData.postEvent
|
||||
this.eventBody = restoredData.eventBody
|
||||
this.segment = restoredData.segment
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deleteTemporaryData(){
|
||||
window['temp.path:/home/agenda/new-event.component.ts'] = {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user