mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve save for edit and create event in agenda
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
<ion-icon class="right-icons" src="assets/images/icons-received-event.svg"></ion-icon>
|
||||
</button>
|
||||
|
||||
<button class="btn-no-color" (click)="clearContact();openAddEvent()">
|
||||
<button class="btn-no-color" (click)="clearContact();openAddEvent();">
|
||||
<ion-icon class="right-icons" src="assets/images/icons-add-new-event.svg" ></ion-icon>
|
||||
</button>
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ export class AgendaPage implements OnInit {
|
||||
// this will make toggle add event and.
|
||||
showEventEditOrOpen: "edit" | "add" | "" = ""
|
||||
prEventList: Event[];
|
||||
mdEventList: Event[]
|
||||
mdEventList: Event[];
|
||||
|
||||
showLoader: boolean;
|
||||
|
||||
@@ -383,7 +383,7 @@ export class AgendaPage implements OnInit {
|
||||
const profile_ = profile == 'md'? 'mdgpr': 'pr';
|
||||
|
||||
return `
|
||||
<div class=" overflow-hidden timeline-box timeline-box-event-${eventIndex} timeline-${profile_}-box-${calendarName} calendar-top${top}">
|
||||
<div class="overflow-hidden timeline-box timeline-box-event-${eventIndex} timeline-${profile_}-box-${calendarName} calendar-top${top}">
|
||||
<div>
|
||||
<span class="timeline-start-time">${startHours.toString().padStart(2, '0')}:${startMinutos.toString().padStart(2, '0')}</span><span class="timeline-location">${eventlocation}</span>
|
||||
</div>
|
||||
@@ -474,9 +474,9 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
this.showTimelineFilterState = false;
|
||||
|
||||
if( profile =='md'){
|
||||
/* if( profile =='md'){
|
||||
console.log('eventsList: ', eventsList);
|
||||
}
|
||||
} */
|
||||
|
||||
eventsList.forEach((element, eventIndex) => {
|
||||
|
||||
@@ -491,6 +491,7 @@ export class AgendaPage implements OnInit {
|
||||
console.log('mdEvent:', element,eventIndex);
|
||||
}
|
||||
|
||||
// console.log( element.CalendarName);
|
||||
events.push({
|
||||
title: this.timeLineTemplate(startHours, element.Location, element.Body, element.CalendarName, element.Subject,startHoursOtherFormate,EndHoursOtherFormate, eventIndex, profile),
|
||||
start: setHours(setMinutes(new Date(element.StartDate), 0), parseInt(startHours)),
|
||||
@@ -834,7 +835,7 @@ export class AgendaPage implements OnInit {
|
||||
}
|
||||
|
||||
async openAddEvent() {
|
||||
|
||||
|
||||
await this.cloneAllmobileComponent();
|
||||
|
||||
this.showEventEditOrOpen = 'add';
|
||||
@@ -1063,5 +1064,4 @@ export class AgendaPage implements OnInit {
|
||||
this.postEvent = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,10 +23,10 @@ export class EditEventComponent implements OnInit {
|
||||
minDate: string;
|
||||
|
||||
@Input() taskParticipants: EventPerson[];
|
||||
@Input() taskParticipantsCc: any = [];
|
||||
@Input() taskParticipantsCc: EventPerson[];
|
||||
@Input() profile:string;
|
||||
@Input() selectedSegment: string;
|
||||
@Input() postEvent: any;
|
||||
@Input() postEvent: Event;
|
||||
@Output() clearContact = new EventEmitter<any>();
|
||||
|
||||
@Output() openAttendeesComponent = new EventEmitter<any>();
|
||||
@@ -45,32 +45,41 @@ export class EditEventComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if(this.postEvent){
|
||||
this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, '');
|
||||
}
|
||||
|
||||
// attendees list
|
||||
if(this.postEvent.Attendees != null) {
|
||||
this.postEvent.Attendees.forEach(e =>{
|
||||
if(e.IsRequired) {
|
||||
this.taskParticipants.push(e);
|
||||
} else {
|
||||
this.taskParticipantsCc.push(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.taskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
if(!this.restoreTemporaryData()){
|
||||
|
||||
if(this.postEvent){
|
||||
this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, '');
|
||||
}
|
||||
|
||||
// attendees list
|
||||
alert(JSON.stringify(this.postEvent.Attendees))
|
||||
if(this.postEvent.Attendees != null) {
|
||||
this.postEvent.Attendees.forEach(e =>{
|
||||
if(e.IsRequired) {
|
||||
this.taskParticipants.push(e);
|
||||
} else {
|
||||
this.taskParticipantsCc.push(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.taskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
|
||||
this.isEventEdited = false;
|
||||
|
||||
if(this.postEvent.IsRecurring == false){
|
||||
this.isRecurring = "Não se repete";
|
||||
}
|
||||
else{
|
||||
this.isRecurring = "Repete";
|
||||
this.setIntervenient.emit(this.taskParticipants);
|
||||
this.setIntervenientCC.emit(this.taskParticipantsCc);
|
||||
|
||||
this.isEventEdited = false;
|
||||
|
||||
if(this.postEvent.IsRecurring == false){
|
||||
this.isRecurring = "Não se repete";
|
||||
}
|
||||
else{
|
||||
this.isRecurring = "Repete";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(){
|
||||
@@ -78,6 +87,8 @@ export class EditEventComponent implements OnInit {
|
||||
this.setIntervenient.emit([]);
|
||||
this.setIntervenientCC.emit([]);
|
||||
this.clearContact.emit();
|
||||
|
||||
this.deleteTemporaryData();
|
||||
}
|
||||
|
||||
async save(){
|
||||
@@ -96,11 +107,14 @@ export class EditEventComponent implements OnInit {
|
||||
});
|
||||
|
||||
this.clearPostEvent.emit();
|
||||
|
||||
this.deleteTemporaryData();
|
||||
this.close();
|
||||
}
|
||||
|
||||
async addParticipants() {
|
||||
|
||||
this.saveTemporaryData();
|
||||
|
||||
this.openAttendeesComponent.emit({
|
||||
type: "intervenient"
|
||||
});
|
||||
@@ -109,6 +123,9 @@ export class EditEventComponent implements OnInit {
|
||||
}
|
||||
|
||||
async addParticipantsCc() {
|
||||
|
||||
this.saveTemporaryData();
|
||||
|
||||
this.openAttendeesComponent.emit({
|
||||
type: "CC"
|
||||
});
|
||||
@@ -116,4 +133,35 @@ export class EditEventComponent implements OnInit {
|
||||
this.clearContact.emit();
|
||||
}
|
||||
|
||||
|
||||
saveTemporaryData(){
|
||||
|
||||
window['temp.path:/home/agenda/edit-event.component.ts'] = {
|
||||
postEvent: this.postEvent,
|
||||
eventBody: this.eventBody,
|
||||
segment: this.segment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
restoreTemporaryData(): boolean{
|
||||
|
||||
const restoredData = window['temp.path:/home/agenda/edit-event.component.ts']
|
||||
|
||||
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
|
||||
this.postEvent = restoredData.postEvent
|
||||
this.eventBody = restoredData.eventBody
|
||||
this.segment = restoredData.segment
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deleteTemporaryData(){
|
||||
window['temp.path:/home/agenda/edit-event.component.ts'] = {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
import { Event } from 'src/app/models/event.model';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-event',
|
||||
@@ -13,7 +15,6 @@ import { ModalController } from '@ionic/angular';
|
||||
|
||||
export class NewEventPage implements OnInit {
|
||||
|
||||
postEvent: Event;
|
||||
eventBody: EventBody;
|
||||
segment:string = "true";
|
||||
|
||||
@@ -27,6 +28,7 @@ export class NewEventPage implements OnInit {
|
||||
@Output() setIntervenient = new EventEmitter<any>();
|
||||
@Output() setIntervenientCC = new EventEmitter<any>();
|
||||
|
||||
@Input() postEvent: Event;
|
||||
@Output() onAddEvent = new EventEmitter<any>();
|
||||
@Output() openAttendeesComponent = new EventEmitter<any>();
|
||||
@Output() clearContact = new EventEmitter<any>();
|
||||
@@ -99,7 +101,24 @@ export class NewEventPage implements OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(this.postEvent.Attendees != null) {
|
||||
this.postEvent.Attendees.forEach(e =>{
|
||||
if(e.IsRequired) {
|
||||
this.taskParticipants.push(e);
|
||||
} else {
|
||||
this.taskParticipantsCc.push(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.taskParticipants = removeDuplicate(this.taskParticipants);
|
||||
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
|
||||
|
||||
this.setIntervenient.emit(this.taskParticipants);
|
||||
this.setIntervenientCC.emit(this.taskParticipantsCc);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -110,11 +129,13 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
this.cloneAllmobileComponent.emit();
|
||||
this.clearContact.emit();
|
||||
this.setIntervenient.emit([]);
|
||||
this.setIntervenientCC.emit([]);
|
||||
}
|
||||
|
||||
save(){
|
||||
|
||||
this.postEvent.Attendees = this.taskParticipants;
|
||||
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
||||
|
||||
if(this.profile=='mdgpr') {
|
||||
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe();
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ContactsService } from 'src/app/services/contacts.service';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
||||
@Component({
|
||||
selector: 'app-attendee-modal',
|
||||
templateUrl: './attendee-modal.page.html',
|
||||
@@ -37,11 +37,11 @@ export class AttendeeModalPage implements OnInit {
|
||||
|
||||
this.fetchContacts("");
|
||||
|
||||
if(this.taskParticipants == null || this.taskParticipants == undefined){
|
||||
if(this.taskParticipants == null || this.taskParticipants == undefined) {
|
||||
this.taskParticipants = [];
|
||||
}
|
||||
|
||||
if(this.taskParticipantsCc == null || this.taskParticipantsCc == undefined){
|
||||
if(this.taskParticipantsCc == null || this.taskParticipantsCc == undefined) {
|
||||
this.taskParticipantsCc = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user